diff -r 5b6f2a396979 -r b1e3a4d88f13 mapeditor.cpp --- a/mapeditor.cpp Wed May 31 12:27:39 2006 +0000 +++ b/mapeditor.cpp Tue Sep 05 10:03:29 2006 +0000 @@ -1,24 +1,34 @@ #include "mapeditor.h" #include -#include +#include #include #include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include +//Added by qt3to4: +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -34,7 +44,6 @@ #include "linkablemapobj.h" #include "mainwindow.h" #include "misc.h" -#include "settings.h" #include "texteditor.h" #include "warningdialog.h" #include "xml.h" @@ -49,10 +58,11 @@ extern FlagRowObj *systemFlagsDefault; extern FlagRowObj *standardFlagsDefault; -extern QPtrList actionListBranches; +extern Q3PtrList actionListBranches; extern QAction *actionFileSave; extern QAction *actionEditUndo; +extern QAction *actionEditRedo; extern QAction *actionEditCopy; extern QAction *actionEditCut; extern QAction *actionEditPaste; @@ -113,44 +123,51 @@ extern QAction *actionSettingsAutoedit; extern QAction *actionSettingsAutoselectHeading; extern QAction *actionSettingsAutoselectText; -extern QAction *actionSettingsPasteNewHeading; extern QAction *actionSettingsUseFlagGroups; -extern QPopupMenu *branchContextMenu; -extern QPopupMenu *branchLinksContextMenu; -extern QPopupMenu *branchLinksContextMenuDup; -extern QPopupMenu *floatimageContextMenu; -extern QPopupMenu *saveImageFormatMenu; -extern QPopupMenu *exportImageFormatMenu; -extern QPopupMenu *canvasContextMenu; +extern QMenu* branchContextMenu; +extern QMenu* branchAddContextMenu; +extern QMenu* branchRemoveContextMenu; +extern QMenu* branchLinksContextMenu; +extern QMenu* branchXLinksContextMenuEdit; +extern QMenu* branchXLinksContextMenuFollow; +extern QMenu* floatimageContextMenu; +extern QMenu* saveImageFormatMenu; +extern QMenu* canvasContextMenu; +extern QMenu* lastMapsMenu; +extern QMenu* importMenu; +extern QMenu* exportMenu; + extern Settings settings; +extern ImageIO imageIO; extern QString iconPath; extern QDir vymBaseDir; +extern QDir lastImageDir; int MapEditor::mapNum=0; // make instance /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// MapEditor::MapEditor( - QWidget* parent, bool interactive, const char* name, WFlags f) : - QCanvasView(parent,name,f), urlOperator(0), imageBuffer(0) + QWidget* parent, bool interactive, const char* name, Qt::WFlags f) : + Q3CanvasView(parent,name,f), urlOperator(0), imageBuffer(0) { //cout << "Constructor ME "<setAcceptDrops(true); - mapCanvas = new QCanvas(1000,800); + mapCanvas = new Q3Canvas(width(),height()); mapCanvas->setAdvancePeriod(30); - mapCanvas->setBackgroundColor (white); + mapCanvas->setBackgroundColor (Qt::white); setCanvas (mapCanvas); // Always show scroll bars (automatic would flicker sometimes) - setVScrollBarMode ( QScrollView::AlwaysOn ); - setHScrollBarMode ( QScrollView::AlwaysOn ); + setVScrollBarMode ( Q3ScrollView::AlwaysOn ); + setHScrollBarMode ( Q3ScrollView::AlwaysOn ); mapCenter = new MapCenterObj(mapCanvas); mapCenter->setVisibility (true); @@ -160,24 +177,18 @@ printer=NULL; - lineedit = new QLineEdit(this, "lineedit" ); - connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEdit() ) ); - lineedit->hide(); - - actColor=black; setColor (actColor); + actColor=Qt::black; setColor (actColor); defLinkColor=QColor (0,0,255); defXLinkColor=QColor (180,180,180); linkcolorhint=DefaultColor; linkstyle=StylePolyParabel; - // Create bitmap cursors, patform dependant + // Create bitmap cursors, platform dependant #if defined(Q_OS_MACX) - handOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png") ); - // set hot spot to tip of picker + handOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png"),1,1 ); pickColorCursor=QCursor ( QPixmap (iconPath+"cursorcolorpicker16.png"), 1,15 ); #else - handOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen16.png")); - // set hot spot to tip of picker + handOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1); pickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 ); #endif @@ -190,6 +201,8 @@ selectionLast=NULL; movingObj=NULL; + xelection.setMapCenter (mapCenter); + defXLinkWidth=1; defXLinkColor=QColor (230,230,230); @@ -202,9 +215,7 @@ fileName=tr("unnamed"); mapName=""; - undosTotal=settings.readNumEntry("/vym/mapeditor/undoLevels",50); - undosAvail=0; - undoNum=0; + undosTotal=settings.readNumEntry("/mapeditor/undoLevels",50); // Initialize find routine itFind=NULL; @@ -231,6 +242,8 @@ historyWindow->setCaption (fileName); mapCenter->reposition(); // for positioning heading + + } MapEditor::~MapEditor() @@ -244,7 +257,7 @@ //cout <<"Destructor MapEditor\n"; // Save Settings - //settings.writeEntry( "/vym/mapeditor/editmode/autoselect", ); + //settings.writeEntry( "/mapeditor/editmode/autoselect", ); } @@ -263,7 +276,7 @@ return mapCenter; } -QCanvas* MapEditor::getCanvas() +Q3Canvas* MapEditor::getCanvas() { return mapCanvas; } @@ -355,12 +368,13 @@ void MapEditor::makeTmpDirs() { // Create unique temporary directories - tmpMapDir=tmpVymDir+QString("/mapeditor-%1").arg(mapNum); + tmpMapDir=QDir::convertSeparators (tmpVymDir+QString("/mapeditor-%1").arg(mapNum)); + histPath=QDir::convertSeparators (tmpMapDir+"/history"); QDir d; d.mkdir (tmpMapDir,true); } -QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection) +QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSel) { // tmpdir temporary directory to which data will be written // prefix mapname, which will be appended to images etc. @@ -392,7 +406,7 @@ colhint=attribut("linkColorHint","HeadingColor"); QString mapAttr=attribut("version",__VYM_VERSION); - if (!saveSelection) + if (!saveSel) mapAttr+= attribut("author",mapCenter->getAuthor()) + attribut("comment",mapCenter->getComment()) + attribut("date",mapCenter->getDate()) + @@ -412,25 +426,28 @@ FloatImageObj (mapCanvas).resetSaveCounter(); // Build xml recursivly - if (!saveSelection) + if (!saveSel) + // Save complete map, if saveSel not set s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset); else { - if ( typeid(*saveSelection) == typeid(BranchObj) ) - s+=((BranchObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset); - else if ( typeid(*saveSelection) == typeid(FloatImageObj) ) - s+=((FloatImageObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset); + if ( typeid(*saveSel) == typeid(BranchObj) ) + // Save Subtree + s+=((BranchObj*)(saveSel))->saveToDir(tmpdir,prefix,offset); + else if ( typeid(*saveSel) == typeid(FloatImageObj) ) + // Save image + s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix,offset); else if (selection && typeid(*selection)==typeid(BranchObj)) - // This is used if selected branch is saved from mainwindow - s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset); + // Save selected branch is saved from mainwindow //FIXME maybe use "subtree" above? + s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset); } // Save local settings s+=settings.getXMLData (destPath); // Save selection - if (selection && !saveSelection ) + if (selection && !saveSel ) s+=valueElement("select",selection->getSelectString()); decIndent(); @@ -441,60 +458,112 @@ return s; } -void MapEditor::saveState(const QString &comment) +void MapEditor::saveStateComplete(const QString &comment) { - // Save complete map - saveState (CompleteMap,"",NULL,"",NULL, comment); + // Save complete map, Undo will replace whole map + saveState (CompleteMap, + "", "", + "", "", + comment, + mapCenter); } -void MapEditor::saveState(LinkableMapObj *undoSel, const QString &comment) +void MapEditor::saveStatePart(LinkableMapObj *undoSel, const QString &comment) { - // save the given part of the map - saveState (PartOfMap,"",undoSel,"",NULL, comment); + // save the selected part of the map, Undo will replace part of map + QString undoSelection=""; + if (undoSel) undoSelection=undoSel->getSelectString(); + + saveState (PartOfMap, + undoSelection, "", + "", "", + comment, + undoSel); } -void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment) +void MapEditor::saveStateConstSelection(const QString &uc, const QString &rc, const QString &comment) { // selection does not change during action, // so just save commands for undo and redo - LinkableMapObj *unsel; - if (selection) - unsel=selection; - else - unsel=NULL; - saveState (UndoCommand,uc,unsel,rc,unsel, comment); + // and use current selection + + QString sel; + if (selection) sel=selection->getSelectString(); + + saveState (UndoCommand, + sel, uc, + sel, rc, + comment, + NULL); } -void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel, const QString &comment) +void MapEditor::saveStateComData(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment, LinkableMapObj *saveSel) { - saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment); + QString redoSelection=""; + if (redoSel) redoSelection=redoSel->getSelectString(); + QString undoSelection=""; + if (undoSel) undoSelection=undoSel->getSelectString(); + + saveState (UndoCommand, + undoSelection, uc, + redoSelection, "FIXME-redoCom", //FIXME + comment, + saveSel); } -void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel, const QString &comment) +void MapEditor::saveState(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment) +{ + // "Normal" savestate: save commands, selections and comment + // so just save commands for undo and redo + // and use current selection + + QString redoSelection=""; + if (redoSel) redoSelection=redoSel->getSelectString(); + QString undoSelection=""; + if (undoSel) undoSelection=undoSel->getSelectString(); + + saveState (UndoCommand, + undoSelection, uc, + redoSelection, rc, + comment, + NULL); +} + +void MapEditor::saveState(const QString &undoSel, const QString &uc, const QString &redoSel, const QString &rc, const QString &comment) +{ + // "Normal" savestate: save commands, selections and comment + // so just save commands for undo and redo + // and use current selection + saveState (UndoCommand, + undoSel, uc, + redoSel, rc, + comment, + NULL); +} + + +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 - cout << "ME::saveState() begin\n"<append (comment); setChanged(); + int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0); + int curStep=undoSet.readNumEntry ("/history/curStep",0); // Find out current undo directory if (undosAvailundosTotal) undoNum=1; + curStep++; + if (curStep>undosTotal) curStep=1; QString backupXML; - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum)); + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml"); // Create bakMapDir if not available @@ -502,59 +571,50 @@ if (!d.exists()) makeSubDirs (bakMapDir); - // Save current selection - QString redoSelection=""; - if (redoSel) - redoSelection=redoSel->getSelectString(); - - // Save the object, which should be undone - QString undoSelection=""; - if (undoSel) - undoSelection=undoSel->getSelectString(); + // Save depending on how much needs to be saved + if (!saveSel) + backupXML=""; + else + backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),saveSel); - // Save depending on how much needs to be saved QString undoCommand=""; if (savemode==UndoCommand) { undoCommand=undoCom; - backupXML=""; } - else if (savemode==PartOfMap && undoSel) + else if (savemode==PartOfMap ) { undoCommand="undoPart (\""+ undoSelection+"\",\""+bakMapPath+"\")"; - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel); } else { undoCommand="undoMap (\""+bakMapPath+"\")"; - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL); - undoSelection=""; } if (!backupXML.isEmpty()) // Write XML Data to disk saveStringToDisk (QString(bakMapPath),backupXML); - SimpleSettings set; - set.setEntry (QString("undoCommand"),undoCommand); - set.setEntry (QString("undoSelection"),undoSelection); - set.setEntry (QString("redoCommand"),redoCom); - set.setEntry (QString("redoSelection"),redoSelection); - set.setEntry (QString("comment"),comment); - set.writeSettings(QString(bakMapDir+"/commands")); + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); + 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.writeSettings(histPath); /* TODO remove after testing - cout << " into="<< bakMapDir<findObjBySelect (s); if (dst) @@ -620,23 +711,56 @@ if (api.checkParamCount(1)) { s=api.parString (ok,0); - if (ok) setHeading (s); + if (ok) + setHeading (s); } } else if (com=="setURL") { if (api.checkParamCount(1)) { s=api.parString (ok,0); - if (ok) setURL(s); + if (ok) setURLInt(s); } } else if (com=="setVymLink") { if (api.checkParamCount(1)) { s=api.parString (ok,0); - if (ok) setVymLink(s); + if (ok) setVymLinkInt(s); } } + else if (com=="setFlag") + { + if (selection && typeid(*selection) == typeid(BranchObj) ) + { + if (api.checkParamCount(1) ) + { + s=api.parString(ok,0); + if (ok) + { + BranchObj* bo=(BranchObj*)selection; + bo->activateStandardFlag(s); + bo->updateFlagsToolbar(); + } + } + } + } + else if (com=="unsetFlag") + { + if (selection && typeid(*selection) == typeid(BranchObj) ) + { + if (api.checkParamCount(1) ) + { + s=api.parString(ok,0); + if (ok) + { + BranchObj* bo=(BranchObj*)selection; + bo->deactivateStandardFlag(s); + bo->updateFlagsToolbar(); + } + } + } + } // Internal commands, used for undo etc. else if (com==QString("undoMap")) { @@ -646,55 +770,32 @@ { if (api.checkParamCount(2)) { - s=api.parString (ok,0); - t=api.parString (ok,1); + s=api.parString (ok,0); // undo selection + t=api.parString (ok,1); // backup dir undoXML(s,t); } } else if (com=="select") + { if (api.checkParamCount(1)) { s=api.parString(ok,0); if (ok) select (s); } + } else { api.setError ("Unknown command in: "+atom); - cout << "ME::parse api should have error now...\n"; } // Any errors? if (api.error()) { - cout << "MapEditor::parseAtom: Error!\n"; - cout << " "<setFocus() - - if (editingBO!=NULL) - { - saveState("setHeading (\""+editingBO->getHeading()+"\")",editingBO, QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(lineedit->text()) ); - editingBO->setHeading(lineedit->text() ); - editingBO=NULL; - lineedit->releaseKeyboard(); - lineedit->hide(); - parentWidget()->setFocus(); - mapCenter->reposition(); - adjustCanvasSize(); - ensureSelectionVisible(); - } -} - void MapEditor::toggleHistoryWindow() { if (historyWindow->isVisible()) @@ -731,9 +832,6 @@ void MapEditor::closeMap() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - // Unselect before disabling the toolbar actions if (selection) selection->unselect(); selection=NULL; @@ -799,9 +897,6 @@ ErrorCode MapEditor::load (QString fname, LoadMode lmode) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - ErrorCode err=success; if (lmode==NewMap) @@ -813,7 +908,7 @@ // (map state is set later at end of load...) } else { - saveState(selection,"Load map"); + saveStatePart(selection,"Load map"); } @@ -868,9 +963,6 @@ int MapEditor::save (const SaveMode &savemode) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - int returnCode=0; // The SaveMode UndoCommand is not supported here @@ -918,14 +1010,11 @@ void MapEditor::print() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if ( !printer ) { printer = new QPrinter; printer->setColorMode (QPrinter::Color); - printer->setPrinterName (settings.readEntry("/vym/mainwindow/printerName",printer->printerName())); + printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString()); } QRect totalBBox=mapCenter->getTotalBBox(); @@ -962,15 +1051,15 @@ // e.g. (0,50,700,700) is upper part on A4 // see also /usr/lib/qt3/doc/html/coordsys.html - QPaintDeviceMetrics metrics (printer); + Q3PaintDeviceMetrics metrics (printer); double paperAspect = (double)metrics.width() / (double)metrics.height(); double mapAspect = (double)totalBBox.width() / (double)totalBBox.height(); QRect mapRect=totalBBox; - QCanvasRectangle *frame=NULL; - QCanvasText *footerFN=NULL; - QCanvasText *footerDate=NULL; + Q3CanvasRectangle *frame=NULL; + Q3CanvasText *footerFN=NULL; + Q3CanvasText *footerDate=NULL; if (printFrame || printFooter) { @@ -979,9 +1068,9 @@ // Print frame around map mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10, totalBBox.width()+20, totalBBox.height()+20); - frame=new QCanvasRectangle (mapRect,mapCanvas); - frame->setBrush (QColor(white)); - frame->setPen (QColor(black)); + frame=new Q3CanvasRectangle (mapRect,mapCanvas); + frame->setBrush (QColor(Qt::white)); + frame->setPen (QColor(Qt::black)); frame->setZ(0); frame->show(); } @@ -998,13 +1087,13 @@ // Print footer below map QFont font; font.setPointSize(10); - footerFN=new QCanvasText (mapCanvas); + footerFN=new Q3CanvasText (mapCanvas); footerFN->setText ("VYM - " + fileName); footerFN->setFont(font); footerFN->move (mapRect.x(), mapRect.y() + mapRect.height() ); footerFN->setZ(Z_TEXT); footerFN->show(); - footerDate=new QCanvasText (mapCanvas); + footerDate=new Q3CanvasText (mapCanvas); footerDate->setText (QDate::currentDate().toString(Qt::TextDate)); footerDate->setFont(font); footerDate->move (mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() ); @@ -1045,7 +1134,7 @@ } // Save settings in vymrc - settings.writeEntry("/vym/mainwindow/printerName",printer->printerName()); + settings.writeEntry("/mainwindow/printerName",printer->printerName()); } } @@ -1094,9 +1183,6 @@ void MapEditor::exportImage(QString fn) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - setExportMode (true); QPixmap pix (getPixmap()); pix.save(fn, "PNG"); @@ -1107,20 +1193,17 @@ { // should be called before and after exports // depending on the settings - if (b && settings.readEntry("/vym/export/useHideExport","yes")) + if (b && settings.value("/export/useHideExport","yes")=="yes") setHideTmpMode (HideExport); else setHideTmpMode (HideNone); } -void MapEditor::exportImage(QString fn, int item) +void MapEditor::exportImage(QString fn, QString format) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - setExportMode (true); QPixmap pix (getPixmap()); - pix.save(fn, exportImageFormatMenu->text(item) ); + pix.save(fn, format); setExportMode (false); } @@ -1152,7 +1235,7 @@ QFile file; file.setName ( dir + "/"+mapName+".xml"); - if ( !file.open( IO_WriteOnly ) ) + if ( !file.open( QIODevice::WriteOnly ) ) { // This should neverever happen QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name())); @@ -1184,9 +1267,6 @@ void MapEditor::copy() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { // write to directory @@ -1195,7 +1275,7 @@ QFile file; file.setName ( clipboardDir + "/"+clipfile+".xml"); - if ( !file.open( IO_WriteOnly ) ) + if ( !file.open( QIODevice::WriteOnly ) ) { // This should neverever happen QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name())); @@ -1215,124 +1295,126 @@ void MapEditor::redo() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - blockSaveState=true; + // Restore variables + int curStep=undoSet.readNumEntry (QString("/history/curStep")); + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); + int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail")); + if (redosAvail>0) redosAvail--; + if (undosAvailundosTotal) curStep=1; + QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep)); + QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep)); + QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep)); + QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep)); + QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep)); + // Find out current undo directory - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum)); - - // Restore variables - QString undoCommand; - QString undoSelection; - QString redoCommand; - QString redoSelection; - SimpleSettings set; - set.readSettings(QString(bakMapDir+"/commands")); - undoCommand=set.readEntry ("undoCommand"); - undoSelection=set.readEntry ("undoSelection"); - redoCommand=set.readEntry ("redoCommand"); - redoSelection=set.readEntry ("redoSelection"); + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); + +/* TODO remove testing +*/ + cout << "ME::redo() begin\n"; + cout << " undosAvail="<reposition(); + + blockSaveState=false; + + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); + undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail)); + undoSet.setEntry ("/history/curStep",QString::number(curStep)); + undoSet.writeSettings(histPath); + + updateActions(); + + /* TODO remove testing */ - parseAtom (undoCommand); - mapCenter->reposition(); - - //if (!redoSelection.isEmpty()) - // select (redoSelection); - - undosAvail--; - if (undosAvail<1) - // Undo not longer available now - actionEditUndo->setEnabled (false); - else - undoNum--; if (undoNum<1) undoNum=undosTotal; - - blockSaveState=false; -/* TODO remove testing cout << "ME::redo() end\n"; cout << " undosAvail="<reposition(); - //if (!redoSelection.isEmpty()) - // select (redoSelection); - undosAvail--; - if (undosAvail<1) - // Undo not longer available now - actionEditUndo->setEnabled (false); - else - undoNum--; if (undoNum<1) undoNum=undosTotal; + curStep--; + if (curStep<1) curStep=undosTotal; + + redosAvail++; blockSaveState=false; /* TODO remove testing +*/ cout << "ME::undo() end\n"; cout << " undosAvail="<reposition(); adjustCanvasSize(); @@ -1409,7 +1488,7 @@ void MapEditor::cut() { - saveState(selection->getParObj(),QString("Cut %1").arg(getName(selection))); + saveStatePart(selection->getParObj(),QString("Cut %1").arg(getName(selection))); copy(); cutNoSave(); mapCenter->reposition(); @@ -1418,17 +1497,39 @@ void MapEditor::move(const int &x, const int &y) { - // TODO no saveState, because this is only internal at undo so far - if (selection) selection->move(x,y); - if (typeid(*selection) == typeid(FloatImageObj)) - ((FloatImageObj*)selection)->setRelPos(); + if (selection) + { + QString ps=qpointToString (selection->getAbsPos()); + QString s=selection->getSelectString(); + saveState( + s, "move "+ps, + s, "move "+qpointToString (QPoint (x,y)), + QString("Move %1 to %2").arg(getName(selection)).arg(ps)); + selection->move(x,y); + mapCenter->reposition(); + adjustCanvasSize(); + } + +} + +void MapEditor::moveRel (const int &x, const int &y) +{ + if (selection) + { + QString ps=qpointToString (selection->getRelPos()); + QString s=selection->getSelectString(); + saveState( + s, "moveRel "+ps, + s, "moveRel "+qpointToString (QPoint (x,y)), + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps)); + selection->setRelPos (QPoint(x,y)); + mapCenter->reposition(); + adjustCanvasSize(); + } } void MapEditor::moveBranchUp() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (typeid(*selection) == typeid(BranchObj) ) @@ -1437,9 +1538,9 @@ if (!bo->canMoveBranchUp()) return; par=(BranchObj*)(bo->getParObj()); selection->unselect(); - selection=par->moveBranchUp (bo); + bo=par->moveBranchUp (bo); // bo will be the one below selection selection->select(); - saveState("moveBranchDown ()",bo,QString("Move up %1").arg(getName(bo))); + saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo))); mapCenter->reposition(); ensureSelectionVisible(); } @@ -1447,9 +1548,6 @@ void MapEditor::moveBranchDown() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (typeid(*selection) == typeid(BranchObj) ) @@ -1458,54 +1556,51 @@ if (!bo->canMoveBranchDown()) return; par=(BranchObj*)(bo->getParObj()); selection->unselect(); - selection=par->moveBranchDown(bo); + bo=par->moveBranchDown(bo); // bo will be the one above selection selection->select(); - saveState("moveBranchUp ()",bo,QString("Move down %1").arg(getName(bo))); + saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo))); mapCenter->reposition(); ensureSelectionVisible(); } } -void MapEditor::editHeading() +QString MapEditor::getHeading(bool &ok, QPoint &p) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + ok=true; + ensureSelectionVisible(); + p = ((BranchObj*)selection)->getAbsPos(); + p.setX (p.x() - contentsX()); + p.setY (p.y() - contentsY() + ((BranchObj*)selection)->height()/2); + return ((BranchObj*)selection)->getHeading(); + } + ok=false; + return QString(); +} + +void MapEditor::setHeading(const QString &s) +{ if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { editingBO=(BranchObj*)selection; - - ensureSelectionVisible(); - QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y())); - lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25); - QString s=editingBO->getHeading(); - lineedit->setText(s); - lineedit->setCursorPosition(1); - if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() ) - lineedit->selectAll(); - lineedit->show(); - lineedit->grabKeyboard(); - lineedit->setFocus(); - } -} - -void MapEditor::setHeading(const QString &s) -{ - // Internal function, no saveState needed - if (selection && - (typeid(*selection) == typeid(BranchObj) || - typeid(*selection) == typeid(MapCenterObj) ) ) - { - ((BranchObj*)selection)->setHeading(s); + saveStateConstSelection( + "setHeading (\""+editingBO->getHeading()+"\")", + "setHeading (\""+s+"\")", + QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(s) ); + editingBO->setHeading(s ); + editingBO=NULL; mapCenter->reposition(); adjustCanvasSize(); ensureSelectionVisible(); } } -void MapEditor::setURL (const QString &s) +void MapEditor::setURLInt (const QString &s) { // Internal function, no saveState needed if (selection && @@ -1519,7 +1614,20 @@ } } -void MapEditor::setVymLink (const QString &s) +void MapEditor::setHeadingInt(const QString &s) +{ + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + ((BranchObj*)selection)->setHeading(s); + mapCenter->reposition(); + adjustCanvasSize(); + ensureSelectionVisible(); + } +} + +void MapEditor::setVymLinkInt (const QString &s) { // Internal function, no saveState needed if (selection && @@ -1533,44 +1641,107 @@ } } -void MapEditor::addNewBranch(int pos) +BranchObj* MapEditor::addNewBranchInt(int num) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - + // Depending on pos: + // -3 insert in childs of parent above selection + // -2 add branch to selection + // -1 insert in childs of parent below selection + // 0..n insert in childs of parent at pos + BranchObj *newbo=NULL; if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { - BranchObj* bo1 = (BranchObj*) selection; - saveState(selection, QString("Add new branch to %1").arg(getName(bo1))); //TODO undoCommand - - bool wasScrolled=false; - BranchObj *newbo=NULL; - if (pos==0) + BranchObj* bo = (BranchObj*) selection; + if (num==-2) { // save scroll state. If scrolled, automatically select // new branch in order to tmp unscroll parent... - wasScrolled=bo1->isScrolled(); - newbo=bo1->addBranch(); - } else + return bo->addBranch(); + + }else if (num==-1) { - BranchObj *parbo=(BranchObj*)(selection->getParObj()); - if (parbo) + num=bo->getNum()+1; + bo=(BranchObj*)bo->getParObj(); + }else if (num==-3) + { + num=bo->getNum(); + bo=(BranchObj*)bo->getParObj(); + } + if (!bo) return bo; + newbo=bo->insertBranch(num); + } + return newbo; +} + +void MapEditor::addNewBranch(int pos) +{ + // Different meaning than num in addNewBranchInt! + // -1 add above + // 0 add as child + // +1 add below + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + BranchObj *bo = (BranchObj*) selection; + BranchObj *newbo; + newbo=addNewBranchInt (pos-2); + + if (newbo) + { + saveStateConstSelection ( + QString ("delete (\"%1\")").arg(newbo->getSelectString()), + QString ("addBranch (%1)").arg(pos-2), + QString ("Add new branch to %1").arg(getName(bo))); //TODO undoCommand + + LinkableMapObj *oldselection=selection; + + mapCenter->reposition(); + adjustCanvasSize(); + + + if (actionSettingsAutoedit->isOn() || + actionSettingsAutoselectHeading->isOn() ) { - if (pos<0) - // add above selection - newbo=parbo->insertBranch(bo1->getNum()); - else - // add below selection - newbo=parbo->insertBranch(bo1->getNum()+1); - } else - // This should not happen... - return; - - } + selection->unselect(); + selection=newbo; + selection->select(); + if (actionSettingsAutoedit->isOn() ) + mainWindow->editHeading(); + if (!actionSettingsAutoselectHeading->isOn() + )//&& !wasScrolled) //FIXME wasScrolled was moved to addNewBranchInt + { + selection->unselect(); + selection=oldselection; + selection->select(); + } + } + } + } +} + + +void MapEditor::addNewBranchHere() +{ + if (selection && + (typeid(*selection) == typeid(BranchObj) ) ) + { + BranchObj* bo1 = (BranchObj*) selection; + saveStatePart(selection, QString("Add new branch here").arg(getName(bo1))); + + bool wasScrolled=false; + BranchObj *newbo=NULL; + BranchObj *parbo=(BranchObj*)(selection->getParObj()); + if (parbo) + { + // add below selection + newbo=parbo->insertBranch(bo1->getNum()+1); + } LinkableMapObj *oldselection=selection; + ((BranchObj*)selection)->moveBranchTo (newbo,-1); mapCenter->reposition(); adjustCanvasSize(); @@ -1580,13 +1751,8 @@ selection->unselect(); selection=newbo; selection->select(); - if (actionSettingsPasteNewHeading->isOn() ) - { - BranchObj *bo2= (BranchObj*)selection; - bo2->setHeading(""); - } if (actionSettingsAutoedit->isOn() ) - editHeading(); + mainWindow->editHeading(); if (!actionSettingsAutoselectHeading->isOn() && !wasScrolled) { @@ -1598,74 +1764,22 @@ } } - -void MapEditor::addNewBranchHere() -{ - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - - if (selection && - (typeid(*selection) == typeid(BranchObj) ) ) - { - BranchObj* bo1 = (BranchObj*) selection; - saveState(selection, QString("Add new branch here").arg(getName(bo1))); - - bool wasScrolled=false; - BranchObj *newbo=NULL; - BranchObj *parbo=(BranchObj*)(selection->getParObj()); - if (parbo) - { - // add below selection - newbo=parbo->insertBranch(bo1->getNum()+1); - } - - LinkableMapObj *oldselection=selection; - ((BranchObj*)selection)->moveBranchTo (newbo,-1); - - mapCenter->reposition(); - adjustCanvasSize(); - if (actionSettingsAutoedit->isOn() || - actionSettingsAutoselectHeading->isOn() ) - { - selection->unselect(); - selection=newbo; - selection->select(); - if (actionSettingsPasteNewHeading->isOn() ) - { - BranchObj *bo2= (BranchObj*)selection; - bo2->setHeading(""); - } - if (actionSettingsAutoedit->isOn() ) - editHeading(); - if (!actionSettingsAutoselectHeading->isOn() - && !wasScrolled) - { - selection->unselect(); - selection=oldselection; - selection->select(); - } - } - } -} - void MapEditor::deleteSelection() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection && typeid(*selection) ==typeid(BranchObj) ) { - BranchObj* bo=dynamic_cast (selection); + BranchObj* bo=(BranchObj*)selection; BranchObj* par=(BranchObj*)(bo->getParObj()); bo->unselect(); if (selection->getDepth()>1) // Normal branch, save parent with childs - saveState(par,QString("Delete %1").arg(getName(bo))); + saveStatePart(par,QString("Delete %1").arg(getName(bo))); + // naveState (UndoCom, par, QString("insertBranchAt (%1)", bo, "", QString ("Delete %1").arg(getName(bo)))); else // Mainbranch, save whole map // TODO Better would be to insert mainbranch again at pos // But undoCommand is missing right now - saveState(QString("Delete %1").arg(getName(bo))); + saveStateComplete(QString("Delete %1").arg(getName(bo))); selection=NULL; par->removeBranch(bo); selection=par; @@ -1676,9 +1790,9 @@ } if (selection && typeid(*selection) ==typeid(FloatImageObj) ) { - FloatImageObj* fio=dynamic_cast (selection); + FloatImageObj* fio=(FloatImageObj*)selection; BranchObj* par=(BranchObj*)(fio->getParObj()); - saveState(par, QString("Delete %1").arg(getName(fio))); + saveStatePart(par, QString("Delete %1").arg(getName(fio))); fio->unselect(); selection=NULL; par->removeFloatImage(fio); @@ -1732,7 +1846,13 @@ return false; } -void MapEditor::select (LinkableMapObj *lmo) +QString MapEditor::getSelectString() +{ + if (selection) return selection->getSelectString(); + return QString(); +} + +void MapEditor::selectInt (LinkableMapObj *lmo) { if (lmo && selection != lmo) { @@ -1743,10 +1863,9 @@ adjustCanvasSize(); } - } -void MapEditor::selectNextBranch() +void MapEditor::selectNextBranchInt() { // Increase number of branch if (selection) @@ -1826,7 +1945,7 @@ } } -void MapEditor::selectPrevBranch() +void MapEditor::selectPrevBranchInt() { // Decrease number of branch if (selection) @@ -1907,40 +2026,34 @@ void MapEditor::selectUpperBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { if (typeid(*selection) == typeid(BranchObj)) { if (selection->getOrientation()==OrientRightOfCenter) - selectPrevBranch(); + selectPrevBranchInt(); else if (selection->getDepth()==1) - selectNextBranch(); + selectNextBranchInt(); else - selectPrevBranch(); + selectPrevBranchInt(); } } } void MapEditor::selectLowerBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { if (typeid(*selection) == typeid(BranchObj)) { if (selection->getOrientation()==OrientRightOfCenter) - selectNextBranch(); + selectNextBranchInt(); else if (selection->getDepth()==1) - selectPrevBranch(); + selectPrevBranchInt(); else - selectNextBranch(); + selectNextBranchInt(); } } } @@ -1948,9 +2061,6 @@ void MapEditor::selectLeftBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (selection) @@ -2010,9 +2120,6 @@ void MapEditor::selectRightBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; @@ -2024,7 +2131,7 @@ bo=par->getLastSelectedBranch(); if (bo) { - // Workaround for relecting on left and right side + // Workaround for reselecting on left and right side if (bo->getOrientation()==OrientLeftOfCenter) bo=par->getFirstBranch(); if (bo) @@ -2070,9 +2177,6 @@ void MapEditor::selectFirstBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj *bo1; BranchObj *bo2; BranchObj* par; @@ -2095,9 +2199,6 @@ void MapEditor::selectLastBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj *bo1; BranchObj *bo2; BranchObj* par; @@ -2125,13 +2226,11 @@ void MapEditor::selectBackgroundColor() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this ); if ( !col.isValid() ) return; setBackgroundColor( col ); - saveState(QString("Set background color of map to %1").arg(col.name())); + //TODO undocomm + saveStateComplete(QString("Set background color of map to %1").arg(col.name())); } void MapEditor::setBackgroundColor(QColor c) @@ -2161,7 +2260,7 @@ typeid(*selection) == typeid(MapCenterObj)) { BranchObj *bo=(BranchObj*)selection; - saveState(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand + saveStatePart(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand bo->setColor(actColor); // color branch } } @@ -2175,7 +2274,7 @@ typeid(*selection) == typeid(MapCenterObj)) { BranchObj *bo=(BranchObj*)selection; - saveState(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand + saveStatePart(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand bo->setColorChilds(actColor); // color links, color childs } } @@ -2186,15 +2285,27 @@ { if (selection) { - BranchObj *bo=(BranchObj*)selection; - QString s; - if (bo->isSetStandardFlag(f)) - s="Unset"; - else - s="Set"; - saveState(selection, QString("%1 standard flag \"%2\" of %3").arg(s).arg(f).arg(getName(bo)));// TODO undoCommand - bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn()); - adjustCanvasSize(); + if (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj)) + { + BranchObj *bo=(BranchObj*)selection; + QString u,r; + if (bo->isSetStandardFlag(f)) + { + r="unsetFlag"; + u="setFlag"; + } + else + { + u="unsetFlag"; + r="setFlag"; + } + saveStateConstSelection(QString("%1 (\"%2\")").arg(u).arg(f), + QString("%1 (\"%2\")").arg(r).arg(f), + QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo))); + bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn()); + adjustCanvasSize(); + } } } @@ -2208,6 +2319,9 @@ BranchObj* MapEditor::findText (QString s, bool cs) { + QTextDocument::FindFlags flags=0; + if (cs) flags=QTextDocument::FindCaseSensitively; + if (!itFind) { // Nothing found or new find process if (EOFind) @@ -2232,7 +2346,7 @@ adjustCanvasSize(); ensureSelectionVisible(); } - if (textEditor->findText(s,cs)) + if (textEditor->findText(s,flags)) { searching=false; foundNote=true; @@ -2282,7 +2396,7 @@ if ( ok) { // user entered something and pressed OK - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text)); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text)); bo->setURL (text); updateActions(); } @@ -2298,13 +2412,31 @@ return ""; } +QStringList MapEditor::getURLs() +{ + QStringList urls; + if (selection && (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj)) ) + { + BranchObj *bo=(BranchObj*)selection; + bo=bo->first(); + while (bo) + { + if (!bo->getURL().isEmpty()) urls.append( bo->getURL()); + bo=bo->next(); + } + } + return urls; +} + + void MapEditor::editHeading2URL() { if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo))); bo->setURL (bo->getHeading()); updateActions(); } @@ -2317,7 +2449,7 @@ { BranchObj *bo=(BranchObj*)selection; QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading(); - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo))); bo->setURL (url); updateActions(); } @@ -2330,7 +2462,7 @@ { BranchObj *bo=(BranchObj*)selection; QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading(); - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo))); bo->setURL (url); updateActions(); } @@ -2342,7 +2474,7 @@ typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - QFileDialog *fd=new QFileDialog( this,__VYM " - " +tr("Link to another map")); + Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Link to another map")); fd->addFilter (QString (tr("vym map") + " (*.vym)")); fd->setCaption(__VYM " - " +tr("Link to another map")); if (! bo->getVymLink().isEmpty() ) @@ -2352,7 +2484,7 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())); + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())); bo->setVymLink (fd->selectedFile() ); updateActions(); mapCenter->reposition(); @@ -2368,7 +2500,7 @@ typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo))); + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo))); bo->setVymLink ("" ); updateActions(); mapCenter->reposition(); @@ -2396,7 +2528,7 @@ oo->setHideInExport(true); s="Set"; } - saveState(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand + saveStateComplete(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand actionEditToggleHideExport->setOn (oo->hideInExport()); updateActions(); mapCenter->reposition(); @@ -2416,6 +2548,24 @@ } +QStringList MapEditor::getVymLinks() +{ + QStringList links; + if (selection && (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj)) ) + { + BranchObj *bo=(BranchObj*)selection; + bo=bo->first(); + while (bo) + { + if (!bo->getVymLink().isEmpty()) links.append( bo->getVymLink()); + bo=bo->next(); + } + } + return links; +} + + void MapEditor::removeBranchKeepChilds() { if (selection && (typeid(*selection) == typeid(BranchObj) )) @@ -2424,9 +2574,9 @@ BranchObj* par=(BranchObj*)(bo->getParObj()); QString s=QString("Remove %1 and keep its childs").arg(getName(bo)); if (bo->getDepth()==1) - saveState(s); + saveStateComplete(s); else - saveState(selection->getParObj(),s); // TODO undoCommand + saveStatePart(selection->getParObj(),s); // TODO undoCommand QString sel=selection->getSelectString(); unselect(); par->removeBranchHere(bo); @@ -2439,7 +2589,7 @@ { if (selection && (typeid(*selection) == typeid(BranchObj) )) { - saveState(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection))); + saveStatePart(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection))); ((BranchObj*)selection)->removeChilds(); mapCenter->reposition(); } @@ -2455,8 +2605,8 @@ // Calc some stats QString stats; int i=0; - QCanvasItemList l=canvas()->allItems(); - for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) + Q3CanvasItemList l=canvas()->allItems(); + for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) i++; stats+=QString ("%1 items on canvas\n").arg (i,6); @@ -2483,7 +2633,7 @@ // Finally show dialog if (dia.exec() == QDialog::Accepted) { - saveState("Edit info about map"); //TODO undoCommand + saveStateComplete("Edit info about map"); //TODO undoCommand mapCenter->setAuthor (dia.getAuthor() ); mapCenter->setComment (dia.getComment() ); } @@ -2521,8 +2671,16 @@ pix.fill( defLinkColor ); actionFormatLinkColor->setIconSet( pix ); - actionEditUndo->setEnabled( mapChanged ); actionFileSave->setEnabled( mapUnsaved ); + if (undoSet.readNumEntry("/history/undosAvail",0)>0) + actionEditUndo->setEnabled( true); + else + actionEditUndo->setEnabled( false); + + if (undoSet.readNumEntry("/history/redosAvail",0)>0) + actionEditRedo->setEnabled( true); + else + actionEditRedo->setEnabled( false); if (selection) { @@ -2533,17 +2691,14 @@ // Take care of links if (bo->countXLinks()==0) { - branchLinksContextMenu->clear(); - branchLinksContextMenu->insertItem ("No xLink available"); - branchLinksContextMenuDup->clear(); - branchLinksContextMenuDup->insertItem ("No xLink available"); - + branchXLinksContextMenuEdit->clear(); + branchXLinksContextMenuFollow->clear(); } else { BranchObj *bot; QString s; - branchLinksContextMenu->clear(); - branchLinksContextMenuDup->clear(); + branchXLinksContextMenuEdit->clear(); + branchXLinksContextMenuFollow->clear(); for (int i=0; i<=bo->countXLinks();i++) { bot=bo->XLinkTargetAt(i); @@ -2552,8 +2707,8 @@ s=bot->getHeading(); if (s.length()>25) s=s.left(25)+"..."; - branchLinksContextMenu->insertItem (s); - branchLinksContextMenuDup->insertItem (s); + branchXLinksContextMenuFollow->addAction (s); + branchXLinksContextMenuEdit->addAction (s); } } } @@ -2629,7 +2784,7 @@ if ( (typeid(*selection) == typeid(FloatImageObj)) ) { FloatObj *fo=(FloatImageObj*)selection; - standardFlagsDefault->setEnabled (false); +//FIXME do this in mainwindow standardFlagsDefault->setEnabled (false); actionEditOpenURL->setEnabled (false); actionEditOpenVymLink->setEnabled (false); @@ -2652,7 +2807,7 @@ } else { - standardFlagsDefault->setEnabled (false); +//FIXME do this in mainwindow standardFlagsDefault->setEnabled (false); actionEditCopy->setEnabled (false); actionEditCut->setEnabled (false); @@ -2684,7 +2839,7 @@ { linkstyle=ls; - saveState("Set link style"); // TODO undoCommand + saveStateComplete("Set link style"); // TODO undoCommand BranchObj *bo; bo=mapCenter->first(); bo=bo->next(); @@ -2772,13 +2927,10 @@ void MapEditor::selectLinkColor() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QColor col = QColorDialog::getColor( defLinkColor, this ); if ( !col.isValid() ) return; setLinkColor( col ); - saveState(QString("Set link color to %1").arg(col.name())); //TODO undoCommand + saveStateComplete(QString("Set link color to %1").arg(col.name())); //TODO undoCommand } @@ -2794,7 +2946,7 @@ s="Unscroll"; else s="Scroll"; - saveState(selection, QString ("%1 %2").arg(s).arg(getName(bo))); + saveStatePart(selection, QString ("%1 %2").arg(s).arg(getName(bo))); bo->toggleScroll(); adjustCanvasSize(); canvas()->update(); @@ -2820,13 +2972,13 @@ { BranchObj *bo=((BranchObj*)selection); - QFileDialog *fd=new QFileDialog( this); - fd->setMode (QFileDialog::ExistingFiles); + Q3FileDialog *fd=new Q3FileDialog( this); + fd->setMode (Q3FileDialog::ExistingFiles); fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)")); ImagePreview *p =new ImagePreview (fd); fd->setContentsPreviewEnabled( TRUE ); fd->setContentsPreview( p, p ); - fd->setPreviewMode( QFileDialog::Contents ); + fd->setPreviewMode( Q3FileDialog::Contents ); fd->setCaption(__VYM " - " +tr("Load image")); fd->setDir (lastImageDir); fd->show(); @@ -2834,8 +2986,9 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - saveState(selection, QString("Add floatimage to %1").arg(getName(selection))); - lastImageDir=fn.left(fn.findRev ("/")); + saveStatePart(selection, QString("Add floatimage to %1").arg(getName(selection))); + // FIXME in QT4 use: lastImageDir=fd->directory(); + lastImageDir=QDir (fd->dirPath()); QStringList flist = fd->selectedFiles(); QStringList::Iterator it = flist.begin(); while( it != flist.end() ) @@ -2857,26 +3010,18 @@ } } -void MapEditor::saveFloatImage (int item) +void MapEditor::saveFloatImage () { if (selection && (typeid(*selection) == typeid(FloatImageObj)) ) { FloatImageObj *fio=((FloatImageObj*)selection); - const char* fmt = saveImageFormatMenu->text(item); - - QFileDialog *fd=new QFileDialog( this, tr("vym - save image as") + fmt); - fd->addFilter ("PNG (*.png)"); - fd->addFilter ("BMP (*.bmp)"); - fd->addFilter ("XBM (*.xbm)"); - fd->addFilter ("JPG (*.jpg)"); - fd->addFilter ("XPM (*.xpm)"); - fd->addFilter ("GIF (*.gif)"); - fd->addFilter ("PNM (*.pnm)"); - fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)")); - fd->setCaption(__VYM " - " +tr("Save image as %1").arg(fmt)); - fd->setMode( QFileDialog::AnyFile ); - fd->setSelection (fio->getOriginalFilename()); + QFileDialog *fd=new QFileDialog( this); + fd->setFilters (imageIO.getFilters()); + fd->setCaption(__VYM " - " +tr("Save image")); + fd->setFileMode( QFileDialog::AnyFile ); + fd->setDirectory (lastImageDir); +// fd->setSelection (fio->getOriginalFilename()); fd->show(); QString fn; @@ -2905,7 +3050,7 @@ break; } } - fio->save (fd->selectedFile(),fmt); + fio->save (fd->selectedFile(),imageIO.getType (fd->selectedFilter() ) ); } } } @@ -2949,7 +3094,7 @@ selection->setHideLinkUnselected(b); } -void MapEditor::importDir(BranchObj *dst, QDir d) +void MapEditor::importDirInt(BranchObj *dst, QDir d) { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -2959,45 +3104,42 @@ // Traverse directories d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks ); - const QFileInfoList *dirlist = d.entryInfoList(); - QFileInfoListIterator itdir( *dirlist ); - QFileInfo *fi; - - while ( (fi = itdir.current()) != 0 ) + QFileInfoList list = d.entryInfoList(); + QFileInfo fi; + + for (int i = 0; i < list.size(); ++i) { - if (fi->fileName() != "." && fi->fileName() != ".." ) + fi=list.at(i); + if (fi.fileName() != "." && fi.fileName() != ".." ) { dst->addBranch(); bo=dst->getLastBranch(); - bo->setHeading (fi->fileName() ); + bo->setHeading (fi.fileName() ); bo->setColor (QColor("blue")); bo->toggleScroll(); - if ( !d.cd(fi->fileName()) ) - QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi->fileName())); + if ( !d.cd(fi.fileName()) ) + QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi.fileName())); else { // Recursively add subdirs - importDir (bo,d); + importDirInt (bo,d); d.cdUp(); } } - ++itdir; } // Traverse files d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks ); - const QFileInfoList *filelist = d.entryInfoList(); - QFileInfoListIterator itfile( *filelist ); - - while ( (fi = itfile.current()) != 0 ) + list = d.entryInfoList(); + + for (int i = 0; i < list.size(); ++i) { + fi=list.at(i); dst->addBranch(); bo=dst->getLastBranch(); - bo->setHeading (fi->fileName() ); + bo->setHeading (fi.fileName() ); bo->setColor (QColor("black")); - if (fi->fileName().right(4) == ".vym" ) - bo->setVymLink (fi->filePath()); - - ++itfile; + if (fi.fileName().right(4) == ".vym" ) + bo->setVymLink (fi.filePath()); } } } @@ -3008,8 +3150,8 @@ (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj)) ) { - QFileDialog *fd=new QFileDialog( this,__VYM " - " +tr("Choose directory structure to import")); - fd->setMode (QFileDialog::DirectoryOnly); + Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Choose directory structure to import")); + fd->setMode (Q3FileDialog::DirectoryOnly); fd->addFilter (QString (tr("vym map") + " (*.vym)")); fd->setCaption(__VYM " - " +tr("Choose directory structure to import")); fd->show(); @@ -3018,7 +3160,7 @@ if ( fd->exec() == QDialog::Accepted ) { BranchObj *bo=((BranchObj*)selection); - importDir (bo,QDir(fd->selectedFile()) ); + importDirInt (bo,QDir(fd->selectedFile()) ); mapCenter->reposition(); adjustCanvasSize(); canvas()->update(); @@ -3045,6 +3187,7 @@ void MapEditor::editXLink(int i) { + qDebug ("ko."); //FIXME Huh? if (selection && (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj)) ) @@ -3064,7 +3207,7 @@ } if (dia.deleteXLink()) ((BranchObj*)selection)->deleteXLinkAt(i); - saveState("Edit xLink"); //TODO undoCommand + saveStateComplete("Edit xLink"); //TODO undoCommand } } } @@ -3074,33 +3217,44 @@ { cout << "MapEditor::testFunction() called\n"; - mapCenter->positionBBox(); +/* + bool ok; + QString text = QInputDialog::getText( + this, + tr("QInputDialog::getText()"), + tr("User name:"), QLineEdit::Normal, + QDir::home().dirName(), &ok, Qt::FramelessWindowHint); +*/ + + QDialog *d =new QDialog(NULL); + QLineEdit *le=new QLineEdit (d); +// d->setModal (true); + d->setWindowFlags (Qt::FramelessWindowHint); + le->setFocus(); + le->setText ("Foo"); + le->selectAll(); + connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); + d->exec(); + qWarning( le->text()); return; - + + + +/* WarningDialog dia; dia.setCancelButton (true); dia.setText("This is a longer \nWarning"); dia.setCaption("Warning: Flux problem"); - dia.setShowAgainName("/vym/warnings/mapeditor"); + dia.setShowAgainName("/warnings/mapeditor"); + dia.setWindowFlags (Qt::FramelessWindowHint); if (dia.exec()==QDialog::Accepted) cout << "accepted!\n"; else cout << "canceled!\n"; return; - - QString ub=vymBaseDir.path()+"/scripts/update-bookmarks"; - QProcess *proc = new QProcess( this ); - proc->addArgument(ub); - - if ( !proc->start() ) - { - QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub)); - } - - -/* +*/ + +/* Hide hidden stuff temporary, maybe add this as regular function somewhere if (hidemode==HideNone) { setHideTmpMode (HideExport); @@ -3199,15 +3353,12 @@ void MapEditor::contentsMousePressEvent(QMouseEvent* e) { // Ignore right clicks, these will go to context menus - if (e->button() == QMouseEvent::RightButton ) + if (e->button() == Qt::RightButton ) { e->ignore(); return; } - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QPoint p = inverseWorldMatrix().map(e->pos()); LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL); @@ -3222,10 +3373,10 @@ if (!foname.isEmpty()) { // systemFlag clicked - select (lmo); + selectInt (lmo); if (foname=="url") { - if (e->state() & QMouseEvent::ControlButton) + if (e->state() & Qt::ControlModifier) mainWindow->editOpenURLTab(); else mainWindow->editOpenURL(); @@ -3245,7 +3396,7 @@ // No system flag clicked, take care of modmodes // Special case: CTRL is pressed - if (e->state() & QMouseEvent::ControlButton) + if (e->state() & Qt::ControlModifier) { if (actionModModeColor->isOn()) { @@ -3280,19 +3431,20 @@ } if (lmo) { - select (lmo); + selectInt (lmo); // Left Button Move Branches - if (e->button() == QMouseEvent::LeftButton ) + if (e->button() == Qt::LeftButton ) { movingObj_start.setX( p.x() - selection->x() ); movingObj_start.setY( p.y() - selection->y() ); movingObj_orgPos.setX (lmo->x() ); movingObj_orgPos.setY (lmo->y() ); + movingObj_orgRelPos=lmo->getRelPos(); // If modMode==copy, then we want to "move" the _new_ object around // then we need the offset from p to the _old_ selection, because of tmp if (actionModModeCopy->isOn() && - e->state() & QMouseEvent::ControlButton) + e->state() & Qt::ControlModifier) { if (typeid(*selection)==typeid(BranchObj) ) { @@ -3309,13 +3461,13 @@ // Middle Button Toggle Scroll // (On Mac OS X this won't work, but we still have // a button in the toolbar) - if (e->button() == QMouseEvent::MidButton ) + if (e->button() == Qt::MidButton ) toggleScroll(); updateActions(); } else { // No MapObj found, we are on the Canvas itself // Left Button move Pos of CanvasView - if (e->button() == QMouseEvent::LeftButton ) + if (e->button() == Qt::LeftButton ) { movingObj=NULL; // move Content not Obj movingObj_start=e->globalPos(); @@ -3353,16 +3505,13 @@ if (typeid(*selection) == typeid(FloatImageObj)) { FloatObj *fo=(FloatObj*)selection; - saveState( - "move "+qpointToString(movingObj_orgPos),fo->getSelectString() , - QString("Move %1").arg(getName(selection))); fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); fo->setRelPos(); fo->reposition(); // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent - if ( (e->state() & QMouseEvent::ShiftButton) && lmo && + if ( (e->state() & Qt::ShiftModifier) && lmo && ( (typeid(*lmo)==typeid(BranchObj)) || (typeid(*lmo)==typeid(MapCenterObj)) ) && ( lmo != fo->getParObj()) @@ -3370,7 +3519,8 @@ { if (typeid(*fo) == typeid(FloatImageObj)) { - saveState(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) ); + //TODO undocom + saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) ); FloatImageObj *fio=(FloatImageObj*)(fo); ((BranchObj*)(lmo))->addFloatImage (fio); fio->unselect(); @@ -3387,7 +3537,7 @@ { if (lmosel->getDepth()==0) { - if (e->state() == (LeftButton | !ShiftButton)) + if (e->state() == Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) // If mapCenter is moved, move all the rest by default, too. mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); else @@ -3417,12 +3567,12 @@ (typeid(*lmo) == typeid(MapCenterObj) ) ) ) { - if (e->state() & QMouseEvent::ControlButton) + if (e->state() & Qt::ControlModifier) { // Special case: CTRL to link below lmo lmosel->setParObjTmp (lmo,p,+1); } - else if (e->state() & QMouseEvent::ShiftButton) + else if (e->state() & Qt::ShiftModifier) lmosel->setParObjTmp (lmo,p,-1); else lmosel->setParObjTmp (lmo,p,0); @@ -3466,12 +3616,12 @@ if (pickingColor) { pickingColor=false; - setCursor (ArrowCursor); + setCursor (Qt::ArrowCursor); // Check if we are over another branch dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL); if (dst && selection) { - if (e->state() & QMouseEvent::ShiftButton) + if (e->state() & Qt::ShiftModifier) { ((BranchObj*)selection)->setColor (((BranchObj*)(dst))->getColor()); ((BranchObj*)selection)->setLinkColor (); @@ -3496,7 +3646,7 @@ tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); tmpXLink->activate(); - saveState(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand + saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand } else { delete(tmpXLink); @@ -3511,6 +3661,14 @@ // Moved FloatObj? Maybe we need to reposition if(typeid(*selection)==typeid (FloatImageObj)) { + FloatImageObj *fo=(FloatImageObj*)selection; + QString pold=qpointToString(movingObj_orgRelPos); + QString pnow=qpointToString(fo->getRelPos()); + saveStateConstSelection( + "moveRel "+pold, + "moveRel "+pnow, + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow)); + selection->getParObj()->requestReposition(); mapCenter->reposition(); } @@ -3532,41 +3690,64 @@ // Reset the temporary drawn link to the original one ((LinkableMapObj*)selection)->unsetParObjTmp(); + // For Redo we may need to save original selection + QString preSelStr=selection->getSelectString(); copyingObj=false; if (dst ) { - BranchObj* bs=((BranchObj*)selection); + BranchObj* bsel=(BranchObj*)selection; + BranchObj* bdst=(BranchObj*)dst; + + QString preParStr=(bsel->getParObj())->getSelectString(); + QString preNum=QString::number (bsel->getNum(),10); + QString preDstParStr; + + if (e->state() & Qt::ShiftModifier && dst->getParObj()) + { // Link above dst + preDstParStr=dst->getParObj()->getSelectString(); + bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()); + } else + if (e->state() & Qt::ControlModifier && dst->getParObj()) + { + // Link below dst + preDstParStr=dst->getParObj()->getSelectString(); + bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()+1); + } else + { // Append to dst + preDstParStr=dst->getSelectString(); + bsel->moveBranchTo (bdst,-1); + if (dst->getDepth()==0) bsel->move (savePos); + } + QString postSelStr=selection->getSelectString(); + QString postNum=QString::number (bsel->getNum(),10); + QString undoCom="linkBranchToPos (\""+ - (bs->getParObj())->getSelectString()+ - "\","+ - QString("%1").arg(bs->getNum())+ - ","+ - QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ - ")"; - // TODO we also could check, if dest and src are on same branch, - // then it would be sufficient to saveState of this branch - - // Modifiers allow to insert above/below dst - if (e->state() & QMouseEvent::ShiftButton) - { - bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum()); - } else - if (e->state() & QMouseEvent::ControlButton) - { - bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum()+1); - } else - { - bs->moveBranchTo ((BranchObj*)(dst),-1); - if (dst->getDepth()==0) - bs->move (savePos); - } - saveState (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) ); + preParStr+ "\"," + preNum +"," + + QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")"; + + QString redoCom="linkBranchToPos (\""+ + preDstParStr + "\"," + postNum + "," + + QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")"; + + saveState ( + postSelStr,undoCom, + preSelStr, redoCom, + QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) ); } else if (selection->getDepth()==1) - // If we have moved mainbranch only save endposition - saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos))); + { + // The select string might be different _after_ moving around. + // Therefor reposition and then use string of old selection, too + mapCenter->reposition(); + + QString ps=qpointToString ( ((BranchObj*)selection)->getRelPos() ); + saveState( + selection->getSelectString(), "moveRel "+qpointToString(movingObj_orgRelPos), + preSelStr, "moveRel "+ps, + QString("Move %1 to relative position %2").arg(getName(selection)).arg(ps)); + } // Draw the original link, before selection was moved around mapCenter->reposition(); } @@ -3574,18 +3755,18 @@ adjustCanvasSize(); canvas()->update(); movingObj=NULL; + + // Just make sure, that actions are still ok,e.g. the move branch up/down buttons... + updateActions(); } else // maybe we moved View: set old cursor - setCursor (ArrowCursor); + setCursor (Qt::ArrowCursor); } void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - - if (e->button() == QMouseEvent::LeftButton ) + if (e->button() == Qt::LeftButton ) { QPoint p = inverseWorldMatrix().map(e->pos()); LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL); @@ -3594,14 +3775,14 @@ if (selection) selection->unselect(); selection=lmo; selection->select(); - editHeading(); + mainWindow->editHeading(); } } } void MapEditor::resizeEvent (QResizeEvent* e) { - QCanvasView::resizeEvent( e ); + Q3CanvasView::resizeEvent( e ); adjustCanvasSize(); } @@ -3616,7 +3797,7 @@ (typeid(*selection) == typeid(MapCenterObj))) { // If QImageDrag can decode mime type - if (QImageDrag::canDecode(event)) { + if (Q3ImageDrag::canDecode(event)) { event->accept(); return; } @@ -3629,7 +3810,7 @@ } // If QUriDrag can decode mime type - if (QUriDrag::canDecode(event)) { + if (Q3UriDrag::canDecode(event)) { event->accept(); return; } @@ -3641,7 +3822,7 @@ } // If QTextDrag can decode mime type - if (QTextDrag::canDecode(event)) { + if (Q3TextDrag::canDecode(event)) { event->accept(); return; } @@ -3667,12 +3848,12 @@ (typeid(*selection) == typeid(MapCenterObj))) { bool update=false; - QStrList uris; + Q3StrList uris; QString heading; if (event->provides("image/png")) { QPixmap pix; - if (QImageDrag::decode(event, pix)) + if (Q3ImageDrag::decode(event, pix)) { addFloatImage(pix); event->accept(); @@ -3691,7 +3872,7 @@ update=true; } else if (event->provides ("text/uri-list")) { // Uris provided e.g. by konqueror - QUriDrag::decode (event,uris); + Q3UriDrag::decode (event,uris); } else if (event->provides ("_NETSCAPE_URL")) { // Uris provided by Mozilla QStringList l = QStringList::split("\n", event->encodedData("_NETSCAPE_URL")); @@ -3737,8 +3918,9 @@ bo=((BranchObj*)selection)->addBranch(); if (bo) { - s=QUriDrag::uriToLocalFile(u); - if (s) { + s=Q3UriDrag::uriToLocalFile(u); + if (!s.isEmpty()) + { QString file = QDir::convertSeparators(s); heading = QFileInfo(file).baseName(); files.append(file); @@ -3746,12 +3928,13 @@ bo->setVymLink(file); else bo->setURL(u); - } else { + } else + { urls.append (u); bo->setURL(u); } - if (heading) + if (!heading.isEmpty()) bo->setHeading(heading); else bo->setHeading(u); @@ -3763,7 +3946,7 @@ if (update) { //FIXME saveState has to be called earlier for each of the drops... - saveState("Drop Event"); //TODO undo Command + saveStateComplete("Drop Event"); //TODO undo Command mapCenter->reposition(); adjustCanvasSize(); canvas()->update(); @@ -3778,7 +3961,7 @@ (typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=((BranchObj*)selection); - saveState(selection,QString("Add floatimage to %1").arg(getName(bo))); + saveStatePart(selection,QString("Add floatimage to %1").arg(getName(bo))); //QString fn=fd->selectedFile(); //lastImageDir=fn.left(fn.findRev ("/")); bo->addFloatImage(); @@ -3792,19 +3975,19 @@ } -void MapEditor::imageDataFetched(const QByteArray &a, QNetworkOperation */*nop*/) +void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation */*nop*/) { if (!imageBuffer) imageBuffer = new QBuffer(); if (!imageBuffer->isOpen()) { - imageBuffer->open(IO_WriteOnly | IO_Append); + imageBuffer->open(QIODevice::WriteOnly | QIODevice::Append); } imageBuffer->at(imageBuffer->at()+imageBuffer->writeBlock(a)); } -void MapEditor::imageDataFinished(QNetworkOperation *nop) +void MapEditor::imageDataFinished(Q3NetworkOperation *nop) { - if (nop->state()==QNetworkProtocol::StDone) { + if (nop->state()==Q3NetworkProtocol::StDone) { QPixmap img(imageBuffer->buffer()); addFloatImage(img); } @@ -3827,11 +4010,11 @@ delete urlOperator; } - urlOperator = new QUrlOperator(url); - connect(urlOperator, SIGNAL(finished(QNetworkOperation *)), - this, SLOT(imageDataFinished(QNetworkOperation*))); - - connect(urlOperator, SIGNAL(data(const QByteArray &, QNetworkOperation *)), - this, SLOT(imageDataFetched(const QByteArray &, QNetworkOperation *))); + urlOperator = new Q3UrlOperator(url); + connect(urlOperator, SIGNAL(finished(Q3NetworkOperation *)), + this, SLOT(imageDataFinished(Q3NetworkOperation*))); + + connect(urlOperator, SIGNAL(data(const QByteArray &, Q3NetworkOperation *)), + this, SLOT(imageDataFetched(const QByteArray &, Q3NetworkOperation *))); urlOperator->get(); }