1.1 --- a/mainwindow.cpp Tue Jun 13 08:49:12 2006 +0000
1.2 +++ b/mainwindow.cpp Tue Jun 13 13:54:53 2006 +0000
1.3 @@ -25,7 +25,6 @@
1.4 #include <Q3PtrList>
1.5 //#include <qdatetime.h> // for random seed
1.6
1.7 -
1.8 #include <iostream>
1.9 #include <cstdlib>
1.10 #include <typeinfo>
1.11 @@ -131,23 +130,25 @@
1.12 extern QAction* actionSettingsUseFlagGroups;
1.13 extern QAction* actionSettingsUseHideExport;
1.14
1.15 -extern Q3PopupMenu* branchContextMenu;
1.16 -extern Q3PopupMenu* branchAddContextMenu;
1.17 -extern Q3PopupMenu* branchRemoveContextMenu;
1.18 -extern Q3PopupMenu* branchLinksContextMenu;
1.19 -extern Q3PopupMenu* branchLinksContextMenuDup;
1.20 -extern Q3PopupMenu* floatimageContextMenu;
1.21 -extern Q3PopupMenu* saveImageFormatMenu;
1.22 -extern Q3PopupMenu* canvasContextMenu;
1.23 -extern Q3PopupMenu* lastMapsMenu;
1.24 -extern Q3PopupMenu* importMenu;
1.25 -extern Q3PopupMenu* exportMenu;
1.26 -extern Q3PopupMenu* exportImageFormatMenu;
1.27 +extern QMenu* branchContextMenu;
1.28 +extern QMenu* branchAddContextMenu;
1.29 +extern QMenu* branchRemoveContextMenu;
1.30 +extern QMenu* branchLinksContextMenu;
1.31 +extern QMenu* branchLinksContextMenuDup;
1.32 +extern QMenu* floatimageContextMenu;
1.33 +extern QMenu* saveImageFormatMenu;
1.34 +extern QMenu* canvasContextMenu;
1.35 +extern QMenu* fileLastMapsMenu;
1.36 +extern QMenu* fileImportMenu;
1.37 +extern QMenu* fileExportMenu;
1.38
1.39
1.40 extern Settings settings;
1.41 extern Options options;
1.42 +extern ImageIO imageIO;
1.43 +
1.44 extern QDir vymBaseDir;
1.45 +extern QDir lastImageDir;
1.46 extern QString iconPath;
1.47 extern QString flagsPath;
1.48
1.49 @@ -234,7 +235,7 @@
1.50 setupHelpActions();
1.51
1.52 // After menu is created, we can enable some actions
1.53 - actionFilePrint->setEnabled (true);
1.54 +//FIXME testing actionFilePrint->setEnabled (true);
1.55
1.56 statusBar();
1.57
1.58 @@ -321,97 +322,130 @@
1.59 // File Actions
1.60 void Main::setupFileActions()
1.61 {
1.62 + QMenu *fileMenu = menuBar()->addMenu ( tr ("&File") );
1.63 QToolBar *tb = addToolBar( tr ("&File") );
1.64 - Q3PopupMenu *menu = new Q3PopupMenu( this );
1.65 - menuBar()->insertItem( tr( "&File" ), menu );
1.66 -
1.67 - // Keycodes: /usr/lib64/qt3/include/qnamespace.h
1.68
1.69 QAction *a;
1.70 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
1.71 a->setStatusTip ( tr( "New map","File menu" ) );
1.72 a->setShortcut ( Qt::CTRL + Qt::Key_N );
1.73 a->addTo( tb );
1.74 - a->addTo( menu );
1.75 + fileMenu->addAction (a);
1.76 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
1.77
1.78 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
1.79 a->setStatusTip (tr( "Open","File menu" ) );
1.80 a->setShortcut ( Qt::CTRL + Qt::Key_O );
1.81 a->addTo( tb );
1.82 - a->addTo( menu );
1.83 + fileMenu->addAction (a);
1.84 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
1.85
1.86 - lastMapsMenu = new Q3PopupMenu (this);
1.87 -
1.88 - menu->insertItem (tr("Open Recent"),lastMapsMenu );
1.89 - menu->insertSeparator();
1.90 + fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
1.91 + fileMenu->addSeparator();
1.92
1.93 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
1.94 a->setStatusTip ( tr( "Save" ));
1.95 a->setShortcut (Qt::CTRL + Qt::Key_S );
1.96 a->addTo( tb );
1.97 - a->addTo( menu );
1.98 + fileMenu->addAction (a);
1.99 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
1.100 actionFileSave=a;
1.101
1.102 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
1.103 a->setStatusTip (tr( "Save &As" ) );
1.104 - a->addTo( menu );
1.105 + fileMenu->addAction (a);
1.106 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
1.107
1.108 - menu->insertSeparator();
1.109 -
1.110 - importMenu = new Q3PopupMenu (this);
1.111 - menu->insertItem (tr("Import"),importMenu );
1.112 + fileMenu->addSeparator();
1.113 +
1.114 + fileImportMenu = fileMenu->addMenu (tr("Import"));
1.115
1.116 a = new QAction(tr("KDE Bookmarks"), this);
1.117 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
1.118 - a->addTo (importMenu);
1.119 + a->addTo (fileImportMenu);
1.120 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
1.121
1.122 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1.123 {
1.124 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
1.125 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
1.126 - a->addTo (importMenu);
1.127 + a->addTo (fileImportMenu);
1.128 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
1.129 }
1.130
1.131 a = new QAction("Mind Manager...",this);
1.132 a->setStatusTip ( tr( "Import")+" Mind Manager" );
1.133 - a->addTo (importMenu);
1.134 + fileImportMenu->addAction (a);
1.135 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
1.136
1.137 a = new QAction( tr( "Import Dir"+QString("...") ), this);
1.138 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
1.139 - a->addTo( importMenu);
1.140 + fileImportMenu->addAction (a);
1.141 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
1.142
1.143 - exportMenu = new Q3PopupMenu (this);
1.144 - menu->insertItem (tr("Export"),exportMenu );
1.145 -
1.146 - menu->insertSeparator();
1.147 -
1.148 + fileExportMenu = fileMenu->addMenu (tr("Export"));
1.149 +
1.150 + a = new QAction( tr("Image")+QString("..."), this);
1.151 + a->setStatusTip( tr( "Export map as image" ));
1.152 + connect( a, SIGNAL( activated() ), this, SLOT( fileExportImage() ) );
1.153 + fileExportMenu->addAction (a);
1.154 +
1.155 + a = new QAction( "Open Office"+QString("..."), this);
1.156 + a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
1.157 + connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1.158 + fileExportMenu->addAction (a);
1.159 +
1.160 + a = new QAction( "Webpage (XHTML)...",this );
1.161 + a->setShortcut (Qt::ALT + Qt::Key_X);
1.162 + a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
1.163 + connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1.164 + fileExportMenu->addAction (a);
1.165 +
1.166 + a = new QAction( "Text (ASCII)...", this);
1.167 + a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
1.168 + connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1.169 + fileExportMenu->addAction (a);
1.170 +
1.171 + a = new QAction( tr("KDE Bookmarks"), this);
1.172 + a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
1.173 + connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1.174 + fileExportMenu->addAction (a);
1.175 +
1.176 + a = new QAction( "Taskjuggler...", this );
1.177 + a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
1.178 + connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1.179 + fileExportMenu->addAction (a);
1.180 +
1.181 + a = new QAction( "LaTeX...", this);
1.182 + a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
1.183 + connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1.184 + fileExportMenu->addAction (a);
1.185 +
1.186 + a = new QAction( "XML..." , this );
1.187 + a->setStatusTip (tr( "Export as")+" XML");
1.188 + connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1.189 + fileExportMenu->addAction (a);
1.190 +
1.191 + fileMenu->addSeparator();
1.192
1.193 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
1.194 a->setStatusTip ( tr( "Print" ) );
1.195 a->setShortcut (Qt::CTRL + Qt::Key_P );
1.196 a->addTo( tb );
1.197 - a->addTo( menu );
1.198 + fileMenu->addAction (a);
1.199 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
1.200 actionFilePrint=a;
1.201
1.202 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
1.203 a->setStatusTip (tr( "Close Map" ) );
1.204 a->setShortcut (Qt::ALT + Qt::Key_C );
1.205 - a->addTo( menu );
1.206 + fileMenu->addAction (a);
1.207 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
1.208
1.209 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
1.210 a->setStatusTip ( tr( "Exit")+" "+__VYM );
1.211 a->setShortcut (Qt::CTRL + Qt::Key_Q );
1.212 - a->addTo( menu );
1.213 + fileMenu->addAction (a);
1.214 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
1.215 }
1.216
1.217 @@ -1435,34 +1469,34 @@
1.218 QAction*a;
1.219
1.220 // Context Menu for branch or mapcenter
1.221 - branchContextMenu =new Q3PopupMenu (this);
1.222 + branchContextMenu =new QMenu (this);
1.223
1.224 // Submenu "Add"
1.225 - branchAddContextMenu =new Q3PopupMenu (this);
1.226 - actionEditPaste->addTo ( branchAddContextMenu );
1.227 - actionEditAddBranch->addTo ( branchAddContextMenu );
1.228 - actionEditAddBranchHere->addTo ( branchAddContextMenu );
1.229 - actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1.230 - actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1.231 - branchAddContextMenu->insertSeparator();
1.232 - actionEditLoadImage->addTo( branchAddContextMenu );
1.233 - branchAddContextMenu->insertSeparator();
1.234 - actionEditImportAdd->addTo ( branchAddContextMenu );
1.235 - actionEditImportReplace->addTo ( branchAddContextMenu );
1.236 + branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1.237 + branchAddContextMenu->addAction (actionEditPaste );
1.238 + branchAddContextMenu->addAction ( actionEditAddBranch );
1.239 + branchAddContextMenu->addAction ( actionEditAddBranchHere );
1.240 + branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1.241 + branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1.242 + branchAddContextMenu->addSeparator();
1.243 + branchAddContextMenu->addAction ( actionEditLoadImage);
1.244 + branchAddContextMenu->addSeparator();
1.245 + branchAddContextMenu->addAction ( actionEditLoadImage);
1.246 + branchAddContextMenu->addAction ( actionEditImportAdd );
1.247 + branchAddContextMenu->addAction ( actionEditImportReplace );
1.248
1.249 // Submenu "Remove"
1.250 - branchRemoveContextMenu =new Q3PopupMenu (this);
1.251 - actionEditCut->addTo ( branchRemoveContextMenu );
1.252 - actionEditDelete->addTo ( branchRemoveContextMenu );
1.253 - actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
1.254 - actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1.255 + branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1.256 + branchRemoveContextMenu->addAction (actionEditCut);
1.257 + branchRemoveContextMenu->addAction ( actionEditDelete );
1.258 + branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1.259 + branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1.260
1.261 - branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1.262 - branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1.263
1.264 actionEditSaveBranch->addTo( branchContextMenu );
1.265
1.266 - branchContextMenu->insertSeparator();
1.267 +/*
1.268 + branchContextMenu->addSeparator();
1.269 actionEditOpenURL->addTo ( branchContextMenu );
1.270 actionEditOpenURLTab->addTo ( branchContextMenu );
1.271 actionEditURL->addTo ( branchContextMenu );
1.272 @@ -1496,19 +1530,17 @@
1.273 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1.274 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1.275
1.276 +*/
1.277 // Context menu for floatimage
1.278 - floatimageContextMenu =new Q3PopupMenu (this);
1.279 - saveImageFormatMenu=new Q3PopupMenu (this);
1.280 - exportImageFormatMenu=new Q3PopupMenu (this);
1.281 -
1.282 -/* FIXME strange error
1.283 + floatimageContextMenu =new QMenu (this);
1.284 + saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image"));
1.285 +
1.286 foreach (QByteArray format, QImageWriter::supportedImageFormats())
1.287 {
1.288 QString text = tr("%1...").arg(QString(format).toUpper());
1.289 - saveImageFormatMenu->insertItem( text );
1.290 - exportImageFormatMenu->insertItem( text );
1.291 + a= new QAction (text,this);
1.292 + saveImageFormatMenu->addAction ( a );
1.293 }
1.294 -*/
1.295
1.296 /* FIXME not needed any longer
1.297 Q3StrList fmt = QImageWriter::supportedImageFormats();
1.298 @@ -1518,57 +1550,19 @@
1.299 exportImageFormatMenu->insertItem( f );
1.300 }
1.301 */
1.302 - connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1.303 - connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1.304 - floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1.305 +// connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1.306 +// connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1.307
1.308 - floatimageContextMenu->insertSeparator();
1.309 + floatimageContextMenu->addSeparator();
1.310 actionEditCopy->addTo( floatimageContextMenu );
1.311 actionEditCut->addTo( floatimageContextMenu );
1.312
1.313 - floatimageContextMenu->insertSeparator();
1.314 - actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1.315 -
1.316 - exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1.317 -
1.318 - a = new QAction( "Open Office"+QString("..."), this);
1.319 - a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
1.320 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1.321 - a->addTo (exportMenu);
1.322 -
1.323 - a = new QAction( "Webpage (XHTML)...",this );
1.324 - a->setShortcut (Qt::ALT + Qt::Key_X);
1.325 - a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
1.326 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1.327 - a->addTo( exportMenu );
1.328 -
1.329 - a = new QAction( "Text (ASCII)...", this);
1.330 - a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
1.331 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1.332 - a->addTo( exportMenu );
1.333 -
1.334 - a = new QAction( tr("KDE Bookmarks"), this);
1.335 - a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
1.336 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1.337 - a->addTo (exportMenu);
1.338 -
1.339 - a = new QAction( "Taskjuggler...", this );
1.340 - a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
1.341 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1.342 - a->addTo( exportMenu );
1.343 -
1.344 - a = new QAction( "LaTeX...", this);
1.345 - a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
1.346 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1.347 - a->addTo( exportMenu );
1.348 -
1.349 - a = new QAction( "XML..." , this );
1.350 - a->setStatusTip (tr( "Export as")+" XML");
1.351 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1.352 - a->addTo( exportMenu );
1.353 + floatimageContextMenu->addSeparator();
1.354 + floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1.355 +
1.356
1.357 // Context menu for canvas
1.358 - canvasContextMenu =new Q3PopupMenu (this);
1.359 + canvasContextMenu =new QMenu (this);
1.360 actionEditMapInfo->addTo( canvasContextMenu );
1.361 canvasContextMenu->insertSeparator();
1.362 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1.363 @@ -1588,7 +1582,7 @@
1.364 lastMaps.append(s);
1.365 }
1.366 setupLastMapsMenu();
1.367 - connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1.368 +// connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1.369 }
1.370
1.371 void Main::setupLastMapsMenu()
1.372 @@ -1614,9 +1608,11 @@
1.373 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1.374
1.375 // build Menu from lastMaps string list
1.376 - lastMapsMenu->clear();
1.377 + fileLastMapsMenu->clear();
1.378 + /* FIXME add actions instead of strings in QT4
1.379 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1.380 - lastMapsMenu->insertItem (*it );
1.381 + fileLastMapsMenu->addAction (*it );
1.382 + */
1.383
1.384 }
1.385
1.386 @@ -1960,7 +1956,7 @@
1.387
1.388 void Main::fileLoadLast(int i)
1.389 {
1.390 - fileLoad(QString(*lastMaps.at(lastMapsMenu->indexOf (i)) ),NewMap);
1.391 + fileLoad(QString(*lastMaps.at(fileLastMapsMenu->indexOf (i)) ),NewMap);
1.392 }
1.393
1.394 void Main::fileSave(const SaveMode &savemode)
1.395 @@ -2263,18 +2259,23 @@
1.396 }
1.397 }
1.398
1.399 -void Main::fileExportImage(int item)
1.400 +void Main::fileExportImage()
1.401 {
1.402 MapEditor *me=currentMapEditor();
1.403 if (me)
1.404 {
1.405 - QString fn = Q3FileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1.406 - this );
1.407 - if ( !fn.isEmpty() )
1.408 - me->exportImage(fn,item);
1.409 - else
1.410 - statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1.411 -
1.412 + QStringList fl;
1.413 + QFileDialog *fd=new QFileDialog (this);
1.414 + fd->setCaption (tr("Export map as image"));
1.415 + fd->setFileMode(QFileDialog::AnyFile);
1.416 + fd->setFilters (imageIO.getFilters() );
1.417 + fd->setDirectory (lastImageDir);
1.418 + if (fd->exec())
1.419 + {
1.420 + fl=fd->selectedFiles();
1.421 + qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
1.422 + me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
1.423 + }
1.424 }
1.425 }
1.426