1.1 --- a/mainwindow.cpp Mon Aug 04 10:43:06 2008 +0000
1.2 +++ b/mainwindow.cpp Mon Aug 04 13:35:54 2008 +0000
1.3 @@ -1721,7 +1721,8 @@
1.4 me=(MapEditor*)tabWidget->page(i);
1.5 me->getModel()->unselect();
1.6 }
1.7 - currentModel()->reselect();
1.8 + VymModel *m=currentModel();
1.9 + if (m) m->reselect();
1.10
1.11 // Update actions to in menus and toolbars according to editor
1.12 updateActions();
1.13 @@ -1732,6 +1733,7 @@
1.14 VymModel *m=new VymModel;
1.15 models.append (m);
1.16 MapEditor* me = new MapEditor (m);
1.17 + me->setObjectName ("MapEditor");
1.18 QString fn="unnamed";
1.19 tabWidget->addTab (me,fn);
1.20 tabWidget->showPage(me);
1.21 @@ -1740,7 +1742,7 @@
1.22 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1.23
1.24 // For the very first map we do not have flagrows yet...
1.25 - currentModel()->select("mc:");
1.26 + m->select("mc:");
1.27 }
1.28
1.29 void Main::fileNewCopy()
1.30 @@ -2339,12 +2341,10 @@
1.31 return;
1.32 }
1.33 }
1.34 - //me->closeMap(); FIXME should not be necessary any longer
1.35 me->close();
1.36 - tabWidget->removePage(m->getMapEditor());
1.37 - if (tabWidget->count()==0)
1.38 - actionFilePrint->setEnabled (false);
1.39 - delete me;
1.40 + tabWidget->removePage(me);
1.41 + delete me; // FIXME if event was triggered _in_ ME this causes warning message
1.42 + updateActions();
1.43 }
1.44 }
1.45
1.46 @@ -2630,85 +2630,8 @@
1.47 m->select(prevSelection);
1.48 prevSelection="";
1.49 }
1.50 -
1.51 -/* FIXME old code, remove now
1.52 - // only called from editHeading(), so there is a currentME
1.53 - VymModel *m=currentModel();
1.54 - if (m)
1.55 - {
1.56 - m->setSelectionBlocked (false);
1.57 - QPoint p; //Not used here, only to find out pos of branch
1.58 - bool ok;
1.59 - QString s=m->getHeading(ok,p);
1.60 -
1.61 -#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
1.62 -#else
1.63 - if (ok && s!=lineedit->text())
1.64 - m->setHeading(lineedit->text());
1.65 -
1.66 - lineedit->releaseKeyboard();
1.67 - lineedit->hide();
1.68 - setFocus();
1.69 -#endif
1.70 - if (!actionSettingsAutoSelectNewBranch->isOn() &&
1.71 - !prevSelection.isEmpty())
1.72 - m->select(prevSelection);
1.73 - prevSelection="";
1.74 - }
1.75 -*/
1.76 }
1.77
1.78 -/*
1.79 -void Main::editHeading()
1.80 -{
1.81 - MapEditor *me=currentMapEditor();
1.82 - VymModel *m=currentModel();
1.83 - if (me && m)
1.84 - {
1.85 - QString oldSel=m->getSelectString();
1.86 -
1.87 - if (lineedit->isVisible())
1.88 - editHeadingFinished();
1.89 - else
1.90 - {
1.91 - bool ok;
1.92 - QPoint p;
1.93 - QString s=m->getHeading(ok,p);
1.94 -
1.95 - if (ok)
1.96 - {
1.97 - m->setSelectionBlocked(true);
1.98 -#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
1.99 - p=me->mapToGlobal (p);
1.100 - QDialog *d =new QDialog(NULL);
1.101 - QLineEdit *le=new QLineEdit (d);
1.102 - d->setWindowFlags (Qt::FramelessWindowHint);
1.103 - d->setGeometry(p.x(),p.y(),230,25);
1.104 - le->resize (d->width()-10,d->height());
1.105 - le->setText (s);
1.106 - le->selectAll();
1.107 - connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
1.108 - d->activateWindow();
1.109 - d->exec();
1.110 - m->setHeading (le->text());
1.111 - delete (le);
1.112 - delete (d);
1.113 - editHeadingFinished();
1.114 -#else
1.115 - p=me->mapTo (this,p);
1.116 - lineedit->setGeometry(p.x(),p.y(),230,25);
1.117 - lineedit->setText(s);
1.118 - lineedit->setCursorPosition(1);
1.119 - lineedit->selectAll();
1.120 - lineedit->show();
1.121 - lineedit->grabKeyboard();
1.122 - lineedit->setFocus();
1.123 -#endif
1.124 - }
1.125 - }
1.126 - }
1.127 -}
1.128 -*/
1.129
1.130 void Main::editAttributeFinished()
1.131 {
1.132 @@ -3490,60 +3413,80 @@
1.133 void Main::updateActions()
1.134 {
1.135 VymModel *m =currentModel();
1.136 - if (!m) return;
1.137 -
1.138 - historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
1.139 + LinkableMapObj *selection;
1.140 + if (m)
1.141 + {
1.142 + // Printing
1.143 + actionFilePrint->setEnabled (true);
1.144 +
1.145 + // Selection
1.146 + selection=m->getSelection();
1.147 +
1.148 + // Link style in context menu
1.149 + switch (m->getMapLinkStyle())
1.150 + {
1.151 + case LinkableMapObj::Line:
1.152 + actionFormatLinkStyleLine->setOn(true);
1.153 + break;
1.154 + case LinkableMapObj::Parabel:
1.155 + actionFormatLinkStyleParabel->setOn(true);
1.156 + break;
1.157 + case LinkableMapObj::PolyLine:
1.158 + actionFormatLinkStylePolyLine->setOn(true);
1.159 + break;
1.160 + case LinkableMapObj::PolyParabel:
1.161 + actionFormatLinkStylePolyParabel->setOn(true);
1.162 + break;
1.163 + default:
1.164 + break;
1.165 + }
1.166 +
1.167 + // Update colors
1.168 + QPixmap pix( 16, 16 );
1.169 + pix.fill( m->getMapBackgroundColor() );
1.170 + actionFormatBackColor->setIconSet( pix );
1.171 + pix.fill( m->getSelectionColor() );
1.172 + actionFormatSelectionColor->setIconSet( pix );
1.173 + pix.fill( m->getMapDefLinkColor() );
1.174 + actionFormatLinkColor->setIconSet( pix );
1.175 +
1.176 + // History window
1.177 + historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
1.178 +
1.179 + } else
1.180 + {
1.181 + // Printing
1.182 + actionFilePrint->setEnabled (false);
1.183 +
1.184 + // Selection
1.185 + selection=NULL;
1.186 + }
1.187
1.188 // updateActions is also called when NoteEditor is closed
1.189 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
1.190 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
1.191 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
1.192
1.193 - if (m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
1.194 + if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
1.195 actionFormatLinkColorHint->setOn(true);
1.196 else
1.197 actionFormatLinkColorHint->setOn(false);
1.198
1.199 - switch (m->getMapLinkStyle())
1.200 - {
1.201 - case LinkableMapObj::Line:
1.202 - actionFormatLinkStyleLine->setOn(true);
1.203 - break;
1.204 - case LinkableMapObj::Parabel:
1.205 - actionFormatLinkStyleParabel->setOn(true);
1.206 - break;
1.207 - case LinkableMapObj::PolyLine:
1.208 - actionFormatLinkStylePolyLine->setOn(true);
1.209 - break;
1.210 - case LinkableMapObj::PolyParabel:
1.211 - actionFormatLinkStylePolyParabel->setOn(true);
1.212 - break;
1.213 - default:
1.214 - break;
1.215 - }
1.216 -
1.217 - // Update colors
1.218 - QPixmap pix( 16, 16 );
1.219 - pix.fill( m->getMapBackgroundColor() );
1.220 - actionFormatBackColor->setIconSet( pix );
1.221 - pix.fill( m->getSelectionColor() );
1.222 - actionFormatSelectionColor->setIconSet( pix );
1.223 - pix.fill( m->getMapDefLinkColor() );
1.224 - actionFormatLinkColor->setIconSet( pix );
1.225 -
1.226 -
1.227 - actionFileSave->setEnabled( m->hasChanged() );
1.228 - if (m->isUndoAvailable())
1.229 +
1.230 + if (m && m->hasChanged() )
1.231 + actionFileSave->setEnabled( true);
1.232 + else
1.233 + actionFileSave->setEnabled( true);
1.234 + if (m && m->isUndoAvailable())
1.235 actionUndo->setEnabled( true);
1.236 else
1.237 actionUndo->setEnabled( false);
1.238
1.239 - if (m->isRedoAvailable())
1.240 + if (m && m->isRedoAvailable())
1.241 actionRedo->setEnabled( true);
1.242 else
1.243 actionRedo->setEnabled( false);
1.244
1.245 - LinkableMapObj *selection=m->getSelection();
1.246 if (selection)
1.247 {
1.248 if ( (typeid(*selection) == typeid(BranchObj)) ||
1.249 @@ -3612,10 +3555,12 @@
1.250 else
1.251 actionMoveDown->setEnabled (false);
1.252
1.253 + actionSortChildren->setEnabled (true);
1.254
1.255 actionToggleHideExport->setEnabled (true);
1.256 actionToggleHideExport->setOn (bo->hideInExport() );
1.257
1.258 + actionFileSave->setEnabled (true);
1.259 actionCopy->setEnabled (true);
1.260 actionCut->setEnabled (true);
1.261 if (!clipboardEmpty)
1.262 @@ -3653,6 +3598,8 @@
1.263
1.264 } else
1.265 {
1.266 + standardFlagsDefault->setEnabled (false);
1.267 + actionFileSave->setEnabled (false);
1.268 actionCopy->setEnabled (false);
1.269 actionCut->setEnabled (false);
1.270 actionPaste->setEnabled (false);
1.271 @@ -3667,6 +3614,7 @@
1.272 actionDelete->setEnabled (false);
1.273 actionMoveUp->setEnabled (false);
1.274 actionMoveDown->setEnabled (false);
1.275 + actionSortChildren->setEnabled (false);
1.276 actionToggleHideExport->setEnabled (false);
1.277 }
1.278 }