diff -r aff86e2f2a4a -r 9c86935835a4 mapeditor.cpp --- a/mapeditor.cpp Wed May 02 15:31:18 2007 +0000 +++ b/mapeditor.cpp Wed May 02 15:31:20 2007 +0000 @@ -281,6 +281,93 @@ return s; } +void MapEditor::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel) +{ + // Main saveState + + if (blockSaveState) return; + + /* TODO remove after testing + */ + if (debug) cout << "ME::saveState() for "<stepsTotal) curStep=1; + + QString backupXML=""; + QString bakMapName=QDir::convertSeparators (QString("history-%1").arg(curStep)); + QString bakMapDir=QDir::convertSeparators (tmpMapDir +"/"+bakMapName); + QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml"); + + // Create bakMapDir if not available + QDir d(bakMapDir); + if (!d.exists()) + makeSubDirs (bakMapDir); + + // Save depending on how much needs to be saved + if (saveSel) + backupXML=saveToDir (bakMapDir,mapName+"-",false, QPointF (),saveSel); + + QString undoCommand=""; + if (savemode==UndoCommand) + { + undoCommand=undoCom; + } + else if (savemode==PartOfMap ) + { + undoCommand=undoCom; + undoCommand.replace ("PATH",bakMapPath); + } + + if (!backupXML.isEmpty()) + // Write XML Data to disk + saveStringToDisk (QString(bakMapPath),backupXML); + + // We would have to save all actions in a tree, to keep track of + // possible redos after a action. Possible, but we are too lazy: forget about redos. + redosAvail=0; + + // Write the current state to disk + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); + undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail)); + undoSet.setEntry ("/history/curStep",QString::number(curStep)); + undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand); + undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection); + undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom); + undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection); + undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment); + undoSet.setEntry (QString("/history/version"),vymVersion); + undoSet.writeSettings(histPath); + + if (debug) + { + // TODO remove after testing + //cout << " into="<< histPath.toStdString()<updateHistory (undoSet); + setChanged(); + updateActions(); +} + + void MapEditor::saveStateChangingPart(LinkableMapObj *undoSel, LinkableMapObj* redoSel, const QString &rc, const QString &comment) { // save the selected part of the map, Undo will replace part of map @@ -355,92 +442,6 @@ } -void MapEditor::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel) -{ - // Main saveState - - if (blockSaveState) return; - - /* TODO remove after testing - */ - if (debug) cout << "ME::saveState() for "<stepsTotal) curStep=1; - - QString backupXML=""; - QString bakMapName=QDir::convertSeparators (QString("history-%1").arg(curStep)); - QString bakMapDir=QDir::convertSeparators (tmpMapDir +"/"+bakMapName); - QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml"); - - // Create bakMapDir if not available - QDir d(bakMapDir); - if (!d.exists()) - makeSubDirs (bakMapDir); - - // Save depending on how much needs to be saved - if (saveSel) - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPointF (),saveSel); - - QString undoCommand=""; - if (savemode==UndoCommand) - { - undoCommand=undoCom; - } - else if (savemode==PartOfMap ) - { - undoCommand=undoCom; - undoCommand.replace ("PATH",bakMapPath); - } - - if (!backupXML.isEmpty()) - // Write XML Data to disk - saveStringToDisk (QString(bakMapPath),backupXML); - - // We would have to save all actions in a tree, to keep track of - // possible redos after a action. Possible, but we are too lazy: forget about redos. - redosAvail=0; - - // Write the current state to disk - undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); - undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail)); - undoSet.setEntry ("/history/curStep",QString::number(curStep)); - undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand); - undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection); - undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom); - undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection); - undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment); - undoSet.setEntry (QString("/history/version"),vymVersion); - undoSet.writeSettings(histPath); - - if (debug) - { - // TODO remove after testing - //cout << " into="<< histPath.toStdString()<updateHistory (undoSet); - setChanged(); - updateActions(); -} - void MapEditor::parseAtom(const QString &atom) { BranchObj *selb=xelection.getBranch(); @@ -830,6 +831,50 @@ s=parser.parString(ok,0); if (ok) setFrameType (s); } + } else if (com=="setFramePenColor") + { + if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage) + { + parser.setError (Aborted,"Type of selection does not allow setting of pen color"); + } + else if (parser.checkParamCount(1)) + { + QColor c=parser.parColor(ok,0); + if (ok) setFramePenColor (c); + } + } else if (com=="setFrameBrushColor") + { + if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage) + { + parser.setError (Aborted,"Type of selection does not allow setting brush color"); + } + else if (parser.checkParamCount(1)) + { + QColor c=parser.parColor(ok,0); + if (ok) setFrameBrushColor (c); + } + } else if (com=="setFramePadding") + { + if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage) + { + parser.setError (Aborted,"Type of selection does not allow setting frame padding"); + } + else if (parser.checkParamCount(1)) + { + x=parser.parInt(ok,0); + if (ok) setFramePadding(x); + } + } else if (com=="setFrameBorderWidth") + { + if ( xelection.type()!=Branch && xelection.type()!= MapCenter && xelection.type()!=FloatImage) + { + parser.setError (Aborted,"Type of selection does not allow setting frame border width"); + } + else if (parser.checkParamCount(1)) + { + x=parser.parInt(ok,0); + if (ok) setFrameBorderWidth (x); + } } else if (com=="setMapAuthor") { if (parser.checkParamCount(1)) @@ -1084,11 +1129,6 @@ return mapDefault; } -bool MapEditor::isUnsaved() -{ - return mapUnsaved; -} - bool MapEditor::hasChanged() { return mapChanged; @@ -1116,26 +1156,21 @@ close(); } -void MapEditor::setFilePath(QString fname) +void MapEditor::setFilePath(QString fpath, QString destname) { - setFilePath (fname,fname); -} - -void MapEditor::setFilePath(QString fname, QString destname) -{ - if (fname.isEmpty() || fname=="") + if (fpath.isEmpty() || fpath=="") { filePath=""; fileName=""; destPath=""; } else { - filePath=fname; // becomes absolute path - fileName=fname; // gets stripped of path + filePath=fpath; // becomes absolute path + fileName=fpath; // gets stripped of path destPath=destname; // needed for vymlinks - // If fname is not an absolute path, complete it - filePath=QDir(fname).absPath(); + // If fpath is not an absolute path, complete it + filePath=QDir(fpath).absPath(); fileDir=filePath.left (1+filePath.findRev ("/")); // Set short name, too. Search from behind: @@ -1147,6 +1182,11 @@ } } +void MapEditor::setFilePath(QString fpath) +{ + setFilePath (fpath,fpath); +} + QString MapEditor::getFilePath() { return filePath; @@ -3442,30 +3482,30 @@ } } -void MapEditor::setFramePadding (const int &) +void MapEditor::setFramePadding (const int &i) { BranchObj *bo=xelection.getBranch(); - /* if (bo) { - saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ), - bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() )); - bo->setFrameBrushColor (c); + saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ), + bo, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i)); + bo->setFramePadding (i); + mapCenter->reposition(); + bo->updateLink(); } - */ } -void MapEditor::setFrameBorderWidth(const int &) +void MapEditor::setFrameBorderWidth(const int &i) { BranchObj *bo=xelection.getBranch(); - /* if (bo) { - saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ), - bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() )); - bo->setFrameBrushColor (c); + saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ), + bo, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i)); + bo->setFrameBorderWidth (i); + mapCenter->reposition(); + bo->updateLink(); } - */ } void MapEditor::setIncludeImagesVer(bool b)