1.1 --- a/mapeditor.cpp Tue Oct 24 15:36:38 2006 +0000
1.2 +++ b/mapeditor.cpp Mon Oct 30 12:39:37 2006 +0000
1.3 @@ -85,7 +85,6 @@
1.4
1.5 printer=NULL;
1.6
1.7 - actColor=Qt::black; setColor (actColor);
1.8 defLinkColor=QColor (0,0,255);
1.9 defXLinkColor=QColor (180,180,180);
1.10 linkcolorhint=DefaultColor;
1.11 @@ -163,11 +162,6 @@
1.12 //cout <<"Destructor MapEditor\n";
1.13 }
1.14
1.15 -QColor MapEditor::getColor()
1.16 -{
1.17 - return actColor;
1.18 -}
1.19 -
1.20 QColor MapEditor::getBackgroundColor()
1.21 {
1.22 return mapCanvas->backgroundColor();
1.23 @@ -372,15 +366,24 @@
1.24 mapCenter);
1.25 }
1.26
1.27 -void MapEditor::saveStateChangingPart(LinkableMapObj *undoSel, const QString &comment)
1.28 +void MapEditor::saveStateChangingPart(LinkableMapObj *undoSel, LinkableMapObj* redoSel, const QString &rc, const QString &comment)
1.29 {
1.30 // save the selected part of the map, Undo will replace part of map
1.31 QString undoSelection="";
1.32 - if (undoSel) undoSelection=undoSel->getSelectString();
1.33 + if (undoSel)
1.34 + undoSelection=undoSel->getSelectString();
1.35 + else
1.36 + qWarning ("MapEditor::saveStateChangingPart no undoSel given!");
1.37 + QString redoSelection="";
1.38 + if (redoSel)
1.39 + redoSelection=undoSel->getSelectString();
1.40 + else
1.41 + qWarning ("MapEditor::saveStateChangingPart no redoSel given!");
1.42 +
1.43
1.44 saveState (PartOfMap,
1.45 undoSelection, "",
1.46 - "", "",
1.47 + redoSelection, rc,
1.48 comment,
1.49 undoSel);
1.50 }
1.51 @@ -407,8 +410,6 @@
1.52 // save the selected mainbranch of the map, Undo will insert part of map
1.53 saveState (PartOfMap,
1.54 undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(((BranchObj*)redoSel)->getNum()),
1.55 -// undoSelection, QString("addMapInsert (\"PATH\",%1,%2)").arg(((BranchObj*)redoSel)->getNum())
1.56 -// .arg(((BranchObj*)redoSel)->x()).arg(((BranchObj*)redoSel)->y()),
1.57 redoSelection, "delete ()",
1.58 comment,
1.59 redoSel);
1.60 @@ -416,21 +417,6 @@
1.61 }
1.62 }
1.63
1.64 -void MapEditor::saveStateConstSelection(const QString &uc, const QString &rc, const QString &comment)
1.65 -{
1.66 - // selection does not change during action,
1.67 - // so just save commands for undo and redo
1.68 - // and use current selection
1.69 -
1.70 - QString sel;
1.71 - if (selection) sel=selection->getSelectString();
1.72 -
1.73 - saveState (UndoCommand,
1.74 - sel, uc,
1.75 - sel, rc,
1.76 - comment,
1.77 - NULL);
1.78 -}
1.79
1.80 void MapEditor::saveState(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment)
1.81 {
1.82 @@ -473,8 +459,6 @@
1.83 */
1.84 cout << "ME::saveState() "<<endl;
1.85
1.86 - setChanged();
1.87 -
1.88 int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0);
1.89 int redosAvail=undoSet.readNumEntry ("/history/redosAvail",0);
1.90 int curStep=undoSet.readNumEntry ("/history/curStep",0);
1.91 @@ -529,6 +513,7 @@
1.92 undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom);
1.93 undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection);
1.94 undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment);
1.95 + undoSet.setEntry (QString("/history/version"),__VYM_VERSION);
1.96 undoSet.writeSettings(histPath);
1.97
1.98 /* TODO remove after testing
1.99 @@ -547,6 +532,8 @@
1.100 cout << " ---------------------------"<<endl;
1.101
1.102 historyWindow.update (undoSet);
1.103 + setChanged();
1.104 + updateActions();
1.105 }
1.106
1.107 void MapEditor::parseAtom(const QString &atom)
1.108 @@ -554,7 +541,7 @@
1.109 API api;
1.110 QString s,t;
1.111 int x,y;
1.112 - bool ok;
1.113 + bool b,ok;
1.114
1.115 // Split string s into command and parameters
1.116 api.parseInput (atom);
1.117 @@ -636,6 +623,48 @@
1.118 addMapInsertInt(t,y);
1.119 }
1.120 }
1.121 + } else if (com=="colorItem")
1.122 + {
1.123 + if (!selection)
1.124 + {
1.125 + api.setError (Aborted,"Nothing selected");
1.126 + } else if ( typeid(*selection) != typeid(BranchObj) &&
1.127 + typeid(*selection) != typeid(MapCenterObj))
1.128 + {
1.129 + api.setError (Aborted,"Type of selection is not a branch");
1.130 + } else if (api.checkParamCount(1))
1.131 + {
1.132 + QColor c=api.parColor (ok,0);
1.133 + if (ok) colorItem (c);
1.134 + }
1.135 + } else if (com=="colorBranch")
1.136 + {
1.137 + if (!selection)
1.138 + {
1.139 + api.setError (Aborted,"Nothing selected");
1.140 + } else if ( typeid(*selection) != typeid(BranchObj) &&
1.141 + typeid(*selection) != typeid(MapCenterObj))
1.142 + {
1.143 + api.setError (Aborted,"Type of selection is not a branch");
1.144 + } else if (api.checkParamCount(1))
1.145 + {
1.146 + QColor c=api.parColor (ok,0);
1.147 + if (ok) colorBranch (c);
1.148 + }
1.149 + } else if (com=="cut")
1.150 + {
1.151 + if (!selection)
1.152 + {
1.153 + api.setError (Aborted,"Nothing selected");
1.154 + } else if ( typeid(*selection) != typeid(BranchObj) &&
1.155 + typeid(*selection) != typeid(MapCenterObj) &&
1.156 + typeid(*selection) != typeid(FloatImageObj) )
1.157 + {
1.158 + api.setError (Aborted,"Type of selection is not a branch or floatimage");
1.159 + } else if (api.checkParamCount(0))
1.160 + {
1.161 + cut();
1.162 + }
1.163 } else if (com=="delete")
1.164 {
1.165 if (!selection)
1.166 @@ -660,7 +689,20 @@
1.167 api.setError (Aborted,"Type of selection is not a branch");
1.168 } else if (api.checkParamCount(0))
1.169 {
1.170 - removeBranchKeepChilds();
1.171 + deleteKeepChilds();
1.172 + }
1.173 + } else if (com=="deleteChilds")
1.174 + {
1.175 + if (!selection)
1.176 + {
1.177 + api.setError (Aborted,"Nothing selected");
1.178 + } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.179 + typeid(*selection) != typeid(MapCenterObj)) )
1.180 + {
1.181 + api.setError (Aborted,"Type of selection is not a branch");
1.182 + } else if (api.checkParamCount(0))
1.183 + {
1.184 + deleteChilds();
1.185 }
1.186 } else if (com=="linkBranchToPos")
1.187 {
1.188 @@ -744,8 +786,7 @@
1.189 if (ok) move (x,y);
1.190 }
1.191 }
1.192 - }
1.193 - else if (com=="moveRel")
1.194 + } else if (com=="moveRel")
1.195 {
1.196 if (!selection)
1.197 {
1.198 @@ -764,6 +805,19 @@
1.199 if (ok) moveRel (x,y);
1.200 }
1.201 }
1.202 + } else if (com=="paste")
1.203 + {
1.204 + if (!selection)
1.205 + {
1.206 + api.setError (Aborted,"Nothing selected");
1.207 + } else if ( typeid(*selection) != typeid(BranchObj) &&
1.208 + typeid(*selection) != typeid(MapCenterObj) )
1.209 + {
1.210 + api.setError (Aborted,"Type of selection is not a branch");
1.211 + } else if (api.checkParamCount(0))
1.212 + {
1.213 + paste();
1.214 + }
1.215 } else if (com=="setHeading")
1.216 {
1.217 if (!selection)
1.218 @@ -779,6 +833,20 @@
1.219 if (ok)
1.220 setHeading (s);
1.221 }
1.222 + } else if (com=="setHideExport")
1.223 + {
1.224 + if (!selection)
1.225 + {
1.226 + api.setError (Aborted,"Nothing selected");
1.227 + } else if ( typeid(*selection) != typeid(BranchObj) &&
1.228 + typeid(*selection) != typeid(FloatImageObj) )
1.229 + {
1.230 + api.setError (Aborted,"Type of selection is not a branch or floatimage");
1.231 + } else if (api.checkParamCount(1))
1.232 + {
1.233 + b=api.parBool(ok,0);
1.234 + if (ok) setHideExport (b);
1.235 + }
1.236 } else if (com=="setURL")
1.237 {
1.238 if (!selection)
1.239 @@ -808,27 +876,6 @@
1.240 if (ok) setVymLinkInt(s);
1.241 }
1.242 }
1.243 - else if (com=="setHideExport")
1.244 - {
1.245 - if (!selection)
1.246 - {
1.247 - api.setError (Aborted,"Nothing selected");
1.248 - } else if ( typeid(*selection) != typeid(BranchObj) &&
1.249 - typeid(*selection) != typeid(MapCenterObj) &&
1.250 - typeid(*selection) != typeid(FloatImageObj) )
1.251 - {
1.252 - api.setError (Aborted,"Type of selection is not a branch or floatimage");
1.253 - } else if (api.checkParamCount(2))
1.254 - {
1.255 - s=api.parString(ok,0);
1.256 - if (ok)
1.257 - {
1.258 - BranchObj* bo=(BranchObj*)selection;
1.259 - bo->activateStandardFlag(s);
1.260 - bo->updateFlagsToolbar();
1.261 - }
1.262 - }
1.263 - }
1.264 else if (com=="setFlag")
1.265 {
1.266 if (!selection)
1.267 @@ -1007,7 +1054,22 @@
1.268 // (map state is set later at end of load...)
1.269 } else
1.270 {
1.271 - saveStateChangingPart(selection,"Load map");
1.272 + if (!selection || (typeid(*selection) != typeid(BranchObj) &&
1.273 + typeid(*selection) != typeid (MapCenterObj)))
1.274 + return aborted;
1.275 + BranchObj *bo=(BranchObj*)selection;
1.276 + if (lmode==ImportAdd)
1.277 + saveStateChangingPart(
1.278 + selection,
1.279 + selection,
1.280 + QString("addMapInsert (%1)").arg(fname),
1.281 + QString("Add map %1 to %2").arg(fname).arg(getName(bo)));
1.282 + else
1.283 + saveStateChangingPart(
1.284 + selection,
1.285 + selection,
1.286 + QString("addMapReplace(%1)").arg(fname),
1.287 + QString("Add map %1 to %2").arg(fname).arg(getName(bo)));
1.288 }
1.289
1.290
1.291 @@ -1412,6 +1474,12 @@
1.292 QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
1.293 QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
1.294 QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
1.295 + QString version=undoSet.readEntry ("/history/version");
1.296 +
1.297 + if (!checkVersion(version))
1.298 + QMessageBox::warning(0,tr("Warning"),
1.299 + tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(__VYM_VERSION));
1.300 +
1.301
1.302 // Find out current undo directory
1.303 QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.304 @@ -1485,6 +1553,11 @@
1.305 QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
1.306 QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
1.307 QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
1.308 + QString version=undoSet.readEntry ("/history/version");
1.309 +
1.310 + if (!checkVersion(version))
1.311 + QMessageBox::warning(0,tr("Warning"),
1.312 + tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(__VYM_VERSION));
1.313
1.314 // Find out current undo directory
1.315 QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.316 @@ -1655,8 +1728,13 @@
1.317 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.318 typeid(*selection) == typeid(MapCenterObj)))
1.319 {
1.320 - saveStateChangingPart(selection,QString("Paste to %1").arg( getName(selection)));
1.321 pasteNoSave();
1.322 + saveStateChangingPart(
1.323 + selection,
1.324 + selection,
1.325 + "paste ()",
1.326 + QString("Paste to %1").arg( getName(selection))
1.327 + );
1.328 mapCenter->reposition();
1.329 adjustCanvasSize();
1.330 }
1.331 @@ -1664,7 +1742,12 @@
1.332
1.333 void MapEditor::cut()
1.334 {
1.335 - saveStateChangingPart(selection->getParObj(),QString("Cut %1").arg(getName(selection)));
1.336 + saveStateChangingPart(
1.337 + selection->getParObj(),
1.338 + selection,
1.339 + "cut ()",
1.340 + QString("Cut %1").arg(getName(selection))
1.341 + );
1.342 copy();
1.343 cutNoSave();
1.344 mapCenter->reposition();
1.345 @@ -1766,8 +1849,10 @@
1.346 typeid(*selection) == typeid(MapCenterObj) ) )
1.347 {
1.348 editingBO=(BranchObj*)selection;
1.349 - saveStateConstSelection(
1.350 + saveState(
1.351 + selection,
1.352 "setHeading (\""+editingBO->getHeading()+"\")",
1.353 + selection,
1.354 "setHeading (\""+s+"\")",
1.355 QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(s) );
1.356 editingBO->setHeading(s );
1.357 @@ -1870,11 +1955,12 @@
1.358
1.359 if (newbo)
1.360 {
1.361 - saveStateConstSelection (
1.362 - //QString ("delete (\"%1\")").arg(newbo->getSelectString()),
1.363 + saveState(
1.364 + selection, // FIXME sholdnt newbo be deleted here???
1.365 "delete ()",
1.366 + selection,
1.367 QString ("addBranch (%1)").arg(pos-2),
1.368 - QString ("Add new branch to %1").arg(getName(bo))); //TODO undoCommand
1.369 + QString ("Add new branch to %1").arg(getName(bo)));
1.370
1.371 mapCenter->reposition();
1.372 adjustCanvasSize();
1.373 @@ -1936,7 +2022,12 @@
1.374 {
1.375 FloatImageObj* fio=(FloatImageObj*)selection;
1.376 BranchObj* par=(BranchObj*)(fio->getParObj());
1.377 - saveStateChangingPart(par, QString("Delete %1").arg(getName(fio)));
1.378 + saveStateChangingPart(
1.379 + par,
1.380 + fio,
1.381 + "delete ()",
1.382 + QString("Delete %1").arg(getName(fio))
1.383 + );
1.384 fio->unselect();
1.385 selection=NULL;
1.386 par->removeFloatImage(fio);
1.387 @@ -2363,11 +2454,6 @@
1.388 }
1.389 }
1.390
1.391 -void MapEditor::setColor(QColor c)
1.392 -{
1.393 - actColor=c;
1.394 -}
1.395 -
1.396 void MapEditor::selectBackgroundColor()
1.397 {
1.398 QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
1.399 @@ -2382,7 +2468,7 @@
1.400 mapCanvas->setBackgroundColor (c);
1.401 }
1.402
1.403 -QColor MapEditor::pickColor()
1.404 +QColor MapEditor::getCurrentHeadingColor()
1.405 {
1.406 if (selection)
1.407 {
1.408 @@ -2390,13 +2476,15 @@
1.409 typeid(*selection) == typeid(MapCenterObj))
1.410 {
1.411 BranchObj *bo=(BranchObj*)selection;
1.412 - actColor=bo->getColor();
1.413 + return bo->getColor();
1.414 }
1.415 }
1.416 - return actColor;
1.417 +
1.418 + QMessageBox::warning(0,tr("Warning"),tr("Can't get color of heading,\nthere's no branch selected"));
1.419 + return Qt::black;
1.420 }
1.421
1.422 -void MapEditor::colorItem()
1.423 +void MapEditor::colorItem(QColor c)
1.424 {
1.425 if (selection)
1.426 {
1.427 @@ -2404,13 +2492,18 @@
1.428 typeid(*selection) == typeid(MapCenterObj))
1.429 {
1.430 BranchObj *bo=(BranchObj*)selection;
1.431 - saveStateChangingPart(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.432 - bo->setColor(actColor); // color branch
1.433 + saveStateChangingPart(
1.434 + selection,
1.435 + selection,
1.436 + QString ("colorItem (%1)").arg(c.name()),
1.437 + QString("Set color of %1 to %2").arg(getName(bo)).arg(c.name())
1.438 + ); //TODO with complete API: undoCommand
1.439 + bo->setColor(c); // color branch
1.440 }
1.441 }
1.442 }
1.443
1.444 -void MapEditor::colorBranch()
1.445 +void MapEditor::colorBranch(QColor c)
1.446 {
1.447 if (selection)
1.448 {
1.449 @@ -2418,8 +2511,13 @@
1.450 typeid(*selection) == typeid(MapCenterObj))
1.451 {
1.452 BranchObj *bo=(BranchObj*)selection;
1.453 - saveStateChangingPart(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.454 - bo->setColorChilds(actColor); // color links, color childs
1.455 + saveStateChangingPart(
1.456 + selection,
1.457 + selection,
1.458 + QString ("colorBranch (%1)").arg(c.name()),
1.459 + QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(c.name())
1.460 + );
1.461 + bo->setColorChilds(c); // color links, color childs
1.462 }
1.463 }
1.464 }
1.465 @@ -2444,7 +2542,10 @@
1.466 u="unsetFlag";
1.467 r="setFlag";
1.468 }
1.469 - saveStateConstSelection(QString("%1 (\"%2\")").arg(u).arg(f),
1.470 + saveState(
1.471 + selection,
1.472 + QString("%1 (\"%2\")").arg(u).arg(f),
1.473 + selection,
1.474 QString("%1 (\"%2\")").arg(r).arg(f),
1.475 QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo)));
1.476 bo->toggleStandardFlag (f,mainWindow->useFlagGroups());
1.477 @@ -2526,6 +2627,24 @@
1.478 itFind=NULL;
1.479 EOFind=false;
1.480 }
1.481 +void MapEditor::setURL(const QString &url)
1.482 +{
1.483 + if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.484 + typeid(*selection) == typeid(MapCenterObj)) )
1.485 + {
1.486 + BranchObj *bo=(BranchObj*)selection;
1.487 + QString oldurl=bo->getURL();
1.488 + bo->setURL (url);
1.489 + saveState (
1.490 + selection,
1.491 + QString ("setURL (\"%1\")").arg(oldurl),
1.492 + selection,
1.493 + QString ("setURL (\"%1\")").arg(url),
1.494 + QString ("set URL of %1 to %2").arg(getName(bo)).arg(url)
1.495 + );
1.496 + updateActions();
1.497 + }
1.498 +}
1.499
1.500 void MapEditor::editURL()
1.501 {
1.502 @@ -2538,12 +2657,8 @@
1.503 "VYM", tr("Enter URL:"), QLineEdit::Normal,
1.504 bo->getURL(), &ok, this );
1.505 if ( ok)
1.506 - {
1.507 // user entered something and pressed OK
1.508 - saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text));
1.509 - bo->setURL (text);
1.510 - updateActions();
1.511 - }
1.512 + setURL (text);
1.513 }
1.514 }
1.515
1.516 @@ -2578,12 +2693,7 @@
1.517 {
1.518 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.519 typeid(*selection) == typeid(MapCenterObj)) )
1.520 - {
1.521 - BranchObj *bo=(BranchObj*)selection;
1.522 - saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo)));
1.523 - bo->setURL (bo->getHeading());
1.524 - updateActions();
1.525 - }
1.526 + setURL (((BranchObj*)selection)->getHeading());
1.527 }
1.528
1.529 void MapEditor::editBugzilla2URL()
1.530 @@ -2593,9 +2703,7 @@
1.531 {
1.532 BranchObj *bo=(BranchObj*)selection;
1.533 QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
1.534 - saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo)));
1.535 - bo->setURL (url);
1.536 - updateActions();
1.537 + setURL (url);
1.538 }
1.539 }
1.540
1.541 @@ -2606,7 +2714,13 @@
1.542 {
1.543 BranchObj *bo=(BranchObj*)selection;
1.544 QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
1.545 - saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo)));
1.546 + saveState(
1.547 + selection,
1.548 + "setURL (\""+bo->getURL()+"\")",
1.549 + selection,
1.550 + "setURL (\""+url+"\")",
1.551 + QString("Use heading of %1 as link to FATE").arg(getName(bo))
1.552 + );
1.553 bo->setURL (url);
1.554 updateActions();
1.555 }
1.556 @@ -2628,7 +2742,13 @@
1.557 QString fn;
1.558 if ( fd->exec() == QDialog::Accepted )
1.559 {
1.560 - saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()));
1.561 + saveState(
1.562 + selection,
1.563 + "setVymLink (\""+bo->getVymLink()+"\")",
1.564 + selection,
1.565 + "setVymLink (\""+fd->selectedFile()+"\")",
1.566 + QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())
1.567 + );
1.568 bo->setVymLink (fd->selectedFile() );
1.569 updateActions();
1.570 mapCenter->reposition();
1.571 @@ -2644,7 +2764,13 @@
1.572 typeid(*selection) == typeid(MapCenterObj)) )
1.573 {
1.574 BranchObj *bo=(BranchObj*)selection;
1.575 - saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo)));
1.576 + saveState(
1.577 + selection,
1.578 + "setVymLink (\""+bo->getVymLink()+"\")",
1.579 + selection,
1.580 + "setVymLink (\"\")",
1.581 + QString("Unset vymlink of %1").arg(getName(bo))
1.582 + );
1.583 bo->setVymLink ("" );
1.584 updateActions();
1.585 mapCenter->reposition();
1.586 @@ -2653,26 +2779,23 @@
1.587 }
1.588 }
1.589
1.590 -void MapEditor::toggleHideExport()
1.591 +void MapEditor::setHideExport(bool b)
1.592 {
1.593 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.594 - typeid(*selection) == typeid(MapCenterObj)) ||
1.595 - (typeid(*selection)==typeid(FloatImageObj))
1.596 - )
1.597 - {
1.598 + typeid(*selection)==typeid(FloatImageObj)))
1.599 + {
1.600 OrnamentedObj *oo=(OrnamentedObj*)selection;
1.601 - QString s;
1.602 - if (oo->hideInExport())
1.603 - {
1.604 - oo->setHideInExport(false);
1.605 - s="Unset";
1.606 - }
1.607 - else
1.608 - {
1.609 - oo->setHideInExport(true);
1.610 - s="Set";
1.611 - }
1.612 - saveStateComplete(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand
1.613 + oo->setHideInExport (b);
1.614 + QString u= b ? "false" : "true";
1.615 + QString r=!b ? "false" : "true";
1.616 +
1.617 + saveState(
1.618 + selection,
1.619 + QString ("setHideExport (%1)").arg(u),
1.620 + selection,
1.621 + QString ("setHideExport (%1)").arg(r),
1.622 + QString ("Set HideExport flag of %1 to %2").arg(getName(oo)).arg (r)
1.623 + );
1.624 updateActions();
1.625 mapCenter->reposition();
1.626 adjustCanvasSize();
1.627 @@ -2680,6 +2803,13 @@
1.628 }
1.629 }
1.630
1.631 +void MapEditor::toggleHideExport()
1.632 +{
1.633 + if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.634 + typeid(*selection)==typeid(FloatImageObj)))
1.635 + setHideExport ( !((OrnamentedObj*)selection)->hideInExport() );
1.636 +}
1.637 +
1.638 QString MapEditor::getVymLink()
1.639 {
1.640 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.641 @@ -2709,18 +2839,19 @@
1.642 }
1.643
1.644
1.645 -void MapEditor::removeBranchKeepChilds()
1.646 +void MapEditor::deleteKeepChilds()
1.647 {
1.648 if (selection && (typeid(*selection) == typeid(BranchObj) ))
1.649 {
1.650 BranchObj* bo=(BranchObj*)selection;
1.651 BranchObj* par=(BranchObj*)(bo->getParObj());
1.652 QPoint p=bo->getRelPos();
1.653 - QString s=QString("Remove %1 and keep its childs").arg(getName(bo));
1.654 - if (bo->getDepth()==1)
1.655 - saveStateComplete(s);
1.656 - else
1.657 - saveStateChangingPart(selection->getParObj(),s); // TODO undoCommand
1.658 + saveStateChangingPart(
1.659 + selection->getParObj(),
1.660 + selection,
1.661 + "deleteKeepChilds ()",
1.662 + QString("Remove %1 and keep its childs").arg(getName(bo))
1.663 + );
1.664
1.665 QString sel=selection->getSelectString();
1.666 unselect();
1.667 @@ -2733,12 +2864,17 @@
1.668 }
1.669 }
1.670
1.671 -void MapEditor::removeChilds()
1.672 +void MapEditor::deleteChilds()
1.673 {
1.674 - if (selection && (typeid(*selection) == typeid(BranchObj) ))
1.675 + if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.676 + typeid(*selection)==typeid(MapCenterObj)))
1.677 {
1.678 - // TODO undoCommand
1.679 - saveStateChangingPart(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection)));
1.680 + saveStateChangingPart(
1.681 + selection->getParObj(),
1.682 + selection,
1.683 + "deleteChilds ()",
1.684 + QString( "Remove childs of branch %1").arg(getName(selection))
1.685 + );
1.686 ((BranchObj*)selection)->removeChilds();
1.687 mapCenter->reposition();
1.688 }
1.689 @@ -2908,12 +3044,24 @@
1.690 BranchObj *bo=((BranchObj*)selection);
1.691 if (bo->countBranches()==0) return;
1.692 if (bo->getDepth()==0) return;
1.693 - QString s;
1.694 + QString u,r;
1.695 if (bo->isScrolled())
1.696 - s="Unscroll";
1.697 + {
1.698 + r="unscroll";
1.699 + u="scroll";
1.700 + }
1.701 else
1.702 - s="Scroll";
1.703 - saveStateChangingPart(selection, QString ("%1 %2").arg(s).arg(getName(bo)));
1.704 + {
1.705 + u="scroll";
1.706 + r="unscroll";
1.707 + }
1.708 + saveState(
1.709 + selection,
1.710 + QString ("%1 ()").arg(u),
1.711 + selection,
1.712 + QString ("%1 ()").arg(r),
1.713 + QString ("%1 %2").arg(r).arg(getName(bo))
1.714 + );
1.715 bo->toggleScroll();
1.716 adjustCanvasSize();
1.717 canvas()->update();
1.718 @@ -2953,17 +3101,25 @@
1.719 QString fn;
1.720 if ( fd->exec() == QDialog::Accepted )
1.721 {
1.722 - saveStateChangingPart(selection, QString("Add floatimage to %1").arg(getName(selection)));
1.723 // FIXME in QT4 use: lastImageDir=fd->directory();
1.724 lastImageDir=QDir (fd->dirPath());
1.725 QStringList flist = fd->selectedFiles();
1.726 QStringList::Iterator it = flist.begin();
1.727 + FloatImageObj *fio;
1.728 while( it != flist.end() )
1.729 {
1.730 fn = *it;
1.731 bo->addFloatImage();
1.732 - // TODO check if load was successful
1.733 - bo->getLastFloatImage()->load(*it);
1.734 + fio=bo->getLastFloatImage();
1.735 + fio->load(*it);
1.736 + // FIXME check if load of fio was successful
1.737 + saveState(
1.738 + (LinkableMapObj*)fio,
1.739 + "delete ()",
1.740 + selection,
1.741 + QString ("loadFloatImage (%1)").arg(*it),
1.742 + QString("Add floatimage %1 to %2").arg(*it).arg(getName(selection))
1.743 + );
1.744 bo->getLastFloatImage()->setOriginalFilename(fn);
1.745 ++it;
1.746 }
1.747 @@ -3618,8 +3774,10 @@
1.748 FloatImageObj *fo=(FloatImageObj*)selection;
1.749 QString pold=qpointToString(movingObj_orgRelPos);
1.750 QString pnow=qpointToString(fo->getRelPos());
1.751 - saveStateConstSelection(
1.752 + saveState(
1.753 + selection,
1.754 "moveRel "+pold,
1.755 + selection,
1.756 "moveRel "+pnow,
1.757 QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow));
1.758
1.759 @@ -3815,7 +3973,7 @@
1.760 QPixmap pix;
1.761 if (Q3ImageDrag::decode(event, pix))
1.762 {
1.763 - addFloatImage(pix);
1.764 + addFloatImageInt(pix);
1.765 event->accept();
1.766 update=true;
1.767 } else
1.768 @@ -3914,20 +4072,19 @@
1.769 }
1.770 }
1.771
1.772 -void MapEditor::addFloatImage(const QPixmap &img)
1.773 +void MapEditor::addFloatImageInt (const QPixmap &img)
1.774 {
1.775 if (selection &&
1.776 (typeid(*selection) == typeid(BranchObj)) ||
1.777 (typeid(*selection) == typeid(MapCenterObj)) )
1.778 {
1.779 BranchObj *bo=((BranchObj*)selection);
1.780 - saveStateChangingPart(selection,QString("Add floatimage to %1").arg(getName(bo)));
1.781 + //FIXME XXX saveStateChangingPart(selection,QString("Add floatimage to %1").arg(getName(bo)));
1.782 //QString fn=fd->selectedFile();
1.783 //lastImageDir=fn.left(fn.findRev ("/"));
1.784 - bo->addFloatImage();
1.785 - // FIXME check if load was successful
1.786 - bo->getLastFloatImage()->load(img);
1.787 - //bo->getLastFloatImage()->setOriginalFilename(fn);
1.788 + FloatImageObj *fio=bo->addFloatImage();
1.789 + fio->load(img);
1.790 + fio->setOriginalFilename("Image added by Drag and Drop");
1.791 mapCenter->reposition();
1.792 adjustCanvasSize();
1.793 canvas()->update();
1.794 @@ -3949,7 +4106,7 @@
1.795 {
1.796 if (nop->state()==Q3NetworkProtocol::StDone) {
1.797 QPixmap img(imageBuffer->buffer());
1.798 - addFloatImage(img);
1.799 + addFloatImageInt (img);
1.800 }
1.801
1.802 if (imageBuffer) {