diff -r 4ffc47ae27e4 -r 22955004d512 mapeditor.cpp --- a/mapeditor.cpp Fri Nov 09 12:07:21 2007 +0000 +++ b/mapeditor.cpp Fri Nov 09 12:07:22 2007 +0000 @@ -159,6 +159,10 @@ { //cout <<"Destructor MapEditor\n"; autosaveTimer->stop(); + + // tmpMapDir is in tmpVymDir, so it gets removed automagically when vym closes + + //removeDir(QDir(tmpMapDir)); } MapCenterObj* MapEditor::getMapCenter() @@ -227,8 +231,8 @@ void MapEditor::makeTmpDirs() { // Create unique temporary directories - tmpMapDir=QDir::convertSeparators (tmpVymDir+QString("/mapeditor-%1").arg(mapNum)); - histPath=QDir::convertSeparators (tmpMapDir+"/history"); + tmpMapDir = tmpVymDir+QString("/mapeditor-%1").arg(mapNum); + histPath = tmpMapDir+"/history"; QDir d; d.mkdir (tmpMapDir); } @@ -317,8 +321,8 @@ QString MapEditor::getHistoryDir() { - QString histName=QDir::convertSeparators (QString("history-%1").arg(curStep)); - return QDir::convertSeparators (tmpMapDir +"/"+histName); + QString histName(QString("history-%1").arg(curStep)); + return (tmpMapDir+"/"+histName); } void MapEditor::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel) @@ -339,7 +343,7 @@ QString backupXML=""; QString histDir=getHistoryDir(); - QString bakMapPath=QDir::convertSeparators(histDir+"/map.xml"); + QString bakMapPath=histDir+"/map.xml"; // Create histDir if not available QDir d(histDir); @@ -363,7 +367,7 @@ if (!backupXML.isEmpty()) // Write XML Data to disk - saveStringToDisk (QString(bakMapPath),backupXML); + saveStringToDisk (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. @@ -545,7 +549,7 @@ { //s=parser.parString (ok,0); // selection t=parser.parString (ok,0); // path to map - if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t); + if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t); addMapReplaceInt(selb->getSelectString(),t); } ///////////////////////////////////////////////////////////////////// @@ -563,7 +567,7 @@ { t=parser.parString (ok,0); // path to map n=parser.parInt(ok,1); // position - if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t); + if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t); addMapInsertInt(t,n); } } @@ -1952,8 +1956,8 @@ } // Copy also to global clipboard, because we are at last step in history - QString bakMapName=QDir::convertSeparators (QString("history-%1").arg(curStep)); - QString bakMapDir=QDir::convertSeparators (tmpMapDir +"/"+bakMapName); + QString bakMapName(QString("history-%1").arg(curStep)); + QString bakMapDir(tmpMapDir +"/"+bakMapName); copyDir (bakMapDir,clipboardDir ); clipboardEmpty=false; @@ -1987,7 +1991,7 @@ // Find out current undo directory - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); + QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep)); if (debug) { @@ -2063,7 +2067,7 @@ tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion)); // Find out current undo directory - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); + QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep)); // select object before undo if (!undoSelection.isEmpty()) @@ -2227,8 +2231,8 @@ if (redosAvail > 0 || n!=0) { // Use the "historical" buffer - QString bakMapName=QDir::convertSeparators (QString("history-%1").arg(n)); - QString bakMapDir=QDir::convertSeparators (tmpMapDir +"/"+bakMapName); + QString bakMapName(QString("history-%1").arg(n)); + QString bakMapDir(tmpMapDir +"/"+bakMapName); load (bakMapDir+"/"+clipboardFile,ImportAdd, VymMap); } else // Use the global buffer @@ -2278,17 +2282,21 @@ LinkableMapObj *sel=xelection.single(); if (sel) { - QString ps=qpointfToString (sel->getAbsPos()); - QString s=xelection.single()->getSelectString(); - saveState( - s, "move "+ps, - s, "move "+qpointfToString (QPointF (x,y)), - QString("Move %1 to %2").arg(getName(sel)).arg(ps)); - sel->move(x,y); - mapCenter->reposition(); - xelection.update(); + QPointF ap(sel->getAbsPos()); + QPointF to(x, y); + if (ap != to) + { + QString ps=qpointfToString(ap); + QString s=xelection.single()->getSelectString(); + saveState( + s, "move "+ps, + s, "move "+qpointfToString(to), + QString("Move %1 to %2").arg(getName(sel)).arg(ps)); + sel->move(x,y); + mapCenter->reposition(); + xelection.update(); + } } - } void MapEditor::moveRel (const double &x, const double &y) @@ -2296,16 +2304,21 @@ LinkableMapObj *sel=xelection.single(); if (sel) { - QString ps=qpointfToString (sel->getRelPos()); - QString s=sel->getSelectString(); - saveState( - s, "moveRel "+ps, - s, "moveRel "+qpointfToString (QPointF (x,y)), - QString("Move %1 to relativ position %2").arg(getName(sel)).arg(ps)); - ((OrnamentedObj*)sel)->move2RelPos (x,y); - mapCenter->reposition(); - sel->updateLink(); - xelection.update(); + QPointF rp(sel->getRelPos()); + QPointF to(x, y); + if (rp != to) + { + QString ps=qpointfToString (sel->getRelPos()); + QString s=sel->getSelectString(); + saveState( + s, "moveRel "+ps, + s, "moveRel "+qpointfToString(to), + QString("Move %1 to relative position %2").arg(getName(sel)).arg(ps)); + ((OrnamentedObj*)sel)->move2RelPos (x,y); + mapCenter->reposition(); + sel->updateLink(); + xelection.update(); + } } } @@ -4452,7 +4465,7 @@ "moveRel "+pold, fio, "moveRel "+pnow, - QString("Move %1 to relativ position %2").arg(getName(fio)).arg(pnow)); + QString("Move %1 to relative position %2").arg(getName(fio)).arg(pnow)); fio->getParObj()->requestReposition(); mapCenter->reposition(); @@ -4596,7 +4609,7 @@ "moveRel "+pold, fo, "moveRel "+pnow, - QString("Move %1 to relativ position %2").arg(getName(fo)).arg(pnow)); + QString("Move %1 to relative position %2").arg(getName(fo)).arg(pnow)); fo->getParObj()->requestReposition(); mapCenter->reposition(); @@ -4613,16 +4626,19 @@ { // TODO: Check for problems if graphicsview is resized for // undo/redo... - QString pold=qpointfToString(movingObj_orgPos); - QString pnow=qpointfToString(mapCenter->getAbsPos()); - saveState( - fo, - "move "+pold, - fo, - "move "+pnow, - QString("Move mapcenter %1 to position %2").arg(getName(mapCenter)).arg(pnow)); + if (movingObj_orgPos != mapCenter->getAbsPos()) + { + QString pold=qpointfToString(movingObj_orgPos); + QString pnow=qpointfToString(mapCenter->getAbsPos()); + saveState( + fo, + "move "+pold, + fo, + "move "+pnow, + QString("Move mapcenter %1 to position %2").arg(getName(mapCenter)).arg(pnow)); + } } - + if (xelection.type() == Selection::Branch ) { // A branch was moved @@ -4683,12 +4699,15 @@ // Therefor reposition and then use string of old selection, too mapCenter->reposition(); - QString ps=qpointfToString ( lmosel->getRelPos() ); - saveState( - lmosel->getSelectString(), "moveRel "+qpointfToString(movingObj_orgRelPos), - preSelStr, "moveRel "+ps, - QString("Move %1 to relative position %2").arg(getName(lmosel)).arg(ps)); - + QPointF rp(lmosel->getRelPos()); + if (rp != movingObj_orgRelPos) + { + QString ps=qpointfToString(rp); + saveState( + lmosel->getSelectString(), "moveRel "+qpointfToString(movingObj_orgRelPos), + preSelStr, "moveRel "+ps, + QString("Move %1 to relative position %2").arg(getName(lmosel)).arg(ps)); + } } // Draw the original link, before selection was moved around mapCenter->reposition(); @@ -4788,7 +4807,7 @@ s=uris.at(i).toLocalFile(); if (!s.isEmpty()) { - QString file = QDir::convertSeparators(s); + QString file = QDir::fromNativeSeparators(s); heading = QFileInfo(file).baseName(); files.append(file); if (file.endsWith(".vym", false))