1.1 --- a/mainwindow.cpp Thu Mar 05 09:33:30 2009 +0000
1.2 +++ b/mainwindow.cpp Tue Mar 10 11:27:17 2009 +0000
1.3 @@ -1,251 +1,267 @@
1.4 #include "mainwindow.h"
1.5
1.6 -#include <qstatusbar.h>
1.7 -#include <qmessagebox.h>
1.8 -#include <qmenubar.h>
1.9 -#include <qapplication.h>
1.10 -#include <qpainter.h>
1.11 -#include <qprinter.h>
1.12 -#include <qfile.h>
1.13 -#include <qfiledialog.h>
1.14 -#include <qcolor.h>
1.15 -#include <qcolordialog.h>
1.16 -#include <qbitmap.h>
1.17 -#include <qinputdialog.h>
1.18 -
1.19 +#include <QtGui>
1.20
1.21 #include <iostream>
1.22 -#include <stdlib.h>
1.23 #include <typeinfo>
1.24
1.25 -#include "version.h"
1.26 -
1.27 -#include "icons/filenew.xpm"
1.28 -#include "icons/fileopen.xpm"
1.29 -#include "icons/filesave.xpm"
1.30 -#include "icons/fileprint.xpm"
1.31 -#include "icons/editundo.xpm"
1.32 -//#include "icons/editredo.xpm" // TODO
1.33 -#include "icons/editcopy.xpm"
1.34 -#include "icons/editcut.xpm"
1.35 -#include "icons/editpaste.xpm"
1.36 -#include "icons/editmoveup.xpm"
1.37 -#include "icons/editmovedown.xpm"
1.38 -#include "icons/formatcoloritem.xpm"
1.39 -#include "icons/formatcolorbranch.xpm"
1.40 -#include "icons/formatcolorpicker.xpm"
1.41 -#include "icons/viewzoomreset.xpm"
1.42 -#include "icons/viewzoomin.xpm"
1.43 -#include "icons/viewzoomout.xpm"
1.44 -#include "icons/vym-48x48.xpm"
1.45 -#include "icons/flag-note.xpm"
1.46 -#include "icons/flag-url.xpm"
1.47 -#include "icons/flag-vymlink.xpm"
1.48 -#include "icons/flag-scrolled-right.xpm"
1.49 -
1.50 +#include "aboutdialog.h"
1.51 +#include "branchpropwindow.h"
1.52 +#include "exportoofiledialog.h"
1.53 +#include "exports.h"
1.54 +#include "file.h"
1.55 #include "flagrowobj.h"
1.56 -#include "texteditor.h"
1.57 +#include "historywindow.h"
1.58 +#include "imports.h"
1.59 #include "mapeditor.h"
1.60 -#include "exporthtmldialog.h"
1.61 -#include "exportxhtmldialog.h"
1.62 -#include "showtextdialog.h"
1.63 +#include "misc.h"
1.64 +#include "options.h"
1.65 #include "process.h"
1.66 #include "settings.h"
1.67 -#include "options.h"
1.68 +#include "texteditor.h"
1.69 +#include "warningdialog.h"
1.70 +
1.71 +#if defined(Q_OS_WIN32)
1.72 +// Define only this structure as opposed to
1.73 +// including full 'windows.h'. FindWindow
1.74 +// clashes with the one in Win32 API.
1.75 +typedef struct _PROCESS_INFORMATION
1.76 +{
1.77 + long hProcess;
1.78 + long hThread;
1.79 + long dwProcessId;
1.80 + long dwThreadId;
1.81 +} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
1.82 +#endif
1.83
1.84 extern TextEditor *textEditor;
1.85 extern Main *mainWindow;
1.86 +extern QString tmpVymDir;
1.87 +extern QString clipboardDir;
1.88 +extern QString clipboardFile;
1.89 +extern bool clipboardEmpty;
1.90 extern int statusbarTime;
1.91 -extern MapEditor *clipboardME;
1.92 extern FlagRowObj* standardFlagsDefault;
1.93 -
1.94 -extern QAction* actionFileSave;
1.95 -extern QAction* actionFilePrint;
1.96 -extern QAction* actionEditUndo;
1.97 -extern QAction *actionEditCopy;
1.98 -extern QAction *actionEditCut;
1.99 -extern QAction *actionEditPaste;
1.100 -extern QAction *actionEditMoveUp;
1.101 -extern QAction *actionEditMoveDown;
1.102 -extern QAction *actionEditToggleScroll;
1.103 -extern QAction* actionEditOpenURL;
1.104 -extern QAction* actionEditURL;
1.105 -extern QAction* actionEditHeading2URL;
1.106 -extern QAction* actionEditBugzilla2URL;
1.107 -extern QAction *actionEditOpenVymLink;
1.108 -extern QAction *actionEditVymLink;
1.109 -extern QAction *actionEditDeleteVymLink;
1.110 -extern QAction *actionEditMapInfo;
1.111 -extern QAction *actionEditHeading;
1.112 -extern QAction *actionEditDelete;
1.113 -extern QAction *actionEditAddBranch;
1.114 -extern QAction *actionEditAddBranchAbove;
1.115 -extern QAction *actionEditAddBranchBelow;
1.116 -extern QAction *actionEditImportAdd;
1.117 -extern QAction *actionEditImportReplace;
1.118 -extern QAction *actionEditSaveBranch;
1.119 -extern QAction *actionEditSelectFirst;
1.120 -extern QAction *actionEditSelectLast;
1.121 -extern QAction *actionEditLoadImage;
1.122 -extern QAction *actionEditToggleFloatExport;
1.123 -
1.124 -extern QAction* actionFormatColor;
1.125 -extern QAction* actionFormatPickColor;
1.126 -extern QAction* actionFormatColorBranch;
1.127 -extern QAction* actionFormatColorSubtree;
1.128 -extern QAction* actionFormatLinkColorHint;
1.129 -extern QAction* actionFormatBackColor;
1.130 -extern QAction* actionFormatLinkColor;
1.131 -
1.132 -extern QActionGroup *actionGroupFormatFrameTypes;
1.133 -extern QAction *actionFormatFrameNone;
1.134 -extern QAction *actionFormatFrameRectangle;
1.135 -
1.136 -extern QActionGroup *actionGroupFormatLinkStyles;
1.137 -extern QAction *actionFormatLinkStyleLine;
1.138 -extern QAction *actionFormatLinkStyleParabel;
1.139 -extern QAction *actionFormatLinkStylePolyLine;
1.140 -extern QAction *actionFormatLinkStylePolyParabel;
1.141 -
1.142 -extern QAction *actionViewToggleNoteEditor;
1.143 -
1.144 -extern QAction* actionSettingsAutoedit;
1.145 -extern QAction* actionSettingsAutoselectHeading;
1.146 -extern QAction* actionSettingsAutoselectHeading;
1.147 -extern QAction* actionSettingsAutoselectText;
1.148 -extern QAction* actionSettingsPasteNewHeading;
1.149 -extern QAction* actionSettingsUseDelKey;
1.150 -
1.151 -extern QPopupMenu* branchContextMenu;
1.152 -extern QPopupMenu* floatimageContextMenu;
1.153 -extern QPopupMenu* saveImageFormatMenu;
1.154 -extern QPopupMenu* canvasContextMenu;
1.155 -extern QPopupMenu* lastMapsMenu;
1.156 -extern QPopupMenu* exportMenu;
1.157 -extern QPopupMenu* exportImageFormatMenu;
1.158 +extern FlagRowObj* systemFlagsDefault;
1.159 +extern QString vymName;
1.160 +extern QString vymVersion;
1.161 +extern QString vymBuildDate;
1.162 +extern bool debug;
1.163 +
1.164 +QMenu* branchContextMenu;
1.165 +QMenu* branchAddContextMenu;
1.166 +QMenu* branchRemoveContextMenu;
1.167 +QMenu* branchLinksContextMenu;
1.168 +QMenu* branchXLinksContextMenuEdit;
1.169 +QMenu* branchXLinksContextMenuFollow;
1.170 +QMenu* floatimageContextMenu;
1.171 +QMenu* canvasContextMenu;
1.172 +QMenu* fileLastMapsMenu;
1.173 +QMenu* fileImportMenu;
1.174 +QMenu* fileExportMenu;
1.175
1.176
1.177 extern Settings settings;
1.178 extern Options options;
1.179 -
1.180 -#if defined(Q_OS_LINUX)
1.181 -extern void qt_wait_for_window_manager( QWidget* w );
1.182 +extern ImageIO imageIO;
1.183 +
1.184 +extern QDir vymBaseDir;
1.185 +extern QDir lastImageDir;
1.186 +extern QDir lastFileDir;
1.187 +#if defined(Q_OS_WIN32)
1.188 +extern QDir vymInstallDir;
1.189 #endif
1.190 -
1.191 -Main::Main(QWidget* parent, const char* name, WFlags f) :
1.192 +extern QString iconPath;
1.193 +extern QString flagsPath;
1.194 +
1.195 +Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
1.196 QMainWindow(parent,name,f)
1.197 {
1.198 mainWindow=this;
1.199
1.200 + setObjectName ("MainWindow");
1.201 +
1.202 setCaption ("VYM - View Your Mind");
1.203
1.204 // Load window settings
1.205 - resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
1.206 - settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
1.207 - move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
1.208 - settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
1.209 -
1.210 +#if defined(Q_OS_WIN32)
1.211 + if (settings.value("/mainwindow/geometry/maximized", false).toBool())
1.212 + {
1.213 + setWindowState(Qt::WindowMaximized);
1.214 + }
1.215 + else
1.216 +#endif
1.217 + {
1.218 + resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
1.219 + move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
1.220 + }
1.221 +
1.222 + // Sometimes we may need to remember old selections
1.223 + prevSelection="";
1.224 +
1.225 + // Default color
1.226 + currentColor=Qt::black;
1.227 +
1.228 + // Create unique temporary directory
1.229 + bool ok;
1.230 + tmpVymDir=makeTmpDir (ok,"vym");
1.231 + if (!ok)
1.232 + {
1.233 + qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
1.234 + exit (1);
1.235 + }
1.236 + if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
1.237 +
1.238 + // Create direcctory for clipboard
1.239 + clipboardDir=tmpVymDir+"/clipboard";
1.240 + clipboardFile="map.xml";
1.241 + QDir d(clipboardDir);
1.242 + d.mkdir (clipboardDir,true);
1.243 + makeSubDirs (clipboardDir);
1.244 + clipboardEmpty=true;
1.245 +
1.246 + procBrowser=NULL;
1.247 +
1.248 + // Satellite windows //////////////////////////////////////////
1.249 +
1.250 + // history window
1.251 + historyWindow=new HistoryWindow();
1.252 + connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
1.253 +
1.254 + // properties window
1.255 + branchPropertyWindow = new BranchPropertyWindow();
1.256 + connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
1.257 +
1.258 + // Connect TextEditor, so that we can update flags if text changes
1.259 + connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
1.260 + connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
1.261 +
1.262 + // Connect HistoryWindow, so that we can update flags
1.263 + connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
1.264 +
1.265 +
1.266 + // Initialize script editor
1.267 + scriptEditor = new SimpleScriptEditor();
1.268 + scriptEditor->move (50,50);
1.269 +
1.270 + connect( scriptEditor, SIGNAL( runScript ( QString ) ),
1.271 + this, SLOT( runScript( QString ) ) );
1.272 +
1.273 +
1.274 + // Initialize Find window
1.275 + findWindow=new FindWindow(NULL);
1.276 + findWindow->move (x(),y()+70);
1.277 + connect (findWindow, SIGNAL( findButton(QString) ),
1.278 + this, SLOT(editFind(QString) ) );
1.279 + connect (findWindow, SIGNAL( somethingChanged() ),
1.280 + this, SLOT(editFindChanged() ) );
1.281
1.282 // Initialize some settings, which are platform dependant
1.283 QString p,s;
1.284
1.285 // application to open URLs
1.286 - p="/vym/mainwindow/readerURL";
1.287 + p="/mainwindow/readerURL";
1.288 #if defined(Q_OS_LINUX)
1.289 - s=settings.readEntry (p,"konqueror");
1.290 + s=settings.value (p,"xdg-open").toString();
1.291 #else
1.292 #if defined(Q_OS_MACX)
1.293 - s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
1.294 - #else
1.295 - s=settings.readEntry (p,"mozilla");
1.296 + s=settings.value (p,"/usr/bin/open").toString();
1.297 +
1.298 + #else
1.299 + #if defined(Q_OS_WIN32)
1.300 + // Assume that system has been set up so that
1.301 + // Explorer automagically opens up the URL
1.302 + // in the user's preferred browser.
1.303 + s=settings.value (p,"explorer").toString();
1.304 + #else
1.305 + s=settings.value (p,"mozilla").toString();
1.306 + #endif
1.307 #endif
1.308 #endif
1.309 - settings.writeEntry( p,s);
1.310 + settings.setValue( p,s);
1.311
1.312 // application to open PDFs
1.313 - p="/vym/mainwindow/readerPDF";
1.314 + p="/mainwindow/readerPDF";
1.315 #if defined(Q_OS_LINUX)
1.316 - s=settings.readEntry (p,"acroread");
1.317 + s=settings.value (p,"xdg-open").toString();
1.318 #else
1.319 #if defined(Q_OS_MACX)
1.320 - s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
1.321 + s=settings.value (p,"/usr/bin/open").toString();
1.322 + #elif defined(Q_OS_WIN32)
1.323 + s=settings.value (p,"acrord32").toString();
1.324 #else
1.325 - s=settings.readEntry (p,"acroread");
1.326 + s=settings.value (p,"acroread").toString();
1.327 #endif
1.328 #endif
1.329 - settings.writeEntry( p,s);
1.330 -
1.331 + settings.setValue( p,s);
1.332 +
1.333 + // width of xLinksMenu
1.334 + xLinkMenuWidth=60;
1.335
1.336 - maxLastMaps=9;
1.337 -
1.338 // Create tab widget which holds the maps
1.339 tabWidget= new QTabWidget (this);
1.340 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
1.341 this, SLOT( editorChanged( QWidget * ) ) );
1.342
1.343 + lineedit=new QLineEdit (this);
1.344 + lineedit->hide();
1.345 +
1.346 setCentralWidget(tabWidget);
1.347
1.348 setupFileActions();
1.349 setupEditActions();
1.350 setupFormatActions();
1.351 setupViewActions();
1.352 + setupModeActions();
1.353 setupFlagActions();
1.354 + setupNetworkActions();
1.355 setupSettingsActions();
1.356 setupContextMenus();
1.357 - if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
1.358 + setupMacros();
1.359 + if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
1.360 setupHelpActions();
1.361
1.362 - // After menu is created, we can enable some actions
1.363 - actionFilePrint->setEnabled (true);
1.364 -
1.365 statusBar();
1.366
1.367 - // Create the default map into first tab
1.368 -// fileNew();
1.369 -// tabWidget->addTab (new MapEditor(tabWidget,true), "unnamed");
1.370 -// currentMapEditor()->show();
1.371 -
1.372 - // Initialize Find window
1.373 - findWindow=new FindWindow(NULL,"findwindow");
1.374 - connect (findWindow, SIGNAL( findButton(QString) ),
1.375 - this, SLOT(editFind(QString) ) );
1.376 - connect (findWindow, SIGNAL( somethingChanged() ),
1.377 - this, SLOT(editFindChanged() ) );
1.378 + restoreState (settings.value("/mainwindow/state",0).toByteArray());
1.379
1.380 updateGeometry();
1.381 }
1.382
1.383 Main::~Main()
1.384 {
1.385 + //cout << "Destr MainWindow\n";
1.386 // Save Settings
1.387 - settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
1.388 - settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
1.389 - settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
1.390 - settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
1.391 -
1.392 - settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
1.393 - settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
1.394 -
1.395 - settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
1.396 - settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
1.397 - settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
1.398 - settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
1.399 - settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
1.400 -
1.401 - QString s;
1.402 - int maps=lastMaps.count();
1.403 - settings.writeEntry( "/vym/lastMaps/number",maps );
1.404 - for (int i=1;i<=maps;i++)
1.405 - {
1.406 - QStringList::Iterator it = lastMaps.at(i-1);
1.407 - s=QString("/vym/lastMaps/map-%1").arg(i);
1.408 - if (!s.isEmpty() && i<=maxLastMaps)
1.409 - settings.writeEntry (s, *it);
1.410 - }
1.411 -
1.412 -
1.413 - // To make the texteditor save its settings, call the destructor
1.414 - delete (textEditor);
1.415 +#if defined(Q_OS_WIN32)
1.416 + settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
1.417 +#endif
1.418 + settings.setValue ("/mainwindow/geometry/size", size());
1.419 + settings.setValue ("/mainwindow/geometry/pos", pos());
1.420 + settings.setValue ("/mainwindow/state",saveState(0));
1.421 +
1.422 + settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
1.423 + settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
1.424 + settings.setValue( "/version/version", vymVersion );
1.425 + settings.setValue( "/version/builddate", vymBuildDate );
1.426 +
1.427 + settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
1.428 + settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
1.429 + settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
1.430 + settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
1.431 + settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
1.432 + settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
1.433 + settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
1.434 + settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
1.435 +
1.436 + //TODO save scriptEditor settings
1.437 +
1.438 + // call the destructors
1.439 + delete textEditor;
1.440 + delete historyWindow;
1.441 + delete branchPropertyWindow;
1.442 +
1.443 + // Remove temporary directory
1.444 + removeDir (QDir(tmpVymDir));
1.445 }
1.446
1.447 void Main::loadCmdLine()
1.448 @@ -269,7 +285,7 @@
1.449
1.450 void Main::statusMessage(const QString &s)
1.451 {
1.452 - statusBar()->message (s);
1.453 + statusBar()->message( s);
1.454 }
1.455
1.456 void Main::closeEvent (QCloseEvent* )
1.457 @@ -280,490 +296,1238 @@
1.458 // File Actions
1.459 void Main::setupFileActions()
1.460 {
1.461 - QToolBar *tb = new QToolBar( this );
1.462 - tb->setLabel( "File Actions" );
1.463 - QPopupMenu *menu = new QPopupMenu( this );
1.464 - menuBar()->insertItem( tr( "&File" ), menu );
1.465 -
1.466 - // Keycodes: /usr/lib64/qt3/include/qnamespace.h
1.467 + QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
1.468 + QToolBar *tb = addToolBar( tr ("&Map") );
1.469 + tb->setObjectName ("mapTB");
1.470
1.471 QAction *a;
1.472 - a = new QAction( tr( "New map" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
1.473 - connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
1.474 + a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
1.475 + a->setStatusTip ( tr( "New map","Status tip File menu" ) );
1.476 + a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
1.477 a->addTo( tb );
1.478 - a->addTo( menu );
1.479 + fileMenu->addAction (a);
1.480 + connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
1.481
1.482 - a = new QAction( tr( "Open" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
1.483 - connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
1.484 + a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
1.485 + a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
1.486 + a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
1.487 + fileMenu->addAction (a);
1.488 + connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
1.489 + actionFileNewCopy=a;
1.490 +
1.491 + a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
1.492 + a->setStatusTip (tr( "Open","Status tip File menu" ) );
1.493 + a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
1.494 a->addTo( tb );
1.495 - a->addTo( menu );
1.496 + fileMenu->addAction (a);
1.497 + connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
1.498
1.499 - lastMapsMenu = new QPopupMenu (this);
1.500 -
1.501 - menu->insertItem (tr("Open Recent"),lastMapsMenu );
1.502 - menu->insertSeparator();
1.503 + fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
1.504 + fileMenu->addSeparator();
1.505
1.506 - a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
1.507 - connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
1.508 + a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
1.509 + a->setStatusTip ( tr( "Save","Status tip file menu" ));
1.510 + a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
1.511 a->addTo( tb );
1.512 - a->addTo( menu );
1.513 + fileMenu->addAction (a);
1.514 + connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
1.515 actionFileSave=a;
1.516
1.517 - a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
1.518 - connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
1.519 - a->addTo( menu );
1.520 -
1.521 - menu->insertSeparator();
1.522 -
1.523 - a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir" ), 0, this, "export" );
1.524 - connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
1.525 - a->addTo( menu );
1.526 -
1.527 - exportMenu = new QPopupMenu (this);
1.528 - menu->insertItem (tr("Export"),exportMenu );
1.529 -
1.530 - menu->insertSeparator();
1.531 -
1.532 -
1.533 - a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
1.534 - connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
1.535 + a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
1.536 + a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
1.537 + fileMenu->addAction (a);
1.538 + connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
1.539 +
1.540 + fileMenu->addSeparator();
1.541 +
1.542 + fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
1.543 +
1.544 + a = new QAction(tr("KDE Bookmarks"), this);
1.545 + a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
1.546 + a->addTo (fileImportMenu);
1.547 + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
1.548 +
1.549 + if (settings.value( "/mainwindow/showTestMenu",false).toBool())
1.550 + {
1.551 + a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
1.552 + a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
1.553 + a->addTo (fileImportMenu);
1.554 + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
1.555 + }
1.556 +
1.557 + a = new QAction("Freemind...",this);
1.558 + a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
1.559 + fileImportMenu->addAction (a);
1.560 + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
1.561 +
1.562 + a = new QAction("Mind Manager...",this);
1.563 + a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
1.564 + fileImportMenu->addAction (a);
1.565 + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
1.566 +
1.567 + a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
1.568 + a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
1.569 + fileImportMenu->addAction (a);
1.570 + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
1.571 +
1.572 + fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
1.573 +
1.574 + a = new QAction( tr("Image%1","File export menu").arg("..."), this);
1.575 + a->setStatusTip( tr( "Export map as image","status tip file menu" ));
1.576 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
1.577 + fileExportMenu->addAction (a);
1.578 +
1.579 + a = new QAction( "Open Office...", this);
1.580 + a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
1.581 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
1.582 + fileExportMenu->addAction (a);
1.583 +
1.584 + a = new QAction( "Webpage (XHTML)...",this );
1.585 + a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
1.586 + a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
1.587 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
1.588 + fileExportMenu->addAction (a);
1.589 +
1.590 + a = new QAction( "Text (ASCII)...", this);
1.591 + a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
1.592 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
1.593 + fileExportMenu->addAction (a);
1.594 +
1.595 + a = new QAction( "Spreadsheet (CSV)...", this);
1.596 + a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
1.597 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
1.598 + fileExportMenu->addAction (a);
1.599 +
1.600 + a = new QAction( tr("KDE Bookmarks","File menu"), this);
1.601 + a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
1.602 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
1.603 + fileExportMenu->addAction (a);
1.604 +
1.605 + a = new QAction( "Taskjuggler...", this );
1.606 + a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
1.607 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
1.608 + fileExportMenu->addAction (a);
1.609 +
1.610 + a = new QAction( "LaTeX...", this);
1.611 + a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
1.612 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
1.613 + fileExportMenu->addAction (a);
1.614 +
1.615 + a = new QAction( "XML..." , this );
1.616 + a->setStatusTip (tr( "Export as %1").arg("XML"));
1.617 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
1.618 + fileExportMenu->addAction (a);
1.619 +
1.620 + fileMenu->addSeparator();
1.621 +
1.622 + a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
1.623 + a->setStatusTip ( tr( "Print" ,"File menu") );
1.624 + a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
1.625 a->addTo( tb );
1.626 - a->addTo( menu );
1.627 + fileMenu->addAction (a);
1.628 + connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
1.629 actionFilePrint=a;
1.630
1.631 - a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
1.632 - connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
1.633 - a->addTo( menu );
1.634 -
1.635 - a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
1.636 - connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
1.637 - a->addTo( menu );
1.638 + a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
1.639 + a->setStatusTip (tr( "Close Map" ) );
1.640 + a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
1.641 + fileMenu->addAction (a);
1.642 + connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
1.643 +
1.644 + a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
1.645 + a->setStatusTip ( tr( "Exit")+" "+vymName );
1.646 + a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
1.647 + fileMenu->addAction (a);
1.648 + connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
1.649 }
1.650
1.651
1.652 //Edit Actions
1.653 void Main::setupEditActions()
1.654 {
1.655 - QToolBar *tb = new QToolBar( this );
1.656 + QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
1.657 tb->setLabel( "Edit Actions" );
1.658 - QPopupMenu *menu = new QPopupMenu( this );
1.659 - menuBar()->insertItem( tr( "&Edit" ), menu );
1.660 + tb->setObjectName ("actionsTB");
1.661 + QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
1.662
1.663 QAction *a;
1.664 - a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
1.665 - connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
1.666 + QAction *alt;
1.667 + a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
1.668 + connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
1.669 + a->setStatusTip (tr( "Undo" ) );
1.670 + a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
1.671 a->setEnabled (false);
1.672 - a->addTo( tb );
1.673 - a->addTo( menu );
1.674 + tb->addAction (a);
1.675 + editMenu->addAction (a);
1.676 actionEditUndo=a;
1.677 - /*
1.678 - a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
1.679 - connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
1.680 - a->addTo( tb );
1.681 - a->addTo( menu );
1.682 - */
1.683 - menu->insertSeparator();
1.684 - a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
1.685 - connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
1.686 +
1.687 + a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
1.688 + a->setStatusTip (tr( "Redo" ));
1.689 + a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
1.690 + tb->addAction (a);
1.691 + editMenu->addAction (a);
1.692 + connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
1.693 + actionEditRedo=a;
1.694 +
1.695 + editMenu->addSeparator();
1.696 + a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
1.697 + a->setStatusTip ( tr( "Copy" ) );
1.698 + a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
1.699 a->setEnabled (false);
1.700 - a->addTo( tb );
1.701 - a->addTo( menu );
1.702 + tb->addAction (a);
1.703 + editMenu->addAction (a);
1.704 + connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
1.705 actionEditCopy=a;
1.706 - a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
1.707 - connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
1.708 +
1.709 + a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
1.710 + a->setStatusTip ( tr( "Cut" ) );
1.711 + a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
1.712 a->setEnabled (false);
1.713 - a->addTo( tb );
1.714 - a->addTo( menu );
1.715 + tb->addAction (a);
1.716 + editMenu->addAction (a);
1.717 actionEditCut=a;
1.718 - a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
1.719 - connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
1.720 + connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
1.721 +
1.722 + a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
1.723 + connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
1.724 + a->setStatusTip ( tr( "Paste" ) );
1.725 + a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
1.726 a->setEnabled (false);
1.727 - a->addTo( tb );
1.728 - a->addTo( menu );
1.729 + tb->addAction (a);
1.730 + editMenu->addAction (a);
1.731 actionEditPaste=a;
1.732 - a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
1.733 - connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
1.734 +
1.735 + // Shortcuts to modify heading:
1.736 + a = new QAction(tr( "Edit heading","Edit menu" ),this);
1.737 + a->setStatusTip ( tr( "edit Heading" ));
1.738 + a->setShortcut ( Qt::Key_Enter); //Edit heading
1.739 +// a->setShortcutContext (Qt::WindowShortcut);
1.740 + addAction (a);
1.741 + connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
1.742 + actionListBranches.append(a);
1.743 + a = new QAction( tr( "Edit heading","Edit menu" ), this);
1.744 + a->setStatusTip (tr( "edit Heading" ));
1.745 + a->setShortcut (Qt::Key_Return ); //Edit heading
1.746 + //a->setShortcutContext (Qt::WindowShortcut);
1.747 + addAction (a);
1.748 + connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
1.749 + actionListBranches.append(a);
1.750 + editMenu->addAction (a);
1.751 + actionEditHeading=a;
1.752 + a = new QAction( tr( "Edit heading","Edit menu" ), this);
1.753 + a->setStatusTip (tr( "edit Heading" ));
1.754 + //a->setShortcut ( Qt::Key_F2 ); //Edit heading
1.755 + a->setShortcutContext (Qt::WindowShortcut);
1.756 + addAction (a);
1.757 + connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
1.758 + actionListBranches.append(a);
1.759 +
1.760 + // Shortcut to delete selection
1.761 + a = new QAction( tr( "Delete Selection","Edit menu" ),this);
1.762 + a->setStatusTip (tr( "Delete Selection" ));
1.763 + a->setShortcut ( Qt::Key_Delete); //Delete selection
1.764 + a->setShortcutContext (Qt::WindowShortcut);
1.765 + addAction (a);
1.766 + connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
1.767 + actionEditDelete=a;
1.768 +
1.769 + // Shortcut to add mapcenter
1.770 + a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
1.771 + connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
1.772 + actionEditAddMapCenter = a;
1.773 +
1.774 +
1.775 + // Shortcut to add branch
1.776 + alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
1.777 + alt->setStatusTip ( tr( "Add a branch as child of selection" ));
1.778 + alt->setShortcut (Qt::Key_A); //Add branch
1.779 + alt->setShortcutContext (Qt::WindowShortcut);
1.780 + addAction (alt);
1.781 + connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
1.782 + a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
1.783 + a->setStatusTip ( tr( "Add a branch as child of selection" ));
1.784 + a->setShortcut (Qt::Key_Insert); //Add branch
1.785 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
1.786 + actionListBranches.append(a);
1.787 + #if defined (Q_OS_MACX)
1.788 + // In OSX show different shortcut in menues, the keys work indepently always
1.789 + actionEditAddBranch=alt;
1.790 + #else
1.791 + actionEditAddBranch=a;
1.792 + #endif
1.793 + editMenu->addAction (actionEditAddBranch);
1.794 + tb->addAction (actionEditAddBranch);
1.795 +
1.796 +
1.797 + // Add branch by inserting it at selection
1.798 + a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
1.799 + a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
1.800 + a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
1.801 + a->setShortcutContext (Qt::WindowShortcut);
1.802 + addAction (a);
1.803 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
1.804 a->setEnabled (false);
1.805 - a->addTo( tb );
1.806 - a->addTo( menu );
1.807 + actionListBranches.append(a);
1.808 + actionEditAddBranchBefore=a;
1.809 + a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
1.810 + a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
1.811 + a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
1.812 + a->setShortcutContext (Qt::WindowShortcut);
1.813 + addAction (a);
1.814 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
1.815 + actionListBranches.append(a);
1.816 +
1.817 + // Add branch above
1.818 + a = new QAction(tr( "Add branch above","Edit menu" ), this);
1.819 + a->setStatusTip ( tr( "Add a branch above selection" ));
1.820 + a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
1.821 + a->setShortcutContext (Qt::WindowShortcut);
1.822 + addAction (a);
1.823 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
1.824 + a->setEnabled (false);
1.825 + actionListBranches.append(a);
1.826 + actionEditAddBranchAbove=a;
1.827 + a = new QAction(tr( "Add branch above","Edit menu" ), this);
1.828 + a->setStatusTip ( tr( "Add a branch above selection" ));
1.829 + a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
1.830 + a->setShortcutContext (Qt::WindowShortcut);
1.831 + addAction (a);
1.832 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
1.833 + actionListBranches.append(a);
1.834 +
1.835 + // Add branch below
1.836 + a = new QAction(tr( "Add branch below","Edit menu" ), this);
1.837 + a->setStatusTip ( tr( "Add a branch below selection" ));
1.838 + a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
1.839 + a->setShortcutContext (Qt::WindowShortcut);
1.840 + addAction (a);
1.841 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
1.842 + a->setEnabled (false);
1.843 + actionListBranches.append(a);
1.844 + actionEditAddBranchBelow=a;
1.845 + a = new QAction(tr( "Add branch below","Edit menu" ), this);
1.846 + a->setStatusTip ( tr( "Add a branch below selection" ));
1.847 + a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
1.848 + a->setShortcutContext (Qt::WindowShortcut);
1.849 + addAction (a);
1.850 + connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
1.851 + actionListBranches.append(a);
1.852 +
1.853 + a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
1.854 + a->setStatusTip ( tr( "Move branch up" ) );
1.855 + a->setShortcut (Qt::Key_PageUp ); // Move branch up
1.856 + a->setEnabled (false);
1.857 + tb->addAction (a);
1.858 + editMenu->addAction (a);
1.859 + connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
1.860 actionEditMoveUp=a;
1.861 - a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
1.862 - connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
1.863 +
1.864 + a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
1.865 + connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
1.866 + a->setStatusTip (tr( "Move branch down" ) );
1.867 + a->setShortcut ( Qt::Key_PageDown ); // Move branch down
1.868 a->setEnabled (false);
1.869 - a->addTo( tb );
1.870 - a->addTo( menu );
1.871 + tb->addAction (a);
1.872 + editMenu->addAction (a);
1.873 actionEditMoveDown=a;
1.874 -
1.875 - a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
1.876 - connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
1.877 - a->setEnabled (false);
1.878 - a->addTo( tb );
1.879 - a->addTo( menu );
1.880 - actionEditToggleScroll=a;
1.881
1.882 - a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
1.883 - connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
1.884 - a->addTo( menu );
1.885 + a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
1.886 + connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
1.887 + a->setEnabled (true);
1.888 + a->addTo( tb );
1.889 + editMenu->addAction (a);
1.890 + actionEditSortChildren=a;
1.891 +
1.892 + a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
1.893 + a->setShortcut ( Qt::Key_ScrollLock );
1.894 + a->setStatusTip (tr( "Scroll branch" ) );
1.895 + connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
1.896 +
1.897 + alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
1.898 + alt->setShortcut ( Qt::Key_S ); // Scroll branch
1.899 + alt->setStatusTip (tr( "Scroll branch" ));
1.900 + connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
1.901 + #if defined(Q_OS_MACX)
1.902 + actionEditToggleScroll=alt;
1.903 + #else
1.904 + actionEditToggleScroll=a;
1.905 + #endif
1.906 + actionEditToggleScroll->setEnabled (false);
1.907 + actionEditToggleScroll->setToggleAction(true);
1.908 + tb->addAction (actionEditToggleScroll);
1.909 + editMenu->addAction ( actionEditToggleScroll);
1.910 + editMenu->addAction (actionEditToggleScroll);
1.911 + addAction (a);
1.912 + addAction (alt);
1.913 + actionListBranches.append(actionEditToggleScroll);
1.914
1.915 - menu->insertSeparator();
1.916 -
1.917 - a = new QAction( tr( "Find" ), QPixmap(), tr( "Find" ), CTRL + Key_F, this, "find" );
1.918 - connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
1.919 - a->addTo( menu );
1.920 + a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
1.921 + a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
1.922 + editMenu->addAction (a);
1.923 + connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
1.924 +
1.925 + editMenu->addSeparator();
1.926 +
1.927 + a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
1.928 + a->setStatusTip (tr( "Find" ) );
1.929 + a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
1.930 + editMenu->addAction (a);
1.931 + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
1.932
1.933 - menu->insertSeparator();
1.934 -
1.935 - a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
1.936 - connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
1.937 - a->addTo( menu );
1.938 - a->addTo( tb );
1.939 - a->setEnabled (false);
1.940 + editMenu->addSeparator();
1.941 +
1.942 + a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
1.943 + a->setShortcut (Qt::CTRL + Qt::Key_U );
1.944 + a->setShortcut (tr( "Open URL" ));
1.945 + tb->addAction (a);
1.946 + addAction(a);
1.947 + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
1.948 actionEditOpenURL=a;
1.949
1.950 - a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL" ), SHIFT + CTRL + Key_U, this, "url" );
1.951 - connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
1.952 - a->addTo( menu );
1.953 - a->setEnabled (false);
1.954 + a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
1.955 + a->setStatusTip (tr( "Open URL in new tab" ));
1.956 + //a->setShortcut (Qt::CTRL+Qt::Key_U );
1.957 + addAction(a);
1.958 + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
1.959 + actionEditOpenURLTab=a;
1.960 +
1.961 + a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
1.962 + a->setStatusTip (tr( "Open all URLs in subtree" ));
1.963 + addAction(a);
1.964 + actionListBranches.append(a);
1.965 + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
1.966 + actionEditOpenMultipleURLTabs=a;
1.967 +
1.968 + a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
1.969 + a->setStatusTip ( tr( "Edit URL" ) );
1.970 + a->setShortcut ( Qt::Key_U );
1.971 + a->setShortcutContext (Qt::WindowShortcut);
1.972 + actionListBranches.append(a);
1.973 + addAction(a);
1.974 + connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
1.975 actionEditURL=a;
1.976
1.977 - a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
1.978 - connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
1.979 - a->addTo( menu );
1.980 + a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
1.981 + a->setStatusTip ( tr( "Edit local URL" ) );
1.982 + a->setShortcut (Qt::SHIFT + Qt::Key_U );
1.983 + a->setShortcutContext (Qt::WindowShortcut);
1.984 + actionListBranches.append(a);
1.985 + addAction(a);
1.986 + connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
1.987 + actionEditLocalURL=a;
1.988 +
1.989 + a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
1.990 + a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
1.991 a->setEnabled (false);
1.992 + actionListBranches.append(a);
1.993 + connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
1.994 actionEditHeading2URL=a;
1.995
1.996 - a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
1.997 - connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
1.998 + a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
1.999 + a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
1.1000 a->setEnabled (false);
1.1001 + actionListBranches.append(a);
1.1002 + connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
1.1003 actionEditBugzilla2URL=a;
1.1004
1.1005 - menu->insertSeparator();
1.1006 + a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
1.1007 + a->setStatusTip ( tr( "Create URL to Novell FATE" ));
1.1008 + a->setEnabled (false);
1.1009 + actionListBranches.append(a);
1.1010 + connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
1.1011 + actionEditFATE2URL=a;
1.1012
1.1013 - a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flag_vymlink_xpm), tr( "Jump to map" ), 0, this, "jumpMap" );
1.1014 - connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
1.1015 - a->addTo( menu );
1.1016 - a->addTo( tb );
1.1017 + a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
1.1018 + a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
1.1019 + tb->addAction (a);
1.1020 a->setEnabled (false);
1.1021 + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
1.1022 actionEditOpenVymLink=a;
1.1023
1.1024 - a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link" ), 0, this, "editLinkMap" );
1.1025 - connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
1.1026 - a->addTo( menu );
1.1027 + a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
1.1028 + a->setStatusTip ( tr( "Open all vym links in subtree" ));
1.1029 a->setEnabled (false);
1.1030 + actionListBranches.append(a);
1.1031 + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
1.1032 + actionEditOpenMultipleVymLinks=a;
1.1033 +
1.1034 +
1.1035 + a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
1.1036 + a->setEnabled (false);
1.1037 + a->setStatusTip ( tr( "Edit link to another vym map" ));
1.1038 + connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
1.1039 + actionListBranches.append(a);
1.1040 actionEditVymLink=a;
1.1041
1.1042 - a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
1.1043 - connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
1.1044 - a->addTo( menu );
1.1045 + a = new QAction(tr( "Delete vym link","Edit menu" ),this);
1.1046 + a->setStatusTip ( tr( "Delete link to another vym map" ));
1.1047 a->setEnabled (false);
1.1048 + connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
1.1049 actionEditDeleteVymLink=a;
1.1050
1.1051 - menu->insertSeparator();
1.1052 -
1.1053 - a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info" ), 0, this, "editMapInfo" );
1.1054 - connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
1.1055 - a->addTo( menu );
1.1056 + a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
1.1057 + a->setStatusTip ( tr( "Hide object in exports" ) );
1.1058 + a->setShortcut (Qt::Key_H );
1.1059 + a->setToggleAction(true);
1.1060 + tb->addAction (a);
1.1061 + a->setEnabled (false);
1.1062 + connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
1.1063 + actionEditToggleHideExport=a;
1.1064 +
1.1065 + a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
1.1066 + a->setStatusTip ( tr( "Edit Map Info" ));
1.1067 a->setEnabled (true);
1.1068 + connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
1.1069 actionEditMapInfo=a;
1.1070
1.1071 - menu->insertSeparator();
1.1072 -
1.1073 - // Shortcuts to modify heading:
1.1074 - a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
1.1075 - connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
1.1076 + // Import at selection (adding to selection)
1.1077 + a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
1.1078 + a->setStatusTip (tr( "Add map at selection" ));
1.1079 + connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
1.1080 a->setEnabled (false);
1.1081 - a->addTo ( menu );
1.1082 - actionEditHeading=a;
1.1083 - a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
1.1084 - connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
1.1085 - //a->addTo ( menu );
1.1086 -
1.1087 - // Shortcut to delete selection
1.1088 - a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
1.1089 - connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
1.1090 + actionListBranches.append(a);
1.1091 + actionEditImportAdd=a;
1.1092 +
1.1093 + // Import at selection (replacing selection)
1.1094 + a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
1.1095 + a->setStatusTip (tr( "Replace selection with map" ));
1.1096 + connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
1.1097 a->setEnabled (false);
1.1098 - a->addTo ( menu );
1.1099 - actionEditDelete=a;
1.1100 -
1.1101 - // Shortcut to add branch
1.1102 - #if defined (Q_OS_MACX)
1.1103 - a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), CTRL + Key_I, this, "newBranch" );
1.1104 - #else
1.1105 - a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
1.1106 - #endif
1.1107 - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
1.1108 + actionListBranches.append(a);
1.1109 + actionEditImportReplace=a;
1.1110 +
1.1111 + // Save selection
1.1112 + a = new QAction( tr( "Save selection","Edit menu" ), this);
1.1113 + a->setStatusTip (tr( "Save selection" ));
1.1114 + connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
1.1115 a->setEnabled (false);
1.1116 - a->addTo ( menu );
1.1117 - actionEditAddBranch=a;
1.1118 -
1.1119 - // Add branch above
1.1120 - a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
1.1121 - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
1.1122 + actionListBranches.append(a);
1.1123 + actionEditSaveBranch=a;
1.1124 +
1.1125 + // Only remove branch, not its childs
1.1126 + a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
1.1127 + a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
1.1128 + a->setShortcut (Qt::ALT + Qt::Key_Delete );
1.1129 + connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
1.1130 a->setEnabled (false);
1.1131 - a->addTo ( menu );
1.1132 - actionEditAddBranchAbove=a;
1.1133 -
1.1134 - // Add branch below
1.1135 - a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
1.1136 - connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
1.1137 + addAction (a);
1.1138 + actionListBranches.append(a);
1.1139 + actionEditDeleteKeepChilds=a;
1.1140 +
1.1141 + // Only remove childs of a branch
1.1142 + a = new QAction( tr( "Remove childs","Edit menu" ), this);
1.1143 + a->setStatusTip (tr( "Remove childs of branch" ));
1.1144 + a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
1.1145 + connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
1.1146 a->setEnabled (false);
1.1147 - a->addTo ( menu );
1.1148 - actionEditAddBranchBelow=a;
1.1149 -
1.1150 - // Import at selection (adding to selection)
1.1151 - a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
1.1152 - connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
1.1153 + actionListBranches.append(a);
1.1154 + actionEditDeleteChilds=a;
1.1155 +
1.1156 + // Shortcuts for navigating with cursor:
1.1157 + a = new QAction(tr( "Select upper branch","Edit menu" ), this);
1.1158 + a->setStatusTip ( tr( "Select upper branch" ));
1.1159 + a->setShortcut (Qt::Key_Up );
1.1160 + a->setShortcutContext (Qt::WindowShortcut);
1.1161 + addAction (a);
1.1162 + connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
1.1163 + a = new QAction( tr( "Select lower branch","Edit menu" ),this);
1.1164 + a->setStatusTip (tr( "Select lower branch" ));
1.1165 + a->setShortcut ( Qt::Key_Down );
1.1166 + a->setShortcutContext (Qt::WindowShortcut);
1.1167 + addAction (a);
1.1168 + connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
1.1169 + a = new QAction(tr( "Select left branch","Edit menu" ), this);
1.1170 + a->setStatusTip ( tr( "Select left branch" ));
1.1171 + a->setShortcut (Qt::Key_Left );
1.1172 + a->setShortcutContext (Qt::WindowShortcut);
1.1173 + addAction (a);
1.1174 + connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
1.1175 + a = new QAction( tr( "Select child branch","Edit menu" ), this);
1.1176 + a->setStatusTip (tr( "Select right branch" ));
1.1177 + a->setShortcut (Qt::Key_Right);
1.1178 + a->setShortcutContext (Qt::WindowShortcut);
1.1179 + addAction (a);
1.1180 + connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
1.1181 + a = new QAction( tr( "Select first branch","Edit menu" ), this);
1.1182 + a->setStatusTip (tr( "Select first branch" ));
1.1183 + a->setShortcut (Qt::Key_Home );
1.1184 + a->setShortcutContext (Qt::WindowShortcut);
1.1185 + addAction (a);
1.1186 a->setEnabled (false);
1.1187 - a->addTo ( menu );
1.1188 - actionEditImportAdd=a;
1.1189 -
1.1190 - // Import at selection (replacing selection)
1.1191 - a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
1.1192 - connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
1.1193 + editMenu->addAction (a);
1.1194 + actionListBranches.append(a);
1.1195 + actionEditSelectFirst=a;
1.1196 + connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
1.1197 + a = new QAction( tr( "Select last branch","Edit menu" ),this);
1.1198 + a->setStatusTip (tr( "Select last branch" ));
1.1199 + a->setShortcut ( Qt::Key_End );
1.1200 + a->setShortcutContext (Qt::WindowShortcut);
1.1201 + addAction (a);
1.1202 + connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
1.1203 a->setEnabled (false);
1.1204 - a->addTo ( menu );
1.1205 - actionEditImportReplace=a;
1.1206 -
1.1207 - // Save selection
1.1208 - a = new QAction( tr( "Save selction" ),tr( "Save selection" ), 0, this, "saveSelection" );
1.1209 - connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
1.1210 - a->setEnabled (false);
1.1211 - a->addTo ( menu );
1.1212 - actionEditSaveBranch=a;
1.1213 -
1.1214 - // Shortcuts for navigating with cursor:
1.1215 - a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
1.1216 - connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
1.1217 - a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
1.1218 - connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
1.1219 - a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
1.1220 - connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
1.1221 - a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
1.1222 - connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
1.1223 - a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
1.1224 - a->setEnabled (false);
1.1225 - a->addTo ( menu );
1.1226 - actionEditSelectFirst=a;
1.1227 - connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
1.1228 - a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
1.1229 - connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
1.1230 - a->setEnabled (false);
1.1231 - a->addTo ( menu );
1.1232 + editMenu->addAction (a);
1.1233 + actionListBranches.append(a);
1.1234 actionEditSelectLast=a;
1.1235
1.1236 - a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" );
1.1237 - connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
1.1238 + a = new QAction( tr( "Add Image...","Edit menu" ), this);
1.1239 + a->setStatusTip (tr( "Add Image" ));
1.1240 + connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
1.1241 actionEditLoadImage=a;
1.1242 +
1.1243 + a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
1.1244 + a->setStatusTip (tr( "Set properties for selection" ));
1.1245 + a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
1.1246 + a->setShortcutContext (Qt::WindowShortcut);
1.1247 + a->setToggleAction (true);
1.1248 + addAction (a);
1.1249 + connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
1.1250 + actionViewTogglePropertyWindow=a;
1.1251 }
1.1252
1.1253 // Format Actions
1.1254 void Main::setupFormatActions()
1.1255 {
1.1256 - QPopupMenu *menu = new QPopupMenu( this );
1.1257 - menuBar()->insertItem( tr( "&Format" ), menu );
1.1258 -
1.1259 - QToolBar *tb = new QToolBar( this );
1.1260 + QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
1.1261 +
1.1262 + QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
1.1263 + tb->setObjectName ("formatTB");
1.1264 QAction *a;
1.1265 QPixmap pix( 16,16);
1.1266 - pix.fill (black);
1.1267 - actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" ), 0, this, "formatColor" );
1.1268 - connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
1.1269 - actionFormatColor->addTo( tb );
1.1270 - actionFormatColor->addTo( menu );
1.1271 - a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(formatcolorpicker_xpm), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
1.1272 - connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
1.1273 + pix.fill (Qt::black);
1.1274 + a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
1.1275 + a->setStatusTip ( tr( "Set Color" ));
1.1276 + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
1.1277 + a->addTo( tb );
1.1278 + formatMenu->addAction (a);
1.1279 + actionFormatColor=a;
1.1280 + a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
1.1281 + a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
1.1282 + a->setShortcut (Qt::CTRL + Qt::Key_K );
1.1283 + connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
1.1284 a->setEnabled (false);
1.1285 a->addTo( tb );
1.1286 - a->addTo( menu );
1.1287 + formatMenu->addAction (a);
1.1288 + actionListBranches.append(a);
1.1289 actionFormatPickColor=a;
1.1290 - a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
1.1291 - connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
1.1292 +
1.1293 + a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
1.1294 + a->setStatusTip ( tr( "Color branch" ) );
1.1295 + a->setShortcut (Qt::CTRL + Qt::Key_B);
1.1296 + connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1.1297 a->setEnabled (false);
1.1298 a->addTo( tb );
1.1299 - a->addTo( menu );
1.1300 - actionFormatColorBranch=a;
1.1301 - a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
1.1302 - connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
1.1303 + formatMenu->addAction (a);
1.1304 + actionListBranches.append(a);
1.1305 + actionFormatColorSubtree=a;
1.1306 +
1.1307 + a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1.1308 + a->setStatusTip ( tr( "Color Subtree" ));
1.1309 + a->setShortcut (Qt::CTRL + Qt::Key_T);
1.1310 + connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1.1311 a->setEnabled (false);
1.1312 - a->addTo( menu );
1.1313 + formatMenu->addAction (a);
1.1314 a->addTo( tb );
1.1315 + actionListBranches.append(a);
1.1316 actionFormatColorSubtree=a;
1.1317
1.1318 - menu->insertSeparator();
1.1319 - actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
1.1320 + formatMenu->addSeparator();
1.1321 + actionGroupFormatLinkStyles=new QActionGroup ( this);
1.1322 actionGroupFormatLinkStyles->setExclusive (true);
1.1323 - a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
1.1324 + a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1.1325 + a->setStatusTip (tr( "Line" ));
1.1326 a->setToggleAction(true);
1.1327 - connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
1.1328 + connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1.1329 + formatMenu->addAction (a);
1.1330 actionFormatLinkStyleLine=a;
1.1331 - a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
1.1332 + a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1.1333 + a->setStatusTip (tr( "Line" ));
1.1334 a->setToggleAction(true);
1.1335 - connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
1.1336 + connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1.1337 + formatMenu->addAction (a);
1.1338 actionFormatLinkStyleParabel=a;
1.1339 - a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
1.1340 + a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1.1341 + a->setStatusTip (tr( "PolyLine" ));
1.1342 a->setToggleAction(true);
1.1343 - connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
1.1344 + connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1.1345 + formatMenu->addAction (a);
1.1346 actionFormatLinkStylePolyLine=a;
1.1347 - a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
1.1348 + a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1.1349 + a->setStatusTip (tr( "PolyParabel" ) );
1.1350 a->setToggleAction(true);
1.1351 - connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
1.1352 + a->setChecked (true);
1.1353 + connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1.1354 + formatMenu->addAction (a);
1.1355 actionFormatLinkStylePolyParabel=a;
1.1356 - actionGroupFormatLinkStyles->addTo (menu);
1.1357
1.1358 - actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
1.1359 - actionGroupFormatFrameTypes->setExclusive (true);
1.1360 - a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
1.1361 + a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1.1362 + a->setStatusTip (tr( "Hide link" ));
1.1363 a->setToggleAction(true);
1.1364 - connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
1.1365 - actionFormatFrameNone=a;
1.1366 - a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
1.1367 + connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1.1368 + actionFormatHideLinkUnselected=a;
1.1369 +
1.1370 + formatMenu->addSeparator();
1.1371 + a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1.1372 + a->setStatusTip (tr( "Use same color for links and headings" ));
1.1373 a->setToggleAction(true);
1.1374 - connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
1.1375 - actionFormatFrameRectangle=a;
1.1376 -
1.1377 - menu->insertSeparator();
1.1378 - a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
1.1379 - a->setToggleAction(true);
1.1380 - connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
1.1381 - a->addTo( menu );
1.1382 + connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1.1383 + formatMenu->addAction (a);
1.1384 actionFormatLinkColorHint=a;
1.1385 - pix.fill (white);
1.1386 - actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color" ), 0, this, "formatLinkColor" );
1.1387 - connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
1.1388 - actionFormatLinkColor->addTo( menu );
1.1389 - actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" ), 0, this, "formatBackColor" );
1.1390 - connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
1.1391 - actionFormatBackColor->addTo( menu );
1.1392 +
1.1393 + pix.fill (Qt::white);
1.1394 + a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1.1395 + a->setStatusTip (tr( "Set Link Color" ));
1.1396 + formatMenu->addAction (a);
1.1397 + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1.1398 + actionFormatLinkColor=a;
1.1399 +
1.1400 + a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1.1401 + a->setStatusTip (tr( "Set Selection Color" ));
1.1402 + formatMenu->addAction (a);
1.1403 + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1.1404 + actionFormatSelectionColor=a;
1.1405 +
1.1406 + a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1.1407 + a->setStatusTip (tr( "Set Background Color" ));
1.1408 + formatMenu->addAction (a);
1.1409 + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1.1410 + actionFormatBackColor=a;
1.1411 +
1.1412 + a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1.1413 + a->setStatusTip (tr( "Set Background image" ));
1.1414 + formatMenu->addAction (a);
1.1415 + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1.1416 + actionFormatBackImage=a;
1.1417 }
1.1418
1.1419 // View Actions
1.1420 void Main::setupViewActions()
1.1421 {
1.1422 - QToolBar *tb = new QToolBar( this );
1.1423 + QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1.1424 tb->setLabel( "View Actions" );
1.1425 - QPopupMenu *menu = new QPopupMenu( this );
1.1426 - menuBar()->insertItem( tr( "&View" ), menu );
1.1427 + tb->setObjectName ("viewTB");
1.1428 + QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1.1429
1.1430 QAction *a;
1.1431 - a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), 0, this, "zoomReset" );
1.1432 - connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
1.1433 + a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1.1434 + a->setStatusTip ( tr( "Zoom reset" ) );
1.1435 + a->setShortcut (Qt::CTRL + Qt::Key_0 );
1.1436 a->addTo( tb );
1.1437 - a->addTo( menu );
1.1438 - a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
1.1439 - connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
1.1440 + viewMenu->addAction (a);
1.1441 + connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1.1442 +
1.1443 + a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1.1444 + a->setStatusTip (tr( "Zoom in" ));
1.1445 + a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1.1446 a->addTo( tb );
1.1447 - a->addTo( menu );
1.1448 - a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
1.1449 - connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
1.1450 + viewMenu->addAction (a);
1.1451 + connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1.1452 +
1.1453 + a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1.1454 + a->setStatusTip (tr( "Zoom out" ));
1.1455 + a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1.1456 a->addTo( tb );
1.1457 - a->addTo( menu );
1.1458 - a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
1.1459 - connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
1.1460 + viewMenu->addAction (a);
1.1461 + connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1.1462 +
1.1463 + a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1.1464 + a->setStatusTip (tr( "Show selection" ));
1.1465 + a->setShortcut (Qt::Key_Period);
1.1466 + a->addTo( tb );
1.1467 + viewMenu->addAction (a);
1.1468 + connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1.1469 +
1.1470 + viewMenu->addSeparator();
1.1471 +
1.1472 + a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1.1473 + a->setStatusTip ( tr( "Show Note Editor" ));
1.1474 + a->setShortcut ( Qt::CTRL + Qt::Key_E );
1.1475 a->setToggleAction(true);
1.1476 - if (textEditor->showWithMain())
1.1477 - a->setOn(true);
1.1478 - else
1.1479 - a->setOn(false);
1.1480 a->addTo( tb );
1.1481 - a->addTo( menu );
1.1482 + viewMenu->addAction (a);
1.1483 + connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1.1484 actionViewToggleNoteEditor=a;
1.1485 - a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
1.1486 - connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1.1487 - a->addTo( menu );
1.1488 - a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
1.1489 - connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1.1490 - a->addTo( menu );
1.1491 +
1.1492 + a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1.1493 + a->setStatusTip ( tr( "Show History Window" ));
1.1494 + a->setShortcut ( Qt::CTRL + Qt::Key_H );
1.1495 + a->setToggleAction(true);
1.1496 + a->addTo( tb );
1.1497 + viewMenu->addAction (a);
1.1498 + connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1.1499 + actionViewToggleHistoryWindow=a;
1.1500 +
1.1501 + viewMenu->addAction (actionViewTogglePropertyWindow);
1.1502 +
1.1503 + viewMenu->addSeparator();
1.1504 +
1.1505 + a = new QAction(tr( "Antialiasing","View action" ),this );
1.1506 + a->setStatusTip ( tr( "Antialiasing" ));
1.1507 + a->setToggleAction(true);
1.1508 + a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1.1509 + viewMenu->addAction (a);
1.1510 + connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1.1511 + actionViewToggleAntiAlias=a;
1.1512 +
1.1513 + a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1.1514 + a->setStatusTip (a->text());
1.1515 + a->setToggleAction(true);
1.1516 + a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1.1517 + viewMenu->addAction (a);
1.1518 + connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1.1519 + actionViewToggleSmoothPixmapTransform=a;
1.1520 +
1.1521 + a = new QAction(tr( "Next Map","View action" ), this);
1.1522 + a->setStatusTip (a->text());
1.1523 + a->setShortcut (Qt::ALT + Qt::Key_N );
1.1524 + viewMenu->addAction (a);
1.1525 + connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1.1526 +
1.1527 + a = new QAction (tr( "Previous Map","View action" ), this );
1.1528 + a->setStatusTip (a->text());
1.1529 + a->setShortcut (Qt::ALT + Qt::Key_P );
1.1530 + viewMenu->addAction (a);
1.1531 + connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1.1532 +}
1.1533 +
1.1534 +// Mode Actions
1.1535 +void Main::setupModeActions()
1.1536 +{
1.1537 + //QPopupMenu *menu = new QPopupMenu( this );
1.1538 + //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1.1539 +
1.1540 + QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1.1541 + tb->setObjectName ("modesTB");
1.1542 + QAction *a;
1.1543 + actionGroupModModes=new QActionGroup ( this);
1.1544 + actionGroupModModes->setExclusive (true);
1.1545 + a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1.1546 + a->setShortcut (Qt::Key_J);
1.1547 + a->setStatusTip ( tr( "Use modifier to color branches" ));
1.1548 + a->setToggleAction(true);
1.1549 + a->addTo (tb);
1.1550 + a->setOn(true);
1.1551 + actionModModeColor=a;
1.1552 +
1.1553 + a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1.1554 + a->setShortcut( Qt::Key_K);
1.1555 + a->setStatusTip( tr( "Use modifier to copy" ));
1.1556 + a->setToggleAction(true);
1.1557 + a->addTo (tb);
1.1558 + actionModModeCopy=a;
1.1559 +
1.1560 + a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1.1561 + a->setShortcut (Qt::Key_L);
1.1562 + a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1.1563 + a->setToggleAction(true);
1.1564 + a->addTo (tb);
1.1565 + actionModModeXLink=a;
1.1566 }
1.1567
1.1568 // Flag Actions
1.1569 void Main::setupFlagActions()
1.1570 {
1.1571 - standardFlagsDefault->makeToolbar(this, "Standard Flags");
1.1572 + // Create System Flags
1.1573 + QToolBar *tb=NULL;
1.1574 + bool avis=true;
1.1575 +
1.1576 + systemFlagsDefault = new FlagRowObj ();
1.1577 + systemFlagsDefault->setVisibility (false);
1.1578 + systemFlagsDefault->setName ("systemFlagsDef");
1.1579 +
1.1580 + FlagObj *fo = new FlagObj ();
1.1581 + fo->load(QPixmap(flagsPath+"flag-note.png"));
1.1582 + setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1.1583 +
1.1584 + fo->load(QPixmap(flagsPath+"flag-url.png"));
1.1585 + setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1.1586 +
1.1587 + fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1.1588 + setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1.1589 +
1.1590 + fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1.1591 + setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1.1592 +
1.1593 + fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1.1594 + setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1.1595 +
1.1596 + fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1.1597 + setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1.1598 +
1.1599 + // Create Standard Flags
1.1600 + tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1.1601 + tb->setObjectName ("standardFlagTB");
1.1602 +
1.1603 + standardFlagsDefault = new FlagRowObj ();
1.1604 + standardFlagsDefault->setVisibility (false);
1.1605 + standardFlagsDefault->setName ("standardFlagsDef");
1.1606 + standardFlagsDefault->setToolBar (tb);
1.1607 +
1.1608 + fo->load(flagsPath+"flag-exclamationmark.png");
1.1609 + fo->setGroup("standard-mark");
1.1610 + setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1.1611 +
1.1612 + fo->load(flagsPath+"flag-questionmark.png");
1.1613 + fo->setGroup("standard-mark");
1.1614 + setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1.1615 +
1.1616 + fo->load(flagsPath+"flag-hook-green.png");
1.1617 + fo->setGroup("standard-hook");
1.1618 + setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1.1619 +
1.1620 + fo->load(flagsPath+"flag-cross-red.png");
1.1621 + fo->setGroup("standard-hook");
1.1622 + setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1.1623 + fo->unsetGroup();
1.1624 +
1.1625 + fo->load(flagsPath+"flag-stopsign.png");
1.1626 + setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1.1627 +
1.1628 + fo->load(flagsPath+"flag-smiley-good.png");
1.1629 + fo->setGroup("standard-smiley");
1.1630 + setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1.1631 +
1.1632 + fo->load(flagsPath+"flag-smiley-sad.png");
1.1633 + fo->setGroup("standard-smiley");
1.1634 + setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1.1635 +
1.1636 + fo->load(flagsPath+"flag-smiley-omg.png");
1.1637 + fo->setGroup("standard-smiley");
1.1638 + setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1.1639 + // Original omg.png (in KDE emoticons)
1.1640 + fo->unsetGroup();
1.1641 +
1.1642 + fo->load(flagsPath+"flag-kalarm.png");
1.1643 + setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1.1644 +
1.1645 + fo->load(flagsPath+"flag-phone.png");
1.1646 + setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1.1647 +
1.1648 + fo->load(flagsPath+"flag-lamp.png");
1.1649 + setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1.1650 +
1.1651 + fo->load(flagsPath+"flag-arrow-up.png");
1.1652 + fo->setGroup("standard-arrow");
1.1653 + setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1.1654 +
1.1655 + fo->load(flagsPath+"flag-arrow-down.png");
1.1656 + fo->setGroup("standard-arrow");
1.1657 + setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1.1658 +
1.1659 + fo->load(flagsPath+"flag-arrow-2up.png");
1.1660 + fo->setGroup("standard-arrow");
1.1661 + setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1.1662 +
1.1663 + fo->load(flagsPath+"flag-arrow-2down.png");
1.1664 + fo->setGroup("standard-arrow");
1.1665 + setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1.1666 + fo->unsetGroup();
1.1667 +
1.1668 + fo->load(flagsPath+"flag-thumb-up.png");
1.1669 + fo->setGroup("standard-thumb");
1.1670 + setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1.1671 +
1.1672 + fo->load(flagsPath+"flag-thumb-down.png");
1.1673 + fo->setGroup("standard-thumb");
1.1674 + setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1.1675 + fo->unsetGroup();
1.1676 +
1.1677 + fo->load(flagsPath+"flag-rose.png");
1.1678 + setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1.1679 +
1.1680 + fo->load(flagsPath+"flag-heart.png");
1.1681 + setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1.1682 +
1.1683 + fo->load(flagsPath+"flag-present.png");
1.1684 + setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1.1685 +
1.1686 + fo->load(flagsPath+"flag-flash.png");
1.1687 + setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1.1688 +
1.1689 + // Original: xsldbg_output.png
1.1690 + fo->load(flagsPath+"flag-info.png");
1.1691 + setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1.1692 +
1.1693 + // Original khelpcenter.png
1.1694 + fo->load(flagsPath+"flag-lifebelt.png");
1.1695 + setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1.1696 +
1.1697 + // Freemind flags
1.1698 +
1.1699 + avis=false;
1.1700 +
1.1701 + fo->load(flagsPath+"freemind/warning.png");
1.1702 + setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1.1703 +
1.1704 + for (int i=1; i<8; i++)
1.1705 + {
1.1706 + fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1.1707 + setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1.1708 + }
1.1709 +
1.1710 + fo->load(flagsPath+"freemind/back.png");
1.1711 + setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1.1712 +
1.1713 + fo->load(flagsPath+"freemind/forward.png");
1.1714 + setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1.1715 +
1.1716 + fo->load(flagsPath+"freemind/attach.png");
1.1717 + setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1.1718 +
1.1719 + fo->load(flagsPath+"freemind/clanbomber.png");
1.1720 + setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1.1721 +
1.1722 + fo->load(flagsPath+"freemind/desktopnew.png");
1.1723 + setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1.1724 +
1.1725 + fo->load(flagsPath+"freemind/flag.png");
1.1726 + setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1.1727 +
1.1728 +
1.1729 + fo->load(flagsPath+"freemind/gohome.png");
1.1730 + setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1.1731 +
1.1732 +
1.1733 + fo->load(flagsPath+"freemind/kaddressbook.png");
1.1734 + setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1.1735 +
1.1736 + fo->load(flagsPath+"freemind/knotify.png");
1.1737 + setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1.1738 +
1.1739 + fo->load(flagsPath+"freemind/korn.png");
1.1740 + setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1.1741 +
1.1742 + fo->load(flagsPath+"freemind/mail.png");
1.1743 + setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1.1744 +
1.1745 + fo->load(flagsPath+"freemind/password.png");
1.1746 + setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1.1747 +
1.1748 + fo->load(flagsPath+"freemind/pencil.png");
1.1749 + setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1.1750 +
1.1751 + fo->load(flagsPath+"freemind/stop.png");
1.1752 + setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1.1753 +
1.1754 + fo->load(flagsPath+"freemind/wizard.png");
1.1755 + setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1.1756 +
1.1757 + fo->load(flagsPath+"freemind/xmag.png");
1.1758 + setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1.1759 +
1.1760 + fo->load(flagsPath+"freemind/bell.png");
1.1761 + setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1.1762 +
1.1763 + fo->load(flagsPath+"freemind/bookmark.png");
1.1764 + setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1.1765 +
1.1766 + fo->load(flagsPath+"freemind/penguin.png");
1.1767 + setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1.1768 +
1.1769 + fo->load(flagsPath+"freemind/licq.png");
1.1770 + setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1.1771 +
1.1772 + delete (fo);
1.1773 }
1.1774
1.1775 +void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1.1776 +{
1.1777 + fo->setName(name);
1.1778 + fo->setToolTip (tooltip);
1.1779 + QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1.1780 + if (tb)
1.1781 + {
1.1782 + // StandardFlag
1.1783 + tb->addAction (a);
1.1784 + fo->setAction (a);
1.1785 + fo->setAlwaysVisible(aw);
1.1786 + a->setCheckable(true);
1.1787 + a->setObjectName(fo->getName());
1.1788 + a->setToolTip(tooltip);
1.1789 + connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1.1790 + standardFlagsDefault->addFlag (fo);
1.1791 + } else
1.1792 + {
1.1793 + // SystemFlag
1.1794 + systemFlagsDefault->addFlag (fo);
1.1795 + }
1.1796 +}
1.1797 +// Network Actions
1.1798 +void Main::setupNetworkActions()
1.1799 +{
1.1800 + if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1.1801 + return;
1.1802 + QMenu *netMenu = menuBar()->addMenu( "Network" );
1.1803 +
1.1804 + QAction *a;
1.1805 +
1.1806 + a = new QAction( "Start TCPserver for MapEditor",this);
1.1807 + //a->setStatusTip ( "Set application to open pdf files"));
1.1808 + a->setShortcut ( Qt::Key_T ); //New TCP server
1.1809 + connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1.1810 + netMenu->addAction (a);
1.1811 +
1.1812 + a = new QAction( "Connect MapEditor to server",this);
1.1813 + //a->setStatusTip ( "Set application to open pdf files"));
1.1814 + a->setShortcut ( Qt::Key_C ); // Connect to server
1.1815 + connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1.1816 + netMenu->addAction (a);
1.1817 +}
1.1818 +
1.1819 // Settings Actions
1.1820 void Main::setupSettingsActions()
1.1821 {
1.1822 - QPopupMenu *menu = new QPopupMenu( this );
1.1823 - menuBar()->insertItem( tr( "&Settings" ), menu );
1.1824 + QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1.1825
1.1826 QAction *a;
1.1827
1.1828 -
1.1829 - a = new QAction( tr( "Set application to open pdf files" ), QPixmap(), tr( "Set application to open pdf files" ), 0, this, "setPDF" );
1.1830 - connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1.1831 - a->addTo( menu );
1.1832 -
1.1833 - a = new QAction( tr( "Set application to open an URL" ), QPixmap(), tr( "Set application to open an URL" ), 0, this, "setURL" );
1.1834 - connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1.1835 - a->addTo( menu );
1.1836 -
1.1837 - menu->insertSeparator();
1.1838 - a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1.1839 + a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1.1840 + a->setStatusTip ( tr( "Set application to open pdf files"));
1.1841 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1.1842 + settingsMenu->addAction (a);
1.1843 +
1.1844 + a = new QAction( tr( "Set application to open external links","Settings action"), this);
1.1845 + a->setStatusTip( tr( "Set application to open external links"));
1.1846 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1.1847 + settingsMenu->addAction (a);
1.1848 +
1.1849 + a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1.1850 + a->setStatusTip( tr( "Set path for macros"));
1.1851 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1.1852 + settingsMenu->addAction (a);
1.1853 +
1.1854 + a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1.1855 + a->setStatusTip( tr( "Set number of undo levels"));
1.1856 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1.1857 + settingsMenu->addAction (a);
1.1858 +
1.1859 + settingsMenu->addSeparator();
1.1860 +
1.1861 + a = new QAction( tr( "Autosave","Settings action"), this);
1.1862 + a->setStatusTip( tr( "Autosave"));
1.1863 a->setToggleAction(true);
1.1864 - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1.1865 - a->addTo( menu );
1.1866 - actionSettingsAutoedit=a;
1.1867 -
1.1868 - a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1.1869 + a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1.1870 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1.1871 + settingsMenu->addAction (a);
1.1872 + actionSettingsAutosaveToggle=a;
1.1873 +
1.1874 + a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1.1875 + a->setStatusTip( tr( "Autosave time"));
1.1876 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1.1877 + settingsMenu->addAction (a);
1.1878 + actionSettingsAutosaveTime=a;
1.1879 +
1.1880 + a = new QAction( tr( "Write backup file on save","Settings action"), this);
1.1881 + a->setStatusTip( tr( "Write backup file on save"));
1.1882 a->setToggleAction(true);
1.1883 - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1.1884 - a->addTo( menu );
1.1885 - actionSettingsAutoselectHeading=a;
1.1886 + a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1.1887 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1.1888 + settingsMenu->addAction (a);
1.1889 + actionSettingsWriteBackupFile=a;
1.1890 +
1.1891 + settingsMenu->addSeparator();
1.1892 +
1.1893 + a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1.1894 + a->setStatusTip( tr( "Edit branch after adding it" ));
1.1895 + a->setToggleAction(true);
1.1896 + a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1.1897 + settingsMenu->addAction (a);
1.1898 + actionSettingsAutoEditNewBranch=a;
1.1899 +
1.1900 + a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1.1901 + a->setStatusTip( tr( "Select branch after adding it" ));
1.1902 + a->setToggleAction(true);
1.1903 + a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1.1904 + settingsMenu->addAction (a);
1.1905 + actionSettingsAutoSelectNewBranch=a;
1.1906
1.1907 - a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1.1908 + a= new QAction(tr( "Select existing heading","Settings action" ), this);
1.1909 + a->setStatusTip( tr( "Select heading before editing" ));
1.1910 a->setToggleAction(true);
1.1911 - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1.1912 - a->addTo( menu );
1.1913 - actionSettingsAutoselectText=a;
1.1914 + a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1.1915 + settingsMenu->addAction (a);
1.1916 + actionSettingsAutoSelectText=a;
1.1917
1.1918 - a= new QAction( tr( "Enable pasting into new branch" ), QPixmap(), tr( "Enable pasting into new branch" ), 0, this, "pastenewheading" );
1.1919 + a= new QAction( tr( "Delete key","Settings action" ), this);
1.1920 + a->setStatusTip( tr( "Delete key for deleting branches" ));
1.1921 a->setToggleAction(true);
1.1922 - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1.1923 - a->addTo( menu );
1.1924 - actionSettingsPasteNewHeading=a;
1.1925 + a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1.1926 + settingsMenu->addAction (a);
1.1927 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1.1928 + actionSettingsUseDelKey=a;
1.1929 +
1.1930 + a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1.1931 + a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1.1932 + a->setToggleAction(true);
1.1933 + a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1.1934 + settingsMenu->addAction (a);
1.1935 + actionSettingsUseFlagGroups=a;
1.1936
1.1937 - a= new QAction( tr( "Enable Delete key for deleting branches" ), QPixmap(), tr( "Enable Delete key" ), 0, this, "delkey" );
1.1938 + a= new QAction( tr( "Use hide flags","Settings action" ), this);
1.1939 + a->setStatusTip( tr( "Use hide flag during exports " ));
1.1940 a->setToggleAction(true);
1.1941 - a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1.1942 - a->addTo( menu );
1.1943 - actionSettingsUseDelKey=a;
1.1944 + a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1.1945 + settingsMenu->addAction (a);
1.1946 + actionSettingsUseHideExport=a;
1.1947 +
1.1948 + a = new QAction( tr( "Animation","Settings action"), this);
1.1949 + a->setStatusTip( tr( "Animation"));
1.1950 + a->setToggleAction(true);
1.1951 + a->setOn (settings.value("/animation/use",false).toBool() );
1.1952 + connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1.1953 + if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1.1954 + {
1.1955 + settingsMenu->addAction (a);
1.1956 + }
1.1957 + actionSettingsUseAnimation=a;
1.1958 }
1.1959
1.1960 // Test Actions
1.1961 void Main::setupTestActions()
1.1962 {
1.1963 - QPopupMenu *menu = new QPopupMenu( this );
1.1964 - menuBar()->insertItem( tr( "&Test" ), menu );
1.1965 + QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1.1966
1.1967 QAction *a;
1.1968 - a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1.1969 - connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1.1970 - a->addTo( menu );
1.1971 -
1.1972 - a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
1.1973 - connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
1.1974 - a->addTo( menu );
1.1975 + a = new QAction( "Test function 1" , this);
1.1976 + a->setStatusTip( "Call test function 1" );
1.1977 + testMenu->addAction (a);
1.1978 + connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1.1979 +
1.1980 + a = new QAction( "Test function 2" , this);
1.1981 + a->setStatusTip( "Call test function 2" );
1.1982 + testMenu->addAction (a);
1.1983 + connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1.1984 +
1.1985 + a = new QAction( "Command" , this);
1.1986 + a->setStatusTip( "Enter command to call in editor" );
1.1987 + connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1.1988 + testMenu->addAction (a);
1.1989 }
1.1990
1.1991 // Help Actions
1.1992 void Main::setupHelpActions()
1.1993 {
1.1994 - QPopupMenu *menu = new QPopupMenu( this );
1.1995 - menuBar()->insertItem( tr( "&Help" ), menu );
1.1996 + QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1.1997
1.1998 QAction *a;
1.1999 - a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1.2000 - connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1.2001 - a->addTo( menu );
1.2002 -
1.2003 - a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
1.2004 - connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1.2005 - a->addTo( menu );
1.2006 -
1.2007 - a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1.2008 - connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1.2009 - a->addTo( menu );
1.2010 + a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1.2011 + a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1.2012 + connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1.2013 + helpMenu->addAction (a);
1.2014 +
1.2015 + a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1.2016 + a->setStatusTip( tr( "Open VYM example maps " ));
1.2017 + connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1.2018 + helpMenu->addAction (a);
1.2019 +
1.2020 + a = new QAction( tr( "About VYM","Help action" ), this);
1.2021 + a->setStatusTip( tr( "About VYM")+vymName);
1.2022 + connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1.2023 + helpMenu->addAction (a);
1.2024 +
1.2025 + a = new QAction( tr( "About QT","Help action" ), this);
1.2026 + a->setStatusTip( tr( "Information about QT toolkit" ));
1.2027 + connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1.2028 + helpMenu->addAction (a);
1.2029 }
1.2030
1.2031 // Context Menus
1.2032 @@ -772,135 +1536,146 @@
1.2033 QAction*a;
1.2034
1.2035 // Context Menu for branch or mapcenter
1.2036 - branchContextMenu =new QPopupMenu (this);
1.2037 - actionEditAddBranch->addTo ( branchContextMenu );
1.2038 - actionEditAddBranchAbove->addTo ( branchContextMenu );
1.2039 - actionEditAddBranchBelow->addTo ( branchContextMenu );
1.2040 + branchContextMenu =new QMenu (this);
1.2041 + branchContextMenu->addAction (actionViewTogglePropertyWindow);
1.2042 + branchContextMenu->addSeparator();
1.2043 +
1.2044 + // Submenu "Add"
1.2045 + branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1.2046 + branchAddContextMenu->addAction (actionEditPaste );
1.2047 + branchAddContextMenu->addAction ( actionEditAddBranch );
1.2048 + branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1.2049 + branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1.2050 + branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1.2051 + branchAddContextMenu->addSeparator();
1.2052 + branchAddContextMenu->addAction ( actionEditImportAdd );
1.2053 + branchAddContextMenu->addAction ( actionEditImportReplace );
1.2054 +
1.2055 + // Submenu "Remove"
1.2056 + branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1.2057 + branchRemoveContextMenu->addAction (actionEditCut);
1.2058 + branchRemoveContextMenu->addAction ( actionEditDelete );
1.2059 + branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1.2060 + branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1.2061 +
1.2062 +
1.2063 actionEditSaveBranch->addTo( branchContextMenu );
1.2064 - branchContextMenu->insertSeparator();
1.2065 - actionEditImportAdd->addTo ( branchContextMenu );
1.2066 - actionEditImportReplace->addTo ( branchContextMenu );
1.2067 - branchContextMenu->insertSeparator();
1.2068 - actionEditOpenURL->addTo ( branchContextMenu );
1.2069 - actionEditURL->addTo ( branchContextMenu );
1.2070 - actionEditHeading2URL->addTo ( branchContextMenu );
1.2071 - if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1.2072 - actionEditBugzilla2URL->addTo( branchContextMenu );
1.2073 - branchContextMenu->insertSeparator();
1.2074 - actionEditOpenVymLink->addTo ( branchContextMenu );
1.2075 - actionEditVymLink->addTo ( branchContextMenu );
1.2076 - actionEditDeleteVymLink->addTo ( branchContextMenu );
1.2077 - branchContextMenu->insertSeparator();
1.2078 - actionEditLoadImage->addTo( branchContextMenu );
1.2079 - branchContextMenu->insertSeparator();
1.2080 - actionEditCopy->addTo( branchContextMenu );
1.2081 - actionEditCut->addTo( branchContextMenu );
1.2082 - actionEditPaste->addTo( branchContextMenu );
1.2083 - branchContextMenu->insertSeparator();
1.2084 - actionGroupFormatFrameTypes->addTo( branchContextMenu );
1.2085 -
1.2086 + actionFileNewCopy->addTo (branchContextMenu );
1.2087 +
1.2088 + branchContextMenu->addSeparator();
1.2089 + branchContextMenu->addAction ( actionEditLoadImage);
1.2090 +
1.2091 + // Submenu for Links (URLs, vymLinks)
1.2092 + branchLinksContextMenu =new QMenu (this);
1.2093 +
1.2094 + branchContextMenu->addSeparator();
1.2095 + branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1.2096 + branchLinksContextMenu->addAction ( actionEditOpenURL );
1.2097 + branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1.2098 + branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1.2099 + branchLinksContextMenu->addAction ( actionEditURL );
1.2100 + branchLinksContextMenu->addAction ( actionEditLocalURL );
1.2101 + branchLinksContextMenu->addAction ( actionEditHeading2URL );
1.2102 + branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1.2103 + if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1.2104 + {
1.2105 + branchLinksContextMenu->addAction ( actionEditFATE2URL );
1.2106 + }
1.2107 + branchLinksContextMenu->addSeparator();
1.2108 + branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1.2109 + branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1.2110 + branchLinksContextMenu->addAction ( actionEditVymLink );
1.2111 + branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1.2112 +
1.2113 +
1.2114 + // Context Menu for XLinks in a branch menu
1.2115 + // This will be populated "on demand" in MapEditor::updateActions
1.2116 + branchContextMenu->addSeparator();
1.2117 + branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1.2118 + branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1.2119 + connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1.2120 + connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1.2121 +
1.2122 +
1.2123 // Context menu for floatimage
1.2124 - floatimageContextMenu =new QPopupMenu (this);
1.2125 - saveImageFormatMenu=new QPopupMenu (this);
1.2126 - exportImageFormatMenu=new QPopupMenu (this);
1.2127 -
1.2128 - QStrList fmt = QImage::outputFormats();
1.2129 - for (const char* f = fmt.first(); f; f = fmt.next())
1.2130 - {
1.2131 - saveImageFormatMenu->insertItem( f );
1.2132 - exportImageFormatMenu->insertItem( f );
1.2133 - }
1.2134 - connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1.2135 - connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1.2136 - floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1.2137 -
1.2138 - floatimageContextMenu->insertSeparator();
1.2139 + floatimageContextMenu =new QMenu (this);
1.2140 + a= new QAction (tr ("Save image","Context action"),this);
1.2141 + connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1.2142 + floatimageContextMenu->addAction (a);
1.2143 +
1.2144 + floatimageContextMenu->addSeparator();
1.2145 actionEditCopy->addTo( floatimageContextMenu );
1.2146 actionEditCut->addTo( floatimageContextMenu );
1.2147
1.2148 - floatimageContextMenu->insertSeparator();
1.2149 - a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1.2150 - a->setToggleAction(true);
1.2151 - connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1.2152 - a->addTo( floatimageContextMenu);
1.2153 - actionEditToggleFloatExport=a;
1.2154 -
1.2155 -
1.2156 -
1.2157 - // Context menu for exports
1.2158 - exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
1.2159 -
1.2160 - a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
1.2161 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1.2162 - a->addTo( exportMenu );
1.2163 -
1.2164 - a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ), 0, this, "exportXML" );
1.2165 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1.2166 - a->addTo( exportMenu );
1.2167 -
1.2168 - if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1.2169 - {
1.2170 - a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML" );
1.2171 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1.2172 - a->addTo( exportMenu );
1.2173 - }
1.2174 -
1.2175 - a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" ), ALT + Key_X, this, "exportXHTML" );
1.2176 - connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1.2177 - a->addTo( exportMenu );
1.2178 + floatimageContextMenu->addSeparator();
1.2179 + floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1.2180
1.2181
1.2182 // Context menu for canvas
1.2183 - canvasContextMenu =new QPopupMenu (this);
1.2184 + canvasContextMenu =new QMenu (this);
1.2185 actionEditMapInfo->addTo( canvasContextMenu );
1.2186 + if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1.2187 + actionEditAddMapCenter->addTo( canvasContextMenu );
1.2188 canvasContextMenu->insertSeparator();
1.2189 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1.2190 canvasContextMenu->insertSeparator();
1.2191 actionFormatLinkColorHint->addTo( canvasContextMenu );
1.2192 actionFormatLinkColor->addTo( canvasContextMenu );
1.2193 + actionFormatSelectionColor->addTo( canvasContextMenu );
1.2194 actionFormatBackColor->addTo( canvasContextMenu );
1.2195 + // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1.2196
1.2197 // Menu for last opened files
1.2198 - // Read settings initially
1.2199 - QString s;
1.2200 - int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1.2201 - for (int i=1;i<=j;i++)
1.2202 + // Create actions
1.2203 + for (int i = 0; i < MaxRecentFiles; ++i)
1.2204 {
1.2205 - s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1.2206 - if (!s.isEmpty() && j<=maxLastMaps)
1.2207 - lastMaps.append(s);
1.2208 - }
1.2209 - setupLastMapsMenu();
1.2210 - connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1.2211 + recentFileActions[i] = new QAction(this);
1.2212 + recentFileActions[i]->setVisible(false);
1.2213 + fileLastMapsMenu->addAction(recentFileActions[i]);
1.2214 + connect(recentFileActions[i], SIGNAL(triggered()),
1.2215 + this, SLOT(fileLoadRecent()));
1.2216 + }
1.2217 + setupRecentMapsMenu();
1.2218 }
1.2219
1.2220 -void Main::setupLastMapsMenu()
1.2221 +void Main::setupRecentMapsMenu()
1.2222 {
1.2223 - // Remove double entries
1.2224 - QStringList::Iterator it=lastMaps.begin();
1.2225 - QStringList::Iterator jt;
1.2226 - while (it!=lastMaps.end() )
1.2227 + QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1.2228 +
1.2229 + int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1.2230 +
1.2231 + for (int i = 0; i < numRecentFiles; ++i) {
1.2232 + QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1.2233 + recentFileActions[i]->setText(text);
1.2234 + recentFileActions[i]->setData(files[i]);
1.2235 + recentFileActions[i]->setVisible(true);
1.2236 + }
1.2237 + for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1.2238 + recentFileActions[j]->setVisible(false);
1.2239 +}
1.2240 +
1.2241 +void Main::setupMacros()
1.2242 +{
1.2243 + for (int i = 0; i <= 11; i++)
1.2244 {
1.2245 - jt=it;
1.2246 - ++jt;
1.2247 - while (jt!=lastMaps.end() )
1.2248 - {
1.2249 - if (*it == *jt)
1.2250 - jt=lastMaps.remove(jt);
1.2251 - else
1.2252 - jt++;
1.2253 - }
1.2254 - it++;
1.2255 - }
1.2256 -
1.2257 - // Limit length of list to maxLastMaps
1.2258 - while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1.2259 -
1.2260 - // build Menu from lastMaps string list
1.2261 - lastMapsMenu->clear();
1.2262 - for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1.2263 - lastMapsMenu->insertItem (*it );
1.2264 -
1.2265 + macroActions[i] = new QAction(this);
1.2266 + macroActions[i]->setData(i);
1.2267 + addAction (macroActions[i]);
1.2268 + connect(macroActions[i], SIGNAL(triggered()),
1.2269 + this, SLOT(callMacro()));
1.2270 + }
1.2271 + macroActions[0]->setShortcut ( Qt::Key_F1 );
1.2272 + macroActions[1]->setShortcut ( Qt::Key_F2 );
1.2273 + macroActions[2]->setShortcut ( Qt::Key_F3 );
1.2274 + macroActions[3]->setShortcut ( Qt::Key_F4 );
1.2275 + macroActions[4]->setShortcut ( Qt::Key_F5 );
1.2276 + macroActions[5]->setShortcut ( Qt::Key_F6 );
1.2277 + macroActions[6]->setShortcut ( Qt::Key_F7 );
1.2278 + macroActions[7]->setShortcut ( Qt::Key_F8 );
1.2279 + macroActions[8]->setShortcut ( Qt::Key_F9 );
1.2280 + macroActions[9]->setShortcut ( Qt::Key_F10 );
1.2281 + macroActions[10]->setShortcut ( Qt::Key_F11 );
1.2282 + macroActions[11]->setShortcut ( Qt::Key_F12 );
1.2283 }
1.2284
1.2285 void Main::hideEvent (QHideEvent * )
1.2286 @@ -910,51 +1685,9 @@
1.2287
1.2288 void Main::showEvent (QShowEvent * )
1.2289 {
1.2290 - if (textEditor->showWithMain()) textEditor->show();
1.2291 + if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1.2292 }
1.2293
1.2294 -bool Main::reallyWriteDirectory(const QString &dir)
1.2295 -{
1.2296 - QStringList eList = QDir(dir).entryList();
1.2297 - if (eList.first() ==".") eList.pop_front(); // remove "."
1.2298 - if (eList.first() =="..") eList.pop_front(); // remove "."
1.2299 - if (!eList.isEmpty())
1.2300 - {
1.2301 - QMessageBox mb( "VYM",
1.2302 - tr("The directory ") + dir +
1.2303 - tr(" is not empty. Do you risk to overwrite its contents?"),
1.2304 - QMessageBox::Warning,
1.2305 - QMessageBox::Yes ,
1.2306 - QMessageBox::Cancel | QMessageBox::Default,
1.2307 - QMessageBox::QMessageBox::NoButton );
1.2308 -
1.2309 - mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1.2310 - mb.setButtonText( QMessageBox::No, tr("Cancel"));
1.2311 - switch( mb.exec() )
1.2312 - {
1.2313 - case QMessageBox::Yes:
1.2314 - // save
1.2315 - return true;
1.2316 - case QMessageBox::Cancel:
1.2317 - // do nothing
1.2318 - return false;
1.2319 - }
1.2320 - }
1.2321 - return true;
1.2322 -}
1.2323 -
1.2324 -QString Main::browseDirectory (const QString &caption)
1.2325 -{
1.2326 - QFileDialog fd(this,caption);
1.2327 - fd.setMode (QFileDialog::DirectoryOnly);
1.2328 - fd.setCaption("VYM - "+caption);
1.2329 - fd.show();
1.2330 -
1.2331 - if ( fd.exec() == QDialog::Accepted )
1.2332 - return fd.selectedFile();
1.2333 - else
1.2334 - return "";
1.2335 -}
1.2336
1.2337 MapEditor* Main::currentMapEditor() const
1.2338 {
1.2339 @@ -964,49 +1697,64 @@
1.2340 return NULL;
1.2341 }
1.2342
1.2343 -//TODO not used now, maybe use this for overview window later
1.2344 -void Main::newView()
1.2345 -{
1.2346 - // Open a new view... have it delete when closed.
1.2347 - Main *m = new Main(0, 0, WDestructiveClose);
1.2348 - qApp->setMainWidget(m);
1.2349 - m->show();
1.2350 - qApp->setMainWidget(0);
1.2351 -}
1.2352
1.2353 void Main::editorChanged(QWidget *)
1.2354 {
1.2355 // Unselect all possibly selected objects
1.2356 // (Important to update note editor)
1.2357 - int i;
1.2358 MapEditor *me;
1.2359 - for (i=0;i<=tabWidget->count() -1;i++)
1.2360 + for (int i=0;i<=tabWidget->count() -1;i++)
1.2361 {
1.2362 -
1.2363 me=(MapEditor*)tabWidget->page(i);
1.2364 me->unselect();
1.2365 }
1.2366 - currentMapEditor()->reselect();
1.2367 + me=currentMapEditor();
1.2368 + if (me) me->reselect();
1.2369
1.2370 // Update actions to in menus and toolbars according to editor
1.2371 - currentMapEditor()->updateActions();
1.2372 + updateActions();
1.2373 }
1.2374
1.2375 void Main::fileNew()
1.2376 {
1.2377 QString fn="unnamed";
1.2378 - MapEditor* medit = new MapEditor (tabWidget, true);
1.2379 - tabWidget->addTab (medit,fn);
1.2380 - tabWidget->showPage(medit);
1.2381 - medit->viewport()->setFocus();
1.2382 - medit->select("mc:");
1.2383 + MapEditor* me = new MapEditor ( NULL);
1.2384 + tabWidget->addTab (me,fn);
1.2385 + tabWidget->showPage(me);
1.2386 + me->viewport()->setFocus();
1.2387 + me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1.2388 + me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1.2389 +
1.2390 + // For the very first map we do not have flagrows yet...
1.2391 + me->select("mc:");
1.2392 }
1.2393
1.2394 -void Main::fileLoad(QString fn, const LoadMode &lmode)
1.2395 +void Main::fileNewCopy()
1.2396 {
1.2397 - // Error codes
1.2398 - enum errorCode {success,aborted};
1.2399 - errorCode err=success;
1.2400 + QString fn="unnamed";
1.2401 + MapEditor* oldME =currentMapEditor();
1.2402 + if (oldME)
1.2403 + {
1.2404 + oldME->copy();
1.2405 + MapEditor* newME = new MapEditor ( NULL);
1.2406 + if (newME)
1.2407 + {
1.2408 + tabWidget->addTab (newME,fn);
1.2409 + tabWidget->showPage(newME);
1.2410 + newME->viewport()->setFocus();
1.2411 + newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1.2412 + newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1.2413 + // For the very first map we do not have flagrows yet...
1.2414 + newME->select("mc:");
1.2415 + newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1.2416 + }
1.2417 +
1.2418 + }
1.2419 +}
1.2420 +
1.2421 +ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1.2422 +{
1.2423 + ErrorCode err=success;
1.2424
1.2425 // fn is usually the archive, mapfile the file after uncompressing
1.2426 QString mapfile;
1.2427 @@ -1026,15 +1774,15 @@
1.2428 if (me->getFilePath() == fn)
1.2429 {
1.2430 // Already there, ask for confirmation
1.2431 - QMessageBox mb( "VYM",
1.2432 - tr("The map ") + fn + tr ("\n is already opened."
1.2433 + QMessageBox mb( vymName,
1.2434 + tr("The map %1\nis already opened."
1.2435 "Opening the same map in multiple editors may lead \n"
1.2436 "to confusion when finishing working with vym."
1.2437 - "Do you want to"),
1.2438 + "Do you want to").arg(fn),
1.2439 QMessageBox::Warning,
1.2440 QMessageBox::Yes | QMessageBox::Default,
1.2441 QMessageBox::Cancel | QMessageBox::Escape,
1.2442 - QMessageBox::QMessageBox::NoButton);
1.2443 + QMessageBox::NoButton);
1.2444 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1.2445 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1.2446 switch( mb.exec() )
1.2447 @@ -1045,7 +1793,7 @@
1.2448 break;
1.2449 case QMessageBox::Cancel:
1.2450 // do nothing
1.2451 - return;
1.2452 + return aborted;
1.2453 break;
1.2454 }
1.2455 }
1.2456 @@ -1064,23 +1812,26 @@
1.2457 // create a new mapeditor in a new tab
1.2458 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1.2459 {
1.2460 - me = new MapEditor (tabWidget,true);
1.2461 + me= new MapEditor ( NULL);
1.2462 tabWidget->addTab (me,fn);
1.2463 tabIndex=tabWidget->indexOf (me);
1.2464 tabWidget->setCurrentPage (tabIndex);
1.2465 + me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1.2466 + me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1.2467 }
1.2468
1.2469 // Check, if file exists (important for creating new files
1.2470 // from command line
1.2471 + /*
1.2472 + */
1.2473 if (!QFile(fn).exists() )
1.2474 {
1.2475 - QMessageBox mb( "VYM",
1.2476 - tr("The map") + fn +
1.2477 - tr(" does not exist.\n Do you want to create a new one?"),
1.2478 + QMessageBox mb( vymName,
1.2479 + tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1.2480 QMessageBox::Question,
1.2481 QMessageBox::Yes ,
1.2482 QMessageBox::Cancel | QMessageBox::Default,
1.2483 - QMessageBox::QMessageBox::NoButton );
1.2484 + QMessageBox::NoButton );
1.2485
1.2486 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1.2487 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1.2488 @@ -1092,162 +1843,78 @@
1.2489 tabWidget->setTabLabel (currentMapEditor(),
1.2490 currentMapEditor()->getFileName() );
1.2491 statusBar()->message( "Created " + fn , statusbarTime );
1.2492 - return;
1.2493 + return success;
1.2494
1.2495 case QMessageBox::Cancel:
1.2496 // don't create new map
1.2497 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1.2498 fileCloseMap();
1.2499 - return;
1.2500 + return aborted;
1.2501 }
1.2502 }
1.2503
1.2504 -
1.2505 //tabWidget->currentPage() won't be NULL here, because of above...
1.2506 tabWidget->showPage(me);
1.2507 me->viewport()->setFocus();
1.2508
1.2509 - // Create temporary directory for packing
1.2510 - char tmpdir1[]="/tmp/vym-XXXXXX";
1.2511 - QString tmpMapDir=mkdtemp(tmpdir1);
1.2512 -
1.2513 - // Try to unzip file
1.2514 - Process *zipProc=new Process ();
1.2515 - zipProc->clearArguments();
1.2516 - zipProc->setWorkingDirectory (QDir(tmpMapDir));
1.2517 - zipProc->addArgument ("unzip");
1.2518 - zipProc->addArgument (fn );
1.2519 - zipProc->addArgument ("-d");
1.2520 - zipProc->addArgument (tmpMapDir);
1.2521 -
1.2522 - if (!zipProc->start() )
1.2523 + if (err!=aborted)
1.2524 {
1.2525 - QMessageBox::critical( 0, tr( "Critical Load Error" ),
1.2526 - tr("Couldn't start unzip to decompress data."));
1.2527 - err=aborted;
1.2528 -
1.2529 - } else
1.2530 + // Save existing filename in case we import
1.2531 + QString fn_org=me->getFilePath();
1.2532 +
1.2533 + // Finally load map into mapEditor
1.2534 + me->setFilePath (fn);
1.2535 + err=me->load(fn,lmode,ftype);
1.2536 +
1.2537 + // Restore old (maybe empty) filepath, if this is an import
1.2538 + if (lmode!=NewMap)
1.2539 + me->setFilePath (fn_org);
1.2540 + }
1.2541 +
1.2542 + // Finally check for errors and go home
1.2543 + if (err==aborted)
1.2544 {
1.2545 - zipProc->waitFinished();
1.2546 - if (!zipProc->normalExit() )
1.2547 - {
1.2548 - QMessageBox::critical( 0, tr( "Critical Load Error" ),
1.2549 - tr("unzip didn't exit normally") +
1.2550 - zipProc->getErrout() );
1.2551 - err=aborted;
1.2552 - } else
1.2553 - {
1.2554 - if (zipProc->exitStatus()>0)
1.2555 - {
1.2556 - if (zipProc->exitStatus()==9)
1.2557 - {
1.2558 - // no zipped file, but maybe .xml or old version? Try again.
1.2559 - mapfile=fn;
1.2560 - me->setZipped(false);
1.2561 - }
1.2562 - else
1.2563 - {
1.2564 - QMessageBox::critical( 0, tr( "Critical Load Error" ),
1.2565 - QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1.2566 - zipProc->getErrout() );
1.2567 - err=aborted;
1.2568 - }
1.2569 - } else
1.2570 - { // Uncompressing was successfull,
1.2571 - // load from uncompressed temporary directory
1.2572 -
1.2573 - me->setZipped(true);
1.2574 -
1.2575 -
1.2576 - // Look for mapname.xml
1.2577 - mapfile= fn.left(fn.findRev(".",-1,true));
1.2578 - mapfile=mapfile.section( '/', -1 );
1.2579 - QFile file( tmpMapDir + "/" + mapfile + ".xml");
1.2580 - if (!file.exists() )
1.2581 - {
1.2582 - // mapname.xml does not exist, well,
1.2583 - // maybe some renamed the mapname.vym file...
1.2584 - // Try to find any .xml in the toplevel
1.2585 - // directory of the .vym file
1.2586 - QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1.2587 - if (flist.count()==1)
1.2588 - {
1.2589 - // Only one entry, take this one
1.2590 - mapfile=tmpMapDir + "/"+flist.first();
1.2591 - } else
1.2592 - {
1.2593 - for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1.2594 - *it=tmpMapDir + "/" + *it;
1.2595 - // FIXME
1.2596 - // Multiple entries, load all (but only the first one into this ME)
1.2597 - //mainWindow->fileLoadFromTmp (flist);
1.2598 - //returnCode=1; // Silently forget this attempt to load
1.2599 - qWarning ("MainWindow::load (fn) multimap found...");
1.2600 - }
1.2601 -
1.2602 - if (flist.isEmpty() )
1.2603 - {
1.2604 - QMessageBox::critical( 0, tr( "Critical Load Error" ),
1.2605 - tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1.2606 - err=aborted;
1.2607 - }
1.2608 - } //file doesn't exist
1.2609 - else
1.2610 - mapfile=file.name();
1.2611 - } // Uncompressing successfull
1.2612 - }
1.2613 - }
1.2614 -
1.2615 - // Finally load map into mapEditor
1.2616 - me->setFilePath (mapfile,fn);
1.2617 - if (me->load(mapfile,lmode))
1.2618 - err=aborted;
1.2619 -
1.2620 - // Delete tmpDir
1.2621 - system ( "rm -rf "+tmpMapDir);
1.2622 -
1.2623 - // Check for errors
1.2624 - if (err==success)
1.2625 + if (lmode==NewMap) fileCloseMap();
1.2626 + statusBar()->message( "Could not load " + fn, statusbarTime );
1.2627 + } else
1.2628 {
1.2629 if (lmode==NewMap)
1.2630 {
1.2631 me->setFilePath (fn);
1.2632 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1.2633 - lastMaps.prepend(me->getFilePath() );
1.2634 - setupLastMapsMenu();
1.2635 + if (!isInTmpDir (fn))
1.2636 + {
1.2637 + // Only append to lastMaps if not loaded from a tmpDir
1.2638 + // e.g. imported bookmarks are in a tmpDir
1.2639 + addRecentMap(me->getFilePath() );
1.2640 + }
1.2641 actionFilePrint->setEnabled (true);
1.2642 }
1.2643 statusBar()->message( "Loaded " + fn, statusbarTime );
1.2644 - return;
1.2645 - } else
1.2646 - {
1.2647 - if (lmode==NewMap)
1.2648 - fileCloseMap();
1.2649 }
1.2650 -
1.2651 -
1.2652 }
1.2653 - statusBar()->message( "Could not load " + fn, statusbarTime );
1.2654 + return err;
1.2655 }
1.2656
1.2657
1.2658 void Main::fileLoad(const LoadMode &lmode)
1.2659 {
1.2660 + QStringList filters;
1.2661 + filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1.2662 QFileDialog *fd=new QFileDialog( this);
1.2663 - if (!lastFileDir.isEmpty())
1.2664 - fd->setDir (lastFileDir);
1.2665 - fd->addFilter ("XML (*.xml)");
1.2666 - fd->addFilter ("VYM map (*.vym *.vyp)");
1.2667 + fd->setDir (lastFileDir);
1.2668 + fd->setFileMode (QFileDialog::ExistingFiles);
1.2669 + fd->setFilters (filters);
1.2670 switch (lmode)
1.2671 {
1.2672 case NewMap:
1.2673 - fd->setCaption(tr("Load vym map"));
1.2674 + fd->setCaption(vymName+ " - " +tr("Load vym map"));
1.2675 break;
1.2676 case ImportAdd:
1.2677 - fd->setCaption(tr("Import: Add vym map to selection"));
1.2678 + fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1.2679 break;
1.2680 case ImportReplace:
1.2681 - fd->setCaption(tr("Import: Replace selection with vym map"));
1.2682 + fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1.2683 break;
1.2684 }
1.2685 fd->show();
1.2686 @@ -1255,10 +1922,17 @@
1.2687 QString fn;
1.2688 if ( fd->exec() == QDialog::Accepted )
1.2689 {
1.2690 - lastFileDir=fd->dirPath();
1.2691 - fn = fd->selectedFile();
1.2692 - fileLoad(fn, lmode);
1.2693 + lastFileDir=fd->directory().path();
1.2694 + QStringList flist = fd->selectedFiles();
1.2695 + QStringList::Iterator it = flist.begin();
1.2696 + while( it != flist.end() )
1.2697 + {
1.2698 + fn = *it;
1.2699 + fileLoad(*it, lmode);
1.2700 + ++it;
1.2701 + }
1.2702 }
1.2703 + delete (fd);
1.2704 }
1.2705
1.2706 void Main::fileLoad()
1.2707 @@ -1266,182 +1940,84 @@
1.2708 fileLoad (NewMap);
1.2709 }
1.2710
1.2711 -void Main::fileLoadLast(int i)
1.2712 +void Main::fileLoadRecent()
1.2713 {
1.2714 - fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1.2715 + QAction *action = qobject_cast<QAction *>(sender());
1.2716 + if (action)
1.2717 + fileLoad (action->data().toString(), NewMap);
1.2718 }
1.2719
1.2720 -void Main::fileSave(const SaveMode &savemode)
1.2721 +void Main::addRecentMap (const QString &fileName)
1.2722 {
1.2723 - // tmp dir for zipping
1.2724 - QString tmpMapDir;
1.2725 -
1.2726 - // Error codes
1.2727 - enum errorCode {success,aborted};
1.2728 - errorCode err=success;
1.2729 -
1.2730 - QString safeFilePath;
1.2731 -
1.2732 - bool saveZipped=currentMapEditor()->saveZipped();
1.2733 -
1.2734 - if (currentMapEditor())
1.2735 +
1.2736 + QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1.2737 + files.removeAll(fileName);
1.2738 + files.prepend(fileName);
1.2739 + while (files.size() > MaxRecentFiles)
1.2740 + files.removeLast();
1.2741 +
1.2742 + settings.setValue("/mainwindow/recentFileList", files);
1.2743 +
1.2744 + setupRecentMapsMenu();
1.2745 +}
1.2746 +
1.2747 +void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1.2748 +{
1.2749 + if (!me) return;
1.2750 +
1.2751 + if ( me->getFilePath().isEmpty() )
1.2752 {
1.2753 - QString fn=currentMapEditor()->getFilePath();
1.2754 - // filename=unnamed, filepath="" in constructor...
1.2755 - if ( !fn.isEmpty() )
1.2756 - {
1.2757 - // We have a filepath, go on saving
1.2758 - // First remove existing file, we
1.2759 - // don't want to add to old zip archives
1.2760 - QFile f(fn);
1.2761 - if (f.exists() )
1.2762 - if (!f.remove())
1.2763 - QMessageBox::warning( 0, tr( "Save Error" ),
1.2764 - fn+ tr("\ncould not be removed before saving"));
1.2765 -
1.2766 - // Look, if we should zip the data:
1.2767 - if (!saveZipped)
1.2768 - {
1.2769 - QMessageBox mb( "VYM",
1.2770 - tr("The map ") + fn +
1.2771 - tr ("\ndid not use the compressed "
1.2772 - "vym file format.\nWriting it uncompressed will also write images \n"
1.2773 - "and flags and thus may overwrite files in the "
1.2774 - "given directory\n\nDo you want to write the map"),
1.2775 - QMessageBox::Warning,
1.2776 - QMessageBox::Yes | QMessageBox::Default,
1.2777 - QMessageBox::No ,
1.2778 - QMessageBox::Cancel | QMessageBox::Escape);
1.2779 - mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1.2780 - mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1.2781 - mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1.2782 - switch( mb.exec() )
1.2783 - {
1.2784 - case QMessageBox::Yes:
1.2785 - // save compressed (default file format)
1.2786 - saveZipped=true;
1.2787 - break;
1.2788 - case QMessageBox::No:
1.2789 - // save uncompressed
1.2790 - saveZipped=false;
1.2791 - break;
1.2792 - case QMessageBox::Cancel:
1.2793 - // do nothing
1.2794 - return;
1.2795 - break;
1.2796 - }
1.2797 - }
1.2798 -
1.2799 - if (saveZipped)
1.2800 - {
1.2801 - char tmpdir1[]="/tmp/vym-XXXXXX";
1.2802 - tmpMapDir=mkdtemp(tmpdir1);
1.2803 -
1.2804 - safeFilePath=currentMapEditor()->getFilePath();
1.2805 - currentMapEditor()->setFilePath (tmpMapDir+"/"+
1.2806 - currentMapEditor()->getMapName()+ ".xml",
1.2807 - safeFilePath);
1.2808 - currentMapEditor()->save (savemode);
1.2809 - currentMapEditor()->setFilePath (safeFilePath);
1.2810 -
1.2811 - // zip the temporary directory
1.2812 - Process *zipProc=new Process ();
1.2813 - zipProc->clearArguments();
1.2814 - zipProc->setWorkingDirectory (QDir(tmpMapDir));
1.2815 - zipProc->addArgument ("zip");
1.2816 - zipProc->addArgument ("-r");
1.2817 - zipProc->addArgument (fn);
1.2818 - zipProc->addArgument (".");
1.2819 -
1.2820 - if (!zipProc->start() )
1.2821 - {
1.2822 - // zip could not be started
1.2823 - QMessageBox::critical( 0, tr( "Critical Save Error" ),
1.2824 - tr("Couldn't start zip to compress data."));
1.2825 - err=aborted;
1.2826 - } else
1.2827 - {
1.2828 - // zip could be started
1.2829 - zipProc->waitFinished();
1.2830 - if (!zipProc->normalExit() )
1.2831 - {
1.2832 - QMessageBox::critical( 0, tr( "Critical Save Error" ),
1.2833 - tr("zip didn't exit normally")+
1.2834 - "\n" + zipProc->getErrout());
1.2835 - err=aborted;
1.2836 - } else
1.2837 - {
1.2838 - if (zipProc->exitStatus()>0)
1.2839 - {
1.2840 - QMessageBox::critical( 0, tr( "Critical Save Error" ),
1.2841 - QString("zip exit code: %1").arg(zipProc->exitStatus() )+
1.2842 - "\n" + zipProc->getErrout() );
1.2843 - err=aborted;
1.2844 - }
1.2845 - }
1.2846 - } // zip could be started
1.2847 - } // save zipped
1.2848 - else
1.2849 - {
1.2850 - // Save unzipped.
1.2851 - safeFilePath=currentMapEditor()->getFilePath();
1.2852 - currentMapEditor()->setFilePath (fn, safeFilePath);
1.2853 - currentMapEditor()->save (savemode);
1.2854 - currentMapEditor()->setFilePath (safeFilePath);
1.2855 - } // save zipped
1.2856 - } // filepath available
1.2857 - else
1.2858 - {
1.2859 - // We have no filepath yet,
1.2860 - // call fileSaveAs() now, this will call fileSave()
1.2861 - // again.
1.2862 - fileSaveAs(savemode);
1.2863 - }
1.2864 - }
1.2865 -
1.2866 - if (currentMapEditor()->saveZipped())
1.2867 + // We have no filepath yet,
1.2868 + // call fileSaveAs() now, this will call fileSave()
1.2869 + // again.
1.2870 + // First switch to editor
1.2871 + tabWidget->setCurrentWidget (me);
1.2872 + fileSaveAs(savemode);
1.2873 + }
1.2874 +
1.2875 + if (me->save (savemode)==success)
1.2876 {
1.2877 - // Delete tmpDir
1.2878 - system ( "rm -rf "+ tmpMapDir );
1.2879 - }
1.2880 -
1.2881 - if (err==success)
1.2882 statusBar()->message(
1.2883 - tr("Saved")+" " + currentMapEditor()->getFilePath(),
1.2884 + tr("Saved %1").arg(me->getFilePath()),
1.2885 statusbarTime );
1.2886 - else
1.2887 + addRecentMap (me->getFilePath() );
1.2888 + } else
1.2889 statusBar()->message(
1.2890 - tr("Couldn't save")+" " + currentMapEditor()->getFilePath(),
1.2891 + tr("Couldn't save ").arg(me->getFilePath()),
1.2892 statusbarTime );
1.2893 }
1.2894
1.2895 void Main::fileSave()
1.2896 {
1.2897 - fileSave (CompleteMap);
1.2898 + fileSave (currentMapEditor(), CompleteMap);
1.2899 +}
1.2900 +
1.2901 +void Main::fileSave(MapEditor *me)
1.2902 +{
1.2903 + fileSave (me,CompleteMap);
1.2904 }
1.2905
1.2906 void Main::fileSaveAs(const SaveMode& savemode)
1.2907 {
1.2908 - QString tmpMapDir;
1.2909 QString fn;
1.2910
1.2911 if (currentMapEditor())
1.2912 {
1.2913 if (savemode==CompleteMap)
1.2914 - fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1.2915 + fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1.2916 else
1.2917 - fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1.2918 + fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1.2919 if ( !fn.isEmpty() )
1.2920 {
1.2921 // Check for existing file
1.2922 if (QFile (fn).exists())
1.2923 {
1.2924 - QMessageBox mb( "VYM",
1.2925 - tr("The file ") + fn + tr ("\nexists already. Do you want to"),
1.2926 + QMessageBox mb( vymName,
1.2927 + tr("The file %1\nexists already. Do you want to").arg(fn),
1.2928 QMessageBox::Warning,
1.2929 QMessageBox::Yes | QMessageBox::Default,
1.2930 QMessageBox::Cancel | QMessageBox::Escape,
1.2931 - QMessageBox::QMessageBox::NoButton);
1.2932 + QMessageBox::NoButton);
1.2933 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1.2934 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1.2935 switch( mb.exec() )
1.2936 @@ -1474,11 +2050,12 @@
1.2937
1.2938 // Save now
1.2939 currentMapEditor()->setFilePath(fn);
1.2940 - fileSave(savemode);
1.2941 + fileSave(currentMapEditor(), savemode);
1.2942
1.2943 // Set name of tab
1.2944 - tabWidget->setTabLabel (currentMapEditor(),
1.2945 - currentMapEditor()->getFileName() );
1.2946 + if (savemode==CompleteMap)
1.2947 + tabWidget->setTabLabel (currentMapEditor(),
1.2948 + currentMapEditor()->getFileName() );
1.2949 return;
1.2950 }
1.2951 }
1.2952 @@ -1489,102 +2066,243 @@
1.2953 fileSaveAs (CompleteMap);
1.2954 }
1.2955
1.2956 +void Main::fileImportKDEBookmarks()
1.2957 +{
1.2958 + ImportKDEBookmarks im;
1.2959 + im.transform();
1.2960 + if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1.2961 + currentMapEditor()->setFilePath ("");
1.2962 +}
1.2963 +
1.2964 +void Main::fileImportFirefoxBookmarks()
1.2965 +{
1.2966 + Q3FileDialog *fd=new Q3FileDialog( this);
1.2967 + fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
1.2968 + fd->setMode (Q3FileDialog::ExistingFiles);
1.2969 + fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
1.2970 + fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
1.2971 + fd->show();
1.2972 +
1.2973 + if ( fd->exec() == QDialog::Accepted )
1.2974 + {
1.2975 + ImportFirefoxBookmarks im;
1.2976 + QStringList flist = fd->selectedFiles();
1.2977 + QStringList::Iterator it = flist.begin();
1.2978 + while( it != flist.end() )
1.2979 + {
1.2980 + im.setFile (*it);
1.2981 + if (im.transform() &&
1.2982 + success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
1.2983 + currentMapEditor() )
1.2984 + currentMapEditor()->setFilePath ("");
1.2985 + ++it;
1.2986 + }
1.2987 + }
1.2988 + delete (fd);
1.2989 +}
1.2990 +
1.2991 +void Main::fileImportFreemind()
1.2992 +{
1.2993 + QStringList filters;
1.2994 + filters <<"Freemind map (*.mm)"<<"All files (*)";
1.2995 + QFileDialog *fd=new QFileDialog( this);
1.2996 + fd->setDir (lastFileDir);
1.2997 + fd->setFileMode (QFileDialog::ExistingFiles);
1.2998 + fd->setFilters (filters);
1.2999 + fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
1.3000 + fd->show();
1.3001 +
1.3002 + QString fn;
1.3003 + if ( fd->exec() == QDialog::Accepted )
1.3004 + {
1.3005 + lastFileDir=fd->directory().path();
1.3006 + QStringList flist = fd->selectedFiles();
1.3007 + QStringList::Iterator it = flist.begin();
1.3008 + while( it != flist.end() )
1.3009 + {
1.3010 + fn = *it;
1.3011 + if ( fileLoad (fn,NewMap, FreemindMap) )
1.3012 + {
1.3013 + currentMapEditor()->setFilePath ("");
1.3014 + }
1.3015 + ++it;
1.3016 + }
1.3017 + }
1.3018 + delete (fd);
1.3019 +}
1.3020 +
1.3021 +
1.3022 +void Main::fileImportMM()
1.3023 +{
1.3024 + ImportMM im;
1.3025 +
1.3026 + Q3FileDialog *fd=new Q3FileDialog( this);
1.3027 + fd->setDir (lastFileDir);
1.3028 + fd->setMode (Q3FileDialog::ExistingFiles);
1.3029 + fd->addFilter ("Mind Manager (*.mmap)");
1.3030 + fd->setCaption(tr("Import")+" "+"Mind Manager");
1.3031 + fd->show();
1.3032 +
1.3033 + if ( fd->exec() == QDialog::Accepted )
1.3034 + {
1.3035 + lastFileDir=fd->dirPath();
1.3036 + QStringList flist = fd->selectedFiles();
1.3037 + QStringList::Iterator it = flist.begin();
1.3038 + while( it != flist.end() )
1.3039 + {
1.3040 + im.setFile (*it);
1.3041 + if (im.transform() &&
1.3042 + success==fileLoad (im.getTransformedFile(),NewMap) &&
1.3043 + currentMapEditor() )
1.3044 + currentMapEditor()->setFilePath ("");
1.3045 +
1.3046 + ++it;
1.3047 + }
1.3048 + }
1.3049 + delete (fd);
1.3050 +
1.3051 +}
1.3052 +
1.3053 void Main::fileImportDir()
1.3054 {
1.3055 if (currentMapEditor())
1.3056 currentMapEditor()->importDir();
1.3057 }
1.3058
1.3059 -void Main::fileExportXML()
1.3060 +void Main::fileExportXML()
1.3061 {
1.3062 - if (currentMapEditor())
1.3063 + MapEditor *me=currentMapEditor();
1.3064 + if (me) me->exportXML();
1.3065 +}
1.3066 +
1.3067 +
1.3068 +void Main::fileExportXHTML()
1.3069 +{
1.3070 + MapEditor *me=currentMapEditor();
1.3071 + if (me) me->exportXHTML();
1.3072 +}
1.3073 +
1.3074 +void Main::fileExportImage()
1.3075 +{
1.3076 + MapEditor *me=currentMapEditor();
1.3077 + if (me) me->exportImage();
1.3078 +}
1.3079 +
1.3080 +void Main::fileExportASCII()
1.3081 +{
1.3082 + MapEditor *me=currentMapEditor();
1.3083 + if (me) me->exportASCII();
1.3084 +}
1.3085 +
1.3086 +void Main::fileExportCSV() //FIXME not scriptable yet
1.3087 +{
1.3088 + MapEditor *me=currentMapEditor();
1.3089 + if (me)
1.3090 {
1.3091 - QString dir=browseDirectory(tr("Export XML to directory"));
1.3092 - if (dir !="" && reallyWriteDirectory(dir) )
1.3093 - currentMapEditor()->exportXML(dir);
1.3094 + ExportCSV ex;
1.3095 + ex.setModel (me->getModel());
1.3096 + ex.addFilter ("CSV (*.csv)");
1.3097 + ex.setDir(lastImageDir);
1.3098 + ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
1.3099 + if (ex.execDialog() )
1.3100 + {
1.3101 + me->setExportMode(true);
1.3102 + ex.doExport();
1.3103 + me->setExportMode(false);
1.3104 + }
1.3105 + }
1.3106 +}
1.3107 +
1.3108 +void Main::fileExportLaTeX() //FIXME not scriptable yet
1.3109 +{
1.3110 + MapEditor *me=currentMapEditor();
1.3111 + if (me)
1.3112 + {
1.3113 + ExportLaTeX ex;
1.3114 + ex.setModel (me->getModel());
1.3115 + ex.addFilter ("Tex (*.tex)");
1.3116 + ex.setDir(lastImageDir);
1.3117 + ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1.3118 + if (ex.execDialog() )
1.3119 + {
1.3120 + me->setExportMode(true);
1.3121 + ex.doExport();
1.3122 + me->setExportMode(false);
1.3123 + }
1.3124 + }
1.3125 +}
1.3126 +
1.3127 +void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
1.3128 +{
1.3129 + ExportKDEBookmarks ex;
1.3130 + MapEditor *me=currentMapEditor();
1.3131 + if (me)
1.3132 + {
1.3133 + ex.setModel (me->getModel());
1.3134 + ex.doExport();
1.3135 }
1.3136 }
1.3137
1.3138 -void Main::fileExportHTML()
1.3139 +void Main::fileExportTaskjuggler() //FIXME not scriptable yet
1.3140 {
1.3141 - if (currentMapEditor())
1.3142 + ExportTaskjuggler ex;
1.3143 + MapEditor *me=currentMapEditor();
1.3144 + if (me)
1.3145 {
1.3146 - ExportHTMLDialog dia(this);
1.3147 -
1.3148 - if (dia.exec()==QDialog::Accepted)
1.3149 + ex.setModel (me->getModel());
1.3150 + ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1.3151 + ex.setDir(lastImageDir);
1.3152 + ex.addFilter ("Taskjuggler (*.tjp)");
1.3153 + if (ex.execDialog() )
1.3154 {
1.3155 - QString dir=dia.getDir();
1.3156 - if (reallyWriteDirectory(dir) )
1.3157 - {
1.3158 - currentMapEditor()->exportXML (dia.getDir() );
1.3159 - dia.doExport(currentMapEditor()->getMapName() );
1.3160 - }
1.3161 + me->setExportMode(true);
1.3162 + ex.doExport();
1.3163 + me->setExportMode(false);
1.3164 }
1.3165 }
1.3166 }
1.3167
1.3168 -void Main::fileExportXHTML()
1.3169 +void Main::fileExportOOPresentation() //FIXME not scriptable yet
1.3170 {
1.3171 - QString dir;
1.3172 - if (currentMapEditor())
1.3173 + ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
1.3174 + // TODO add preview in dialog
1.3175 + //ImagePreview *p =new ImagePreview (fd);
1.3176 + //fd->setContentsPreviewEnabled( TRUE );
1.3177 + //fd->setContentsPreview( p, p );
1.3178 + //fd->setPreviewMode( QFileDialog::Contents );
1.3179 + fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
1.3180 + fd->setDir (QDir().current());
1.3181 + if (fd->foundConfig())
1.3182 {
1.3183 - ExportXHTMLDialog dia(this);
1.3184 - dia.setFilePath (currentMapEditor()->getFilePath() );
1.3185 - dia.setMapName (currentMapEditor()->getMapName() );
1.3186 - dia.readSettings();
1.3187 -
1.3188 - if (dia.exec()==QDialog::Accepted)
1.3189 + fd->show();
1.3190 +
1.3191 + if ( fd->exec() == QDialog::Accepted )
1.3192 {
1.3193 - QString dir=dia.getDir();
1.3194 - // Check, if warnings should be used before overwriting
1.3195 - // the output directory
1.3196 - bool ok;
1.3197 - if (dia.warnings())
1.3198 - ok=reallyWriteDirectory(dir);
1.3199 - else
1.3200 - ok=true;
1.3201 -
1.3202 - if (ok)
1.3203 - {
1.3204 - currentMapEditor()->exportXML (dia.getDir() );
1.3205 - dia.doExport(currentMapEditor()->getMapName() );
1.3206 - if (dia.hasChanged())
1.3207 - currentMapEditor()->setChanged();
1.3208 - }
1.3209 + QString fn=fd->selectedFile();
1.3210 + if (!fn.contains (".odp"))
1.3211 + fn +=".odp";
1.3212 +
1.3213 + //lastImageDir=fn.left(fn.findRev ("/"));
1.3214 + if (currentMapEditor())
1.3215 + currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
1.3216 }
1.3217 - }
1.3218 -}
1.3219 -
1.3220 -void Main::fileExportImage(int item)
1.3221 -{
1.3222 - if (currentMapEditor())
1.3223 + } else
1.3224 {
1.3225 - QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1.3226 - this );
1.3227 - if ( !fn.isEmpty() )
1.3228 - {
1.3229 - currentMapEditor()->exportImage(fn,item);
1.3230 - } else {
1.3231 - statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
1.3232 - }
1.3233 + QMessageBox::warning(0,
1.3234 + tr("Warning"),
1.3235 + tr("Couldn't find configuration for export to Open Office\n"));
1.3236 }
1.3237 }
1.3238
1.3239 -void Main::fileExportASCII()
1.3240 -{
1.3241 - if (currentMapEditor())
1.3242 - currentMapEditor()->exportASCII();
1.3243 -}
1.3244 -
1.3245 void Main::fileCloseMap()
1.3246 {
1.3247 - if (currentMapEditor())
1.3248 + MapEditor *me = currentMapEditor();
1.3249 + if (me)
1.3250 {
1.3251 - if (currentMapEditor()->hasChanged())
1.3252 + if (me->hasChanged())
1.3253 {
1.3254 - QMessageBox mb( "VYM",
1.3255 - tr("The map ") + currentMapEditor()->getFileName() +
1.3256 - tr(" has been modified but not saved yet. Do you want to"),
1.3257 + QMessageBox mb( vymName,
1.3258 + tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
1.3259 QMessageBox::Warning,
1.3260 QMessageBox::Yes | QMessageBox::Default,
1.3261 QMessageBox::No,
1.3262 @@ -1595,7 +2313,7 @@
1.3263 {
1.3264 case QMessageBox::Yes:
1.3265 // save and close
1.3266 - fileSave(CompleteMap);
1.3267 + fileSave(me, CompleteMap);
1.3268 break;
1.3269 case QMessageBox::No:
1.3270 // close without saving
1.3271 @@ -1605,11 +2323,17 @@
1.3272 return;
1.3273 }
1.3274 }
1.3275 - currentMapEditor()->closeMap();
1.3276 - tabWidget->removePage(currentMapEditor());
1.3277 + //me->closeMap();
1.3278 + tabWidget->removePage(me);
1.3279 if (tabWidget->count()==0)
1.3280 actionFilePrint->setEnabled (false);
1.3281 - }
1.3282 +
1.3283 + //Remove mapEditor;
1.3284 + // Better would be delete (me), but then we have a Qt error:
1.3285 + // "QObject: Do not delete object, 'MapEditor', during its event handler!"
1.3286 + // So we only remove data now and call deconstructor when vym closes later
1.3287 + me->clear();
1.3288 + }
1.3289 }
1.3290
1.3291 void Main::filePrint()
1.3292 @@ -1629,10 +2353,10 @@
1.3293 me=(MapEditor*)tabWidget->page(i);
1.3294
1.3295 // If something changed, ask what to do
1.3296 - if (me->isUnsaved())
1.3297 + if (me->hasChanged())
1.3298 {
1.3299 tabWidget->setCurrentPage(i);
1.3300 - QMessageBox mb( "VYM",
1.3301 + QMessageBox mb( vymName,
1.3302 tr("This map is not saved yet. Do you want to"),
1.3303 QMessageBox::Warning,
1.3304 QMessageBox::Yes | QMessageBox::Default,
1.3305 @@ -1640,18 +2364,13 @@
1.3306 QMessageBox::Cancel | QMessageBox::Escape );
1.3307 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1.3308 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1.3309 + mb.setModal (true);
1.3310 mb.show();
1.3311 - // Call undocumented function: setActiveWindow is only
1.3312 - // possible, if widget is visible. This depends on
1.3313 - // windowmanager...
1.3314 -#if defined(Q_OS_LINUX)
1.3315 - qt_wait_for_window_manager( this);
1.3316 -#endif
1.3317 mb.setActiveWindow();
1.3318 switch( mb.exec() ) {
1.3319 case QMessageBox::Yes:
1.3320 // save (the changed editors) and exit
1.3321 - fileSave(CompleteMap);
1.3322 + fileSave(currentMapEditor(), CompleteMap);
1.3323 break;
1.3324 case QMessageBox::No:
1.3325 // exit without saving
1.3326 @@ -1661,6 +2380,7 @@
1.3327 return;
1.3328 }
1.3329 }
1.3330 + me->clear(); // remove and unselect now, before mainWindow has gone...
1.3331 } // loop over all MEs
1.3332 qApp->quit();
1.3333 }
1.3334 @@ -1671,8 +2391,16 @@
1.3335 currentMapEditor()->undo();
1.3336 }
1.3337
1.3338 -void Main::editRedo() // TODO
1.3339 +void Main::editRedo()
1.3340 {
1.3341 + if (currentMapEditor())
1.3342 + currentMapEditor()->redo();
1.3343 +}
1.3344 +
1.3345 +void Main::gotoHistoryStep (int i)
1.3346 +{
1.3347 + if (currentMapEditor())
1.3348 + currentMapEditor()->gotoHistoryStep (i);
1.3349 }
1.3350
1.3351 void Main::editCopy()
1.3352 @@ -1697,13 +2425,6 @@
1.3353 {
1.3354 findWindow->popup();
1.3355 findWindow->raise();
1.3356 -
1.3357 - // Call undocumented function: setActiveWindow is only
1.3358 - // possible, if widget is visible. This depends on
1.3359 - // windowmanager...
1.3360 -#if defined(Q_OS_LINUX)
1.3361 - qt_wait_for_window_manager( this);
1.3362 -#endif
1.3363 findWindow->setActiveWindow();
1.3364 }
1.3365
1.3366 @@ -1717,8 +2438,7 @@
1.3367 } else
1.3368 {
1.3369 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
1.3370 - tr("No matches found for ")+
1.3371 - "'<b>"+s+"</b>'");
1.3372 + tr("No matches found for \"%1\"").arg(s));
1.3373 }
1.3374 }
1.3375
1.3376 @@ -1727,11 +2447,130 @@
1.3377 currentMapEditor()->findReset();
1.3378 }
1.3379
1.3380 +void Main::openTabs(QStringList urls)
1.3381 +{
1.3382 + if (!urls.isEmpty())
1.3383 + {
1.3384 + bool success=true;
1.3385 + QStringList args;
1.3386 + QString browser=settings.value("/mainwindow/readerURL" ).toString();
1.3387 + QProcess *p;
1.3388 + if (!procBrowser || procBrowser->state()!=QProcess::Running)
1.3389 + {
1.3390 + QString u=urls.takeFirst();
1.3391 + procBrowser = new QProcess( this );
1.3392 + args<<u;
1.3393 + procBrowser->start(browser,args);
1.3394 + if ( !procBrowser->waitForStarted())
1.3395 + {
1.3396 + // try to set path to browser
1.3397 + QMessageBox::warning(0,
1.3398 + tr("Warning"),
1.3399 + tr("Couldn't find a viewer to open %1.\n").arg(u)+
1.3400 + tr("Please use Settings->")+tr("Set application to open an URL"));
1.3401 + return;
1.3402 + }
1.3403 +#if defined(Q_OS_WIN32)
1.3404 + // There's no sleep in VCEE, replace it with Qt's QThread::wait().
1.3405 + this->thread()->wait(3000);
1.3406 +#else
1.3407 + sleep (3);
1.3408 +#endif
1.3409 + }
1.3410 + if (browser.contains("konqueror"))
1.3411 + {
1.3412 + for (int i=0; i<urls.size(); i++)
1.3413 + {
1.3414 + // Open new browser
1.3415 + // Try to open new tab in existing konqueror started previously by vym
1.3416 + p=new QProcess (this);
1.3417 + args.clear();
1.3418 +#if defined(Q_OS_WIN32)
1.3419 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
1.3420 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
1.3421 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
1.3422 + "konqueror-mainwindow#1"<<
1.3423 + "newTab" <<
1.3424 + urls.at(i);
1.3425 +#else
1.3426 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
1.3427 + "konqueror-mainwindow#1"<<
1.3428 + "newTab" <<
1.3429 + urls.at(i);
1.3430 +#endif
1.3431 + p->start ("dcop",args);
1.3432 + //cout << qPrintable (args.join(" "))<<endl;
1.3433 + if ( !p->waitForStarted() ) success=false;
1.3434 + }
1.3435 + if (!success)
1.3436 + QMessageBox::warning(0,
1.3437 + tr("Warning"),
1.3438 + tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
1.3439 + return;
1.3440 + } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
1.3441 + {
1.3442 + for (int i=0; i<urls.size(); i++)
1.3443 + {
1.3444 + // Try to open new tab in firefox
1.3445 + p=new QProcess (this);
1.3446 + args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
1.3447 + p->start (browser,args);
1.3448 + if ( !p->waitForStarted() ) success=false;
1.3449 + }
1.3450 + if (!success)
1.3451 + QMessageBox::warning(0,
1.3452 + tr("Warning"),
1.3453 + tr("Couldn't start %1 to open a new tab").arg(browser));
1.3454 + return;
1.3455 + }
1.3456 + QMessageBox::warning(0,
1.3457 + tr("Warning"),
1.3458 + tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
1.3459 + }
1.3460 +}
1.3461 +
1.3462 void Main::editOpenURL()
1.3463 {
1.3464 + // Open new browser
1.3465 if (currentMapEditor())
1.3466 - currentMapEditor()->openURL();
1.3467 + {
1.3468 + QString url=currentMapEditor()->getURL();
1.3469 + QStringList args;
1.3470 + if (url=="") return;
1.3471 + QString browser=settings.value("/mainwindow/readerURL" ).toString();
1.3472 + procBrowser = new QProcess( this );
1.3473 + args<<url;
1.3474 + procBrowser->start(browser,args);
1.3475 + if ( !procBrowser->waitForStarted())
1.3476 + {
1.3477 + // try to set path to browser
1.3478 + QMessageBox::warning(0,
1.3479 + tr("Warning"),
1.3480 + tr("Couldn't find a viewer to open %1.\n").arg(url)+
1.3481 + tr("Please use Settings->")+tr("Set application to open an URL"));
1.3482 + settingsURL() ;
1.3483 + }
1.3484 + }
1.3485 }
1.3486 +void Main::editOpenURLTab()
1.3487 +{
1.3488 + if (currentMapEditor())
1.3489 + {
1.3490 + QStringList urls;
1.3491 + urls.append(currentMapEditor()->getURL());
1.3492 + openTabs (urls);
1.3493 + }
1.3494 +}
1.3495 +void Main::editOpenMultipleURLTabs()
1.3496 +{
1.3497 + if (currentMapEditor())
1.3498 + {
1.3499 + QStringList urls;
1.3500 + urls=currentMapEditor()->getURLs();
1.3501 + openTabs (urls);
1.3502 + }
1.3503 +}
1.3504 +
1.3505
1.3506 void Main::editURL()
1.3507 {
1.3508 @@ -1739,6 +2578,12 @@
1.3509 currentMapEditor()->editURL();
1.3510 }
1.3511
1.3512 +void Main::editLocalURL()
1.3513 +{
1.3514 + if (currentMapEditor())
1.3515 + currentMapEditor()->editLocalURL();
1.3516 +}
1.3517 +
1.3518 void Main::editHeading2URL()
1.3519 {
1.3520 if (currentMapEditor())
1.3521 @@ -1751,13 +2596,190 @@
1.3522 currentMapEditor()->editBugzilla2URL();
1.3523 }
1.3524
1.3525 -void Main::editOpenVymLink()
1.3526 +void Main::editFATE2URL()
1.3527 {
1.3528 - // Get current path to map
1.3529 - QString currentVymLink;
1.3530 + if (currentMapEditor())
1.3531 + currentMapEditor()->editFATE2URL();
1.3532 +}
1.3533 +
1.3534 +void Main::editHeadingFinished()
1.3535 +{
1.3536 + // only called from editHeading(), so there is a currentME
1.3537 + MapEditor *me=currentMapEditor();
1.3538 + if (me)
1.3539 + {
1.3540 + me->setStateEditHeading (false);
1.3541 + QPoint p; //Not used here, only to find out pos of branch
1.3542 + bool ok;
1.3543 + QString s=me->getHeading(ok,p);
1.3544 +
1.3545 +#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
1.3546 +#else
1.3547 + if (ok && s!=lineedit->text())
1.3548 + me->setHeading(lineedit->text());
1.3549 +
1.3550 + lineedit->releaseKeyboard();
1.3551 + lineedit->hide();
1.3552 + setFocus();
1.3553 +#endif
1.3554 + if (!actionSettingsAutoSelectNewBranch->isOn() &&
1.3555 + !prevSelection.isEmpty())
1.3556 + me->select(prevSelection);
1.3557 + prevSelection="";
1.3558 + }
1.3559 +}
1.3560 +
1.3561 +void Main::editHeading()
1.3562 +{
1.3563 if (currentMapEditor())
1.3564 {
1.3565 - currentVymLink=currentMapEditor()->getVymLink();
1.3566 + MapEditor *me=currentMapEditor();
1.3567 + QString oldSel=me->getSelectString();
1.3568 +
1.3569 + if (lineedit->isVisible())
1.3570 + editHeadingFinished();
1.3571 + else
1.3572 + {
1.3573 + bool ok;
1.3574 + QPoint p;
1.3575 + QString s=me->getHeading(ok,p);
1.3576 +
1.3577 + if (ok)
1.3578 + {
1.3579 + me->setStateEditHeading (true);
1.3580 +#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
1.3581 + p=me->mapToGlobal (p);
1.3582 + QDialog *d =new QDialog(NULL);
1.3583 + QLineEdit *le=new QLineEdit (d);
1.3584 + d->setWindowFlags (Qt::FramelessWindowHint);
1.3585 + d->setGeometry(p.x(),p.y(),230,25);
1.3586 + le->resize (d->width()-10,d->height());
1.3587 + le->setText (s);
1.3588 + le->selectAll();
1.3589 + connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
1.3590 + d->activateWindow();
1.3591 + d->exec();
1.3592 + me->setHeading (le->text());
1.3593 + delete (le);
1.3594 + delete (d);
1.3595 + editHeadingFinished();
1.3596 +#else
1.3597 + p=me->mapTo (this,p);
1.3598 + lineedit->setGeometry(p.x(),p.y(),230,25);
1.3599 + lineedit->setText(s);
1.3600 + lineedit->setCursorPosition(1);
1.3601 + lineedit->selectAll();
1.3602 + lineedit->show();
1.3603 + lineedit->grabKeyboard();
1.3604 + lineedit->setFocus();
1.3605 +#endif
1.3606 + }
1.3607 + }
1.3608 + } // currentMapEditor()
1.3609 +}
1.3610 +
1.3611 +void Main::editAttributeFinished()
1.3612 +{
1.3613 + // only called from editHeading(), so there is a currentME
1.3614 +
1.3615 + /*
1.3616 + MapEditor *me=currentMapEditor();
1.3617 + if (me)
1.3618 + {
1.3619 + me->setStateEditHeading (false);
1.3620 + QPoint p; //Not used here, only to find out pos of branch
1.3621 + bool ok;
1.3622 + QString s=me->getHeading(ok,p);
1.3623 +
1.3624 +#if defined(Q_OS_MACX)
1.3625 +#else
1.3626 + if (ok && s!=lineedit->text())
1.3627 + me->setHeading(lineedit->text());
1.3628 +
1.3629 + lineedit->releaseKeyboard();
1.3630 + lineedit->hide();
1.3631 + setFocus();
1.3632 +#endif
1.3633 + if (!actionSettingsAutoSelectNewBranch->isOn() &&
1.3634 + !prevSelection.isEmpty())
1.3635 + me->select(prevSelection);
1.3636 + prevSelection="";
1.3637 + }
1.3638 + */
1.3639 +}
1.3640 +
1.3641 +#include "attribute.h"
1.3642 +#include "attributedialog.h"
1.3643 +void Main::editAttribute()
1.3644 +{
1.3645 + MapEditor *me=currentMapEditor();
1.3646 + if (me)
1.3647 + {
1.3648 + BranchObj *bo=me->getSelectedBranch();
1.3649 + if (bo)
1.3650 + {
1.3651 + AttributeDialog dia(this);
1.3652 + dia.setTable (me->attributeTable() );
1.3653 + dia.setBranch (bo);
1.3654 + dia.setMode (Definition);
1.3655 + dia.updateTable();
1.3656 + dia.exec();
1.3657 + }
1.3658 + }
1.3659 + /*
1.3660 + if (currentMapEditor())
1.3661 + {
1.3662 + MapEditor *me=currentMapEditor();
1.3663 + QString oldSel=me->getSelectString();
1.3664 +
1.3665 + if (lineedit->isVisible())
1.3666 + editAttributeFinished();
1.3667 + else
1.3668 + {
1.3669 + bool ok;
1.3670 + QPoint p;
1.3671 + QString s=me->getHeading(ok,p);
1.3672 +
1.3673 + if (ok)
1.3674 + {
1.3675 + me->setStateEditHeading (true);
1.3676 +#if defined(Q_OS_MACX)
1.3677 + p=me->mapToGlobal (p);
1.3678 + QDialog *d =new QDialog(NULL);
1.3679 + QLineEdit *le=new QLineEdit (d);
1.3680 + d->setWindowFlags (Qt::FramelessWindowHint);
1.3681 + d->setGeometry(p.x(),p.y(),230,25);
1.3682 + le->resize (d->width()-10,d->height());
1.3683 + le->setText (s);
1.3684 + le->selectAll();
1.3685 + connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
1.3686 + d->activateWindow();
1.3687 + d->exec();
1.3688 + me->setHeading (le->text());
1.3689 + delete (le);
1.3690 + delete (d);
1.3691 + editHeadingFinished();
1.3692 +#else
1.3693 + p=me->mapTo (this,p);
1.3694 + lineedit->setGeometry(p.x(),p.y(),230,25);
1.3695 + lineedit->setText(s);
1.3696 + lineedit->setCursorPosition(1);
1.3697 + lineedit->selectAll();
1.3698 + lineedit->show();
1.3699 + lineedit->grabKeyboard();
1.3700 + lineedit->setFocus();
1.3701 +#endif
1.3702 + }
1.3703 + }
1.3704 + } // currentMapEditor()
1.3705 +
1.3706 + */
1.3707 +}
1.3708 +
1.3709 +void Main::openVymLinks(const QStringList &vl)
1.3710 +{
1.3711 + for (int j=0; j<vl.size(); j++)
1.3712 + {
1.3713 // compare path with already loaded maps
1.3714 int index=-1;
1.3715 int i;
1.3716 @@ -1765,7 +2787,7 @@
1.3717 for (i=0;i<=tabWidget->count() -1;i++)
1.3718 {
1.3719 me=(MapEditor*)tabWidget->page(i);
1.3720 - if (currentVymLink==me->getFilePath() )
1.3721 + if (vl.at(j)==me->getFilePath() )
1.3722 {
1.3723 index=i;
1.3724 break;
1.3725 @@ -1774,12 +2796,12 @@
1.3726 if (index<0)
1.3727 // Load map
1.3728 {
1.3729 - if (!QFile(currentVymLink).exists() )
1.3730 + if (!QFile(vl.at(j)).exists() )
1.3731 QMessageBox::critical( 0, tr( "Critical Error" ),
1.3732 - tr("Couldn't open map " +currentVymLink)+".");
1.3733 + tr("Couldn't open map %1").arg(vl.at(j)));
1.3734 else
1.3735 {
1.3736 - fileLoad (currentVymLink, NewMap);
1.3737 + fileLoad (vl.at(j), NewMap);
1.3738 tabWidget->setCurrentPage (tabWidget->count()-1);
1.3739 }
1.3740 } else
1.3741 @@ -1788,6 +2810,26 @@
1.3742 }
1.3743 }
1.3744
1.3745 +void Main::editOpenVymLink()
1.3746 +{
1.3747 + if (currentMapEditor())
1.3748 + {
1.3749 + QStringList vl;
1.3750 + vl.append(currentMapEditor()->getVymLink());
1.3751 + openVymLinks (vl);
1.3752 + }
1.3753 +}
1.3754 +
1.3755 +void Main::editOpenMultipleVymLinks()
1.3756 +{
1.3757 + QString currentVymLink;
1.3758 + if (currentMapEditor())
1.3759 + {
1.3760 + QStringList vl=currentMapEditor()->getVymLinks();
1.3761 + openVymLinks (vl);
1.3762 + }
1.3763 +}
1.3764 +
1.3765 void Main::editVymLink()
1.3766 {
1.3767 if (currentMapEditor())
1.3768 @@ -1800,6 +2842,12 @@
1.3769 currentMapEditor()->deleteVymLink();
1.3770 }
1.3771
1.3772 +void Main::editToggleHideExport()
1.3773 +{
1.3774 + if (currentMapEditor())
1.3775 + currentMapEditor()->toggleHideExport();
1.3776 +}
1.3777 +
1.3778 void Main::editMapInfo()
1.3779 {
1.3780 if (currentMapEditor())
1.3781 @@ -1818,6 +2866,12 @@
1.3782 currentMapEditor()->moveBranchDown();
1.3783 }
1.3784
1.3785 +void Main::editSortChildren()
1.3786 +{
1.3787 + if (currentMapEditor())
1.3788 + currentMapEditor()->sortChildren();
1.3789 +}
1.3790 +
1.3791 void Main::editToggleScroll()
1.3792 {
1.3793 if (currentMapEditor())
1.3794 @@ -1826,36 +2880,113 @@
1.3795 }
1.3796 }
1.3797
1.3798 -void Main::editUnScrollAll()
1.3799 +void Main::editUnscrollChilds()
1.3800 {
1.3801 if (currentMapEditor())
1.3802 + currentMapEditor()->unscrollChilds();
1.3803 +}
1.3804 +
1.3805 +void Main::editAddMapCenter()
1.3806 +{
1.3807 + MapEditor *me=currentMapEditor();
1.3808 + if (!lineedit->isVisible() && me)
1.3809 {
1.3810 - currentMapEditor()->unScrollAll();
1.3811 + me->addMapCenter ();
1.3812 }
1.3813 }
1.3814
1.3815 -void Main::editHeading()
1.3816 -{
1.3817 - if (currentMapEditor())
1.3818 - currentMapEditor()->editHeading();
1.3819 -}
1.3820 -
1.3821 void Main::editNewBranch()
1.3822 {
1.3823 - if (currentMapEditor())
1.3824 - currentMapEditor()->addNewBranch(0);
1.3825 + MapEditor *me=currentMapEditor();
1.3826 + if (!lineedit->isVisible() && me)
1.3827 + {
1.3828 + BranchObj *bo=(BranchObj*)me->getSelection();
1.3829 + BranchObj *newbo=me->addNewBranch(0);
1.3830 +
1.3831 + prevSelection=me->getModel()->getSelectString(bo);
1.3832 + if (newbo)
1.3833 + me->select (newbo);
1.3834 + else
1.3835 + return;
1.3836 +
1.3837 + if (actionSettingsAutoEditNewBranch->isOn())
1.3838 + {
1.3839 + editHeading();
1.3840 + return;
1.3841 + }
1.3842 + if (!prevSelection.isEmpty())
1.3843 + {
1.3844 + me->select(prevSelection);
1.3845 + prevSelection="";
1.3846 + }
1.3847 +
1.3848 + }
1.3849 +}
1.3850 +
1.3851 +void Main::editNewBranchBefore()
1.3852 +{
1.3853 + MapEditor *me=currentMapEditor();
1.3854 + if (!lineedit->isVisible() && me)
1.3855 + {
1.3856 + BranchObj *bo=(BranchObj*)me->getSelection();
1.3857 + BranchObj *newbo=me->addNewBranchBefore();
1.3858 +
1.3859 + if (newbo)
1.3860 + me->select (newbo);
1.3861 + else
1.3862 + return;
1.3863 +
1.3864 + if (actionSettingsAutoEditNewBranch->isOn())
1.3865 + {
1.3866 + if (!actionSettingsAutoSelectNewBranch->isOn())
1.3867 + prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
1.3868 + editHeading();
1.3869 + }
1.3870 + }
1.3871 }
1.3872
1.3873 void Main::editNewBranchAbove()
1.3874 {
1.3875 - if (currentMapEditor())
1.3876 - currentMapEditor()->addNewBranch(-1);
1.3877 + MapEditor *me=currentMapEditor();
1.3878 + if (!lineedit->isVisible() && me)
1.3879 + {
1.3880 + BranchObj *bo=(BranchObj*)me->getSelection();
1.3881 + BranchObj *newbo=me->addNewBranch (-1);
1.3882 +
1.3883 + if (newbo)
1.3884 + me->select (newbo);
1.3885 + else
1.3886 + return;
1.3887 +
1.3888 + if (actionSettingsAutoEditNewBranch->isOn())
1.3889 + {
1.3890 + if (!actionSettingsAutoSelectNewBranch->isOn())
1.3891 + prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
1.3892 + editHeading();
1.3893 + }
1.3894 + }
1.3895 }
1.3896
1.3897 void Main::editNewBranchBelow()
1.3898 {
1.3899 - if (currentMapEditor())
1.3900 - currentMapEditor()->addNewBranch(1);
1.3901 + MapEditor *me=currentMapEditor();
1.3902 + if (!lineedit->isVisible() && me)
1.3903 + {
1.3904 + BranchObj *bo=(BranchObj*)me->getSelection();
1.3905 + BranchObj *newbo=me->addNewBranch (1);
1.3906 +
1.3907 + if (newbo)
1.3908 + me->select (newbo);
1.3909 + else
1.3910 + return;
1.3911 +
1.3912 + if (actionSettingsAutoEditNewBranch->isOn())
1.3913 + {
1.3914 + if (!actionSettingsAutoSelectNewBranch->isOn())
1.3915 + prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
1.3916 + editHeading();
1.3917 + }
1.3918 + }
1.3919 }
1.3920
1.3921 void Main::editImportAdd()
1.3922 @@ -1873,9 +3004,21 @@
1.3923 fileSaveAs (PartOfMap);
1.3924 }
1.3925
1.3926 +void Main::editDeleteKeepChilds()
1.3927 +{
1.3928 + if (currentMapEditor())
1.3929 + currentMapEditor()->deleteKeepChilds();
1.3930 +}
1.3931 +
1.3932 +void Main::editDeleteChilds()
1.3933 +{
1.3934 + if (currentMapEditor())
1.3935 + currentMapEditor()->deleteChilds();
1.3936 +}
1.3937 +
1.3938 void Main::editDeleteSelection()
1.3939 {
1.3940 - if (currentMapEditor())
1.3941 + if (currentMapEditor() && actionSettingsUseDelKey->isOn())
1.3942 currentMapEditor()->deleteSelection();
1.3943 }
1.3944
1.3945 @@ -1921,25 +3064,31 @@
1.3946 currentMapEditor()->loadFloatImage();
1.3947 }
1.3948
1.3949 -void Main::editSaveImage(int item)
1.3950 +void Main::editSaveImage()
1.3951 {
1.3952 if (currentMapEditor())
1.3953 - currentMapEditor()->saveFloatImage(item);
1.3954 + currentMapEditor()->saveFloatImage();
1.3955 }
1.3956
1.3957 -void Main::editToggleFloatExport()
1.3958 +void Main::editFollowXLink(QAction *a)
1.3959 +{
1.3960 +
1.3961 + if (currentMapEditor())
1.3962 + currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
1.3963 +}
1.3964 +
1.3965 +void Main::editEditXLink(QAction *a)
1.3966 {
1.3967 if (currentMapEditor())
1.3968 - currentMapEditor()->toggleFloatExport();
1.3969 + currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
1.3970 }
1.3971
1.3972 void Main::formatSelectColor()
1.3973 {
1.3974 if (currentMapEditor())
1.3975 {
1.3976 - QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
1.3977 + QColor col = QColorDialog::getColor((currentColor ), this );
1.3978 if ( !col.isValid() ) return;
1.3979 - currentMapEditor()->setColor( col );
1.3980 colorChanged( col );
1.3981 }
1.3982 }
1.3983 @@ -1947,7 +3096,7 @@
1.3984 void Main::formatPickColor()
1.3985 {
1.3986 if (currentMapEditor())
1.3987 - colorChanged( currentMapEditor()->pickColor() );
1.3988 + colorChanged( currentMapEditor()->getCurrentHeadingColor() );
1.3989 }
1.3990
1.3991 void Main::colorChanged(QColor c)
1.3992 @@ -1955,82 +3104,100 @@
1.3993 QPixmap pix( 16, 16 );
1.3994 pix.fill( c );
1.3995 actionFormatColor->setIconSet( pix );
1.3996 -}
1.3997 -
1.3998 -void Main::formatColorItem()
1.3999 -{
1.4000 - if (currentMapEditor())
1.4001 - currentMapEditor()->colorItem();
1.4002 + currentColor=c;
1.4003 }
1.4004
1.4005 void Main::formatColorBranch()
1.4006 {
1.4007 if (currentMapEditor())
1.4008 - currentMapEditor()->colorBranch();
1.4009 + currentMapEditor()->colorBranch(currentColor);
1.4010 +}
1.4011 +
1.4012 +void Main::formatColorSubtree()
1.4013 +{
1.4014 + if (currentMapEditor())
1.4015 + currentMapEditor()->colorSubtree (currentColor);
1.4016 }
1.4017
1.4018 void Main::formatLinkStyleLine()
1.4019 {
1.4020 if (currentMapEditor())
1.4021 - currentMapEditor()->setLinkStyle(StyleLine);
1.4022 + {
1.4023 + currentMapEditor()->setMapLinkStyle("StyleLine");
1.4024 + actionFormatLinkStyleLine->setOn(true);
1.4025 + }
1.4026 }
1.4027
1.4028 void Main::formatLinkStyleParabel()
1.4029 {
1.4030 if (currentMapEditor())
1.4031 - currentMapEditor()->setLinkStyle(StyleParabel);
1.4032 + {
1.4033 + currentMapEditor()->setMapLinkStyle("StyleParabel");
1.4034 + actionFormatLinkStyleParabel->setOn(true);
1.4035 + }
1.4036 }
1.4037
1.4038 void Main::formatLinkStylePolyLine()
1.4039 {
1.4040 if (currentMapEditor())
1.4041 - currentMapEditor()->setLinkStyle(StylePolyLine);
1.4042 + {
1.4043 + currentMapEditor()->setMapLinkStyle("StylePolyLine");
1.4044 + actionFormatLinkStylePolyLine->setOn(true);
1.4045 + }
1.4046 }
1.4047
1.4048 void Main::formatLinkStylePolyParabel()
1.4049 {
1.4050 if (currentMapEditor())
1.4051 - currentMapEditor()->setLinkStyle(StylePolyParabel);
1.4052 + {
1.4053 + currentMapEditor()->setMapLinkStyle("StylePolyParabel");
1.4054 + actionFormatLinkStylePolyParabel->setOn(true);
1.4055 + }
1.4056 }
1.4057
1.4058 void Main::formatSelectBackColor()
1.4059 {
1.4060 if (currentMapEditor())
1.4061 - currentMapEditor()->selectBackgroundColor();
1.4062 + currentMapEditor()->selectMapBackgroundColor();
1.4063 +}
1.4064 +
1.4065 +void Main::formatSelectBackImage()
1.4066 +{
1.4067 + if (currentMapEditor())
1.4068 + currentMapEditor()->selectMapBackgroundImage();
1.4069 }
1.4070
1.4071 void Main::formatSelectLinkColor()
1.4072 {
1.4073 if (currentMapEditor())
1.4074 - currentMapEditor()->selectLinkColor();
1.4075 + currentMapEditor()->selectMapLinkColor();
1.4076 +}
1.4077 +
1.4078 +void Main::formatSelectSelectionColor()
1.4079 +{
1.4080 + if (currentMapEditor())
1.4081 + currentMapEditor()->selectMapSelectionColor();
1.4082 }
1.4083
1.4084 void Main::formatToggleLinkColorHint()
1.4085 {
1.4086 - currentMapEditor()->toggleLinkColorHint();
1.4087 + currentMapEditor()->toggleMapLinkColorHint();
1.4088 }
1.4089
1.4090 -void Main::formatFrameNone()
1.4091 +
1.4092 +void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
1.4093 {
1.4094 if (currentMapEditor())
1.4095 - currentMapEditor()->setFrame(NoFrame);
1.4096 -}
1.4097 -
1.4098 -void Main::formatFrameRectangle()
1.4099 -{
1.4100 - if (currentMapEditor())
1.4101 - currentMapEditor()->setFrame(Rectangle);
1.4102 + currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
1.4103 }
1.4104
1.4105 void Main::viewZoomReset()
1.4106 {
1.4107 if (currentMapEditor())
1.4108 {
1.4109 - QWMatrix m;
1.4110 + QMatrix m;
1.4111 m.reset();
1.4112 - currentMapEditor()->setWorldMatrix( m );
1.4113 - currentMapEditor()->setViewCenter();
1.4114 - currentMapEditor()->adjustCanvasSize();
1.4115 + currentMapEditor()->setMatrix( m );
1.4116 }
1.4117 }
1.4118
1.4119 @@ -2038,11 +3205,9 @@
1.4120 {
1.4121 if (currentMapEditor())
1.4122 {
1.4123 - QWMatrix m = currentMapEditor()->worldMatrix();
1.4124 + QMatrix m = currentMapEditor()->matrix();
1.4125 m.scale( 1.25, 1.25 );
1.4126 - currentMapEditor()->setWorldMatrix( m );
1.4127 - currentMapEditor()->setViewCenter();
1.4128 - currentMapEditor()->adjustCanvasSize();
1.4129 + currentMapEditor()->setMatrix( m );
1.4130 }
1.4131 }
1.4132
1.4133 @@ -2050,22 +3215,42 @@
1.4134 {
1.4135 if (currentMapEditor())
1.4136 {
1.4137 - QWMatrix m = currentMapEditor()->worldMatrix();
1.4138 + QMatrix m = currentMapEditor()->matrix();
1.4139 m.scale( 0.8, 0.8 );
1.4140 - currentMapEditor()->setWorldMatrix( m );
1.4141 - currentMapEditor()->setViewCenter();
1.4142 - currentMapEditor()->adjustCanvasSize();
1.4143 + currentMapEditor()->setMatrix( m );
1.4144 }
1.4145 }
1.4146 +
1.4147 +void Main::viewCenter()
1.4148 +{
1.4149 + MapEditor *me=currentMapEditor();
1.4150 + if (me)
1.4151 + {
1.4152 + me->ensureSelectionVisible();
1.4153 + }
1.4154 +}
1.4155 +
1.4156 +void Main::networkStartServer()
1.4157 +{
1.4158 + MapEditor *me=currentMapEditor();
1.4159 + if (me) me->newServer();
1.4160 +}
1.4161 +
1.4162 +void Main::networkConnect()
1.4163 +{
1.4164 + MapEditor *me=currentMapEditor();
1.4165 + if (me) me->connectToServer();
1.4166 +}
1.4167 +
1.4168 bool Main::settingsPDF()
1.4169 {
1.4170 // Default browser is set in constructor
1.4171 bool ok;
1.4172 QString text = QInputDialog::getText(
1.4173 - "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
1.4174 - settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
1.4175 + "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
1.4176 + settings.value("/mainwindow/readerPDF").toString(), &ok, this );
1.4177 if (ok)
1.4178 - settings.writeEntry ("/vym/mainwindow/readerPDF",text);
1.4179 + settings.setValue ("/mainwindow/readerPDF",text);
1.4180 return ok;
1.4181 }
1.4182
1.4183 @@ -2075,20 +3260,364 @@
1.4184 // Default browser is set in constructor
1.4185 bool ok;
1.4186 QString text = QInputDialog::getText(
1.4187 - "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
1.4188 - settings.readEntry("/vym/mainwindow/readerURL")
1.4189 + "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
1.4190 + settings.value("/mainwindow/readerURL").toString()
1.4191 , &ok, this );
1.4192 if (ok)
1.4193 - settings.writeEntry ("/vym/mainwindow/readerURL",text);
1.4194 + settings.setValue ("/mainwindow/readerURL",text);
1.4195 return ok;
1.4196 }
1.4197
1.4198 +void Main::settingsMacroDir()
1.4199 +{
1.4200 + QDir defdir(vymBaseDir.path() + "/macros");
1.4201 + if (!defdir.exists())
1.4202 + defdir=vymBaseDir;
1.4203 + QDir dir=QFileDialog::getExistingDirectory (
1.4204 + this,
1.4205 + tr ("Directory with vym macros:"),
1.4206 + settings.value ("/macros/macroDir",defdir.path()).toString()
1.4207 + );
1.4208 + if (dir.exists())
1.4209 + settings.setValue ("/macros/macroDir",dir.absolutePath());
1.4210 +}
1.4211 +
1.4212 +void Main::settingsUndoLevels()
1.4213 +{
1.4214 + bool ok;
1.4215 + int i = QInputDialog::getInteger(
1.4216 + this,
1.4217 + tr("QInputDialog::getInteger()"),
1.4218 + tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
1.4219 + if (ok)
1.4220 + {
1.4221 + settings.setValue ("/mapeditor/stepsTotal",i);
1.4222 + QMessageBox::information( this, tr( "VYM -Information:" ),
1.4223 + tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
1.4224 + }
1.4225 +}
1.4226 +
1.4227 +void Main::settingsAutosaveToggle()
1.4228 +{
1.4229 + settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
1.4230 +}
1.4231 +
1.4232 +void Main::settingsAutosaveTime()
1.4233 +{
1.4234 + bool ok;
1.4235 + int i = QInputDialog::getInteger(
1.4236 + this,
1.4237 + tr("QInputDialog::getInteger()"),
1.4238 + tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
1.4239 + if (ok)
1.4240 + settings.setValue ("/mainwindow/autosave/ms",i * 1000);
1.4241 +}
1.4242 +
1.4243 +void Main::settingsWriteBackupFileToggle()
1.4244 +{
1.4245 + settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
1.4246 +}
1.4247 +
1.4248 +void Main::settingsToggleAnimation()
1.4249 +{
1.4250 + settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
1.4251 +}
1.4252 +
1.4253 +void Main::settingsToggleDelKey()
1.4254 +{
1.4255 + if (actionSettingsUseDelKey->isOn())
1.4256 + {
1.4257 + actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
1.4258 + } else
1.4259 + {
1.4260 + actionEditDelete->setAccel (QKeySequence (""));
1.4261 + }
1.4262 +}
1.4263 +
1.4264 void Main::windowToggleNoteEditor()
1.4265 {
1.4266 - if (textEditor->showWithMain() )
1.4267 + if (textEditor->isVisible() )
1.4268 windowHideNoteEditor();
1.4269 + else
1.4270 + windowShowNoteEditor();
1.4271 +}
1.4272 +
1.4273 +void Main::windowToggleHistory()
1.4274 +{
1.4275 + if (historyWindow->isVisible())
1.4276 + historyWindow->hide();
1.4277 else
1.4278 - windowShowNoteEditor();
1.4279 + historyWindow->show();
1.4280 +
1.4281 +}
1.4282 +
1.4283 +void Main::windowToggleProperty()
1.4284 +{
1.4285 + if (branchPropertyWindow->isVisible())
1.4286 + branchPropertyWindow->hide();
1.4287 + else
1.4288 + branchPropertyWindow->show();
1.4289 +
1.4290 + if(currentMapEditor())
1.4291 + {
1.4292 + BranchObj *bo=currentMapEditor()->getSelectedBranch();
1.4293 + if (bo)
1.4294 + {
1.4295 + branchPropertyWindow->setMapEditor(currentMapEditor());
1.4296 + branchPropertyWindow->setBranch(bo);
1.4297 + return;
1.4298 + }
1.4299 +
1.4300 + }
1.4301 + branchPropertyWindow->setBranch(NULL);
1.4302 +}
1.4303 +
1.4304 +void Main::windowToggleAntiAlias()
1.4305 +{
1.4306 + bool b=actionViewToggleAntiAlias->isOn();
1.4307 + MapEditor *me;
1.4308 + for (int i=0;i<tabWidget->count();i++)
1.4309 + {
1.4310 +
1.4311 + me=(MapEditor*)tabWidget->page(i);
1.4312 + me->setAntiAlias(b);
1.4313 + }
1.4314 +
1.4315 +}
1.4316 +
1.4317 +void Main::windowToggleSmoothPixmap()
1.4318 +{
1.4319 + bool b=actionViewToggleSmoothPixmapTransform->isOn();
1.4320 + MapEditor *me;
1.4321 + for (int i=0;i<tabWidget->count();i++)
1.4322 + {
1.4323 +
1.4324 + me=(MapEditor*)tabWidget->page(i);
1.4325 + me->setSmoothPixmap(b);
1.4326 + }
1.4327 +}
1.4328 +
1.4329 +void Main::updateHistory(SimpleSettings &undoSet)
1.4330 +{
1.4331 + historyWindow->update (undoSet);
1.4332 +}
1.4333 +
1.4334 +void Main::updateNoteFlag()
1.4335 +{
1.4336 + if (currentMapEditor())
1.4337 + currentMapEditor()->updateNoteFlag();
1.4338 +}
1.4339 +
1.4340 +void Main::updateSatellites(MapEditor *me)
1.4341 +{
1.4342 + branchPropertyWindow->setMapEditor (me);
1.4343 +}
1.4344 +
1.4345 +void Main::updateActions()
1.4346 +{
1.4347 + MapEditor *me=currentMapEditor();
1.4348 + if (!me) return;
1.4349 +
1.4350 + historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
1.4351 +
1.4352 + // updateActions is also called when NoteEditor is closed
1.4353 + actionViewToggleNoteEditor->setOn (textEditor->isVisible());
1.4354 + actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
1.4355 + actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
1.4356 +
1.4357 + if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
1.4358 + actionFormatLinkColorHint->setOn(true);
1.4359 + else
1.4360 + actionFormatLinkColorHint->setOn(false);
1.4361 +
1.4362 + switch (me->getMapLinkStyle())
1.4363 + {
1.4364 + case LinkableMapObj::Line:
1.4365 + actionFormatLinkStyleLine->setOn(true);
1.4366 + break;
1.4367 + case LinkableMapObj::Parabel:
1.4368 + actionFormatLinkStyleParabel->setOn(true);
1.4369 + break;
1.4370 + case LinkableMapObj::PolyLine:
1.4371 + actionFormatLinkStylePolyLine->setOn(true);
1.4372 + break;
1.4373 + case LinkableMapObj::PolyParabel:
1.4374 + actionFormatLinkStylePolyParabel->setOn(true);
1.4375 + break;
1.4376 + default:
1.4377 + break;
1.4378 + }
1.4379 +
1.4380 + // Update colors
1.4381 + QPixmap pix( 16, 16 );
1.4382 + pix.fill( me->getMapBackgroundColor() );
1.4383 + actionFormatBackColor->setIconSet( pix );
1.4384 + pix.fill( me->getSelectionColor() );
1.4385 + actionFormatSelectionColor->setIconSet( pix );
1.4386 + pix.fill( me->getMapDefLinkColor() );
1.4387 + actionFormatLinkColor->setIconSet( pix );
1.4388 +
1.4389 +
1.4390 + actionFileSave->setEnabled( me->hasChanged() );
1.4391 + if (me->isUndoAvailable())
1.4392 + actionEditUndo->setEnabled( true);
1.4393 + else
1.4394 + actionEditUndo->setEnabled( false);
1.4395 +
1.4396 + if (me->isRedoAvailable())
1.4397 + actionEditRedo->setEnabled( true);
1.4398 + else
1.4399 + actionEditRedo->setEnabled( false);
1.4400 +
1.4401 + LinkableMapObj *selection=me->getSelection();
1.4402 + if (selection)
1.4403 + {
1.4404 + if ( (typeid(*selection) == typeid(BranchObj)) ||
1.4405 + (typeid(*selection) == typeid(MapCenterObj)) )
1.4406 + {
1.4407 + BranchObj *bo=(BranchObj*)selection;
1.4408 + // Take care of links
1.4409 + if (bo->countXLinks()==0)
1.4410 + {
1.4411 + branchXLinksContextMenuEdit->clear();
1.4412 + branchXLinksContextMenuFollow->clear();
1.4413 + } else
1.4414 + {
1.4415 + BranchObj *bot;
1.4416 + QString s;
1.4417 + branchXLinksContextMenuEdit->clear();
1.4418 + branchXLinksContextMenuFollow->clear();
1.4419 + for (int i=0; i<=bo->countXLinks();i++)
1.4420 + {
1.4421 + bot=bo->XLinkTargetAt(i);
1.4422 + if (bot)
1.4423 + {
1.4424 + s=bot->getHeading();
1.4425 + if (s.length()>xLinkMenuWidth)
1.4426 + s=s.left(xLinkMenuWidth)+"...";
1.4427 + branchXLinksContextMenuFollow->addAction (s);
1.4428 + branchXLinksContextMenuEdit->addAction (s);
1.4429 + }
1.4430 + }
1.4431 + }
1.4432 +
1.4433 + standardFlagsDefault->setEnabled (true);
1.4434 +
1.4435 + actionEditToggleScroll->setEnabled (true);
1.4436 + if ( bo->isScrolled() )
1.4437 + actionEditToggleScroll->setOn(true);
1.4438 + else
1.4439 + actionEditToggleScroll->setOn(false);
1.4440 +
1.4441 + if ( bo->getURL().isEmpty() )
1.4442 + {
1.4443 + actionEditOpenURL->setEnabled (false);
1.4444 + actionEditOpenURLTab->setEnabled (false);
1.4445 + }
1.4446 + else
1.4447 + {
1.4448 + actionEditOpenURL->setEnabled (true);
1.4449 + actionEditOpenURLTab->setEnabled (true);
1.4450 + }
1.4451 + if ( bo->getVymLink().isEmpty() )
1.4452 + {
1.4453 + actionEditOpenVymLink->setEnabled (false);
1.4454 + actionEditDeleteVymLink->setEnabled (false);
1.4455 + } else
1.4456 + {
1.4457 + actionEditOpenVymLink->setEnabled (true);
1.4458 + actionEditDeleteVymLink->setEnabled (true);
1.4459 + }
1.4460 +
1.4461 + if (bo->canMoveBranchUp())
1.4462 + actionEditMoveUp->setEnabled (true);
1.4463 + else
1.4464 + actionEditMoveUp->setEnabled (false);
1.4465 + if (bo->canMoveBranchDown())
1.4466 + actionEditMoveDown->setEnabled (true);
1.4467 + else
1.4468 + actionEditMoveDown->setEnabled (false);
1.4469 +
1.4470 +
1.4471 + actionEditToggleHideExport->setEnabled (true);
1.4472 + actionEditToggleHideExport->setOn (bo->hideInExport() );
1.4473 +
1.4474 + actionEditCopy->setEnabled (true);
1.4475 + actionEditCut->setEnabled (true);
1.4476 + if (!clipboardEmpty)
1.4477 + actionEditPaste->setEnabled (true);
1.4478 + else
1.4479 + actionEditPaste->setEnabled (false);
1.4480 + for (int i=0; i<actionListBranches.size(); ++i)
1.4481 + actionListBranches.at(i)->setEnabled(true);
1.4482 + actionEditDelete->setEnabled (true);
1.4483 + actionFormatHideLinkUnselected->setOn
1.4484 + (selection->getHideLinkUnselected());
1.4485 + }
1.4486 + if ( (typeid(*selection) == typeid(FloatImageObj)) )
1.4487 + {
1.4488 + FloatObj *fo=(FloatImageObj*)selection;
1.4489 +
1.4490 + actionEditOpenURL->setEnabled (false);
1.4491 + actionEditOpenVymLink->setEnabled (false);
1.4492 + actionEditDeleteVymLink->setEnabled (false);
1.4493 + actionEditToggleHideExport->setEnabled (true);
1.4494 + actionEditToggleHideExport->setOn (fo->hideInExport() );
1.4495 +
1.4496 +
1.4497 + actionEditCopy->setEnabled (true);
1.4498 + actionEditCut->setEnabled (true);
1.4499 + actionEditPaste->setEnabled (false);
1.4500 + for (int i=0; i<actionListBranches.size(); ++i)
1.4501 + actionListBranches.at(i)->setEnabled(false);
1.4502 + actionEditDelete->setEnabled (true);
1.4503 + actionFormatHideLinkUnselected->setOn
1.4504 + ( selection->getHideLinkUnselected());
1.4505 + actionEditMoveUp->setEnabled (false);
1.4506 + actionEditMoveDown->setEnabled (false);
1.4507 + }
1.4508 +
1.4509 + } else
1.4510 + {
1.4511 + actionEditCopy->setEnabled (false);
1.4512 + actionEditCut->setEnabled (false);
1.4513 + actionEditPaste->setEnabled (false);
1.4514 + for (int i=0; i<actionListBranches.size(); ++i)
1.4515 + actionListBranches.at(i)->setEnabled(false);
1.4516 +
1.4517 + actionEditToggleScroll->setEnabled (false);
1.4518 + actionEditOpenURL->setEnabled (false);
1.4519 + actionEditOpenVymLink->setEnabled (false);
1.4520 + actionEditDeleteVymLink->setEnabled (false);
1.4521 + actionEditHeading2URL->setEnabled (false);
1.4522 + actionEditDelete->setEnabled (false);
1.4523 + actionEditMoveUp->setEnabled (false);
1.4524 + actionEditMoveDown->setEnabled (false);
1.4525 + actionEditToggleHideExport->setEnabled (false);
1.4526 + }
1.4527 +}
1.4528 +
1.4529 +Main::ModMode Main::getModMode()
1.4530 +{
1.4531 + if (actionModModeColor->isOn()) return ModModeColor;
1.4532 + if (actionModModeCopy->isOn()) return ModModeCopy;
1.4533 + if (actionModModeXLink->isOn()) return ModModeXLink;
1.4534 + return ModModeNone;
1.4535 +}
1.4536 +
1.4537 +bool Main::autoEditNewBranch()
1.4538 +{
1.4539 + return actionSettingsAutoEditNewBranch->isOn();
1.4540 +}
1.4541 +
1.4542 +bool Main::autoSelectNewBranch()
1.4543 +{
1.4544 + return actionSettingsAutoSelectNewBranch->isOn();
1.4545 +}
1.4546 +
1.4547 +bool Main::useFlagGroups()
1.4548 +{
1.4549 + return actionSettingsUseFlagGroups->isOn();
1.4550 }
1.4551
1.4552 void Main::windowShowNoteEditor()
1.4553 @@ -2105,6 +3634,27 @@
1.4554 actionViewToggleNoteEditor->setOn (false);
1.4555 }
1.4556
1.4557 +void Main::setScript (const QString &script)
1.4558 +{
1.4559 + scriptEditor->setScript (script);
1.4560 +}
1.4561 +
1.4562 +void Main::runScript (const QString &script)
1.4563 +{
1.4564 + if (currentMapEditor())
1.4565 + currentMapEditor()->runScript (script);
1.4566 +}
1.4567 +
1.4568 +void Main::runScriptEverywhere (const QString &script)
1.4569 +{
1.4570 + MapEditor *me;
1.4571 + for (int i=0;i<=tabWidget->count() -1;i++)
1.4572 + {
1.4573 + me=(MapEditor*)tabWidget->page(i);
1.4574 + if (me) me->runScript (script);
1.4575 + }
1.4576 +}
1.4577 +
1.4578 void Main::windowNextEditor()
1.4579 {
1.4580 if (tabWidget->currentPageIndex() < tabWidget->count())
1.4581 @@ -2119,91 +3669,142 @@
1.4582
1.4583 void Main::standardFlagChanged()
1.4584 {
1.4585 - currentMapEditor()->toggleStandardFlag(sender()->name());
1.4586 + if (currentMapEditor())
1.4587 + currentMapEditor()->toggleStandardFlag(sender()->name());
1.4588 }
1.4589
1.4590 -void Main::testFunction()
1.4591 +void Main::testFunction1()
1.4592 {
1.4593 - //textEditor->stackUnder(this);
1.4594 - currentMapEditor()->testFunction();
1.4595 + if (!currentMapEditor()) return;
1.4596 + currentMapEditor()->testFunction1();
1.4597 + //editAttribute();
1.4598 }
1.4599
1.4600 -void Main::testShowClipboard()
1.4601 +void Main::testFunction2()
1.4602 {
1.4603 - clipboardME->show();
1.4604 + if (!currentMapEditor()) return;
1.4605 + currentMapEditor()->testFunction2();
1.4606 +}
1.4607 +
1.4608 +void Main::testCommand()
1.4609 +{
1.4610 + if (!currentMapEditor()) return;
1.4611 + scriptEditor->show();
1.4612 + /*
1.4613 + bool ok;
1.4614 + QString com = QInputDialog::getText(
1.4615 + vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
1.4616 + if (ok) currentMapEditor()->parseAtom(com);
1.4617 + */
1.4618 }
1.4619
1.4620 void Main::helpDoc()
1.4621 {
1.4622 - QString docpath;
1.4623 - // default path in SUSE LINUX
1.4624 - docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
1.4625 -
1.4626 - if (!QFile (docpath).exists() )
1.4627 + QString locale = QLocale::system().name();
1.4628 + QString docname;
1.4629 + if (locale.left(2)=="es")
1.4630 + docname="vym_es.pdf";
1.4631 + else
1.4632 + docname="vym.pdf";
1.4633 +
1.4634 + QStringList searchList;
1.4635 + QDir docdir;
1.4636 + #if defined(Q_OS_MACX)
1.4637 + searchList << "./vym.app/Contents/Resources/doc";
1.4638 + #elif defined(Q_OS_WIN32)
1.4639 + searchList << vymInstallDir.path() + "/share/doc/packages/vym";
1.4640 + #else
1.4641 + #if defined(VYM_DOCDIR)
1.4642 + searchList << VYM_DOCDIR;
1.4643 + #endif
1.4644 + // default path in SUSE LINUX
1.4645 + searchList << "/usr/share/doc/packages/vym";
1.4646 + #endif
1.4647 +
1.4648 + searchList << "doc"; // relative path for easy testing in tarball
1.4649 + searchList << "doc/tex"; // Easy testing working on vym.tex
1.4650 + searchList << "/usr/share/doc/vym"; // Debian
1.4651 + searchList << "/usr/share/doc/packages";// Knoppix
1.4652 +
1.4653 + bool found=false;
1.4654 + QFile docfile;
1.4655 + for (int i=0; i<searchList.count(); ++i)
1.4656 {
1.4657 - // relative path for easy testing in tarball
1.4658 - docpath="doc/vym.pdf";
1.4659 - if (!QFile (docpath).exists() )
1.4660 + docfile.setFileName(searchList.at(i)+"/"+docname);
1.4661 + if (docfile.exists())
1.4662 {
1.4663 - // relative path for testing while still writing vym.tex
1.4664 - docpath="doc/tex/vym.pdf";
1.4665 - if (!QFile (docpath).exists() )
1.4666 - {
1.4667 - QMessageBox::critical(0,
1.4668 - tr("Critcal error"),
1.4669 - tr("Couldn't find the documentation\n"
1.4670 - "vym.pdf in various places."));
1.4671 - return;
1.4672 - }
1.4673 - }
1.4674 + found=true;
1.4675 + break;
1.4676 + }
1.4677 }
1.4678 -
1.4679 +
1.4680 + if (!found)
1.4681 + {
1.4682 + QMessageBox::critical(0,
1.4683 + tr("Critcal error"),
1.4684 + tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
1.4685 + return;
1.4686 + }
1.4687 +
1.4688 + QStringList args;
1.4689 Process *pdfProc = new Process();
1.4690 - pdfProc->clearArguments();
1.4691 - pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
1.4692 - pdfProc->addArgument( docpath);
1.4693 -
1.4694 - if ( !pdfProc->start() )
1.4695 + args << QDir::toNativeSeparators(docfile.fileName());
1.4696 +
1.4697 + pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
1.4698 + if ( !pdfProc->waitForStarted() )
1.4699 {
1.4700 // error handling
1.4701 - QMessageBox::critical(0,
1.4702 - tr("Critcal error"),
1.4703 - tr("Couldn't find a viewer to read vym.pdf.\n"
1.4704 - "Please use Settings->")+tr("Set application to open pdf files"));
1.4705 + QMessageBox::warning(0,
1.4706 + tr("Warning"),
1.4707 + tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
1.4708 + tr("Please use Settings->")+tr("Set application to open PDF files"));
1.4709 + settingsPDF();
1.4710 return;
1.4711 }
1.4712 }
1.4713
1.4714
1.4715 +void Main::helpDemo()
1.4716 +{
1.4717 + QStringList filters;
1.4718 + filters <<"VYM example map (*.vym)";
1.4719 + QFileDialog *fd=new QFileDialog( this);
1.4720 + #if defined(Q_OS_MACX)
1.4721 + fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
1.4722 + #else
1.4723 + // default path in SUSE LINUX
1.4724 + fd->setDir (QDir(vymBaseDir.path()+"/demos"));
1.4725 + #endif
1.4726 +
1.4727 + fd->setFileMode (QFileDialog::ExistingFiles);
1.4728 + fd->setFilters (filters);
1.4729 + fd->setCaption(vymName+ " - " +tr("Load vym example map"));
1.4730 + fd->show();
1.4731 +
1.4732 + QString fn;
1.4733 + if ( fd->exec() == QDialog::Accepted )
1.4734 + {
1.4735 + lastFileDir=fd->directory().path();
1.4736 + QStringList flist = fd->selectedFiles();
1.4737 + QStringList::Iterator it = flist.begin();
1.4738 + while( it != flist.end() )
1.4739 + {
1.4740 + fn = *it;
1.4741 + fileLoad(*it, NewMap);
1.4742 + ++it;
1.4743 + }
1.4744 + }
1.4745 + delete (fd);
1.4746 +}
1.4747 +
1.4748 +
1.4749 void Main::helpAbout()
1.4750 {
1.4751 - static QMessageBox* about = new QMessageBox( "VYM",
1.4752 - "<h3>VYM - View Your Mind </h3>"
1.4753 - "<p> A tool to put the things you have got in your mind into a map.</p>"
1.4754 - "<ul>"
1.4755 - "<li> (c) by Uwe Drechsel (vym@InSilmaril.de)</li>"
1.4756 - "<li> vym is released under the GPL (Gnu General Public License)"
1.4757 - ", with one exception (see the file \"LICENSE\"which "
1.4758 - "comes with vym). This exception is needed to build vym with QT libraries for proprietary operating systems.</li>"
1.4759 - "<li> Project homepage <a href=\"http:/www.InSilmaril.de/vym\">"
1.4760 - "http:/www.InSilmaril.de/vym</a></li>"
1.4761 - "<li> Credits "
1.4762 - "<ul>"
1.4763 - "<li>Thomas Schraitle for the stylesheet used for XHTML-export </li>"
1.4764 - "<li>Clemens Kraus for stylesheets and script used for HTML-export "
1.4765 - "<a href=\"http://www.clemens-kraus.de\">(www.clemens-kraus.de)</a></li>"
1.4766 - "<li>Alexander Johannesen for providing stylesheets from his xsiteable project "
1.4767 - "<a href=\"http://www.shelter.nu/xsiteable/xsiteable.html\">(www.shelter.nu/xsiteable/xsiteable.html)</a>. </li>"
1.4768 - "<li>Ken Wimer and Olaf Hering for Mac support</li>"
1.4769 - "</ul>"
1.4770 - "</li>"
1.4771 - "<li> Version " __VYM_VERSION__ "</li>"
1.4772 - "<li> Build date " __BUILD_DATE__"</li>"
1.4773 - "</ul>", QMessageBox::Information, 1, 0, 0, this, 0, FALSE );
1.4774 - about->setButtonText( 1, "Dismiss" );
1.4775 - about->setMinimumSize(QSize(300,300));
1.4776 - about->setIconPixmap (QPixmap(vym_logo_xpm));
1.4777 - about->show();
1.4778 + AboutDialog ad;
1.4779 + ad.setName ("aboutwindow");
1.4780 + ad.setMinimumSize(500,500);
1.4781 + ad.resize (QSize (500,500));
1.4782 + ad.exec();
1.4783 }
1.4784
1.4785 void Main::helpAboutQT()
1.4786 @@ -2211,3 +3812,62 @@
1.4787 QMessageBox::aboutQt( this, "Qt Application Example" );
1.4788 }
1.4789
1.4790 +void Main::callMacro ()
1.4791 +{
1.4792 + QAction *action = qobject_cast<QAction *>(sender());
1.4793 + int i=-1;
1.4794 + if (action)
1.4795 + {
1.4796 + i=action->data().toInt();
1.4797 + QString mDir (settings.value ("macros/macroDir").toString() );
1.4798 +
1.4799 + QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
1.4800 + QFile f (fn);
1.4801 + if ( !f.open( QIODevice::ReadOnly ) )
1.4802 + {
1.4803 + QMessageBox::warning(0,
1.4804 + tr("Warning"),
1.4805 + tr("Couldn't find a macro at %1.\n").arg(fn)+
1.4806 + tr("Please use Settings->")+tr("Set directory for vym macros"));
1.4807 + return;
1.4808 + }
1.4809 +
1.4810 + QTextStream ts( &f );
1.4811 + QString m= ts.read();
1.4812 +
1.4813 + if (! m.isEmpty())
1.4814 + {
1.4815 + //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
1.4816 + currentMapEditor()->runScript (m);
1.4817 + }
1.4818 + }
1.4819 +}
1.4820 +
1.4821 +
1.4822 +
1.4823 +//////////////////////////////////
1.4824 +/*
1.4825 +@@ -2544,18 +2576,27 @@
1.4826 + // Try to open new tab in existing konqueror started previously by vym
1.4827 + p=new QProcess (this);
1.4828 + args.clear();
1.4829 +- args<< QString("konqueror-%1").arg(procBrowser->pid())<<
1.4830 +- "konqueror-mainwindow#1"<<
1.4831 +- "newTab" <<
1.4832 ++#if defined(Q_OS_WIN32)
1.4833 ++ // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
1.4834 ++ // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
1.4835 ++ args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
1.4836 ++ "konqueror-mainwindow#1"<<
1.4837 ++ "newTab" <<
1.4838 + urls.at(i);
1.4839 ++#else
1.4840 ++ args<< QString("konqueror-%1").arg(procBrowser->pid())<<
1.4841 ++ "konqueror-mainwindow#1"<<
1.4842 ++ "newTab" <<
1.4843 ++ urls.at(i);
1.4844 ++#endif
1.4845 + p->start ("dcop",args);
1.4846 + if ( !p->waitForStarted() ) success=false;
1.4847 + }
1.4848 +*/