diff -r 192e1392ba6a -r 12958f987bcf mainwindow.cpp --- a/mainwindow.cpp Wed Jul 16 10:44:44 2008 +0000 +++ b/mainwindow.cpp Wed Jul 16 10:46:14 2008 +0000 @@ -79,8 +79,6 @@ { mainWindow=this; - setObjectName ("MainWindow"); - setCaption ("VYM - View Your Mind"); // Load window settings @@ -496,6 +494,7 @@ editMenu->addAction (a); actionEditPaste=a; +/* // Shortcuts to modify heading: a = new QAction(tr( "Edit heading","Edit menu" ),this); a->setStatusTip ( tr( "edit Heading" )); @@ -513,6 +512,8 @@ actionListBranches.append(a); editMenu->addAction (a); actionEditHeading=a; + +*/ a = new QAction( tr( "Edit heading","Edit menu" ), this); a->setStatusTip (tr( "edit Heading" )); //a->setShortcut ( Qt::Key_F2 ); //Edit heading @@ -660,10 +661,10 @@ addAction (alt); actionListBranches.append(actionEditToggleScroll); - a = new QAction( tr( "Unscroll childs","Edit menu" ), this); + a = new QAction( tr( "Unscroll children","Edit menu" ), this); a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" )); editMenu->addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) ); editMenu->addSeparator(); @@ -803,24 +804,24 @@ actionListBranches.append(a); actionEditSaveBranch=a; - // Only remove branch, not its childs + // Only remove branch, not its children a = new QAction(tr( "Remove only branch ","Edit menu" ), this); - a->setStatusTip ( tr( "Remove only branch and keep its childs" )); + a->setStatusTip ( tr( "Remove only branch and keep its children" )); a->setShortcut (Qt::ALT + Qt::Key_Delete ); - connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) ); a->setEnabled (false); addAction (a); actionListBranches.append(a); - actionEditDeleteKeepChilds=a; - - // Only remove childs of a branch - a = new QAction( tr( "Remove childs","Edit menu" ), this); - a->setStatusTip (tr( "Remove childs of branch" )); + actionEditDeleteKeepChildren=a; + + // Only remove children of a branch + a = new QAction( tr( "Remove children","Edit menu" ), this); + a->setStatusTip (tr( "Remove children of branch" )); a->setShortcut (Qt::SHIFT + Qt::Key_Delete ); - connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) ); a->setEnabled (false); actionListBranches.append(a); - actionEditDeleteChilds=a; + actionEditDeleteChildren=a; // Shortcuts for navigating with cursor: a = new QAction(tr( "Select upper branch","Edit menu" ), this); @@ -1554,8 +1555,8 @@ branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name")); branchRemoveContextMenu->addAction (actionEditCut); branchRemoveContextMenu->addAction ( actionEditDelete ); - branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds ); - branchRemoveContextMenu->addAction ( actionEditDeleteChilds ); + branchRemoveContextMenu->addAction ( actionEditDeleteKeepChildren ); + branchRemoveContextMenu->addAction ( actionEditDeleteChildren ); actionEditSaveBranch->addTo( branchContextMenu ); @@ -1690,12 +1691,24 @@ MapEditor* Main::currentMapEditor() const { + // FIXME currentMapEditor should return the latest used editor for a model, or NULL if no editor is open if ( tabWidget->currentPage() && tabWidget->currentPage()->inherits( "MapEditor" ) ) return (MapEditor*)tabWidget->currentPage(); return NULL; } +VymModel* Main::currentModel() const +{ + // FIXME better get currentModel from a maintained list, + // just in case we allow other views in tabs later + MapEditor *me=currentMapEditor(); + if (me) + return me->getModel(); + else + return NULL; +} + void Main::editorChanged(QWidget *) { @@ -1704,11 +1717,11 @@ MapEditor *me; for (int i=0;i<=tabWidget->count() -1;i++) { + me=(MapEditor*)tabWidget->page(i); - me->unselect(); + me->getModel()->unselect(); } - me=currentMapEditor(); - if (me) me->reselect(); + currentModel()->reselect(); // Update actions to in menus and toolbars according to editor updateActions(); @@ -1716,8 +1729,10 @@ void Main::fileNew() { + VymModel *m=new VymModel; + models.append (m); + MapEditor* me = new MapEditor (m); QString fn="unnamed"; - MapEditor* me = new MapEditor ( NULL); tabWidget->addTab (me,fn); tabWidget->showPage(me); me->viewport()->setFocus(); @@ -1725,7 +1740,7 @@ me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); // For the very first map we do not have flagrows yet... - me->select("mc:"); + currentModel()->select("mc:"); } void Main::fileNewCopy() @@ -1734,8 +1749,10 @@ MapEditor* oldME =currentMapEditor(); if (oldME) { - oldME->copy(); - MapEditor* newME = new MapEditor ( NULL); + oldME->getModel()->copy(); + VymModel *m=new VymModel; + models.append (m); + MapEditor* newME = new MapEditor ( m); if (newME) { tabWidget->addTab (newME,fn); @@ -1744,8 +1761,8 @@ newME->setAntiAlias (actionViewToggleAntiAlias->isOn()); newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); // For the very first map we do not have flagrows yet... - newME->select("mc:"); - newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap); + m->select("mc:"); + m->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap); } } @@ -1770,7 +1787,7 @@ while (i<=tabWidget->count() -1) { me=(MapEditor*)tabWidget->page(i); - if (me->getFilePath() == fn) + if (me->getModel()->getFilePath() == fn) { // Already there, ask for confirmation QMessageBox mb( vymName, @@ -1809,9 +1826,11 @@ // Check first, if mapeditor exists // If it is not default AND we want a new map, // create a new mapeditor in a new tab - if ( lmode==NewMap && (!me || !me->isDefault() ) ) + if ( lmode==NewMap && (!me || !me->getModel()->isDefault() ) ) { - me= new MapEditor ( NULL); + VymModel *m=new VymModel; + models.append (m); + me= new MapEditor ( m); tabWidget->addTab (me,fn); tabIndex=tabWidget->indexOf (me); tabWidget->setCurrentPage (tabIndex); @@ -1821,8 +1840,6 @@ // Check, if file exists (important for creating new files // from command line - /* - */ if (!QFile(fn).exists() ) { QMessageBox mb( vymName, @@ -1838,9 +1855,9 @@ { case QMessageBox::Yes: // Create new map - currentMapEditor()->setFilePath(fn); + currentMapEditor()->getModel()->setFilePath(fn); tabWidget->setTabLabel (currentMapEditor(), - currentMapEditor()->getFileName() ); + currentMapEditor()->getModel()->getFileName() ); statusBar()->message( "Created " + fn , statusbarTime ); return success; @@ -1852,6 +1869,7 @@ } } + //tabWidget->currentPage() won't be NULL here, because of above... tabWidget->showPage(me); me->viewport()->setFocus(); @@ -1859,15 +1877,15 @@ if (err!=aborted) { // Save existing filename in case we import - QString fn_org=me->getFilePath(); + QString fn_org=me->getModel()->getFilePath(); // Finally load map into mapEditor - me->setFilePath (fn); - err=me->load(fn,lmode,ftype); + me->getModel()->setFilePath (fn); + err=me->getModel()->load(fn,lmode,ftype); // Restore old (maybe empty) filepath, if this is an import if (lmode!=NewMap) - me->setFilePath (fn_org); + me->getModel()->setFilePath (fn_org); } // Finally check for errors and go home @@ -1879,13 +1897,13 @@ { if (lmode==NewMap) { - me->setFilePath (fn); - tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName()); + me->getModel()->setFilePath (fn); + tabWidget->changeTab(tabWidget->page(tabIndex), me->getModel()->getFileName()); if (!isInTmpDir (fn)) { // Only append to lastMaps if not loaded from a tmpDir // e.g. imported bookmarks are in a tmpDir - addRecentMap(me->getFilePath() ); + addRecentMap(me->getModel()->getFilePath() ); } actionFilePrint->setEnabled (true); } @@ -1960,40 +1978,40 @@ setupRecentMapsMenu(); } -void Main::fileSave(MapEditor *me, const SaveMode &savemode) +void Main::fileSave(VymModel *m, const SaveMode &savemode) { - if (!me) return; - - if ( me->getFilePath().isEmpty() ) + if (!m) return; + + if ( m->getFilePath().isEmpty() ) { // We have no filepath yet, // call fileSaveAs() now, this will call fileSave() // again. // First switch to editor - tabWidget->setCurrentWidget (me); + tabWidget->setCurrentWidget (m->getMapEditor()); fileSaveAs(savemode); } - if (me->save (savemode)==success) + if (m->save (savemode)==success) { statusBar()->message( - tr("Saved %1").arg(me->getFilePath()), + tr("Saved %1").arg(m->getFilePath()), statusbarTime ); - addRecentMap (me->getFilePath() ); + addRecentMap (m->getFilePath() ); } else statusBar()->message( - tr("Couldn't save ").arg(me->getFilePath()), + tr("Couldn't save ").arg(m->getFilePath()), statusbarTime ); } void Main::fileSave() { - fileSave (currentMapEditor(), CompleteMap); + fileSave (currentModel(), CompleteMap); } -void Main::fileSave(MapEditor *me) +void Main::fileSave(VymModel *m) { - fileSave (me,CompleteMap); + fileSave (m,CompleteMap); } void Main::fileSaveAs(const SaveMode& savemode) @@ -2048,13 +2066,13 @@ // Save now - currentMapEditor()->setFilePath(fn); - fileSave(currentMapEditor(), savemode); + currentModel()->setFilePath(fn); + fileSave(currentModel(), savemode); // Set name of tab if (savemode==CompleteMap) tabWidget->setTabLabel (currentMapEditor(), - currentMapEditor()->getFileName() ); + currentModel()->getFileName() ); return; } } @@ -2070,7 +2088,7 @@ ImportKDEBookmarks im; im.transform(); if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) - currentMapEditor()->setFilePath (""); + currentMapEditor()->getModel()->setFilePath (""); } void Main::fileImportFirefoxBookmarks() @@ -2093,7 +2111,7 @@ if (im.transform() && success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && currentMapEditor() ) - currentMapEditor()->setFilePath (""); + currentMapEditor()->getModel()->setFilePath (""); ++it; } } @@ -2122,7 +2140,7 @@ fn = *it; if ( fileLoad (fn,NewMap, FreemindMap) ) { - currentMapEditor()->setFilePath (""); + currentMapEditor()->getModel()->setFilePath (""); } ++it; } @@ -2153,80 +2171,78 @@ if (im.transform() && success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) - currentMapEditor()->setFilePath (""); - + currentMapEditor()->getModel()->setFilePath (""); ++it; } } delete (fd); - } void Main::fileImportDir() { - if (currentMapEditor()) - currentMapEditor()->importDir(); + VymModel *m=currentModel(); + if (m) m->importDir(); } void Main::fileExportXML() { - MapEditor *me=currentMapEditor(); - if (me) me->exportXML(); + VymModel *m=currentModel(); + if (m) m->exportXML(); } void Main::fileExportXHTML() { - MapEditor *me=currentMapEditor(); - if (me) me->exportXHTML(); + VymModel *m=currentModel(); + if (m) m->exportXHTML(); } void Main::fileExportImage() { - MapEditor *me=currentMapEditor(); - if (me) me->exportImage(); + VymModel *m=currentModel(); + if (m) m->exportImage(); } void Main::fileExportASCII() { - MapEditor *me=currentMapEditor(); - if (me) me->exportASCII(); + VymModel *m=currentModel(); + if (m) m->exportASCII(); } void Main::fileExportCSV() //FIXME not scriptable yet { - MapEditor *me=currentMapEditor(); - if (me) + VymModel *m=currentModel(); + if (m) { ExportCSV ex; - ex.setModel (me->getModel()); + ex.setModel (m); ex.addFilter ("CSV (*.csv)"); ex.setDir(lastImageDir); ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)")); if (ex.execDialog() ) { - me->setExportMode(true); + m->setExportMode(true); ex.doExport(); - me->setExportMode(false); + m->setExportMode(false); } } } void Main::fileExportLaTeX() //FIXME not scriptable yet { - MapEditor *me=currentMapEditor(); - if (me) + VymModel *m=currentModel(); + if (m) { ExportLaTeX ex; - ex.setModel (me->getModel()); + ex.setModel (m); ex.addFilter ("Tex (*.tex)"); ex.setDir(lastImageDir); ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); if (ex.execDialog() ) { - me->setExportMode(true); + m->setExportMode(true); ex.doExport(); - me->setExportMode(false); + m->setExportMode(false); } } } @@ -2234,10 +2250,10 @@ void Main::fileExportKDEBookmarks() //FIXME not scriptable yet { ExportKDEBookmarks ex; - MapEditor *me=currentMapEditor(); - if (me) + VymModel *m=currentModel(); + if (m) { - ex.setModel (me->getModel()); + ex.setModel (m); ex.doExport(); } } @@ -2245,18 +2261,18 @@ void Main::fileExportTaskjuggler() //FIXME not scriptable yet { ExportTaskjuggler ex; - MapEditor *me=currentMapEditor(); - if (me) + VymModel *m=currentModel(); + if (m) { - ex.setModel (me->getModel()); + ex.setModel (m); ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); ex.setDir(lastImageDir); ex.addFilter ("Taskjuggler (*.tjp)"); if (ex.execDialog() ) { - me->setExportMode(true); + m->setExportMode(true); ex.doExport(); - me->setExportMode(false); + m->setExportMode(false); } } } @@ -2282,8 +2298,8 @@ fn +=".odp"; //lastImageDir=fn.left(fn.findRev ("/")); - if (currentMapEditor()) - currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig()); + VymModel *m=currentModel(); + if (m) m->exportOOPresentation(fn,fd->selectedConfig()); } } else { @@ -2296,12 +2312,13 @@ void Main::fileCloseMap() { MapEditor *me = currentMapEditor(); - if (me) + VymModel *m=currentModel(); + if (m) { - if (me->hasChanged()) + if (m->hasChanged()) { QMessageBox mb( vymName, - tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()), + tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, @@ -2312,7 +2329,7 @@ { case QMessageBox::Yes: // save and close - fileSave(me, CompleteMap); + fileSave(m, CompleteMap); break; case QMessageBox::No: // close without saving @@ -2322,13 +2339,12 @@ return; } } - //me->closeMap(); - tabWidget->removePage(me); + //me->closeMap(); FIXME should not be necessary any longer + me->close(); + tabWidget->removePage(m->getMapEditor()); if (tabWidget->count()==0) actionFilePrint->setEnabled (false); - - //delete me; - me->clear(); + delete me; } } @@ -2349,7 +2365,7 @@ me=(MapEditor*)tabWidget->page(i); // If something changed, ask what to do - if (me->hasChanged()) + if (me->getModel()->hasChanged()) { tabWidget->setCurrentPage(i); QMessageBox mb( vymName, @@ -2366,7 +2382,7 @@ switch( mb.exec() ) { case QMessageBox::Yes: // save (the changed editors) and exit - fileSave(currentMapEditor(), CompleteMap); + fileSave(currentModel(), CompleteMap); break; case QMessageBox::No: // exit without saving @@ -2382,38 +2398,38 @@ void Main::editUndo() { - if (currentMapEditor()) - currentMapEditor()->undo(); + VymModel *m=currentModel(); + if (m) m->undo(); } void Main::editRedo() { - if (currentMapEditor()) - currentMapEditor()->redo(); + VymModel *m=currentModel(); + if (m) m->redo(); } void Main::gotoHistoryStep (int i) { - if (currentMapEditor()) - currentMapEditor()->gotoHistoryStep (i); + VymModel *m=currentModel(); + if (m) m->gotoHistoryStep(i); } void Main::editCopy() { - if (currentMapEditor()) - currentMapEditor()->copy(); + VymModel *m=currentModel(); + if (m) m->copy(); } void Main::editPaste() { - if (currentMapEditor()) - currentMapEditor()->paste(); + VymModel *m=currentModel(); + if (m) m->paste(); } void Main::editCut() { - if (currentMapEditor()) - currentMapEditor()->cut(); + VymModel *m=currentModel(); + if (m) m->cut(); } void Main::editOpenFindWindow() @@ -2425,21 +2441,26 @@ void Main::editFind(QString s) { - bool cs=false; - BranchObj *bo=currentMapEditor()->findText(s, cs); - if (bo) - { - statusBar()->message( "Found: " + bo->getHeading(), statusbarTime ); - } else + VymModel *m=currentModel(); + if (m) { - QMessageBox::information( findWindow, tr( "VYM -Information:" ), - tr("No matches found for \"%1\"").arg(s)); - } + bool cs=false; + BranchObj *bo=m->findText(s, cs); + if (bo) + { + statusBar()->message( "Found: " + bo->getHeading(), statusbarTime ); + } else + { + QMessageBox::information( findWindow, tr( "VYM -Information:" ), + tr("No matches found for \"%1\"").arg(s)); + } + } } void Main::editFindChanged() { // Notify editor, to abort the current find process - currentMapEditor()->findReset(); + VymModel *m=currentModel(); + if (m) m->findReset(); } void Main::openTabs(QStringList urls) @@ -2527,9 +2548,10 @@ void Main::editOpenURL() { // Open new browser - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { - QString url=currentMapEditor()->getURL(); + QString url=m->getURL(); QStringList args; if (url=="") return; QString browser=settings.value("/mainwindow/readerURL" ).toString(); @@ -2549,19 +2571,21 @@ } void Main::editOpenURLTab() { - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { QStringList urls; - urls.append(currentMapEditor()->getURL()); + urls.append(m->getURL()); openTabs (urls); } } void Main::editOpenMultipleURLTabs() { - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { QStringList urls; - urls=currentMapEditor()->getURLs(); + urls=m->getURLs(); openTabs (urls); } } @@ -2569,49 +2593,58 @@ void Main::editURL() { - if (currentMapEditor()) - currentMapEditor()->editURL(); + VymModel *m=currentModel(); + if (m) m->editURL(); } void Main::editLocalURL() { - if (currentMapEditor()) - currentMapEditor()->editLocalURL(); + VymModel *m=currentModel(); + if (m) m->editLocalURL(); } void Main::editHeading2URL() { - if (currentMapEditor()) - currentMapEditor()->editHeading2URL(); + VymModel *m=currentModel(); + if (m) m->editHeading2URL(); } void Main::editBugzilla2URL() { - if (currentMapEditor()) - currentMapEditor()->editBugzilla2URL(); + VymModel *m=currentModel(); + if (m) m->editBugzilla2URL(); } void Main::editFATE2URL() { - if (currentMapEditor()) - currentMapEditor()->editFATE2URL(); + VymModel *m=currentModel(); + if (m) m->editFATE2URL(); } -void Main::editHeadingFinished() +void Main::editHeadingFinished(VymModel *m) { + if (m) + { + if (!actionSettingsAutoSelectNewBranch->isOn() && + !prevSelection.isEmpty()) + m->select(prevSelection); + prevSelection=""; + } + +/* FIXME old code, remove now // only called from editHeading(), so there is a currentME - MapEditor *me=currentMapEditor(); - if (me) + VymModel *m=currentModel(); + if (m) { - me->setStateEditHeading (false); + m->setSelectionBlocked (false); QPoint p; //Not used here, only to find out pos of branch bool ok; - QString s=me->getHeading(ok,p); + QString s=m->getHeading(ok,p); #if defined(Q_OS_MACX) || defined(Q_OS_WIN32) #else if (ok && s!=lineedit->text()) - me->setHeading(lineedit->text()); + m->setHeading(lineedit->text()); lineedit->releaseKeyboard(); lineedit->hide(); @@ -2619,17 +2652,20 @@ #endif if (!actionSettingsAutoSelectNewBranch->isOn() && !prevSelection.isEmpty()) - me->select(prevSelection); + m->select(prevSelection); prevSelection=""; } +*/ } +/* void Main::editHeading() { - if (currentMapEditor()) + MapEditor *me=currentMapEditor(); + VymModel *m=currentModel(); + if (me && m) { - MapEditor *me=currentMapEditor(); - QString oldSel=me->getSelectString(); + QString oldSel=m->getSelectString(); if (lineedit->isVisible()) editHeadingFinished(); @@ -2637,11 +2673,11 @@ { bool ok; QPoint p; - QString s=me->getHeading(ok,p); + QString s=m->getHeading(ok,p); if (ok) { - me->setStateEditHeading (true); + m->setSelectionBlocked(true); #if defined(Q_OS_MACX) || defined(Q_OS_WIN32) p=me->mapToGlobal (p); QDialog *d =new QDialog(NULL); @@ -2654,7 +2690,7 @@ connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); d->activateWindow(); d->exec(); - me->setHeading (le->text()); + m->setHeading (le->text()); delete (le); delete (d); editHeadingFinished(); @@ -2670,8 +2706,9 @@ #endif } } - } // currentMapEditor() + } } +*/ void Main::editAttributeFinished() { @@ -2707,10 +2744,11 @@ #include "attributedialog.h" void Main::editAttribute() { +/* MapEditor *me=currentMapEditor(); if (me) { - BranchObj *bo=me->getSelectedBranch(); + BranchObj *bo=me->getModel()->getSelectedBranch(); if (bo) { AttributeDialog dia(this); @@ -2721,6 +2759,7 @@ dia.exec(); } } + */ /* if (currentMapEditor()) { @@ -2782,7 +2821,7 @@ for (i=0;i<=tabWidget->count() -1;i++) { me=(MapEditor*)tabWidget->page(i); - if (vl.at(j)==me->getFilePath() ) + if (vl.at(j)==me->getModel()->getFilePath() ) { index=i; break; @@ -2807,10 +2846,11 @@ void Main::editOpenVymLink() { - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { QStringList vl; - vl.append(currentMapEditor()->getVymLink()); + vl.append(m->getVymLink()); openVymLinks (vl); } } @@ -2818,168 +2858,204 @@ void Main::editOpenMultipleVymLinks() { QString currentVymLink; - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { - QStringList vl=currentMapEditor()->getVymLinks(); + QStringList vl=m->getVymLinks(); openVymLinks (vl); } } void Main::editVymLink() { - if (currentMapEditor()) - currentMapEditor()->editVymLink(); + VymModel *m=currentModel(); + if (m) + m->editVymLink(); } void Main::editDeleteVymLink() { - if (currentMapEditor()) - currentMapEditor()->deleteVymLink(); + VymModel *m=currentModel(); + if (m) m->deleteVymLink(); } void Main::editToggleHideExport() { - if (currentMapEditor()) - currentMapEditor()->toggleHideExport(); + VymModel *m=currentModel(); + if (m) m->toggleHideExport(); } void Main::editMapInfo() { - if (currentMapEditor()) - currentMapEditor()->editMapInfo(); + VymModel *m=currentModel(); + + ExtraInfoDialog dia; + dia.setMapName (m->getFileName() ); + dia.setAuthor (m->getAuthor() ); + dia.setComment(m->getComment() ); + +/* FIXME no stats at the moment (view dependent...) + // Calc some stats + QString stats; + stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6); + + uint b=0; + uint f=0; + uint n=0; + uint xl=0; + BranchObj *bo; + bo=m->first(); + while (bo) + { + if (!bo->getNote().isEmpty() ) n++; + f+= bo->countFloatImages(); + b++; + xl+=bo->countXLinks(); + bo=m->next(bo); + } + stats+=QString ("%1 branches\n").arg (b-1,6); + stats+=QString ("%1 xLinks \n").arg (xl,6); + stats+=QString ("%1 notes\n").arg (n,6); + stats+=QString ("%1 images\n").arg (f,6); + dia.setStats (stats); + +*/ + // Finally show dialog + if (dia.exec() == QDialog::Accepted) + { + m->setAuthor (dia.getAuthor() ); + m->setComment (dia.getComment() ); + } } void Main::editMoveUp() { - if (currentMapEditor()) - currentMapEditor()->moveBranchUp(); + VymModel *m=currentModel(); + if (m) m->moveBranchUp(); } void Main::editMoveDown() { - if (currentMapEditor()) - currentMapEditor()->moveBranchDown(); + VymModel *m=currentModel(); + if (m) m->moveBranchDown(); } void Main::editSortChildren() { - if (currentMapEditor()) - currentMapEditor()->sortChildren(); + VymModel *m=currentModel(); + if (m) m->sortChildren(); } void Main::editToggleScroll() { - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) m->toggleScroll(); +} + +void Main::editUnscrollChildren() +{ + VymModel *m=currentModel(); + if (m) m->unscrollChildren(); +} + +void Main::editAddMapCenter() +{ + VymModel *m=currentModel(); + if (!lineedit->isVisible() && m) { - currentMapEditor()->toggleScroll(); + m->addMapCenter (); } } -void Main::editUnscrollChilds() -{ - if (currentMapEditor()) - currentMapEditor()->unscrollChilds(); -} - -void Main::editAddMapCenter() -{ - MapEditor *me=currentMapEditor(); - if (!lineedit->isVisible() && me) - { - me->addMapCenter (); - } -} - void Main::editNewBranch() { - MapEditor *me=currentMapEditor(); - if (!lineedit->isVisible() && me) + VymModel *m=currentModel(); + if (!lineedit->isVisible() && m) { - BranchObj *bo=(BranchObj*)me->getSelection(); - BranchObj *newbo=me->addNewBranch(0); - - prevSelection=me->getModel()->getSelectString(bo); + BranchObj *bo=(BranchObj*)m->getSelection(); + BranchObj *newbo=m->addNewBranch(0); + + prevSelection=m->getSelectString(bo); if (newbo) - me->select (newbo); + m->select (newbo); else return; if (actionSettingsAutoEditNewBranch->isOn()) { - editHeading(); + currentMapEditor()->editHeading(); return; } if (!prevSelection.isEmpty()) { - me->select(prevSelection); + m->select(prevSelection); prevSelection=""; } - } } void Main::editNewBranchBefore() { - MapEditor *me=currentMapEditor(); - if (!lineedit->isVisible() && me) + VymModel *m=currentModel(); + if (!lineedit->isVisible() && m) { - BranchObj *bo=(BranchObj*)me->getSelection(); - BranchObj *newbo=me->addNewBranchBefore(); + BranchObj *bo=(BranchObj*)m->getSelection(); + BranchObj *newbo=m->addNewBranchBefore(); if (newbo) - me->select (newbo); + m->select (newbo); else return; if (actionSettingsAutoEditNewBranch->isOn()) { if (!actionSettingsAutoSelectNewBranch->isOn()) - prevSelection=me->getModel()->getSelectString(bo); //TODO access directly - editHeading(); + prevSelection=m->getSelectString(bo); + currentMapEditor()->editHeading(); } } } void Main::editNewBranchAbove() { - MapEditor *me=currentMapEditor(); - if (!lineedit->isVisible() && me) + VymModel *m=currentModel(); + if (!lineedit->isVisible() && m) { - BranchObj *bo=(BranchObj*)me->getSelection(); - BranchObj *newbo=me->addNewBranch (-1); + BranchObj *bo=(BranchObj*)m->getSelection(); + BranchObj *newbo=m->addNewBranch (-1); if (newbo) - me->select (newbo); + m->select (newbo); else return; if (actionSettingsAutoEditNewBranch->isOn()) { if (!actionSettingsAutoSelectNewBranch->isOn()) - prevSelection=me->getModel()->getSelectString (bo); // TODO access directly - editHeading(); + prevSelection=m->getSelectString (bo); + currentMapEditor()->editHeading(); } } } void Main::editNewBranchBelow() { - MapEditor *me=currentMapEditor(); - if (!lineedit->isVisible() && me) + VymModel *m=currentModel(); + if (!lineedit->isVisible() && m) { - BranchObj *bo=(BranchObj*)me->getSelection(); - BranchObj *newbo=me->addNewBranch (1); + BranchObj *bo=(BranchObj*)m->getSelection(); + BranchObj *newbo=m->addNewBranch (1); if (newbo) - me->select (newbo); + m->select (newbo); else return; if (actionSettingsAutoEditNewBranch->isOn()) { if (!actionSettingsAutoSelectNewBranch->isOn()) - prevSelection=me->getModel()->getSelectString(bo); //TODO access directly - editHeading(); + prevSelection=m->getSelectString(bo); + currentMapEditor()->editHeading(); } } } @@ -2999,99 +3075,100 @@ fileSaveAs (PartOfMap); } -void Main::editDeleteKeepChilds() +void Main::editDeleteKeepChildren() { - if (currentMapEditor()) - currentMapEditor()->deleteKeepChilds(); + VymModel *m=currentModel(); + if (m) m->deleteKeepChildren(); } -void Main::editDeleteChilds() +void Main::editDeleteChildren() { - if (currentMapEditor()) - currentMapEditor()->deleteChilds(); + VymModel *m=currentModel(); + if (m) m->deleteChildren(); } void Main::editDeleteSelection() { - if (currentMapEditor() && actionSettingsUseDelKey->isOn()) - currentMapEditor()->deleteSelection(); + VymModel *m=currentModel(); + if (m && actionSettingsUseDelKey->isOn()) + m->deleteSelection(); } void Main::editUpperBranch() { - if (currentMapEditor()) - currentMapEditor()->selectUpperBranch(); + VymModel *m=currentModel(); + if (m) m->selectUpperBranch(); } void Main::editLowerBranch() { - if (currentMapEditor()) - currentMapEditor()->selectLowerBranch(); + VymModel *m=currentModel(); + if (m) m->selectLowerBranch(); } void Main::editLeftBranch() { - if (currentMapEditor()) - currentMapEditor()->selectLeftBranch(); + VymModel *m=currentModel(); + if (m) m->selectLeftBranch(); } void Main::editRightBranch() { - if (currentMapEditor()) - currentMapEditor()->selectRightBranch(); + VymModel *m=currentModel(); + if (m) m->selectRightBranch(); } void Main::editFirstBranch() { - if (currentMapEditor()) - currentMapEditor()->selectFirstBranch(); + VymModel *m=currentModel(); + if (m) m->selectFirstBranch(); } void Main::editLastBranch() { - if (currentMapEditor()) - currentMapEditor()->selectLastBranch(); + VymModel *m=currentModel(); + if (m) m->selectLastBranch(); } void Main::editLoadImage() { - if (currentMapEditor()) - currentMapEditor()->loadFloatImage(); + VymModel *m=currentModel(); + if (m) m->loadFloatImage(); } void Main::editSaveImage() { - if (currentMapEditor()) - currentMapEditor()->saveFloatImage(); + VymModel *m=currentModel(); + if (m) m->saveFloatImage(); } void Main::editFollowXLink(QAction *a) { - if (currentMapEditor()) - currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a)); + VymModel *m=currentModel(); + if (m) + m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a)); } void Main::editEditXLink(QAction *a) { - if (currentMapEditor()) - currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a)); + VymModel *m=currentModel(); + if (m) + m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a)); } void Main::formatSelectColor() { - if (currentMapEditor()) - { - QColor col = QColorDialog::getColor((currentColor ), this ); - if ( !col.isValid() ) return; - colorChanged( col ); - } + QColor col = QColorDialog::getColor((currentColor ), this ); + if ( !col.isValid() ) return; + colorChanged( col ); } void Main::formatPickColor() { - if (currentMapEditor()) - colorChanged( currentMapEditor()->getCurrentHeadingColor() ); + VymModel *m=currentModel(); + if (m) + colorChanged( m->getCurrentHeadingColor() ); } void Main::colorChanged(QColor c) @@ -3104,86 +3181,102 @@ void Main::formatColorBranch() { - if (currentMapEditor()) - currentMapEditor()->colorBranch(currentColor); + VymModel *m=currentModel(); + if (m) m->colorBranch(currentColor); } void Main::formatColorSubtree() { - if (currentMapEditor()) - currentMapEditor()->colorSubtree (currentColor); + VymModel *m=currentModel(); + if (m) m->colorSubtree (currentColor); } void Main::formatLinkStyleLine() { - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { - currentMapEditor()->setMapLinkStyle("StyleLine"); + m->setMapLinkStyle("StyleLine"); actionFormatLinkStyleLine->setOn(true); } } void Main::formatLinkStyleParabel() { - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { - currentMapEditor()->setMapLinkStyle("StyleParabel"); + m->setMapLinkStyle("StyleParabel"); actionFormatLinkStyleParabel->setOn(true); } } void Main::formatLinkStylePolyLine() { - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { - currentMapEditor()->setMapLinkStyle("StylePolyLine"); + m->setMapLinkStyle("StylePolyLine"); actionFormatLinkStylePolyLine->setOn(true); } } void Main::formatLinkStylePolyParabel() { - if (currentMapEditor()) + VymModel *m=currentModel(); + if (m) { - currentMapEditor()->setMapLinkStyle("StylePolyParabel"); + m->setMapLinkStyle("StylePolyParabel"); actionFormatLinkStylePolyParabel->setOn(true); } } void Main::formatSelectBackColor() { - if (currentMapEditor()) - currentMapEditor()->selectMapBackgroundColor(); + VymModel *m=currentModel(); + if (m) m->selectMapBackgroundColor(); } void Main::formatSelectBackImage() { - if (currentMapEditor()) - currentMapEditor()->selectMapBackgroundImage(); + VymModel *m=currentModel(); + if (m) + m->selectMapBackgroundImage(); } void Main::formatSelectLinkColor() { - if (currentMapEditor()) - currentMapEditor()->selectMapLinkColor(); + VymModel *m=currentModel(); + if (m) + { + QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this ); + m->setMapDefLinkColor( col ); + } } void Main::formatSelectSelectionColor() { - if (currentMapEditor()) - currentMapEditor()->selectMapSelectionColor(); + VymModel *m=currentModel(); + if (m) + { + QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this ); + m->setSelectionColor (col); + } + } void Main::formatToggleLinkColorHint() { - currentMapEditor()->toggleMapLinkColorHint(); + VymModel *m=currentModel(); + if (m) m->toggleMapLinkColorHint(); } void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog { - if (currentMapEditor()) - currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn()); + VymModel *m=currentModel(); + if (m) + m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn()); } void Main::viewZoomReset() @@ -3218,23 +3311,20 @@ void Main::viewCenter() { - MapEditor *me=currentMapEditor(); - if (me) - { - me->ensureSelectionVisible(); - } + VymModel *m=currentModel(); + if (m) m->ensureSelectionVisible(); } void Main::networkStartServer() { - MapEditor *me=currentMapEditor(); - if (me) me->newServer(); + VymModel *m=currentModel(); + if (m) m->newServer(); } void Main::networkConnect() { - MapEditor *me=currentMapEditor(); - if (me) me->connectToServer(); + VymModel *m=currentModel(); + if (m) m->connectToServer(); } bool Main::settingsPDF() @@ -3352,19 +3442,7 @@ branchPropertyWindow->hide(); else branchPropertyWindow->show(); - - if(currentMapEditor()) - { - BranchObj *bo=currentMapEditor()->getSelectedBranch(); - if (bo) - { - branchPropertyWindow->setMapEditor(currentMapEditor()); - branchPropertyWindow->setBranch(bo); - return; - } - - } - branchPropertyWindow->setBranch(NULL); + branchPropertyWindow->setModel (currentModel() ); } void Main::windowToggleAntiAlias() @@ -3373,7 +3451,6 @@ MapEditor *me; for (int i=0;icount();i++) { - me=(MapEditor*)tabWidget->page(i); me->setAntiAlias(b); } @@ -3399,33 +3476,35 @@ void Main::updateNoteFlag() { - if (currentMapEditor()) - currentMapEditor()->updateNoteFlag(); + // this slot is connected to TextEditor::textHasChanged() + + VymModel *m=currentModel(); + if (m) m->updateNoteFlag(); } void Main::updateSatellites(MapEditor *me) { - branchPropertyWindow->setMapEditor (me); + branchPropertyWindow->setModel (me->getModel() ); } void Main::updateActions() { - MapEditor *me=currentMapEditor(); - if (!me) return; - - historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName())); + VymModel *m =currentModel(); + if (!m) return; + + historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName())); // updateActions is also called when NoteEditor is closed actionViewToggleNoteEditor->setOn (textEditor->isVisible()); actionViewToggleHistoryWindow->setOn (historyWindow->isVisible()); actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible()); - if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor) + if (m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) actionFormatLinkColorHint->setOn(true); else actionFormatLinkColorHint->setOn(false); - switch (me->getMapLinkStyle()) + switch (m->getMapLinkStyle()) { case LinkableMapObj::Line: actionFormatLinkStyleLine->setOn(true); @@ -3445,26 +3524,26 @@ // Update colors QPixmap pix( 16, 16 ); - pix.fill( me->getMapBackgroundColor() ); + pix.fill( m->getMapBackgroundColor() ); actionFormatBackColor->setIconSet( pix ); - pix.fill( me->getSelectionColor() ); + pix.fill( m->getSelectionColor() ); actionFormatSelectionColor->setIconSet( pix ); - pix.fill( me->getMapDefLinkColor() ); + pix.fill( m->getMapDefLinkColor() ); actionFormatLinkColor->setIconSet( pix ); - actionFileSave->setEnabled( me->hasChanged() ); - if (me->isUndoAvailable()) + actionFileSave->setEnabled( m->hasChanged() ); + if (m->isUndoAvailable()) actionEditUndo->setEnabled( true); else actionEditUndo->setEnabled( false); - if (me->isRedoAvailable()) + if (m->isRedoAvailable()) actionEditRedo->setEnabled( true); else actionEditRedo->setEnabled( false); - LinkableMapObj *selection=me->getSelection(); + LinkableMapObj *selection=m->getSelection(); if (selection) { if ( (typeid(*selection) == typeid(BranchObj)) || @@ -3636,8 +3715,8 @@ void Main::runScript (const QString &script) { - if (currentMapEditor()) - currentMapEditor()->runScript (script); + VymModel *m=currentModel(); + if (m) m->runScript (script); } void Main::runScriptEverywhere (const QString &script) @@ -3646,7 +3725,7 @@ for (int i=0;i<=tabWidget->count() -1;i++) { me=(MapEditor*)tabWidget->page(i); - if (me) me->runScript (script); + if (me) me->getModel()->runScript (script); } } @@ -3828,41 +3907,13 @@ } QTextStream ts( &f ); - QString m= ts.read(); - - if (! m.isEmpty()) + QString macro= ts.read(); + + if (! macro.isEmpty()) { - //cout <<"Main::callMacro m="<runScript (m); + VymModel *m=currentModel(); + if (m) m->runScript(macro); } } } - - -////////////////////////////////// -/* -@@ -2544,18 +2576,27 @@ - // Try to open new tab in existing konqueror started previously by vym - p=new QProcess (this); - args.clear(); -- args<< QString("konqueror-%1").arg(procBrowser->pid())<< -- "konqueror-mainwindow#1"<< -- "newTab" << -+#if defined(Q_OS_WIN32) -+ // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure. -+ // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic. -+ args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<< -+ "konqueror-mainwindow#1"<< -+ "newTab" << - urls.at(i); -+#else -+ args<< QString("konqueror-%1").arg(procBrowser->pid())<< -+ "konqueror-mainwindow#1"<< -+ "newTab" << -+ urls.at(i); -+#endif - p->start ("dcop",args); - if ( !p->waitForStarted() ) success=false; - } -*/