diff -r d8c245d582a3 -r 48ca4c364eab mapeditor.cpp --- a/mapeditor.cpp Mon Jun 11 09:40:59 2007 +0000 +++ b/mapeditor.cpp Thu Jun 14 10:21:41 2007 +0000 @@ -133,6 +133,10 @@ // Create temporary files makeTmpDirs(); + curStep=0; + redosAvail=0; + undosAvail=0; + setAcceptDrops (true); mapCenter->reposition(); // for positioning heading @@ -314,9 +318,6 @@ if (debug) cout << "ME::saveState() for "<getHeading() == u) + { + cout << "PASSED: " << c.ascii() << endl; + } else + { + cout << "FAILED: " << c.ascii() << endl; + } + } + } + } + } + } + } + } } } else if (com=="saveImage") { @@ -1613,23 +1695,18 @@ LinkableMapObj *sel=xelection.single(); if (sel) { - // write to directory - QString saveFile=saveToDir (clipboardDir,clipboardFile+"-",true,QPointF(),sel ); // FIXME check FIO - QFile file; - - file.setName ( clipboardDir + "/"+clipboardFile); - if ( !file.open( QIODevice::WriteOnly ) ) + if (redosAvail == 0) { - // This should neverever happen - QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name())); - return; - } - - // Write it finally, and write in UTF8, no matter what - QTextStream ts( &file ); - ts.setEncoding (QTextStream::UnicodeUTF8); - ts << saveFile; - file.close(); + // Copy to history + QString s=sel->getSelectString(); + saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy to clipboard",sel ); + curClipboard=curStep; + } + + // 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); + copyDir (bakMapDir,clipboardDir ); clipboardEmpty=false; updateActions(); @@ -1638,10 +1715,6 @@ void MapEditor::redo() { - // Restore variables - int curStep=undoSet.readNumEntry (QString("/history/curStep")); - int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); - int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail")); // Can we undo at all? if (redosAvail<1) return; @@ -1722,14 +1795,11 @@ void MapEditor::undo() { - // Restore variables - int curStep=undoSet.readNumEntry (QString("/history/curStep")); - int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); - int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail")); - // Can we undo at all? if (undosAvail<1) return; + mainWindow->statusMessage (tr("Autosave disabled during undo.")); + bool blockSaveStateOrg=blockSaveState; blockSaveState=true; @@ -1902,11 +1972,19 @@ } } -void MapEditor::pasteNoSave() +void MapEditor::pasteNoSave(const int &n) { bool old=blockSaveState; blockSaveState=true; - load (clipboardDir+"/"+clipboardFile,ImportAdd); + if (redosAvail > 0 || n!=0) + { + // Use the "historical" buffer + QString bakMapName=QDir::convertSeparators (QString("history-%1").arg(n)); + QString bakMapDir=QDir::convertSeparators (tmpMapDir +"/"+bakMapName); + load (bakMapDir+"/"+clipboardFile,ImportAdd); + } else + // Use the global buffer + load (clipboardDir+"/"+clipboardFile,ImportAdd); blockSaveState=old; } @@ -1918,10 +1996,10 @@ saveStateChangingPart( sel, sel, - "paste ()", + QString ("paste (%1)").arg(curClipboard), QString("Paste to %1").arg( getName(sel)) ); - pasteNoSave(); + pasteNoSave(0); mapCenter->reposition(); } } @@ -3759,7 +3837,8 @@ void MapEditor::testFunction() { - // This is the playground + mainWindow->statusMessage("Biiiiiiiiiiiiiiing!"); + return; BranchObj *bo=xelection.getBranch(); if (bo) animObjList.append( bo );