diff -r db50e4164311 -r 84f76a3876d7 mainwindow.cpp --- a/mainwindow.cpp Wed Jun 14 14:43:18 2006 +0000 +++ b/mainwindow.cpp Tue Jul 04 12:10:56 2006 +0000 @@ -129,8 +129,8 @@ extern QMenu* branchContextMenu; extern QMenu* branchAddContextMenu; extern QMenu* branchRemoveContextMenu; -extern QMenu* branchLinksContextMenu; -extern QMenu* branchLinksContextMenuDup; +extern QMenu* branchLinksContextMenuEdit; +extern QMenu* branchLinksContextMenuFollow; extern QMenu* floatimageContextMenu; extern QMenu* saveImageFormatMenu; extern QMenu* canvasContextMenu; @@ -505,23 +505,23 @@ a = new QAction(tr( "Edit heading" ),this); a->setStatusTip ( tr( "edit Heading" )); a->setShortcut ( Qt::Key_Enter); - a->setShortcutContext (Qt::ApplicationShortcut); + a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); a = new QAction( tr( "Edit heading" ), this); a->setStatusTip (tr( "edit Heading" )); a->setShortcut (Qt::Key_Return ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); editMenu->addAction (a); - a->setShortcutContext (Qt::ApplicationShortcut); - addAction (a); actionEditHeading=a; a = new QAction( tr( "Edit heading" ), this); a->setStatusTip (tr( "edit Heading" )); a->setShortcut ( Qt::Key_F2 ); - a->setShortcutContext (Qt::ApplicationShortcut); + a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); @@ -530,19 +530,21 @@ a = new QAction( tr( "Delete Selection" ),this); a->setStatusTip (tr( "Delete Selection" )); a->setShortcut ( Qt::Key_Delete); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) ); - a->setEnabled (false); actionEditDelete=a; // Shortcut to add branch alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this); alt->setStatusTip ( tr( "Add a branch as child of selection" )); alt->setShortcut (Qt::Key_A); + alt->setShortcutContext (Qt::WindowShortcut); + addAction (alt); connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) ); a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this); a->setStatusTip ( tr( "Add a branch as child of selection" )); a->setShortcut (Qt::Key_Insert); -// a->setEnabled (false); connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) ); actionListBranches.append(a); #if defined (Q_OS_MACX) @@ -559,6 +561,8 @@ a = new QAction(tr( "Add branch (insert)" ), this); a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); a->setShortcut (Qt::ALT + Qt::Key_Insert ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) ); a->setEnabled (false); actionListBranches.append(a); @@ -566,6 +570,8 @@ a = new QAction(tr( "Add branch (insert)" ),this); a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); a->setShortcut ( Qt::ALT + Qt::Key_A ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) ); actionListBranches.append(a); @@ -573,6 +579,8 @@ a = new QAction(tr( "Add branch above" ), this); a->setStatusTip ( tr( "Add a branch above selection" )); a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) ); a->setEnabled (false); actionListBranches.append(a); @@ -580,6 +588,8 @@ a = new QAction(tr( "Add branch above" ), this); a->setStatusTip ( tr( "Add a branch above selection" )); a->setShortcut (Qt::SHIFT+Qt::Key_A ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) ); actionListBranches.append(a); @@ -587,6 +597,8 @@ a = new QAction(tr( "Add branch below" ), this); a->setStatusTip ( tr( "Add a branch below selection" )); a->setShortcut (Qt::CTRL +Qt::Key_Insert ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) ); a->setEnabled (false); actionListBranches.append(a); @@ -594,6 +606,8 @@ a = new QAction(tr( "Add branch below" ), this); a->setStatusTip ( tr( "Add a branch below selection" )); a->setShortcut (Qt::CTRL +Qt::Key_A ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) ); actionListBranches.append(a); @@ -778,22 +792,32 @@ a = new QAction(tr( "Select upper branch" ), this); a->setStatusTip ( tr( "Select upper branch" )); a->setShortcut (Qt::Key_Up ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) ); a = new QAction( tr( "Select lower branch" ),this); a->setStatusTip (tr( "Select lower branch" )); a->setShortcut ( Qt::Key_Down ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) ); a = new QAction(tr( "Select left branch" ), this); a->setStatusTip ( tr( "Select left branch" )); a->setShortcut (Qt::Key_Left ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) ); a = new QAction( tr( "Select child branch" ), this); a->setStatusTip (tr( "Select right branch" )); a->setShortcut (Qt::Key_Right); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) ); a = new QAction( tr( "Select first branch" ), this); a->setStatusTip (tr( "Select first branch" )); a->setShortcut (Qt::Key_Home ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); a->setEnabled (false); editMenu->addAction (a); actionListBranches.append(a); @@ -802,6 +826,8 @@ a = new QAction( tr( "Select last branch" ),this); a->setStatusTip (tr( "Select last branch" )); a->setShortcut ( Qt::Key_End ); + a->setShortcutContext (Qt::WindowShortcut); + addAction (a); connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) ); a->setEnabled (false); editMenu->addAction (a); @@ -1519,15 +1545,10 @@ // Context Menu for links in a branch menu // This will be populated "on demand" in MapEditor::updateActions branchContextMenu->addSeparator(); - /* FIXME not yet ported from QT3 - branchLinksContextMenu =new Q3PopupMenu (this); - branchLinksContextMenuDup =new Q3PopupMenu (this); - branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup); - connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) ); - - branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu); - connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) ); - */ + branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink")); + branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink")); + connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) ); + connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) ); // Context menu for floatimage floatimageContextMenu =new QMenu (this); @@ -1580,7 +1601,7 @@ lastMaps.append(s); } setupLastMapsMenu(); -// connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) ); + connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) ); } void Main::setupLastMapsMenu() @@ -1607,11 +1628,8 @@ // build Menu from lastMaps string list fileLastMapsMenu->clear(); - /* FIXME add actions instead of strings in QT4 for (it = lastMaps.begin(); it != lastMaps.end(); ++it ) fileLastMapsMenu->addAction (*it ); - */ - } void Main::hideEvent (QHideEvent * ) @@ -1952,9 +1970,9 @@ fileLoad (NewMap); } -void Main::fileLoadLast(int i) +void Main::fileLoadLast(QAction *a) { - fileLoad(QString(*lastMaps.at(fileLastMapsMenu->indexOf (i)) ),NewMap); + fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap); } void Main::fileSave(const SaveMode &savemode) @@ -2793,16 +2811,17 @@ currentMapEditor()->saveFloatImage(item); } -void Main::editFollowXLink(int item) +void Main::editFollowXLink(QAction *a) +{ + + if (currentMapEditor()) + currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a)); +} + +void Main::editEditXLink(QAction *a) { if (currentMapEditor()) - currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item)); -} - -void Main::editEditXLink(int item) -{ - if (currentMapEditor()) - currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item)); + currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a)); } void Main::formatSelectColor()