1.1 --- a/mainwindow.cpp Wed Jun 14 14:43:18 2006 +0000
1.2 +++ b/mainwindow.cpp Tue Jul 04 12:10:56 2006 +0000
1.3 @@ -129,8 +129,8 @@
1.4 extern QMenu* branchContextMenu;
1.5 extern QMenu* branchAddContextMenu;
1.6 extern QMenu* branchRemoveContextMenu;
1.7 -extern QMenu* branchLinksContextMenu;
1.8 -extern QMenu* branchLinksContextMenuDup;
1.9 +extern QMenu* branchLinksContextMenuEdit;
1.10 +extern QMenu* branchLinksContextMenuFollow;
1.11 extern QMenu* floatimageContextMenu;
1.12 extern QMenu* saveImageFormatMenu;
1.13 extern QMenu* canvasContextMenu;
1.14 @@ -505,23 +505,23 @@
1.15 a = new QAction(tr( "Edit heading" ),this);
1.16 a->setStatusTip ( tr( "edit Heading" ));
1.17 a->setShortcut ( Qt::Key_Enter);
1.18 - a->setShortcutContext (Qt::ApplicationShortcut);
1.19 + a->setShortcutContext (Qt::WindowShortcut);
1.20 addAction (a);
1.21 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
1.22 actionListBranches.append(a);
1.23 a = new QAction( tr( "Edit heading" ), this);
1.24 a->setStatusTip (tr( "edit Heading" ));
1.25 a->setShortcut (Qt::Key_Return );
1.26 + a->setShortcutContext (Qt::WindowShortcut);
1.27 + addAction (a);
1.28 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
1.29 actionListBranches.append(a);
1.30 editMenu->addAction (a);
1.31 - a->setShortcutContext (Qt::ApplicationShortcut);
1.32 - addAction (a);
1.33 actionEditHeading=a;
1.34 a = new QAction( tr( "Edit heading" ), this);
1.35 a->setStatusTip (tr( "edit Heading" ));
1.36 a->setShortcut ( Qt::Key_F2 );
1.37 - a->setShortcutContext (Qt::ApplicationShortcut);
1.38 + a->setShortcutContext (Qt::WindowShortcut);
1.39 addAction (a);
1.40 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
1.41 actionListBranches.append(a);
1.42 @@ -530,19 +530,21 @@
1.43 a = new QAction( tr( "Delete Selection" ),this);
1.44 a->setStatusTip (tr( "Delete Selection" ));
1.45 a->setShortcut ( Qt::Key_Delete);
1.46 + a->setShortcutContext (Qt::WindowShortcut);
1.47 + addAction (a);
1.48 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
1.49 - a->setEnabled (false);
1.50 actionEditDelete=a;
1.51
1.52 // Shortcut to add branch
1.53 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
1.54 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
1.55 alt->setShortcut (Qt::Key_A);
1.56 + alt->setShortcutContext (Qt::WindowShortcut);
1.57 + addAction (alt);
1.58 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
1.59 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
1.60 a->setStatusTip ( tr( "Add a branch as child of selection" ));
1.61 a->setShortcut (Qt::Key_Insert);
1.62 -// a->setEnabled (false);
1.63 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
1.64 actionListBranches.append(a);
1.65 #if defined (Q_OS_MACX)
1.66 @@ -559,6 +561,8 @@
1.67 a = new QAction(tr( "Add branch (insert)" ), this);
1.68 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
1.69 a->setShortcut (Qt::ALT + Qt::Key_Insert );
1.70 + a->setShortcutContext (Qt::WindowShortcut);
1.71 + addAction (a);
1.72 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
1.73 a->setEnabled (false);
1.74 actionListBranches.append(a);
1.75 @@ -566,6 +570,8 @@
1.76 a = new QAction(tr( "Add branch (insert)" ),this);
1.77 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
1.78 a->setShortcut ( Qt::ALT + Qt::Key_A );
1.79 + a->setShortcutContext (Qt::WindowShortcut);
1.80 + addAction (a);
1.81 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
1.82 actionListBranches.append(a);
1.83
1.84 @@ -573,6 +579,8 @@
1.85 a = new QAction(tr( "Add branch above" ), this);
1.86 a->setStatusTip ( tr( "Add a branch above selection" ));
1.87 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
1.88 + a->setShortcutContext (Qt::WindowShortcut);
1.89 + addAction (a);
1.90 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
1.91 a->setEnabled (false);
1.92 actionListBranches.append(a);
1.93 @@ -580,6 +588,8 @@
1.94 a = new QAction(tr( "Add branch above" ), this);
1.95 a->setStatusTip ( tr( "Add a branch above selection" ));
1.96 a->setShortcut (Qt::SHIFT+Qt::Key_A );
1.97 + a->setShortcutContext (Qt::WindowShortcut);
1.98 + addAction (a);
1.99 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
1.100 actionListBranches.append(a);
1.101
1.102 @@ -587,6 +597,8 @@
1.103 a = new QAction(tr( "Add branch below" ), this);
1.104 a->setStatusTip ( tr( "Add a branch below selection" ));
1.105 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
1.106 + a->setShortcutContext (Qt::WindowShortcut);
1.107 + addAction (a);
1.108 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
1.109 a->setEnabled (false);
1.110 actionListBranches.append(a);
1.111 @@ -594,6 +606,8 @@
1.112 a = new QAction(tr( "Add branch below" ), this);
1.113 a->setStatusTip ( tr( "Add a branch below selection" ));
1.114 a->setShortcut (Qt::CTRL +Qt::Key_A );
1.115 + a->setShortcutContext (Qt::WindowShortcut);
1.116 + addAction (a);
1.117 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
1.118 actionListBranches.append(a);
1.119
1.120 @@ -778,22 +792,32 @@
1.121 a = new QAction(tr( "Select upper branch" ), this);
1.122 a->setStatusTip ( tr( "Select upper branch" ));
1.123 a->setShortcut (Qt::Key_Up );
1.124 + a->setShortcutContext (Qt::WindowShortcut);
1.125 + addAction (a);
1.126 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
1.127 a = new QAction( tr( "Select lower branch" ),this);
1.128 a->setStatusTip (tr( "Select lower branch" ));
1.129 a->setShortcut ( Qt::Key_Down );
1.130 + a->setShortcutContext (Qt::WindowShortcut);
1.131 + addAction (a);
1.132 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
1.133 a = new QAction(tr( "Select left branch" ), this);
1.134 a->setStatusTip ( tr( "Select left branch" ));
1.135 a->setShortcut (Qt::Key_Left );
1.136 + a->setShortcutContext (Qt::WindowShortcut);
1.137 + addAction (a);
1.138 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
1.139 a = new QAction( tr( "Select child branch" ), this);
1.140 a->setStatusTip (tr( "Select right branch" ));
1.141 a->setShortcut (Qt::Key_Right);
1.142 + a->setShortcutContext (Qt::WindowShortcut);
1.143 + addAction (a);
1.144 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
1.145 a = new QAction( tr( "Select first branch" ), this);
1.146 a->setStatusTip (tr( "Select first branch" ));
1.147 a->setShortcut (Qt::Key_Home );
1.148 + a->setShortcutContext (Qt::WindowShortcut);
1.149 + addAction (a);
1.150 a->setEnabled (false);
1.151 editMenu->addAction (a);
1.152 actionListBranches.append(a);
1.153 @@ -802,6 +826,8 @@
1.154 a = new QAction( tr( "Select last branch" ),this);
1.155 a->setStatusTip (tr( "Select last branch" ));
1.156 a->setShortcut ( Qt::Key_End );
1.157 + a->setShortcutContext (Qt::WindowShortcut);
1.158 + addAction (a);
1.159 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
1.160 a->setEnabled (false);
1.161 editMenu->addAction (a);
1.162 @@ -1519,15 +1545,10 @@
1.163 // Context Menu for links in a branch menu
1.164 // This will be populated "on demand" in MapEditor::updateActions
1.165 branchContextMenu->addSeparator();
1.166 - /* FIXME not yet ported from QT3
1.167 - branchLinksContextMenu =new Q3PopupMenu (this);
1.168 - branchLinksContextMenuDup =new Q3PopupMenu (this);
1.169 - branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1.170 - connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1.171 -
1.172 - branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1.173 - connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1.174 - */
1.175 + branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1.176 + branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1.177 + connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1.178 + connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1.179
1.180 // Context menu for floatimage
1.181 floatimageContextMenu =new QMenu (this);
1.182 @@ -1580,7 +1601,7 @@
1.183 lastMaps.append(s);
1.184 }
1.185 setupLastMapsMenu();
1.186 -// connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1.187 + connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1.188 }
1.189
1.190 void Main::setupLastMapsMenu()
1.191 @@ -1607,11 +1628,8 @@
1.192
1.193 // build Menu from lastMaps string list
1.194 fileLastMapsMenu->clear();
1.195 - /* FIXME add actions instead of strings in QT4
1.196 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1.197 fileLastMapsMenu->addAction (*it );
1.198 - */
1.199 -
1.200 }
1.201
1.202 void Main::hideEvent (QHideEvent * )
1.203 @@ -1952,9 +1970,9 @@
1.204 fileLoad (NewMap);
1.205 }
1.206
1.207 -void Main::fileLoadLast(int i)
1.208 +void Main::fileLoadLast(QAction *a)
1.209 {
1.210 - fileLoad(QString(*lastMaps.at(fileLastMapsMenu->indexOf (i)) ),NewMap);
1.211 + fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1.212 }
1.213
1.214 void Main::fileSave(const SaveMode &savemode)
1.215 @@ -2793,16 +2811,17 @@
1.216 currentMapEditor()->saveFloatImage(item);
1.217 }
1.218
1.219 -void Main::editFollowXLink(int item)
1.220 +void Main::editFollowXLink(QAction *a)
1.221 +{
1.222 +
1.223 + if (currentMapEditor())
1.224 + currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
1.225 +}
1.226 +
1.227 +void Main::editEditXLink(QAction *a)
1.228 {
1.229 if (currentMapEditor())
1.230 - currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
1.231 -}
1.232 -
1.233 -void Main::editEditXLink(int item)
1.234 -{
1.235 - if (currentMapEditor())
1.236 - currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
1.237 + currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
1.238 }
1.239
1.240 void Main::formatSelectColor()