diff -r 01f2f6d6789d -r e3f722759c7e mainwindow.cpp --- a/mainwindow.cpp Mon May 18 11:22:41 2009 +0000 +++ b/mainwindow.cpp Wed May 20 15:40:14 2009 +0000 @@ -542,34 +542,6 @@ editMenu->addAction (a); actionPaste=a; -/* FIXME-5 - // Shortcuts to modify heading: - a = new QAction(tr( "Edit heading","Edit menu" ),this); - a->setStatusTip ( tr( "edit Heading" )); - a->setShortcut ( Qt::Key_Enter); //Edit heading -// a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); - actionListBranches.append(a); - a = new QAction( tr( "Edit heading","Edit menu" ), this); - a->setStatusTip (tr( "edit Heading" )); - a->setShortcut (Qt::Key_Return ); //Edit heading - //a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); - actionListBranches.append(a); - editMenu->addAction (a); - actionHeading=a; - - a = new QAction( tr( "Edit heading","Edit menu" ), this); - a->setStatusTip (tr( "edit Heading" )); - //a->setShortcut ( Qt::Key_F2 ); //Edit heading - a->setShortcutContext (Qt::WindowShortcut); - addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); - actionListBranches.append(a); -*/ - // Shortcut to delete selection a = new QAction( tr( "Delete Selection","Edit menu" ),this); a->setStatusTip (tr( "Delete Selection" )); @@ -1144,6 +1116,7 @@ QToolBar *tb=NULL; Flag *flag=new Flag;; + flag->setVisible(true); flag->load(QPixmap(flagsPath+"flag-note.png")); setupFlag (flag,tb,"system-note",tr("Note","SystemFlag")); @@ -1167,7 +1140,6 @@ tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar")); tb->setObjectName ("standardFlagTB"); standardFlagsMaster->setToolBar (tb); - flag->load(flagsPath+"flag-exclamationmark.png"); flag->setGroup("standard-mark"); @@ -1259,7 +1231,7 @@ setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag")); // Freemind flags - + flag->setVisible(false); flag->load(flagsPath+"freemind/warning.png"); setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag")); @@ -1343,6 +1315,7 @@ // StandardFlag tb->addAction (a); flag->setAction (a); + a->setVisible (flag->isVisible()); a->setCheckable(true); a->setObjectName(name); a->setToolTip(tooltip); @@ -1696,14 +1669,14 @@ MapEditor* Main::currentMapEditor() const { if ( tabWidget->currentPage()) - return tabModel.at(tabWidget->currentIndex())->getMapEditor(); + return vymViews.at(tabWidget->currentIndex())->getMapEditor(); return NULL; } VymModel* Main::currentModel() const { if ( tabWidget->currentPage()) - return tabModel.at(tabWidget->currentIndex()); + return vymViews.at(tabWidget->currentIndex())->getModel(); return NULL; } @@ -1712,11 +1685,13 @@ { // Unselect all possibly selected objects // (Important to update note editor) + VymModel *m; for (int i=0;i<=tabWidget->count() -1;i++) { - tabModel.at(i)->unselect(); - } - VymModel *m=currentModel(); + m= vymViews.at(tabWidget->currentIndex())->getModel(); + if (m) m->unselect(); + } + m=currentModel(); if (m) m->reselect(); // Update actions to in menus and toolbars according to editor @@ -1726,11 +1701,11 @@ void Main::fileNew() { VymModel *vm=new VymModel; - tabModel.append (vm); VymView *vv=new VymView (vm); + vymViews.append (vv); tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file")); - tabWidget->setCurrentIndex (tabModel.count() ); + tabWidget->setCurrentIndex (vymViews.count() ); vv->initFocus(); @@ -1746,7 +1721,7 @@ { srcModel->copy(); fileNew(); - VymModel *dstModel=tabModel.last (); + VymModel *dstModel=vymViews.last()->getModel(); dstModel->select("mc:"); dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap); } @@ -1770,7 +1745,7 @@ int i=0; while (i<=tabWidget->count() -1) { - if (tabModel.at(i)->getFilePath() == fn) + if (vymViews.at(i)->getModel()->getFilePath() == fn) { // Already there, ask for confirmation QMessageBox mb( vymName, @@ -1813,7 +1788,7 @@ { vm=new VymModel; VymView *vv=new VymView (vm); - tabModel.append (vm); + vymViews.append (vv); tabWidget->addTab (vv,fn); tabIndex=tabWidget->count()-1; tabWidget->setCurrentPage (tabIndex); @@ -2310,16 +2285,15 @@ } } -void Main::fileCloseMap() +void Main::fileCloseMap() { - MapEditor *me = currentMapEditor(); VymModel *m=currentModel(); if (m) { if (m->hasChanged()) { QMessageBox mb( vymName, - tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()), + tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, @@ -2340,14 +2314,16 @@ return; } } - tabModel.removeAt (tabWidget->currentIndex() ); + // And here comes the segfault, because removeTab triggers + // currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet... + vymViews.removeAt (tabWidget->currentIndex() ); tabWidget->removeTab (tabWidget->currentIndex() ); - // Remove mapEditor; + // Remove mapEditor/model FIXME-5 // Better would be delete (me), but then we could have a Qt error: // "QObject: Do not delete object, 'MapEditor', during its event handler!" // So we only remove data now and call deconstructor when vym closes later - // FIXME-3 this needs to be moved to vymview... me->clear(); + // this needs to be moved to vymview... me->clear(); // some model->clear is needed to free up memory ... updateActions(); @@ -2364,10 +2340,10 @@ { // Check if one or more editors have changed int i; - for (i=0;i<=tabModel.count() -1;i++) + for (i=0;i<=vymViews.count() -1;i++) { // If something changed, ask what to do - if (tabModel.at(i)->hasChanged()) + if (vymViews.at(i)->getModel()->hasChanged()) { tabWidget->setCurrentPage(i); QMessageBox mb( vymName, @@ -2641,9 +2617,9 @@ // compare path with already loaded maps int index=-1; int i; - for (i=0;i<=tabModel.count() -1;i++) + for (i=0;i<=vymViews.count() -1;i++) { - if (vl.at(j)==tabModel.at(i)->getFilePath() ) + if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() ) { index=i; break; @@ -2789,11 +2765,7 @@ void Main::editAddMapCenter() { VymModel *m=currentModel(); - if (m) - { - cout <<"Main::editAddMapCenter\n"; - m->addMapCenter (); - } + if (m) m->addMapCenter (); } void Main::editNewBranch() @@ -3226,9 +3198,9 @@ { bool b=actionViewToggleAntiAlias->isOn(); MapEditor *me; - for (int i=0;igetMapEditor(); + me=vymViews.at(i)->getMapEditor(); if (me) me->setAntiAlias(b); } @@ -3248,10 +3220,10 @@ { bool b=actionViewToggleSmoothPixmapTransform->isOn(); MapEditor *me; - for (int i=0;igetMapEditor(); + me=vymViews.at(i)->getMapEditor(); if (me) me->setSmoothPixmap(b); } } @@ -3388,139 +3360,142 @@ else actionRedo->setEnabled( false); - TreeItem *selti=m->getSelectedItem(); - BranchItem *selbi=m->getSelectedBranchItem(); - if (selti) + if (m) { - if (selbi) + TreeItem *selti=m->getSelectedItem(); + BranchItem *selbi=m->getSelectedBranchItem(); + if (selti) { - // Take care of links // FIXME-1 - /* - if (bo->countXLinks()==0) + if (selbi) { - branchXLinksContextMenuEdit->clear(); - branchXLinksContextMenuFollow->clear(); - } else + // Take care of links // FIXME-1 + /* + if (bo->countXLinks()==0) + { + branchXLinksContextMenuEdit->clear(); + branchXLinksContextMenuFollow->clear(); + } else + { + BranchObj *bot; + QString s; + branchXLinksContextMenuEdit->clear(); + branchXLinksContextMenuFollow->clear(); + for (int i=0; i<=bo->countXLinks();i++) + { + bot=bo->XLinkTargetAt(i); + if (bot) + { + s=bot->getHeading(); + if (s.length()>xLinkMenuWidth) + s=s.left(xLinkMenuWidth)+"..."; + branchXLinksContextMenuFollow->addAction (s); + branchXLinksContextMenuEdit->addAction (s); + } + } + } + */ + //Standard Flags + standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() ); + + // System Flags + actionToggleScroll->setEnabled (true); + if ( selbi->isScrolled() ) + actionToggleScroll->setOn(true); + else + actionToggleScroll->setOn(false); + + if ( selti->getURL().isEmpty() ) + { + actionOpenURL->setEnabled (false); + actionOpenURLTab->setEnabled (false); + } + else + { + actionOpenURL->setEnabled (true); + actionOpenURLTab->setEnabled (true); + } + if ( selti->getVymLink().isEmpty() ) + { + actionOpenVymLink->setEnabled (false); + actionDeleteVymLink->setEnabled (false); + } else + { + actionOpenVymLink->setEnabled (true); + actionDeleteVymLink->setEnabled (true); + } + + if (selbi->canMoveUp()) + actionMoveUp->setEnabled (true); + else + actionMoveUp->setEnabled (false); + if (selbi->canMoveDown()) + actionMoveDown->setEnabled (true); + else + actionMoveDown->setEnabled (false); + + actionSortChildren->setEnabled (true); + + actionToggleHideExport->setEnabled (true); + actionToggleHideExport->setOn (selbi->hideInExport() ); + + actionFileSave->setEnabled (true); + actionCopy->setEnabled (true); + actionCut->setEnabled (true); + if (!clipboardEmpty) + actionPaste->setEnabled (true); + else + actionPaste->setEnabled (false); + for (int i=0; isetEnabled(true); + actionDelete->setEnabled (true); + //FIXME-2 actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected()); + } + if ( selti->getType()==TreeItem::Image) { - BranchObj *bot; - QString s; - branchXLinksContextMenuEdit->clear(); - branchXLinksContextMenuFollow->clear(); - for (int i=0; i<=bo->countXLinks();i++) - { - bot=bo->XLinkTargetAt(i); - if (bot) - { - s=bot->getHeading(); - if (s.length()>xLinkMenuWidth) - s=s.left(xLinkMenuWidth)+"..."; - branchXLinksContextMenuFollow->addAction (s); - branchXLinksContextMenuEdit->addAction (s); - } - } - } - */ - //Standard Flags - standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() ); - - // System Flags - actionToggleScroll->setEnabled (true); - if ( selbi->isScrolled() ) - actionToggleScroll->setOn(true); - else - actionToggleScroll->setOn(false); - - if ( selti->getURL().isEmpty() ) - { + /* FIXME-2 + FloatObj *fo=(FloatImageObj*)selection; + actionOpenURL->setEnabled (false); - actionOpenURLTab->setEnabled (false); - } - else - { - actionOpenURL->setEnabled (true); - actionOpenURLTab->setEnabled (true); - } - if ( selti->getVymLink().isEmpty() ) - { actionOpenVymLink->setEnabled (false); - actionDeleteVymLink->setEnabled (false); - } else - { - actionOpenVymLink->setEnabled (true); - actionDeleteVymLink->setEnabled (true); - } - - if (selbi->canMoveUp()) - actionMoveUp->setEnabled (true); - else + actionDeleteVymLink->setEnabled (false); + actionToggleHideExport->setEnabled (true); + actionToggleHideExport->setOn (fo->hideInExport() ); + + + actionCopy->setEnabled (true); + actionCut->setEnabled (true); + actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images? + for (int i=0; isetEnabled(false); + actionDelete->setEnabled (true); + actionFormatHideLinkUnselected->setOn + ( selection->getHideLinkUnselected()); actionMoveUp->setEnabled (false); - if (selbi->canMoveDown()) - actionMoveDown->setEnabled (true); - else actionMoveDown->setEnabled (false); - - actionSortChildren->setEnabled (true); - - actionToggleHideExport->setEnabled (true); - actionToggleHideExport->setOn (selbi->hideInExport() ); - - actionFileSave->setEnabled (true); - actionCopy->setEnabled (true); - actionCut->setEnabled (true); - if (!clipboardEmpty) - actionPaste->setEnabled (true); - else - actionPaste->setEnabled (false); + */ + } //image + + } else + { // !selti + actionFileSave->setEnabled (false); + actionCopy->setEnabled (false); + actionCut->setEnabled (false); + actionPaste->setEnabled (false); for (int i=0; isetEnabled(true); - actionDelete->setEnabled (true); - //FIXME-2 actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected()); - } - if ( selti->getType()==TreeItem::Image) - { - /* FIXME-2 - FloatObj *fo=(FloatImageObj*)selection; - + actionListBranches.at(i)->setEnabled(false); + + actionToggleScroll->setEnabled (false); actionOpenURL->setEnabled (false); actionOpenVymLink->setEnabled (false); actionDeleteVymLink->setEnabled (false); - actionToggleHideExport->setEnabled (true); - actionToggleHideExport->setOn (fo->hideInExport() ); - - - actionCopy->setEnabled (true); - actionCut->setEnabled (true); - actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images? - for (int i=0; isetEnabled(false); - actionDelete->setEnabled (true); - actionFormatHideLinkUnselected->setOn - ( selection->getHideLinkUnselected()); + actionHeading2URL->setEnabled (false); + actionDelete->setEnabled (false); actionMoveUp->setEnabled (false); actionMoveDown->setEnabled (false); - */ - } - - } else - { - actionFileSave->setEnabled (false); - actionCopy->setEnabled (false); - actionCut->setEnabled (false); - actionPaste->setEnabled (false); - for (int i=0; isetEnabled(false); - - actionToggleScroll->setEnabled (false); - actionOpenURL->setEnabled (false); - actionOpenVymLink->setEnabled (false); - actionDeleteVymLink->setEnabled (false); - actionHeading2URL->setEnabled (false); - actionDelete->setEnabled (false); - actionMoveUp->setEnabled (false); - actionMoveDown->setEnabled (false); - actionSortChildren->setEnabled (false); - actionToggleHideExport->setEnabled (false); - } + actionSortChildren->setEnabled (false); + actionToggleHideExport->setEnabled (false); + } + } // m } Main::ModMode Main::getModMode()