diff -r 11f9124c1cca -r cf14046909cd mainwindow.cpp --- a/mainwindow.cpp Mon Aug 04 10:43:06 2008 +0000 +++ b/mainwindow.cpp Mon Aug 04 13:35:54 2008 +0000 @@ -1721,7 +1721,8 @@ me=(MapEditor*)tabWidget->page(i); me->getModel()->unselect(); } - currentModel()->reselect(); + VymModel *m=currentModel(); + if (m) m->reselect(); // Update actions to in menus and toolbars according to editor updateActions(); @@ -1732,6 +1733,7 @@ VymModel *m=new VymModel; models.append (m); MapEditor* me = new MapEditor (m); + me->setObjectName ("MapEditor"); QString fn="unnamed"; tabWidget->addTab (me,fn); tabWidget->showPage(me); @@ -1740,7 +1742,7 @@ me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); // For the very first map we do not have flagrows yet... - currentModel()->select("mc:"); + m->select("mc:"); } void Main::fileNewCopy() @@ -2339,12 +2341,10 @@ return; } } - //me->closeMap(); FIXME should not be necessary any longer me->close(); - tabWidget->removePage(m->getMapEditor()); - if (tabWidget->count()==0) - actionFilePrint->setEnabled (false); - delete me; + tabWidget->removePage(me); + delete me; // FIXME if event was triggered _in_ ME this causes warning message + updateActions(); } } @@ -2630,85 +2630,8 @@ m->select(prevSelection); prevSelection=""; } - -/* FIXME old code, remove now - // only called from editHeading(), so there is a currentME - VymModel *m=currentModel(); - if (m) - { - m->setSelectionBlocked (false); - QPoint p; //Not used here, only to find out pos of branch - bool ok; - QString s=m->getHeading(ok,p); - -#if defined(Q_OS_MACX) || defined(Q_OS_WIN32) -#else - if (ok && s!=lineedit->text()) - m->setHeading(lineedit->text()); - - lineedit->releaseKeyboard(); - lineedit->hide(); - setFocus(); -#endif - if (!actionSettingsAutoSelectNewBranch->isOn() && - !prevSelection.isEmpty()) - m->select(prevSelection); - prevSelection=""; - } -*/ } -/* -void Main::editHeading() -{ - MapEditor *me=currentMapEditor(); - VymModel *m=currentModel(); - if (me && m) - { - QString oldSel=m->getSelectString(); - - if (lineedit->isVisible()) - editHeadingFinished(); - else - { - bool ok; - QPoint p; - QString s=m->getHeading(ok,p); - - if (ok) - { - m->setSelectionBlocked(true); -#if defined(Q_OS_MACX) || defined(Q_OS_WIN32) - p=me->mapToGlobal (p); - QDialog *d =new QDialog(NULL); - QLineEdit *le=new QLineEdit (d); - d->setWindowFlags (Qt::FramelessWindowHint); - d->setGeometry(p.x(),p.y(),230,25); - le->resize (d->width()-10,d->height()); - le->setText (s); - le->selectAll(); - connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); - d->activateWindow(); - d->exec(); - m->setHeading (le->text()); - delete (le); - delete (d); - editHeadingFinished(); -#else - p=me->mapTo (this,p); - lineedit->setGeometry(p.x(),p.y(),230,25); - lineedit->setText(s); - lineedit->setCursorPosition(1); - lineedit->selectAll(); - lineedit->show(); - lineedit->grabKeyboard(); - lineedit->setFocus(); -#endif - } - } - } -} -*/ void Main::editAttributeFinished() { @@ -3490,60 +3413,80 @@ void Main::updateActions() { VymModel *m =currentModel(); - if (!m) return; - - historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName())); + LinkableMapObj *selection; + if (m) + { + // Printing + actionFilePrint->setEnabled (true); + + // Selection + selection=m->getSelection(); + + // Link style in context menu + switch (m->getMapLinkStyle()) + { + case LinkableMapObj::Line: + actionFormatLinkStyleLine->setOn(true); + break; + case LinkableMapObj::Parabel: + actionFormatLinkStyleParabel->setOn(true); + break; + case LinkableMapObj::PolyLine: + actionFormatLinkStylePolyLine->setOn(true); + break; + case LinkableMapObj::PolyParabel: + actionFormatLinkStylePolyParabel->setOn(true); + break; + default: + break; + } + + // Update colors + QPixmap pix( 16, 16 ); + pix.fill( m->getMapBackgroundColor() ); + actionFormatBackColor->setIconSet( pix ); + pix.fill( m->getSelectionColor() ); + actionFormatSelectionColor->setIconSet( pix ); + pix.fill( m->getMapDefLinkColor() ); + actionFormatLinkColor->setIconSet( pix ); + + // History window + historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName())); + + } else + { + // Printing + actionFilePrint->setEnabled (false); + + // Selection + selection=NULL; + } // updateActions is also called when NoteEditor is closed actionViewToggleNoteEditor->setOn (textEditor->isVisible()); actionViewToggleHistoryWindow->setOn (historyWindow->isVisible()); actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible()); - if (m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) + if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) actionFormatLinkColorHint->setOn(true); else actionFormatLinkColorHint->setOn(false); - switch (m->getMapLinkStyle()) - { - case LinkableMapObj::Line: - actionFormatLinkStyleLine->setOn(true); - break; - case LinkableMapObj::Parabel: - actionFormatLinkStyleParabel->setOn(true); - break; - case LinkableMapObj::PolyLine: - actionFormatLinkStylePolyLine->setOn(true); - break; - case LinkableMapObj::PolyParabel: - actionFormatLinkStylePolyParabel->setOn(true); - break; - default: - break; - } - - // Update colors - QPixmap pix( 16, 16 ); - pix.fill( m->getMapBackgroundColor() ); - actionFormatBackColor->setIconSet( pix ); - pix.fill( m->getSelectionColor() ); - actionFormatSelectionColor->setIconSet( pix ); - pix.fill( m->getMapDefLinkColor() ); - actionFormatLinkColor->setIconSet( pix ); - - - actionFileSave->setEnabled( m->hasChanged() ); - if (m->isUndoAvailable()) + + if (m && m->hasChanged() ) + actionFileSave->setEnabled( true); + else + actionFileSave->setEnabled( true); + if (m && m->isUndoAvailable()) actionUndo->setEnabled( true); else actionUndo->setEnabled( false); - if (m->isRedoAvailable()) + if (m && m->isRedoAvailable()) actionRedo->setEnabled( true); else actionRedo->setEnabled( false); - LinkableMapObj *selection=m->getSelection(); if (selection) { if ( (typeid(*selection) == typeid(BranchObj)) || @@ -3612,10 +3555,12 @@ else actionMoveDown->setEnabled (false); + actionSortChildren->setEnabled (true); actionToggleHideExport->setEnabled (true); actionToggleHideExport->setOn (bo->hideInExport() ); + actionFileSave->setEnabled (true); actionCopy->setEnabled (true); actionCut->setEnabled (true); if (!clipboardEmpty) @@ -3653,6 +3598,8 @@ } else { + standardFlagsDefault->setEnabled (false); + actionFileSave->setEnabled (false); actionCopy->setEnabled (false); actionCut->setEnabled (false); actionPaste->setEnabled (false); @@ -3667,6 +3614,7 @@ actionDelete->setEnabled (false); actionMoveUp->setEnabled (false); actionMoveDown->setEnabled (false); + actionSortChildren->setEnabled (false); actionToggleHideExport->setEnabled (false); } }