~ubuntu-branches/ubuntu/oneiric/soqt/oneiric

« back to all changes in this revision

Viewing changes to src/Inventor/Qt/widgets/QtNativePopupMenu.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2009-03-01 11:41:00 UTC
  • mfrom: (1.1.4 upstream) (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090301114100-f4zz3n1oasa52fgk
Tags: 1.4.2~svn20090224-2
* Upload upstream SVN head version containing fixes to build with Coin 3
  (Closes: #515729, #515736, #515742).  Upstream indicated to me that
  SVN is stable enough to release.

* control: Update Standards-Version to 3.8.0; no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
// wrt Qt 4 properly. 20050629 mortene.
34
34
#define QT3_SUPPORT
35
35
 
 
36
// FIXME: create a new Qt4NativePopupMenu. There are just too
 
37
// many differences between Qt3 menu handling and Qt4 menu handling.
 
38
 
36
39
#include <qmetaobject.h>
37
40
 
38
41
// *************************************************************************
121
124
    delete [] rec->title;
122
125
    delete rec;
123
126
  }
 
127
 
 
128
  delete this->menus;
 
129
  delete this->items;
 
130
 
124
131
} // ~QtNativePopupMenu()
125
132
 
126
133
// *************************************************************************
328
335
    rec->flags |= ITEM_MARKED;
329
336
  else
330
337
    rec->flags &= ~ITEM_MARKED;
 
338
 
331
339
  if (rec->parent != NULL) {
332
 
#if QT_VERSION >= 0x040000 // Qt 4.*
 
340
#if QT_VERSION >= 0x040000
333
341
    // FIXME: is this really safe? (20050727 frodo)
334
342
    QAction * action = (QAction *) rec->parent->findItem(itemid);
335
 
    if (action) action->setChecked(marked ? true : false);
 
343
    if (action) {
 
344
      action->setChecked(marked ? true : false);
 
345
    }
336
346
#else
337
347
    rec->parent->setItemChecked(rec->itemid, marked ? true : false);
338
348
#endif
350
360
  assert(rec && "no such menu");
351
361
  if (rec->parent == NULL)
352
362
    return (rec->flags & ITEM_MARKED) ? TRUE : FALSE;
 
363
 
 
364
#if QT_VERSION >= 0x040400
 
365
    QAction * action = (QAction *) rec->parent->findItem(itemid);
 
366
    if (action) return action->isChecked();
 
367
#endif
353
368
  return rec->parent->isItemChecked(rec->itemid) ? TRUE : FALSE;
354
369
} // getMenuItemMarked()
355
370
 
373
388
  // itemActivation(). Multiple calls to itemActivation() causes a
374
389
  // segfault when selecting Quadbuffer stereo, at least when it's not
375
390
  // supported. (20050726 frodo)
376
 
#if QT_VERSION >= 0x040000 // Qt 4.*
 
391
 
 
392
  // this was changed/fixed again in Qt 4.4.0, so now we shouldn't
 
393
  // disconnect menu items if this version is detected... 
 
394
  // (20070530 pederb)
 
395
#if (QT_VERSION >= 0x040000) && (QT_VERSION < 0x040400)
377
396
  QObject::disconnect(sub->menu, SIGNAL(activated(int)),
378
397
                      this, SLOT(itemActivation(int)));
379
 
#endif
 
398
#endif // QT-version >= 400 && QT-version < 4.4.0
380
399
 
381
400
  if (pos == -1)
382
401
    super->menu->insertItem(QString(sub->title), sub->menu, sub->menuid);
405
424
    menu->menu->insertItem(QString(item->title), item->itemid, pos);
406
425
  item->parent = menu->menu;
407
426
 
408
 
#if QT_VERSION >= 0x040000 // Qt 4.*
 
427
#if QT_VERSION >= 0x040000
409
428
  // FIXME: is this really safe? (20050726 frodo)
410
429
  QAction * action = (QAction *) item->parent->findItem(itemid);
411
430
  if (action) action->setCheckable(true);
412
431
#endif // Qt 4.*
413
432
  
414
433
  if (item->flags & ITEM_MARKED) {
415
 
#if QT_VERSION >= 0x040000 // Qt 4.*
 
434
#if QT_VERSION >= 0x040000
416
435
    if (action) action->setChecked(true);
417
436
#else
418
437
    item->parent->setItemChecked(item->itemid, true);
554
573
  rec->name = strcpy(new char [strlen(name)+1], name);
555
574
  rec->title = strcpy(new char [strlen(name)+1], name);
556
575
 
557
 
#if QT_VERSION >= 0x040000 // Qt 4.*
 
576
#if QT_VERSION >= 0x040000
558
577
  rec->menu = new QPOPUPMENU_CLASS(QString(name));
559
578
#else
560
579
  rec->menu = new QPOPUPMENU_CLASS((QWidget *) NULL, name);