1.1 --- a/mapeditor.cpp Wed May 31 12:27:39 2006 +0000
1.2 +++ b/mapeditor.cpp Tue Sep 05 10:03:29 2006 +0000
1.3 @@ -1,24 +1,34 @@
1.4 #include "mapeditor.h"
1.5
1.6 #include <qstatusbar.h>
1.7 -#include <qmessagebox.h>
1.8 +#include <QMessageBox>
1.9 #include <qapplication.h>
1.10 #include <qpainter.h>
1.11 -#include <qpopupmenu.h>
1.12 +#include <q3popupmenu.h>
1.13 #include <qprinter.h>
1.14 -#include <qpaintdevicemetrics.h>
1.15 -#include <qfile.h>
1.16 -#include <qfiledialog.h>
1.17 -#include <qdir.h>
1.18 -#include <qcolor.h>
1.19 -#include <qcolordialog.h>
1.20 -#include <qbitmap.h>
1.21 -#include <qprocess.h>
1.22 +#include <q3paintdevicemetrics.h>
1.23 +#include <QFile>
1.24 +#include <q3filedialog.h>
1.25 +#include <QDir>
1.26 +#include <QColor>
1.27 +#include <QColorDialog>
1.28 +#include <QBitmap>
1.29 #include <qinputdialog.h>
1.30 -#include <qdragobject.h>
1.31 -#include <qurloperator.h>
1.32 -#include <qnetworkprotocol.h>
1.33 -#include <qregexp.h>
1.34 +#include <q3dragobject.h>
1.35 +#include <q3urloperator.h>
1.36 +#include <q3networkprotocol.h>
1.37 +#include <QRegExp>
1.38 +//Added by qt3to4:
1.39 +#include <QResizeEvent>
1.40 +#include <QContextMenuEvent>
1.41 +#include <Q3StrList>
1.42 +#include <QPixmap>
1.43 +#include <QMouseEvent>
1.44 +#include <QDragEnterEvent>
1.45 +#include <QTextStream>
1.46 +#include <QDropEvent>
1.47 +#include <QActionGroup>
1.48 +#include <Q3PtrList>
1.49
1.50 #include <iostream>
1.51 #include <cstdlib>
1.52 @@ -34,7 +44,6 @@
1.53 #include "linkablemapobj.h"
1.54 #include "mainwindow.h"
1.55 #include "misc.h"
1.56 -#include "settings.h"
1.57 #include "texteditor.h"
1.58 #include "warningdialog.h"
1.59 #include "xml.h"
1.60 @@ -49,10 +58,11 @@
1.61 extern FlagRowObj *systemFlagsDefault;
1.62 extern FlagRowObj *standardFlagsDefault;
1.63
1.64 -extern QPtrList <QAction> actionListBranches;
1.65 +extern Q3PtrList <QAction> actionListBranches;
1.66
1.67 extern QAction *actionFileSave;
1.68 extern QAction *actionEditUndo;
1.69 +extern QAction *actionEditRedo;
1.70 extern QAction *actionEditCopy;
1.71 extern QAction *actionEditCut;
1.72 extern QAction *actionEditPaste;
1.73 @@ -113,44 +123,51 @@
1.74 extern QAction *actionSettingsAutoedit;
1.75 extern QAction *actionSettingsAutoselectHeading;
1.76 extern QAction *actionSettingsAutoselectText;
1.77 -extern QAction *actionSettingsPasteNewHeading;
1.78 extern QAction *actionSettingsUseFlagGroups;
1.79
1.80 -extern QPopupMenu *branchContextMenu;
1.81 -extern QPopupMenu *branchLinksContextMenu;
1.82 -extern QPopupMenu *branchLinksContextMenuDup;
1.83 -extern QPopupMenu *floatimageContextMenu;
1.84 -extern QPopupMenu *saveImageFormatMenu;
1.85 -extern QPopupMenu *exportImageFormatMenu;
1.86 -extern QPopupMenu *canvasContextMenu;
1.87 +extern QMenu* branchContextMenu;
1.88 +extern QMenu* branchAddContextMenu;
1.89 +extern QMenu* branchRemoveContextMenu;
1.90 +extern QMenu* branchLinksContextMenu;
1.91 +extern QMenu* branchXLinksContextMenuEdit;
1.92 +extern QMenu* branchXLinksContextMenuFollow;
1.93 +extern QMenu* floatimageContextMenu;
1.94 +extern QMenu* saveImageFormatMenu;
1.95 +extern QMenu* canvasContextMenu;
1.96 +extern QMenu* lastMapsMenu;
1.97 +extern QMenu* importMenu;
1.98 +extern QMenu* exportMenu;
1.99 +
1.100
1.101 extern Settings settings;
1.102 +extern ImageIO imageIO;
1.103
1.104 extern QString iconPath;
1.105 extern QDir vymBaseDir;
1.106 +extern QDir lastImageDir;
1.107
1.108 int MapEditor::mapNum=0; // make instance
1.109
1.110 ///////////////////////////////////////////////////////////////////////
1.111 ///////////////////////////////////////////////////////////////////////
1.112 MapEditor::MapEditor(
1.113 - QWidget* parent, bool interactive, const char* name, WFlags f) :
1.114 - QCanvasView(parent,name,f), urlOperator(0), imageBuffer(0)
1.115 + QWidget* parent, bool interactive, const char* name, Qt::WFlags f) :
1.116 + Q3CanvasView(parent,name,f), urlOperator(0), imageBuffer(0)
1.117 {
1.118 //cout << "Constructor ME "<<this<<endl;
1.119 mapNum++;
1.120
1.121 viewport()->setAcceptDrops(true);
1.122
1.123 - mapCanvas = new QCanvas(1000,800);
1.124 + mapCanvas = new Q3Canvas(width(),height());
1.125 mapCanvas->setAdvancePeriod(30);
1.126 - mapCanvas->setBackgroundColor (white);
1.127 + mapCanvas->setBackgroundColor (Qt::white);
1.128
1.129 setCanvas (mapCanvas);
1.130
1.131 // Always show scroll bars (automatic would flicker sometimes)
1.132 - setVScrollBarMode ( QScrollView::AlwaysOn );
1.133 - setHScrollBarMode ( QScrollView::AlwaysOn );
1.134 + setVScrollBarMode ( Q3ScrollView::AlwaysOn );
1.135 + setHScrollBarMode ( Q3ScrollView::AlwaysOn );
1.136
1.137 mapCenter = new MapCenterObj(mapCanvas);
1.138 mapCenter->setVisibility (true);
1.139 @@ -160,24 +177,18 @@
1.140
1.141 printer=NULL;
1.142
1.143 - lineedit = new QLineEdit(this, "lineedit" );
1.144 - connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEdit() ) );
1.145 - lineedit->hide();
1.146 -
1.147 - actColor=black; setColor (actColor);
1.148 + actColor=Qt::black; setColor (actColor);
1.149 defLinkColor=QColor (0,0,255);
1.150 defXLinkColor=QColor (180,180,180);
1.151 linkcolorhint=DefaultColor;
1.152 linkstyle=StylePolyParabel;
1.153
1.154 - // Create bitmap cursors, patform dependant
1.155 + // Create bitmap cursors, platform dependant
1.156 #if defined(Q_OS_MACX)
1.157 - handOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png") );
1.158 - // set hot spot to tip of picker
1.159 + handOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png"),1,1 );
1.160 pickColorCursor=QCursor ( QPixmap (iconPath+"cursorcolorpicker16.png"), 1,15 );
1.161 #else
1.162 - handOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen16.png"));
1.163 - // set hot spot to tip of picker
1.164 + handOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);
1.165 pickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 );
1.166 #endif
1.167
1.168 @@ -190,6 +201,8 @@
1.169 selectionLast=NULL;
1.170 movingObj=NULL;
1.171
1.172 + xelection.setMapCenter (mapCenter);
1.173 +
1.174 defXLinkWidth=1;
1.175 defXLinkColor=QColor (230,230,230);
1.176
1.177 @@ -202,9 +215,7 @@
1.178 fileName=tr("unnamed");
1.179 mapName="";
1.180
1.181 - undosTotal=settings.readNumEntry("/vym/mapeditor/undoLevels",50);
1.182 - undosAvail=0;
1.183 - undoNum=0;
1.184 + undosTotal=settings.readNumEntry("/mapeditor/undoLevels",50);
1.185
1.186 // Initialize find routine
1.187 itFind=NULL;
1.188 @@ -231,6 +242,8 @@
1.189 historyWindow->setCaption (fileName);
1.190
1.191 mapCenter->reposition(); // for positioning heading
1.192 +
1.193 +
1.194 }
1.195
1.196 MapEditor::~MapEditor()
1.197 @@ -244,7 +257,7 @@
1.198 //cout <<"Destructor MapEditor\n";
1.199
1.200 // Save Settings
1.201 - //settings.writeEntry( "/vym/mapeditor/editmode/autoselect", );
1.202 + //settings.writeEntry( "/mapeditor/editmode/autoselect", );
1.203
1.204 }
1.205
1.206 @@ -263,7 +276,7 @@
1.207 return mapCenter;
1.208 }
1.209
1.210 -QCanvas* MapEditor::getCanvas()
1.211 +Q3Canvas* MapEditor::getCanvas()
1.212 {
1.213 return mapCanvas;
1.214 }
1.215 @@ -355,12 +368,13 @@
1.216 void MapEditor::makeTmpDirs()
1.217 {
1.218 // Create unique temporary directories
1.219 - tmpMapDir=tmpVymDir+QString("/mapeditor-%1").arg(mapNum);
1.220 + tmpMapDir=QDir::convertSeparators (tmpVymDir+QString("/mapeditor-%1").arg(mapNum));
1.221 + histPath=QDir::convertSeparators (tmpMapDir+"/history");
1.222 QDir d;
1.223 d.mkdir (tmpMapDir,true);
1.224 }
1.225
1.226 -QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection)
1.227 +QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSel)
1.228 {
1.229 // tmpdir temporary directory to which data will be written
1.230 // prefix mapname, which will be appended to images etc.
1.231 @@ -392,7 +406,7 @@
1.232 colhint=attribut("linkColorHint","HeadingColor");
1.233
1.234 QString mapAttr=attribut("version",__VYM_VERSION);
1.235 - if (!saveSelection)
1.236 + if (!saveSel)
1.237 mapAttr+= attribut("author",mapCenter->getAuthor()) +
1.238 attribut("comment",mapCenter->getComment()) +
1.239 attribut("date",mapCenter->getDate()) +
1.240 @@ -412,25 +426,28 @@
1.241 FloatImageObj (mapCanvas).resetSaveCounter();
1.242
1.243 // Build xml recursivly
1.244 - if (!saveSelection)
1.245 + if (!saveSel)
1.246 + // Save complete map, if saveSel not set
1.247 s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset);
1.248 else
1.249 {
1.250 - if ( typeid(*saveSelection) == typeid(BranchObj) )
1.251 - s+=((BranchObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset);
1.252 - else if ( typeid(*saveSelection) == typeid(FloatImageObj) )
1.253 - s+=((FloatImageObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset);
1.254 + if ( typeid(*saveSel) == typeid(BranchObj) )
1.255 + // Save Subtree
1.256 + s+=((BranchObj*)(saveSel))->saveToDir(tmpdir,prefix,offset);
1.257 + else if ( typeid(*saveSel) == typeid(FloatImageObj) )
1.258 + // Save image
1.259 + s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix,offset);
1.260
1.261 else if (selection && typeid(*selection)==typeid(BranchObj))
1.262 - // This is used if selected branch is saved from mainwindow
1.263 - s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset);
1.264 + // Save selected branch is saved from mainwindow //FIXME maybe use "subtree" above?
1.265 + s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset);
1.266 }
1.267
1.268 // Save local settings
1.269 s+=settings.getXMLData (destPath);
1.270
1.271 // Save selection
1.272 - if (selection && !saveSelection )
1.273 + if (selection && !saveSel )
1.274 s+=valueElement("select",selection->getSelectString());
1.275
1.276 decIndent();
1.277 @@ -441,60 +458,112 @@
1.278 return s;
1.279 }
1.280
1.281 -void MapEditor::saveState(const QString &comment)
1.282 +void MapEditor::saveStateComplete(const QString &comment)
1.283 {
1.284 - // Save complete map
1.285 - saveState (CompleteMap,"",NULL,"",NULL, comment);
1.286 + // Save complete map, Undo will replace whole map
1.287 + saveState (CompleteMap,
1.288 + "", "",
1.289 + "", "",
1.290 + comment,
1.291 + mapCenter);
1.292 }
1.293
1.294 -void MapEditor::saveState(LinkableMapObj *undoSel, const QString &comment)
1.295 +void MapEditor::saveStatePart(LinkableMapObj *undoSel, const QString &comment)
1.296 {
1.297 - // save the given part of the map
1.298 - saveState (PartOfMap,"",undoSel,"",NULL, comment);
1.299 + // save the selected part of the map, Undo will replace part of map
1.300 + QString undoSelection="";
1.301 + if (undoSel) undoSelection=undoSel->getSelectString();
1.302 +
1.303 + saveState (PartOfMap,
1.304 + undoSelection, "",
1.305 + "", "",
1.306 + comment,
1.307 + undoSel);
1.308 }
1.309
1.310 -void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment)
1.311 +void MapEditor::saveStateConstSelection(const QString &uc, const QString &rc, const QString &comment)
1.312 {
1.313 // selection does not change during action,
1.314 // so just save commands for undo and redo
1.315 - LinkableMapObj *unsel;
1.316 - if (selection)
1.317 - unsel=selection;
1.318 - else
1.319 - unsel=NULL;
1.320 - saveState (UndoCommand,uc,unsel,rc,unsel, comment);
1.321 + // and use current selection
1.322 +
1.323 + QString sel;
1.324 + if (selection) sel=selection->getSelectString();
1.325 +
1.326 + saveState (UndoCommand,
1.327 + sel, uc,
1.328 + sel, rc,
1.329 + comment,
1.330 + NULL);
1.331 }
1.332
1.333 -void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel, const QString &comment)
1.334 +void MapEditor::saveStateComData(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment, LinkableMapObj *saveSel)
1.335 {
1.336 - saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment);
1.337 + QString redoSelection="";
1.338 + if (redoSel) redoSelection=redoSel->getSelectString();
1.339 + QString undoSelection="";
1.340 + if (undoSel) undoSelection=undoSel->getSelectString();
1.341 +
1.342 + saveState (UndoCommand,
1.343 + undoSelection, uc,
1.344 + redoSelection, "FIXME-redoCom", //FIXME
1.345 + comment,
1.346 + saveSel);
1.347 }
1.348
1.349 -void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel, const QString &comment)
1.350 +void MapEditor::saveState(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment)
1.351 +{
1.352 + // "Normal" savestate: save commands, selections and comment
1.353 + // so just save commands for undo and redo
1.354 + // and use current selection
1.355 +
1.356 + QString redoSelection="";
1.357 + if (redoSel) redoSelection=redoSel->getSelectString();
1.358 + QString undoSelection="";
1.359 + if (undoSel) undoSelection=undoSel->getSelectString();
1.360 +
1.361 + saveState (UndoCommand,
1.362 + undoSelection, uc,
1.363 + redoSelection, rc,
1.364 + comment,
1.365 + NULL);
1.366 +}
1.367 +
1.368 +void MapEditor::saveState(const QString &undoSel, const QString &uc, const QString &redoSel, const QString &rc, const QString &comment)
1.369 +{
1.370 + // "Normal" savestate: save commands, selections and comment
1.371 + // so just save commands for undo and redo
1.372 + // and use current selection
1.373 + saveState (UndoCommand,
1.374 + undoSel, uc,
1.375 + redoSel, rc,
1.376 + comment,
1.377 + NULL);
1.378 +}
1.379 +
1.380 +
1.381 +void MapEditor::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel)
1.382 {
1.383 // Main saveState
1.384
1.385 if (blockSaveState) return;
1.386
1.387 /* TODO remove after testing
1.388 - cout << "ME::saveState() begin\n"<<endl;
1.389 - cout << " undosTotal="<<undosTotal<<endl;
1.390 - cout << " undosAvail="<<undosAvail<<endl;
1.391 - cout << " undoNum="<<undoNum<<endl;
1.392 - cout << " ---------------------------"<<endl;
1.393 */
1.394 -
1.395 + cout << "ME::saveState() begin"<<endl;
1.396 historyWindow->append (comment);
1.397
1.398 setChanged();
1.399
1.400 + int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0);
1.401 + int curStep=undoSet.readNumEntry ("/history/curStep",0);
1.402 // Find out current undo directory
1.403 if (undosAvail<undosTotal) undosAvail++;
1.404 - undoNum++;
1.405 - if (undoNum>undosTotal) undoNum=1;
1.406 + curStep++;
1.407 + if (curStep>undosTotal) curStep=1;
1.408
1.409 QString backupXML;
1.410 - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.411 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.412 QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml");
1.413
1.414 // Create bakMapDir if not available
1.415 @@ -502,59 +571,50 @@
1.416 if (!d.exists())
1.417 makeSubDirs (bakMapDir);
1.418
1.419 - // Save current selection
1.420 - QString redoSelection="";
1.421 - if (redoSel)
1.422 - redoSelection=redoSel->getSelectString();
1.423 -
1.424 - // Save the object, which should be undone
1.425 - QString undoSelection="";
1.426 - if (undoSel)
1.427 - undoSelection=undoSel->getSelectString();
1.428 + // Save depending on how much needs to be saved
1.429 + if (!saveSel)
1.430 + backupXML="";
1.431 + else
1.432 + backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),saveSel);
1.433
1.434 - // Save depending on how much needs to be saved
1.435 QString undoCommand="";
1.436 if (savemode==UndoCommand)
1.437 {
1.438 undoCommand=undoCom;
1.439 - backupXML="";
1.440 }
1.441 - else if (savemode==PartOfMap && undoSel)
1.442 + else if (savemode==PartOfMap )
1.443 {
1.444 undoCommand="undoPart (\""+ undoSelection+"\",\""+bakMapPath+"\")";
1.445 - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
1.446 } else
1.447 {
1.448 undoCommand="undoMap (\""+bakMapPath+"\")";
1.449 - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL);
1.450 - undoSelection="";
1.451 }
1.452 if (!backupXML.isEmpty())
1.453 // Write XML Data to disk
1.454 saveStringToDisk (QString(bakMapPath),backupXML);
1.455
1.456 - SimpleSettings set;
1.457 - set.setEntry (QString("undoCommand"),undoCommand);
1.458 - set.setEntry (QString("undoSelection"),undoSelection);
1.459 - set.setEntry (QString("redoCommand"),redoCom);
1.460 - set.setEntry (QString("redoSelection"),redoSelection);
1.461 - set.setEntry (QString("comment"),comment);
1.462 - set.writeSettings(QString(bakMapDir+"/commands"));
1.463 + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
1.464 + undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.465 + undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand);
1.466 + undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection);
1.467 + undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom);
1.468 + undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection);
1.469 + undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment);
1.470 + undoSet.writeSettings(histPath);
1.471
1.472 /* TODO remove after testing
1.473 - cout << " into="<< bakMapDir<<endl;
1.474 - cout << " undosAvail="<<undosAvail<<endl;
1.475 - cout << " undoNum="<<undoNum<<endl;
1.476 + */
1.477 + //cout << " into="<< histPath.toStdString()<<endl;
1.478 + cout << " undosTotal="<<undosTotal<<
1.479 + ", undosAvail="<<undosAvail<<
1.480 + ", curStep="<<curStep<<endl;
1.481 cout << " ---------------------------"<<endl;
1.482 - cout << " comment="<<comment<<endl;
1.483 + cout << " comment="<<comment.toStdString()<<endl;
1.484 + cout << " undoCom="<<undoCommand.toStdString()<<endl;
1.485 + cout << " undoSel="<<undoSelection.toStdString()<<endl;
1.486 + cout << " redoCom="<<redoCom.toStdString()<<endl;
1.487 + cout << " redoSel="<<redoSelection.toStdString()<<endl;
1.488 cout << " ---------------------------"<<endl;
1.489 - cout << " undoCom="<<undoCommand<<endl;
1.490 - cout << " undoSel="<<undoSelection<<endl;
1.491 - cout << " ---------------------------"<<endl;
1.492 - cout << " redoCom="<<redoCom<<endl;
1.493 - cout << " redoSel="<<redoSelection<<endl;
1.494 - cout << " ---------------------------"<<endl<<endl;
1.495 - */
1.496 }
1.497
1.498 void MapEditor::parseAtom(const QString &atom)
1.499 @@ -585,12 +645,43 @@
1.500 }
1.501 }
1.502 }
1.503 + else if (com=="moveRel")
1.504 + {
1.505 + if (api.checkParamCount(2) && selection )
1.506 + {
1.507 + x=api.parInt (ok,0);
1.508 + if (ok)
1.509 + {
1.510 + y=api.parInt (ok,1);
1.511 + if (ok) moveRel (x,y);
1.512 + }
1.513 + }
1.514 + }
1.515 + else if (com=="delete")
1.516 + {
1.517 + if (api.checkParamCount(1) && selection )
1.518 + {
1.519 + s=api.parString(ok,0);
1.520 + if (ok &&select (s)) deleteSelection();
1.521 + }
1.522 + }
1.523 + else if (com=="addBranch")
1.524 + {
1.525 + if (api.checkParamCount(1) && selection )
1.526 + {
1.527 + y=api.parInt (ok,0);
1.528 + if (ok ) addNewBranchInt (y);
1.529 + }
1.530 + }
1.531 else if (com=="linkBranchToPos")
1.532 {
1.533 if (selection && typeid(*selection) == typeid(BranchObj) )
1.534 {
1.535 if (api.checkParamCount(4))
1.536 {
1.537 + // 0 selectstring of parent
1.538 + // 1 num in parent (for branches)
1.539 + // 2,3 x,y of mainbranch or mapcenter
1.540 s=api.parString(ok,0);
1.541 LinkableMapObj *dst=mapCenter->findObjBySelect (s);
1.542 if (dst)
1.543 @@ -620,23 +711,56 @@
1.544 if (api.checkParamCount(1))
1.545 {
1.546 s=api.parString (ok,0);
1.547 - if (ok) setHeading (s);
1.548 + if (ok)
1.549 + setHeading (s);
1.550 }
1.551 } else if (com=="setURL")
1.552 {
1.553 if (api.checkParamCount(1))
1.554 {
1.555 s=api.parString (ok,0);
1.556 - if (ok) setURL(s);
1.557 + if (ok) setURLInt(s);
1.558 }
1.559 } else if (com=="setVymLink")
1.560 {
1.561 if (api.checkParamCount(1))
1.562 {
1.563 s=api.parString (ok,0);
1.564 - if (ok) setVymLink(s);
1.565 + if (ok) setVymLinkInt(s);
1.566 }
1.567 }
1.568 + else if (com=="setFlag")
1.569 + {
1.570 + if (selection && typeid(*selection) == typeid(BranchObj) )
1.571 + {
1.572 + if (api.checkParamCount(1) )
1.573 + {
1.574 + s=api.parString(ok,0);
1.575 + if (ok)
1.576 + {
1.577 + BranchObj* bo=(BranchObj*)selection;
1.578 + bo->activateStandardFlag(s);
1.579 + bo->updateFlagsToolbar();
1.580 + }
1.581 + }
1.582 + }
1.583 + }
1.584 + else if (com=="unsetFlag")
1.585 + {
1.586 + if (selection && typeid(*selection) == typeid(BranchObj) )
1.587 + {
1.588 + if (api.checkParamCount(1) )
1.589 + {
1.590 + s=api.parString(ok,0);
1.591 + if (ok)
1.592 + {
1.593 + BranchObj* bo=(BranchObj*)selection;
1.594 + bo->deactivateStandardFlag(s);
1.595 + bo->updateFlagsToolbar();
1.596 + }
1.597 + }
1.598 + }
1.599 + }
1.600 // Internal commands, used for undo etc.
1.601 else if (com==QString("undoMap"))
1.602 {
1.603 @@ -646,55 +770,32 @@
1.604 {
1.605 if (api.checkParamCount(2))
1.606 {
1.607 - s=api.parString (ok,0);
1.608 - t=api.parString (ok,1);
1.609 + s=api.parString (ok,0); // undo selection
1.610 + t=api.parString (ok,1); // backup dir
1.611 undoXML(s,t);
1.612 }
1.613 } else if (com=="select")
1.614 + {
1.615 if (api.checkParamCount(1))
1.616 {
1.617 s=api.parString(ok,0);
1.618 if (ok) select (s);
1.619 }
1.620 + }
1.621 else
1.622 {
1.623 api.setError ("Unknown command in: "+atom);
1.624 - cout << "ME::parse api should have error now...\n";
1.625 }
1.626
1.627 // Any errors?
1.628 if (api.error())
1.629 {
1.630 - cout << "MapEditor::parseAtom: Error!\n";
1.631 - cout << " "<<api.errorDesc()<<endl;
1.632 + // TODO Error handling
1.633 + qWarning("MapEditor::parseAtom: Error!");
1.634 + qWarning(api.errorDesc());
1.635 }
1.636 }
1.637
1.638 -
1.639 -void MapEditor::finishedLineEdit()
1.640 -{
1.641 - // This is called by finishedLineEdit or any MapEditor method,
1.642 - // which wants to assure, that lineedits finish, before e.g. a branch is
1.643 - // deleted
1.644 -
1.645 - // After calling LineEdit and using the clipboard, the
1.646 - // focus is not any longer on the main widget, we
1.647 - // have to restore it using parentWidget()->setFocus()
1.648 -
1.649 - if (editingBO!=NULL)
1.650 - {
1.651 - saveState("setHeading (\""+editingBO->getHeading()+"\")",editingBO, QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(lineedit->text()) );
1.652 - editingBO->setHeading(lineedit->text() );
1.653 - editingBO=NULL;
1.654 - lineedit->releaseKeyboard();
1.655 - lineedit->hide();
1.656 - parentWidget()->setFocus();
1.657 - mapCenter->reposition();
1.658 - adjustCanvasSize();
1.659 - ensureSelectionVisible();
1.660 - }
1.661 -}
1.662 -
1.663 void MapEditor::toggleHistoryWindow()
1.664 {
1.665 if (historyWindow->isVisible())
1.666 @@ -731,9 +832,6 @@
1.667
1.668 void MapEditor::closeMap()
1.669 {
1.670 - // Finish open lineEdits
1.671 - if (lineedit) finishedLineEdit();
1.672 -
1.673 // Unselect before disabling the toolbar actions
1.674 if (selection) selection->unselect();
1.675 selection=NULL;
1.676 @@ -799,9 +897,6 @@
1.677
1.678 ErrorCode MapEditor::load (QString fname, LoadMode lmode)
1.679 {
1.680 - // Finish open lineEdits
1.681 - if (lineedit) finishedLineEdit();
1.682 -
1.683 ErrorCode err=success;
1.684
1.685 if (lmode==NewMap)
1.686 @@ -813,7 +908,7 @@
1.687 // (map state is set later at end of load...)
1.688 } else
1.689 {
1.690 - saveState(selection,"Load map");
1.691 + saveStatePart(selection,"Load map");
1.692 }
1.693
1.694
1.695 @@ -868,9 +963,6 @@
1.696
1.697 int MapEditor::save (const SaveMode &savemode)
1.698 {
1.699 - // Finish open lineEdits
1.700 - if (lineedit) finishedLineEdit();
1.701 -
1.702 int returnCode=0;
1.703
1.704 // The SaveMode UndoCommand is not supported here
1.705 @@ -918,14 +1010,11 @@
1.706
1.707 void MapEditor::print()
1.708 {
1.709 - // Finish open lineEdits
1.710 - if (lineedit) finishedLineEdit();
1.711 -
1.712 if ( !printer )
1.713 {
1.714 printer = new QPrinter;
1.715 printer->setColorMode (QPrinter::Color);
1.716 - printer->setPrinterName (settings.readEntry("/vym/mainwindow/printerName",printer->printerName()));
1.717 + printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString());
1.718 }
1.719
1.720 QRect totalBBox=mapCenter->getTotalBBox();
1.721 @@ -962,15 +1051,15 @@
1.722 // e.g. (0,50,700,700) is upper part on A4
1.723 // see also /usr/lib/qt3/doc/html/coordsys.html
1.724
1.725 - QPaintDeviceMetrics metrics (printer);
1.726 + Q3PaintDeviceMetrics metrics (printer);
1.727
1.728 double paperAspect = (double)metrics.width() / (double)metrics.height();
1.729 double mapAspect = (double)totalBBox.width() / (double)totalBBox.height();
1.730
1.731 QRect mapRect=totalBBox;
1.732 - QCanvasRectangle *frame=NULL;
1.733 - QCanvasText *footerFN=NULL;
1.734 - QCanvasText *footerDate=NULL;
1.735 + Q3CanvasRectangle *frame=NULL;
1.736 + Q3CanvasText *footerFN=NULL;
1.737 + Q3CanvasText *footerDate=NULL;
1.738 if (printFrame || printFooter)
1.739 {
1.740
1.741 @@ -979,9 +1068,9 @@
1.742 // Print frame around map
1.743 mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10,
1.744 totalBBox.width()+20, totalBBox.height()+20);
1.745 - frame=new QCanvasRectangle (mapRect,mapCanvas);
1.746 - frame->setBrush (QColor(white));
1.747 - frame->setPen (QColor(black));
1.748 + frame=new Q3CanvasRectangle (mapRect,mapCanvas);
1.749 + frame->setBrush (QColor(Qt::white));
1.750 + frame->setPen (QColor(Qt::black));
1.751 frame->setZ(0);
1.752 frame->show();
1.753 }
1.754 @@ -998,13 +1087,13 @@
1.755 // Print footer below map
1.756 QFont font;
1.757 font.setPointSize(10);
1.758 - footerFN=new QCanvasText (mapCanvas);
1.759 + footerFN=new Q3CanvasText (mapCanvas);
1.760 footerFN->setText ("VYM - " + fileName);
1.761 footerFN->setFont(font);
1.762 footerFN->move (mapRect.x(), mapRect.y() + mapRect.height() );
1.763 footerFN->setZ(Z_TEXT);
1.764 footerFN->show();
1.765 - footerDate=new QCanvasText (mapCanvas);
1.766 + footerDate=new Q3CanvasText (mapCanvas);
1.767 footerDate->setText (QDate::currentDate().toString(Qt::TextDate));
1.768 footerDate->setFont(font);
1.769 footerDate->move (mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() );
1.770 @@ -1045,7 +1134,7 @@
1.771 }
1.772
1.773 // Save settings in vymrc
1.774 - settings.writeEntry("/vym/mainwindow/printerName",printer->printerName());
1.775 + settings.writeEntry("/mainwindow/printerName",printer->printerName());
1.776 }
1.777 }
1.778
1.779 @@ -1094,9 +1183,6 @@
1.780
1.781 void MapEditor::exportImage(QString fn)
1.782 {
1.783 - // Finish open lineEdits
1.784 - if (lineedit) finishedLineEdit();
1.785 -
1.786 setExportMode (true);
1.787 QPixmap pix (getPixmap());
1.788 pix.save(fn, "PNG");
1.789 @@ -1107,20 +1193,17 @@
1.790 {
1.791 // should be called before and after exports
1.792 // depending on the settings
1.793 - if (b && settings.readEntry("/vym/export/useHideExport","yes"))
1.794 + if (b && settings.value("/export/useHideExport","yes")=="yes")
1.795 setHideTmpMode (HideExport);
1.796 else
1.797 setHideTmpMode (HideNone);
1.798 }
1.799
1.800 -void MapEditor::exportImage(QString fn, int item)
1.801 +void MapEditor::exportImage(QString fn, QString format)
1.802 {
1.803 - // Finish open lineEdits
1.804 - if (lineedit) finishedLineEdit();
1.805 -
1.806 setExportMode (true);
1.807 QPixmap pix (getPixmap());
1.808 - pix.save(fn, exportImageFormatMenu->text(item) );
1.809 + pix.save(fn, format);
1.810 setExportMode (false);
1.811 }
1.812
1.813 @@ -1152,7 +1235,7 @@
1.814 QFile file;
1.815
1.816 file.setName ( dir + "/"+mapName+".xml");
1.817 - if ( !file.open( IO_WriteOnly ) )
1.818 + if ( !file.open( QIODevice::WriteOnly ) )
1.819 {
1.820 // This should neverever happen
1.821 QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name()));
1.822 @@ -1184,9 +1267,6 @@
1.823
1.824 void MapEditor::copy()
1.825 {
1.826 - // Finish open lineEdits
1.827 - if (lineedit) finishedLineEdit();
1.828 -
1.829 if (selection)
1.830 {
1.831 // write to directory
1.832 @@ -1195,7 +1275,7 @@
1.833 QFile file;
1.834
1.835 file.setName ( clipboardDir + "/"+clipfile+".xml");
1.836 - if ( !file.open( IO_WriteOnly ) )
1.837 + if ( !file.open( QIODevice::WriteOnly ) )
1.838 {
1.839 // This should neverever happen
1.840 QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name()));
1.841 @@ -1215,124 +1295,126 @@
1.842
1.843 void MapEditor::redo()
1.844 {
1.845 - // Finish open lineEdits
1.846 - if (lineedit) finishedLineEdit();
1.847 -
1.848 blockSaveState=true;
1.849
1.850 + // Restore variables
1.851 + int curStep=undoSet.readNumEntry (QString("/history/curStep"));
1.852 + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
1.853 + int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
1.854 + if (redosAvail>0) redosAvail--;
1.855 + if (undosAvail<undosTotal) undosAvail++;
1.856 + curStep++;
1.857 + if (curStep>undosTotal) curStep=1;
1.858 + QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
1.859 + QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
1.860 + QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
1.861 + QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
1.862 + QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
1.863 +
1.864 // Find out current undo directory
1.865 - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.866 -
1.867 - // Restore variables
1.868 - QString undoCommand;
1.869 - QString undoSelection;
1.870 - QString redoCommand;
1.871 - QString redoSelection;
1.872 - SimpleSettings set;
1.873 - set.readSettings(QString(bakMapDir+"/commands"));
1.874 - undoCommand=set.readEntry ("undoCommand");
1.875 - undoSelection=set.readEntry ("undoSelection");
1.876 - redoCommand=set.readEntry ("redoCommand");
1.877 - redoSelection=set.readEntry ("redoSelection");
1.878 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.879 +
1.880 +/* TODO remove testing
1.881 +*/
1.882 + cout << "ME::redo() begin\n";
1.883 + cout << " undosAvail="<<undosAvail<<endl;
1.884 + cout << " redosAvail="<<redosAvail<<endl;
1.885 + cout << " curStep="<<curStep<<endl;
1.886 + cout << " ---------------------------"<<endl;
1.887 + cout << " comment="<<comment.toStdString()<<endl;
1.888 + cout << " undoCom="<<undoCommand.toStdString()<<endl;
1.889 + cout << " undoSel="<<undoSelection.toStdString()<<endl;
1.890 + cout << " redoCom="<<redoCommand.toStdString()<<endl;
1.891 + cout << " redoSel="<<redoSelection.toStdString()<<endl;
1.892 + cout << " ---------------------------"<<endl<<endl;
1.893
1.894 // select object before redo
1.895 + // FIXME better give up if no selection there...
1.896 if (!redoSelection.isEmpty())
1.897 select (redoSelection);
1.898
1.899 -/* TODO remove testing
1.900 - cout << "ME::redo() begin\n";
1.901 - cout << " undosTotal="<<undosTotal<<endl;
1.902 - cout << " undosAvail="<<undosAvail<<endl;
1.903 - cout << " undoNum="<<undoNum<<endl;
1.904 - cout << " ---------------------------"<<endl;
1.905 - cout << " undoCom="<<undoCommand<<endl;
1.906 - cout << " undoSel="<<undoSelection<<endl;
1.907 - cout << " ---------------------------"<<endl;
1.908 - cout << " redoCom="<<redoCommand<<endl;
1.909 - cout << " redoSel="<<redoSelection<<endl;
1.910 - cout << " ---------------------------"<<endl;
1.911 +
1.912 + parseAtom (redoCommand);
1.913 + mapCenter->reposition();
1.914 +
1.915 + blockSaveState=false;
1.916 +
1.917 + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
1.918 + undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
1.919 + undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.920 + undoSet.writeSettings(histPath);
1.921 +
1.922 + updateActions();
1.923 +
1.924 + /* TODO remove testing
1.925 */
1.926 - parseAtom (undoCommand);
1.927 - mapCenter->reposition();
1.928 -
1.929 - //if (!redoSelection.isEmpty())
1.930 - // select (redoSelection);
1.931 -
1.932 - undosAvail--;
1.933 - if (undosAvail<1)
1.934 - // Undo not longer available now
1.935 - actionEditUndo->setEnabled (false);
1.936 - else
1.937 - undoNum--; if (undoNum<1) undoNum=undosTotal;
1.938 -
1.939 - blockSaveState=false;
1.940 -/* TODO remove testing
1.941 cout << "ME::redo() end\n";
1.942 cout << " undosAvail="<<undosAvail<<endl;
1.943 - cout << " undoNum="<<undoNum<<endl;
1.944 + cout << " redosAvail="<<redosAvail<<endl;
1.945 + cout << " curStep="<<curStep<<endl;
1.946 cout << " ---------------------------"<<endl<<endl;
1.947 -*/
1.948 +
1.949 +
1.950 }
1.951
1.952 void MapEditor::undo()
1.953 {
1.954 - // Finish open lineEdits
1.955 - if (lineedit) finishedLineEdit();
1.956 -
1.957 blockSaveState=true;
1.958
1.959 + // Restore variables
1.960 + int curStep=undoSet.readNumEntry (QString("/history/curStep"));
1.961 + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
1.962 + int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
1.963 + QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep));
1.964 + QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep));
1.965 + QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep));
1.966 + QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep));
1.967 + QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep));
1.968 +
1.969 // Find out current undo directory
1.970 - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.971 -
1.972 - // Restore variables
1.973 - QString undoCommand;
1.974 - QString undoSelection;
1.975 - QString redoCommand;
1.976 - QString redoSelection;
1.977 - SimpleSettings set;
1.978 - set.readSettings(QString(bakMapDir+"/commands"));
1.979 - undoCommand= set.readEntry ("undoCommand");
1.980 - undoSelection=set.readEntry ("undoSelection");
1.981 - redoCommand= set.readEntry ("redoCommand");
1.982 - redoSelection=set.readEntry ("redoSelection");
1.983 + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.984
1.985 // select object before undo
1.986 if (!undoSelection.isEmpty())
1.987 select (undoSelection);
1.988
1.989 /* TODO testing
1.990 +*/
1.991 cout << "ME::undo() begin\n";
1.992 - cout << " undosTotal="<<undosTotal<<endl;
1.993 cout << " undosAvail="<<undosAvail<<endl;
1.994 - cout << " undoNum="<<undoNum<<endl;
1.995 + cout << " redosAvail="<<redosAvail<<endl;
1.996 + cout << " curStep="<<curStep<<endl;
1.997 cout << " ---------------------------"<<endl;
1.998 - cout << " undoCom="<<undoCommand<<endl;
1.999 - cout << " undoSel="<<undoSelection<<endl;
1.1000 - cout << " ---------------------------"<<endl;
1.1001 - cout << " redoCom="<<redoCommand<<endl;
1.1002 - cout << " redoSel="<<redoSelection<<endl;
1.1003 - cout << " ---------------------------"<<endl;
1.1004 -*/
1.1005 + cout << " comment="<<comment.toStdString()<<endl;
1.1006 + cout << " undoCom="<<undoCommand.toStdString()<<endl;
1.1007 + cout << " undoSel="<<undoSelection.toStdString()<<endl;
1.1008 + cout << " redoCom="<<redoCommand.toStdString()<<endl;
1.1009 + cout << " redoSel="<<redoSelection.toStdString()<<endl;
1.1010 + cout << " ---------------------------"<<endl<<endl;
1.1011 parseAtom (undoCommand);
1.1012 mapCenter->reposition();
1.1013
1.1014 - //if (!redoSelection.isEmpty())
1.1015 - // select (redoSelection);
1.1016 -
1.1017 undosAvail--;
1.1018 - if (undosAvail<1)
1.1019 - // Undo not longer available now
1.1020 - actionEditUndo->setEnabled (false);
1.1021 - else
1.1022 - undoNum--; if (undoNum<1) undoNum=undosTotal;
1.1023 + curStep--;
1.1024 + if (curStep<1) curStep=undosTotal;
1.1025 +
1.1026 + redosAvail++;
1.1027
1.1028 blockSaveState=false;
1.1029 /* TODO remove testing
1.1030 +*/
1.1031 cout << "ME::undo() end\n";
1.1032 cout << " undosAvail="<<undosAvail<<endl;
1.1033 - cout << " undoNum="<<undoNum<<endl;
1.1034 + cout << " redosAvail="<<redosAvail<<endl;
1.1035 + cout << " curStep="<<curStep<<endl;
1.1036 cout << " ---------------------------"<<endl<<endl;
1.1037 -*/
1.1038 +
1.1039 + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
1.1040 + undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
1.1041 + undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.1042 + undoSet.writeSettings(histPath);
1.1043 +
1.1044 + updateActions();
1.1045 }
1.1046
1.1047 void MapEditor::undoXML(const QString &undoSel, const QString &bakMapPath)
1.1048 @@ -1383,9 +1465,6 @@
1.1049
1.1050 void MapEditor::pasteNoSave()
1.1051 {
1.1052 - // Finish open lineEdits
1.1053 - if (lineedit) finishedLineEdit();
1.1054 -
1.1055 load (clipboardDir+"/part.xml",ImportAdd);
1.1056 }
1.1057
1.1058 @@ -1400,7 +1479,7 @@
1.1059 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1060 typeid(*selection) == typeid(MapCenterObj)))
1.1061 {
1.1062 - saveState(selection,QString("Paste to %1").arg( getName(selection)));
1.1063 + saveStatePart(selection,QString("Paste to %1").arg( getName(selection)));
1.1064 pasteNoSave();
1.1065 mapCenter->reposition();
1.1066 adjustCanvasSize();
1.1067 @@ -1409,7 +1488,7 @@
1.1068
1.1069 void MapEditor::cut()
1.1070 {
1.1071 - saveState(selection->getParObj(),QString("Cut %1").arg(getName(selection)));
1.1072 + saveStatePart(selection->getParObj(),QString("Cut %1").arg(getName(selection)));
1.1073 copy();
1.1074 cutNoSave();
1.1075 mapCenter->reposition();
1.1076 @@ -1418,17 +1497,39 @@
1.1077
1.1078 void MapEditor::move(const int &x, const int &y)
1.1079 {
1.1080 - // TODO no saveState, because this is only internal at undo so far
1.1081 - if (selection) selection->move(x,y);
1.1082 - if (typeid(*selection) == typeid(FloatImageObj))
1.1083 - ((FloatImageObj*)selection)->setRelPos();
1.1084 + if (selection)
1.1085 + {
1.1086 + QString ps=qpointToString (selection->getAbsPos());
1.1087 + QString s=selection->getSelectString();
1.1088 + saveState(
1.1089 + s, "move "+ps,
1.1090 + s, "move "+qpointToString (QPoint (x,y)),
1.1091 + QString("Move %1 to %2").arg(getName(selection)).arg(ps));
1.1092 + selection->move(x,y);
1.1093 + mapCenter->reposition();
1.1094 + adjustCanvasSize();
1.1095 + }
1.1096 +
1.1097 +}
1.1098 +
1.1099 +void MapEditor::moveRel (const int &x, const int &y)
1.1100 +{
1.1101 + if (selection)
1.1102 + {
1.1103 + QString ps=qpointToString (selection->getRelPos());
1.1104 + QString s=selection->getSelectString();
1.1105 + saveState(
1.1106 + s, "moveRel "+ps,
1.1107 + s, "moveRel "+qpointToString (QPoint (x,y)),
1.1108 + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps));
1.1109 + selection->setRelPos (QPoint(x,y));
1.1110 + mapCenter->reposition();
1.1111 + adjustCanvasSize();
1.1112 + }
1.1113 }
1.1114
1.1115 void MapEditor::moveBranchUp()
1.1116 {
1.1117 - // Finish open lineEdits
1.1118 - if (lineedit) finishedLineEdit();
1.1119 -
1.1120 BranchObj* bo;
1.1121 BranchObj* par;
1.1122 if (typeid(*selection) == typeid(BranchObj) )
1.1123 @@ -1437,9 +1538,9 @@
1.1124 if (!bo->canMoveBranchUp()) return;
1.1125 par=(BranchObj*)(bo->getParObj());
1.1126 selection->unselect();
1.1127 - selection=par->moveBranchUp (bo);
1.1128 + bo=par->moveBranchUp (bo); // bo will be the one below selection
1.1129 selection->select();
1.1130 - saveState("moveBranchDown ()",bo,QString("Move up %1").arg(getName(bo)));
1.1131 + saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
1.1132 mapCenter->reposition();
1.1133 ensureSelectionVisible();
1.1134 }
1.1135 @@ -1447,9 +1548,6 @@
1.1136
1.1137 void MapEditor::moveBranchDown()
1.1138 {
1.1139 - // Finish open lineEdits
1.1140 - if (lineedit) finishedLineEdit();
1.1141 -
1.1142 BranchObj* bo;
1.1143 BranchObj* par;
1.1144 if (typeid(*selection) == typeid(BranchObj) )
1.1145 @@ -1458,54 +1556,51 @@
1.1146 if (!bo->canMoveBranchDown()) return;
1.1147 par=(BranchObj*)(bo->getParObj());
1.1148 selection->unselect();
1.1149 - selection=par->moveBranchDown(bo);
1.1150 + bo=par->moveBranchDown(bo); // bo will be the one above selection
1.1151 selection->select();
1.1152 - saveState("moveBranchUp ()",bo,QString("Move down %1").arg(getName(bo)));
1.1153 + saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
1.1154 mapCenter->reposition();
1.1155 ensureSelectionVisible();
1.1156 }
1.1157 }
1.1158
1.1159 -void MapEditor::editHeading()
1.1160 +QString MapEditor::getHeading(bool &ok, QPoint &p)
1.1161 {
1.1162 - // Finish open lineEdits
1.1163 - if (lineedit) finishedLineEdit();
1.1164 -
1.1165 + if (selection &&
1.1166 + (typeid(*selection) == typeid(BranchObj) ||
1.1167 + typeid(*selection) == typeid(MapCenterObj) ) )
1.1168 + {
1.1169 + ok=true;
1.1170 + ensureSelectionVisible();
1.1171 + p = ((BranchObj*)selection)->getAbsPos();
1.1172 + p.setX (p.x() - contentsX());
1.1173 + p.setY (p.y() - contentsY() + ((BranchObj*)selection)->height()/2);
1.1174 + return ((BranchObj*)selection)->getHeading();
1.1175 + }
1.1176 + ok=false;
1.1177 + return QString();
1.1178 +}
1.1179 +
1.1180 +void MapEditor::setHeading(const QString &s)
1.1181 +{
1.1182 if (selection &&
1.1183 (typeid(*selection) == typeid(BranchObj) ||
1.1184 typeid(*selection) == typeid(MapCenterObj) ) )
1.1185 {
1.1186 editingBO=(BranchObj*)selection;
1.1187 -
1.1188 - ensureSelectionVisible();
1.1189 - QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
1.1190 - lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25);
1.1191 - QString s=editingBO->getHeading();
1.1192 - lineedit->setText(s);
1.1193 - lineedit->setCursorPosition(1);
1.1194 - if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() )
1.1195 - lineedit->selectAll();
1.1196 - lineedit->show();
1.1197 - lineedit->grabKeyboard();
1.1198 - lineedit->setFocus();
1.1199 - }
1.1200 -}
1.1201 -
1.1202 -void MapEditor::setHeading(const QString &s)
1.1203 -{
1.1204 - // Internal function, no saveState needed
1.1205 - if (selection &&
1.1206 - (typeid(*selection) == typeid(BranchObj) ||
1.1207 - typeid(*selection) == typeid(MapCenterObj) ) )
1.1208 - {
1.1209 - ((BranchObj*)selection)->setHeading(s);
1.1210 + saveStateConstSelection(
1.1211 + "setHeading (\""+editingBO->getHeading()+"\")",
1.1212 + "setHeading (\""+s+"\")",
1.1213 + QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(s) );
1.1214 + editingBO->setHeading(s );
1.1215 + editingBO=NULL;
1.1216 mapCenter->reposition();
1.1217 adjustCanvasSize();
1.1218 ensureSelectionVisible();
1.1219 }
1.1220 }
1.1221
1.1222 -void MapEditor::setURL (const QString &s)
1.1223 +void MapEditor::setURLInt (const QString &s)
1.1224 {
1.1225 // Internal function, no saveState needed
1.1226 if (selection &&
1.1227 @@ -1519,7 +1614,20 @@
1.1228 }
1.1229 }
1.1230
1.1231 -void MapEditor::setVymLink (const QString &s)
1.1232 +void MapEditor::setHeadingInt(const QString &s)
1.1233 +{
1.1234 + if (selection &&
1.1235 + (typeid(*selection) == typeid(BranchObj) ||
1.1236 + typeid(*selection) == typeid(MapCenterObj) ) )
1.1237 + {
1.1238 + ((BranchObj*)selection)->setHeading(s);
1.1239 + mapCenter->reposition();
1.1240 + adjustCanvasSize();
1.1241 + ensureSelectionVisible();
1.1242 + }
1.1243 +}
1.1244 +
1.1245 +void MapEditor::setVymLinkInt (const QString &s)
1.1246 {
1.1247 // Internal function, no saveState needed
1.1248 if (selection &&
1.1249 @@ -1533,44 +1641,107 @@
1.1250 }
1.1251 }
1.1252
1.1253 -void MapEditor::addNewBranch(int pos)
1.1254 +BranchObj* MapEditor::addNewBranchInt(int num)
1.1255 {
1.1256 - // Finish open lineEdits
1.1257 - if (lineedit) finishedLineEdit();
1.1258 -
1.1259 + // Depending on pos:
1.1260 + // -3 insert in childs of parent above selection
1.1261 + // -2 add branch to selection
1.1262 + // -1 insert in childs of parent below selection
1.1263 + // 0..n insert in childs of parent at pos
1.1264 + BranchObj *newbo=NULL;
1.1265 if (selection &&
1.1266 (typeid(*selection) == typeid(BranchObj) ||
1.1267 typeid(*selection) == typeid(MapCenterObj) ) )
1.1268 {
1.1269 - BranchObj* bo1 = (BranchObj*) selection;
1.1270 - saveState(selection, QString("Add new branch to %1").arg(getName(bo1))); //TODO undoCommand
1.1271 -
1.1272 - bool wasScrolled=false;
1.1273 - BranchObj *newbo=NULL;
1.1274 - if (pos==0)
1.1275 + BranchObj* bo = (BranchObj*) selection;
1.1276 + if (num==-2)
1.1277 {
1.1278 // save scroll state. If scrolled, automatically select
1.1279 // new branch in order to tmp unscroll parent...
1.1280 - wasScrolled=bo1->isScrolled();
1.1281 - newbo=bo1->addBranch();
1.1282 - } else
1.1283 + return bo->addBranch();
1.1284 +
1.1285 + }else if (num==-1)
1.1286 {
1.1287 - BranchObj *parbo=(BranchObj*)(selection->getParObj());
1.1288 - if (parbo)
1.1289 + num=bo->getNum()+1;
1.1290 + bo=(BranchObj*)bo->getParObj();
1.1291 + }else if (num==-3)
1.1292 + {
1.1293 + num=bo->getNum();
1.1294 + bo=(BranchObj*)bo->getParObj();
1.1295 + }
1.1296 + if (!bo) return bo;
1.1297 + newbo=bo->insertBranch(num);
1.1298 + }
1.1299 + return newbo;
1.1300 +}
1.1301 +
1.1302 +void MapEditor::addNewBranch(int pos)
1.1303 +{
1.1304 + // Different meaning than num in addNewBranchInt!
1.1305 + // -1 add above
1.1306 + // 0 add as child
1.1307 + // +1 add below
1.1308 + if (selection &&
1.1309 + (typeid(*selection) == typeid(BranchObj) ||
1.1310 + typeid(*selection) == typeid(MapCenterObj) ) )
1.1311 + {
1.1312 + BranchObj *bo = (BranchObj*) selection;
1.1313 + BranchObj *newbo;
1.1314 + newbo=addNewBranchInt (pos-2);
1.1315 +
1.1316 + if (newbo)
1.1317 + {
1.1318 + saveStateConstSelection (
1.1319 + QString ("delete (\"%1\")").arg(newbo->getSelectString()),
1.1320 + QString ("addBranch (%1)").arg(pos-2),
1.1321 + QString ("Add new branch to %1").arg(getName(bo))); //TODO undoCommand
1.1322 +
1.1323 + LinkableMapObj *oldselection=selection;
1.1324 +
1.1325 + mapCenter->reposition();
1.1326 + adjustCanvasSize();
1.1327 +
1.1328 +
1.1329 + if (actionSettingsAutoedit->isOn() ||
1.1330 + actionSettingsAutoselectHeading->isOn() )
1.1331 {
1.1332 - if (pos<0)
1.1333 - // add above selection
1.1334 - newbo=parbo->insertBranch(bo1->getNum());
1.1335 - else
1.1336 - // add below selection
1.1337 - newbo=parbo->insertBranch(bo1->getNum()+1);
1.1338 - } else
1.1339 - // This should not happen...
1.1340 - return;
1.1341 -
1.1342 - }
1.1343 + selection->unselect();
1.1344 + selection=newbo;
1.1345 + selection->select();
1.1346 + if (actionSettingsAutoedit->isOn() )
1.1347 + mainWindow->editHeading();
1.1348 + if (!actionSettingsAutoselectHeading->isOn()
1.1349 + )//&& !wasScrolled) //FIXME wasScrolled was moved to addNewBranchInt
1.1350 + {
1.1351 + selection->unselect();
1.1352 + selection=oldselection;
1.1353 + selection->select();
1.1354 + }
1.1355 + }
1.1356 + }
1.1357 + }
1.1358 +}
1.1359 +
1.1360 +
1.1361 +void MapEditor::addNewBranchHere()
1.1362 +{
1.1363 + if (selection &&
1.1364 + (typeid(*selection) == typeid(BranchObj) ) )
1.1365 + {
1.1366 + BranchObj* bo1 = (BranchObj*) selection;
1.1367 + saveStatePart(selection, QString("Add new branch here").arg(getName(bo1)));
1.1368 +
1.1369 + bool wasScrolled=false;
1.1370 + BranchObj *newbo=NULL;
1.1371 + BranchObj *parbo=(BranchObj*)(selection->getParObj());
1.1372 + if (parbo)
1.1373 + {
1.1374 + // add below selection
1.1375 + newbo=parbo->insertBranch(bo1->getNum()+1);
1.1376 + }
1.1377
1.1378 LinkableMapObj *oldselection=selection;
1.1379 + ((BranchObj*)selection)->moveBranchTo (newbo,-1);
1.1380
1.1381 mapCenter->reposition();
1.1382 adjustCanvasSize();
1.1383 @@ -1580,13 +1751,8 @@
1.1384 selection->unselect();
1.1385 selection=newbo;
1.1386 selection->select();
1.1387 - if (actionSettingsPasteNewHeading->isOn() )
1.1388 - {
1.1389 - BranchObj *bo2= (BranchObj*)selection;
1.1390 - bo2->setHeading("");
1.1391 - }
1.1392 if (actionSettingsAutoedit->isOn() )
1.1393 - editHeading();
1.1394 + mainWindow->editHeading();
1.1395 if (!actionSettingsAutoselectHeading->isOn()
1.1396 && !wasScrolled)
1.1397 {
1.1398 @@ -1598,74 +1764,22 @@
1.1399 }
1.1400 }
1.1401
1.1402 -
1.1403 -void MapEditor::addNewBranchHere()
1.1404 -{
1.1405 - // Finish open lineEdits
1.1406 - if (lineedit) finishedLineEdit();
1.1407 -
1.1408 - if (selection &&
1.1409 - (typeid(*selection) == typeid(BranchObj) ) )
1.1410 - {
1.1411 - BranchObj* bo1 = (BranchObj*) selection;
1.1412 - saveState(selection, QString("Add new branch here").arg(getName(bo1)));
1.1413 -
1.1414 - bool wasScrolled=false;
1.1415 - BranchObj *newbo=NULL;
1.1416 - BranchObj *parbo=(BranchObj*)(selection->getParObj());
1.1417 - if (parbo)
1.1418 - {
1.1419 - // add below selection
1.1420 - newbo=parbo->insertBranch(bo1->getNum()+1);
1.1421 - }
1.1422 -
1.1423 - LinkableMapObj *oldselection=selection;
1.1424 - ((BranchObj*)selection)->moveBranchTo (newbo,-1);
1.1425 -
1.1426 - mapCenter->reposition();
1.1427 - adjustCanvasSize();
1.1428 - if (actionSettingsAutoedit->isOn() ||
1.1429 - actionSettingsAutoselectHeading->isOn() )
1.1430 - {
1.1431 - selection->unselect();
1.1432 - selection=newbo;
1.1433 - selection->select();
1.1434 - if (actionSettingsPasteNewHeading->isOn() )
1.1435 - {
1.1436 - BranchObj *bo2= (BranchObj*)selection;
1.1437 - bo2->setHeading("");
1.1438 - }
1.1439 - if (actionSettingsAutoedit->isOn() )
1.1440 - editHeading();
1.1441 - if (!actionSettingsAutoselectHeading->isOn()
1.1442 - && !wasScrolled)
1.1443 - {
1.1444 - selection->unselect();
1.1445 - selection=oldselection;
1.1446 - selection->select();
1.1447 - }
1.1448 - }
1.1449 - }
1.1450 -}
1.1451 -
1.1452 void MapEditor::deleteSelection()
1.1453 {
1.1454 - // Finish open lineEdits
1.1455 - if (lineedit) finishedLineEdit();
1.1456 -
1.1457 if (selection && typeid(*selection) ==typeid(BranchObj) )
1.1458 {
1.1459 - BranchObj* bo=dynamic_cast <BranchObj*> (selection);
1.1460 + BranchObj* bo=(BranchObj*)selection;
1.1461 BranchObj* par=(BranchObj*)(bo->getParObj());
1.1462 bo->unselect();
1.1463 if (selection->getDepth()>1)
1.1464 // Normal branch, save parent with childs
1.1465 - saveState(par,QString("Delete %1").arg(getName(bo)));
1.1466 + saveStatePart(par,QString("Delete %1").arg(getName(bo)));
1.1467 + // naveState (UndoCom, par, QString("insertBranchAt (%1)", bo, "", QString ("Delete %1").arg(getName(bo))));
1.1468 else
1.1469 // Mainbranch, save whole map
1.1470 // TODO Better would be to insert mainbranch again at pos
1.1471 // But undoCommand is missing right now
1.1472 - saveState(QString("Delete %1").arg(getName(bo)));
1.1473 + saveStateComplete(QString("Delete %1").arg(getName(bo)));
1.1474 selection=NULL;
1.1475 par->removeBranch(bo);
1.1476 selection=par;
1.1477 @@ -1676,9 +1790,9 @@
1.1478 }
1.1479 if (selection && typeid(*selection) ==typeid(FloatImageObj) )
1.1480 {
1.1481 - FloatImageObj* fio=dynamic_cast <FloatImageObj*> (selection);
1.1482 + FloatImageObj* fio=(FloatImageObj*)selection;
1.1483 BranchObj* par=(BranchObj*)(fio->getParObj());
1.1484 - saveState(par, QString("Delete %1").arg(getName(fio)));
1.1485 + saveStatePart(par, QString("Delete %1").arg(getName(fio)));
1.1486 fio->unselect();
1.1487 selection=NULL;
1.1488 par->removeFloatImage(fio);
1.1489 @@ -1732,7 +1846,13 @@
1.1490 return false;
1.1491 }
1.1492
1.1493 -void MapEditor::select (LinkableMapObj *lmo)
1.1494 +QString MapEditor::getSelectString()
1.1495 +{
1.1496 + if (selection) return selection->getSelectString();
1.1497 + return QString();
1.1498 +}
1.1499 +
1.1500 +void MapEditor::selectInt (LinkableMapObj *lmo)
1.1501 {
1.1502 if (lmo && selection != lmo)
1.1503 {
1.1504 @@ -1743,10 +1863,9 @@
1.1505
1.1506 adjustCanvasSize();
1.1507 }
1.1508 -
1.1509 }
1.1510
1.1511 -void MapEditor::selectNextBranch()
1.1512 +void MapEditor::selectNextBranchInt()
1.1513 {
1.1514 // Increase number of branch
1.1515 if (selection)
1.1516 @@ -1826,7 +1945,7 @@
1.1517 }
1.1518 }
1.1519
1.1520 -void MapEditor::selectPrevBranch()
1.1521 +void MapEditor::selectPrevBranchInt()
1.1522 {
1.1523 // Decrease number of branch
1.1524 if (selection)
1.1525 @@ -1907,40 +2026,34 @@
1.1526
1.1527 void MapEditor::selectUpperBranch()
1.1528 {
1.1529 - // Finish open lineEdits
1.1530 - if (lineedit) finishedLineEdit();
1.1531 -
1.1532 if (selection)
1.1533 {
1.1534 if (typeid(*selection) == typeid(BranchObj))
1.1535 {
1.1536 if (selection->getOrientation()==OrientRightOfCenter)
1.1537 - selectPrevBranch();
1.1538 + selectPrevBranchInt();
1.1539 else
1.1540 if (selection->getDepth()==1)
1.1541 - selectNextBranch();
1.1542 + selectNextBranchInt();
1.1543 else
1.1544 - selectPrevBranch();
1.1545 + selectPrevBranchInt();
1.1546 }
1.1547 }
1.1548 }
1.1549
1.1550 void MapEditor::selectLowerBranch()
1.1551 {
1.1552 - // Finish open lineEdits
1.1553 - if (lineedit) finishedLineEdit();
1.1554 -
1.1555 if (selection)
1.1556 {
1.1557 if (typeid(*selection) == typeid(BranchObj))
1.1558 {
1.1559 if (selection->getOrientation()==OrientRightOfCenter)
1.1560 - selectNextBranch();
1.1561 + selectNextBranchInt();
1.1562 else
1.1563 if (selection->getDepth()==1)
1.1564 - selectPrevBranch();
1.1565 + selectPrevBranchInt();
1.1566 else
1.1567 - selectNextBranch();
1.1568 + selectNextBranchInt();
1.1569 }
1.1570 }
1.1571 }
1.1572 @@ -1948,9 +2061,6 @@
1.1573
1.1574 void MapEditor::selectLeftBranch()
1.1575 {
1.1576 - // Finish open lineEdits
1.1577 - if (lineedit) finishedLineEdit();
1.1578 -
1.1579 BranchObj* bo;
1.1580 BranchObj* par;
1.1581 if (selection)
1.1582 @@ -2010,9 +2120,6 @@
1.1583
1.1584 void MapEditor::selectRightBranch()
1.1585 {
1.1586 - // Finish open lineEdits
1.1587 - if (lineedit) finishedLineEdit();
1.1588 -
1.1589 BranchObj* bo;
1.1590 BranchObj* par;
1.1591
1.1592 @@ -2024,7 +2131,7 @@
1.1593 bo=par->getLastSelectedBranch();
1.1594 if (bo)
1.1595 {
1.1596 - // Workaround for relecting on left and right side
1.1597 + // Workaround for reselecting on left and right side
1.1598 if (bo->getOrientation()==OrientLeftOfCenter)
1.1599 bo=par->getFirstBranch();
1.1600 if (bo)
1.1601 @@ -2070,9 +2177,6 @@
1.1602
1.1603 void MapEditor::selectFirstBranch()
1.1604 {
1.1605 - // Finish open lineEdits
1.1606 - if (lineedit) finishedLineEdit();
1.1607 -
1.1608 BranchObj *bo1;
1.1609 BranchObj *bo2;
1.1610 BranchObj* par;
1.1611 @@ -2095,9 +2199,6 @@
1.1612
1.1613 void MapEditor::selectLastBranch()
1.1614 {
1.1615 - // Finish open lineEdits
1.1616 - if (lineedit) finishedLineEdit();
1.1617 -
1.1618 BranchObj *bo1;
1.1619 BranchObj *bo2;
1.1620 BranchObj* par;
1.1621 @@ -2125,13 +2226,11 @@
1.1622
1.1623 void MapEditor::selectBackgroundColor()
1.1624 {
1.1625 - // Finish open lineEdits
1.1626 - if (lineedit) finishedLineEdit();
1.1627 -
1.1628 QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
1.1629 if ( !col.isValid() ) return;
1.1630 setBackgroundColor( col );
1.1631 - saveState(QString("Set background color of map to %1").arg(col.name()));
1.1632 + //TODO undocomm
1.1633 + saveStateComplete(QString("Set background color of map to %1").arg(col.name()));
1.1634 }
1.1635
1.1636 void MapEditor::setBackgroundColor(QColor c)
1.1637 @@ -2161,7 +2260,7 @@
1.1638 typeid(*selection) == typeid(MapCenterObj))
1.1639 {
1.1640 BranchObj *bo=(BranchObj*)selection;
1.1641 - saveState(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.1642 + saveStatePart(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.1643 bo->setColor(actColor); // color branch
1.1644 }
1.1645 }
1.1646 @@ -2175,7 +2274,7 @@
1.1647 typeid(*selection) == typeid(MapCenterObj))
1.1648 {
1.1649 BranchObj *bo=(BranchObj*)selection;
1.1650 - saveState(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.1651 + saveStatePart(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand
1.1652 bo->setColorChilds(actColor); // color links, color childs
1.1653 }
1.1654 }
1.1655 @@ -2186,15 +2285,27 @@
1.1656 {
1.1657 if (selection)
1.1658 {
1.1659 - BranchObj *bo=(BranchObj*)selection;
1.1660 - QString s;
1.1661 - if (bo->isSetStandardFlag(f))
1.1662 - s="Unset";
1.1663 - else
1.1664 - s="Set";
1.1665 - saveState(selection, QString("%1 standard flag \"%2\" of %3").arg(s).arg(f).arg(getName(bo)));// TODO undoCommand
1.1666 - bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn());
1.1667 - adjustCanvasSize();
1.1668 + if (typeid(*selection) == typeid(BranchObj) ||
1.1669 + typeid(*selection) == typeid(MapCenterObj))
1.1670 + {
1.1671 + BranchObj *bo=(BranchObj*)selection;
1.1672 + QString u,r;
1.1673 + if (bo->isSetStandardFlag(f))
1.1674 + {
1.1675 + r="unsetFlag";
1.1676 + u="setFlag";
1.1677 + }
1.1678 + else
1.1679 + {
1.1680 + u="unsetFlag";
1.1681 + r="setFlag";
1.1682 + }
1.1683 + saveStateConstSelection(QString("%1 (\"%2\")").arg(u).arg(f),
1.1684 + QString("%1 (\"%2\")").arg(r).arg(f),
1.1685 + QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo)));
1.1686 + bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn());
1.1687 + adjustCanvasSize();
1.1688 + }
1.1689 }
1.1690 }
1.1691
1.1692 @@ -2208,6 +2319,9 @@
1.1693
1.1694 BranchObj* MapEditor::findText (QString s, bool cs)
1.1695 {
1.1696 + QTextDocument::FindFlags flags=0;
1.1697 + if (cs) flags=QTextDocument::FindCaseSensitively;
1.1698 +
1.1699 if (!itFind)
1.1700 { // Nothing found or new find process
1.1701 if (EOFind)
1.1702 @@ -2232,7 +2346,7 @@
1.1703 adjustCanvasSize();
1.1704 ensureSelectionVisible();
1.1705 }
1.1706 - if (textEditor->findText(s,cs))
1.1707 + if (textEditor->findText(s,flags))
1.1708 {
1.1709 searching=false;
1.1710 foundNote=true;
1.1711 @@ -2282,7 +2396,7 @@
1.1712 if ( ok)
1.1713 {
1.1714 // user entered something and pressed OK
1.1715 - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text));
1.1716 + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text));
1.1717 bo->setURL (text);
1.1718 updateActions();
1.1719 }
1.1720 @@ -2298,13 +2412,31 @@
1.1721 return "";
1.1722 }
1.1723
1.1724 +QStringList MapEditor::getURLs()
1.1725 +{
1.1726 + QStringList urls;
1.1727 + if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1728 + typeid(*selection) == typeid(MapCenterObj)) )
1.1729 + {
1.1730 + BranchObj *bo=(BranchObj*)selection;
1.1731 + bo=bo->first();
1.1732 + while (bo)
1.1733 + {
1.1734 + if (!bo->getURL().isEmpty()) urls.append( bo->getURL());
1.1735 + bo=bo->next();
1.1736 + }
1.1737 + }
1.1738 + return urls;
1.1739 +}
1.1740 +
1.1741 +
1.1742 void MapEditor::editHeading2URL()
1.1743 {
1.1744 if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1745 typeid(*selection) == typeid(MapCenterObj)) )
1.1746 {
1.1747 BranchObj *bo=(BranchObj*)selection;
1.1748 - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo)));
1.1749 + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo)));
1.1750 bo->setURL (bo->getHeading());
1.1751 updateActions();
1.1752 }
1.1753 @@ -2317,7 +2449,7 @@
1.1754 {
1.1755 BranchObj *bo=(BranchObj*)selection;
1.1756 QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
1.1757 - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo)));
1.1758 + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo)));
1.1759 bo->setURL (url);
1.1760 updateActions();
1.1761 }
1.1762 @@ -2330,7 +2462,7 @@
1.1763 {
1.1764 BranchObj *bo=(BranchObj*)selection;
1.1765 QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
1.1766 - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo)));
1.1767 + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo)));
1.1768 bo->setURL (url);
1.1769 updateActions();
1.1770 }
1.1771 @@ -2342,7 +2474,7 @@
1.1772 typeid(*selection) == typeid(MapCenterObj)) )
1.1773 {
1.1774 BranchObj *bo=(BranchObj*)selection;
1.1775 - QFileDialog *fd=new QFileDialog( this,__VYM " - " +tr("Link to another map"));
1.1776 + Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Link to another map"));
1.1777 fd->addFilter (QString (tr("vym map") + " (*.vym)"));
1.1778 fd->setCaption(__VYM " - " +tr("Link to another map"));
1.1779 if (! bo->getVymLink().isEmpty() )
1.1780 @@ -2352,7 +2484,7 @@
1.1781 QString fn;
1.1782 if ( fd->exec() == QDialog::Accepted )
1.1783 {
1.1784 - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()));
1.1785 + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()));
1.1786 bo->setVymLink (fd->selectedFile() );
1.1787 updateActions();
1.1788 mapCenter->reposition();
1.1789 @@ -2368,7 +2500,7 @@
1.1790 typeid(*selection) == typeid(MapCenterObj)) )
1.1791 {
1.1792 BranchObj *bo=(BranchObj*)selection;
1.1793 - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo)));
1.1794 + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo)));
1.1795 bo->setVymLink ("" );
1.1796 updateActions();
1.1797 mapCenter->reposition();
1.1798 @@ -2396,7 +2528,7 @@
1.1799 oo->setHideInExport(true);
1.1800 s="Set";
1.1801 }
1.1802 - saveState(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand
1.1803 + saveStateComplete(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand
1.1804 actionEditToggleHideExport->setOn (oo->hideInExport());
1.1805 updateActions();
1.1806 mapCenter->reposition();
1.1807 @@ -2416,6 +2548,24 @@
1.1808
1.1809 }
1.1810
1.1811 +QStringList MapEditor::getVymLinks()
1.1812 +{
1.1813 + QStringList links;
1.1814 + if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.1815 + typeid(*selection) == typeid(MapCenterObj)) )
1.1816 + {
1.1817 + BranchObj *bo=(BranchObj*)selection;
1.1818 + bo=bo->first();
1.1819 + while (bo)
1.1820 + {
1.1821 + if (!bo->getVymLink().isEmpty()) links.append( bo->getVymLink());
1.1822 + bo=bo->next();
1.1823 + }
1.1824 + }
1.1825 + return links;
1.1826 +}
1.1827 +
1.1828 +
1.1829 void MapEditor::removeBranchKeepChilds()
1.1830 {
1.1831 if (selection && (typeid(*selection) == typeid(BranchObj) ))
1.1832 @@ -2424,9 +2574,9 @@
1.1833 BranchObj* par=(BranchObj*)(bo->getParObj());
1.1834 QString s=QString("Remove %1 and keep its childs").arg(getName(bo));
1.1835 if (bo->getDepth()==1)
1.1836 - saveState(s);
1.1837 + saveStateComplete(s);
1.1838 else
1.1839 - saveState(selection->getParObj(),s); // TODO undoCommand
1.1840 + saveStatePart(selection->getParObj(),s); // TODO undoCommand
1.1841 QString sel=selection->getSelectString();
1.1842 unselect();
1.1843 par->removeBranchHere(bo);
1.1844 @@ -2439,7 +2589,7 @@
1.1845 {
1.1846 if (selection && (typeid(*selection) == typeid(BranchObj) ))
1.1847 {
1.1848 - saveState(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection)));
1.1849 + saveStatePart(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection)));
1.1850 ((BranchObj*)selection)->removeChilds();
1.1851 mapCenter->reposition();
1.1852 }
1.1853 @@ -2455,8 +2605,8 @@
1.1854 // Calc some stats
1.1855 QString stats;
1.1856 int i=0;
1.1857 - QCanvasItemList l=canvas()->allItems();
1.1858 - for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it)
1.1859 + Q3CanvasItemList l=canvas()->allItems();
1.1860 + for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it)
1.1861 i++;
1.1862 stats+=QString ("%1 items on canvas\n").arg (i,6);
1.1863
1.1864 @@ -2483,7 +2633,7 @@
1.1865 // Finally show dialog
1.1866 if (dia.exec() == QDialog::Accepted)
1.1867 {
1.1868 - saveState("Edit info about map"); //TODO undoCommand
1.1869 + saveStateComplete("Edit info about map"); //TODO undoCommand
1.1870 mapCenter->setAuthor (dia.getAuthor() );
1.1871 mapCenter->setComment (dia.getComment() );
1.1872 }
1.1873 @@ -2521,8 +2671,16 @@
1.1874 pix.fill( defLinkColor );
1.1875 actionFormatLinkColor->setIconSet( pix );
1.1876
1.1877 - actionEditUndo->setEnabled( mapChanged );
1.1878 actionFileSave->setEnabled( mapUnsaved );
1.1879 + if (undoSet.readNumEntry("/history/undosAvail",0)>0)
1.1880 + actionEditUndo->setEnabled( true);
1.1881 + else
1.1882 + actionEditUndo->setEnabled( false);
1.1883 +
1.1884 + if (undoSet.readNumEntry("/history/redosAvail",0)>0)
1.1885 + actionEditRedo->setEnabled( true);
1.1886 + else
1.1887 + actionEditRedo->setEnabled( false);
1.1888
1.1889 if (selection)
1.1890 {
1.1891 @@ -2533,17 +2691,14 @@
1.1892 // Take care of links
1.1893 if (bo->countXLinks()==0)
1.1894 {
1.1895 - branchLinksContextMenu->clear();
1.1896 - branchLinksContextMenu->insertItem ("No xLink available");
1.1897 - branchLinksContextMenuDup->clear();
1.1898 - branchLinksContextMenuDup->insertItem ("No xLink available");
1.1899 -
1.1900 + branchXLinksContextMenuEdit->clear();
1.1901 + branchXLinksContextMenuFollow->clear();
1.1902 } else
1.1903 {
1.1904 BranchObj *bot;
1.1905 QString s;
1.1906 - branchLinksContextMenu->clear();
1.1907 - branchLinksContextMenuDup->clear();
1.1908 + branchXLinksContextMenuEdit->clear();
1.1909 + branchXLinksContextMenuFollow->clear();
1.1910 for (int i=0; i<=bo->countXLinks();i++)
1.1911 {
1.1912 bot=bo->XLinkTargetAt(i);
1.1913 @@ -2552,8 +2707,8 @@
1.1914 s=bot->getHeading();
1.1915 if (s.length()>25)
1.1916 s=s.left(25)+"...";
1.1917 - branchLinksContextMenu->insertItem (s);
1.1918 - branchLinksContextMenuDup->insertItem (s);
1.1919 + branchXLinksContextMenuFollow->addAction (s);
1.1920 + branchXLinksContextMenuEdit->addAction (s);
1.1921 }
1.1922 }
1.1923 }
1.1924 @@ -2629,7 +2784,7 @@
1.1925 if ( (typeid(*selection) == typeid(FloatImageObj)) )
1.1926 {
1.1927 FloatObj *fo=(FloatImageObj*)selection;
1.1928 - standardFlagsDefault->setEnabled (false);
1.1929 +//FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
1.1930
1.1931 actionEditOpenURL->setEnabled (false);
1.1932 actionEditOpenVymLink->setEnabled (false);
1.1933 @@ -2652,7 +2807,7 @@
1.1934
1.1935 } else
1.1936 {
1.1937 - standardFlagsDefault->setEnabled (false);
1.1938 +//FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
1.1939
1.1940 actionEditCopy->setEnabled (false);
1.1941 actionEditCut->setEnabled (false);
1.1942 @@ -2684,7 +2839,7 @@
1.1943 {
1.1944 linkstyle=ls;
1.1945
1.1946 - saveState("Set link style"); // TODO undoCommand
1.1947 + saveStateComplete("Set link style"); // TODO undoCommand
1.1948 BranchObj *bo;
1.1949 bo=mapCenter->first();
1.1950 bo=bo->next();
1.1951 @@ -2772,13 +2927,10 @@
1.1952
1.1953 void MapEditor::selectLinkColor()
1.1954 {
1.1955 - // Finish open lineEdits
1.1956 - if (lineedit) finishedLineEdit();
1.1957 -
1.1958 QColor col = QColorDialog::getColor( defLinkColor, this );
1.1959 if ( !col.isValid() ) return;
1.1960 setLinkColor( col );
1.1961 - saveState(QString("Set link color to %1").arg(col.name())); //TODO undoCommand
1.1962 + saveStateComplete(QString("Set link color to %1").arg(col.name())); //TODO undoCommand
1.1963
1.1964 }
1.1965
1.1966 @@ -2794,7 +2946,7 @@
1.1967 s="Unscroll";
1.1968 else
1.1969 s="Scroll";
1.1970 - saveState(selection, QString ("%1 %2").arg(s).arg(getName(bo)));
1.1971 + saveStatePart(selection, QString ("%1 %2").arg(s).arg(getName(bo)));
1.1972 bo->toggleScroll();
1.1973 adjustCanvasSize();
1.1974 canvas()->update();
1.1975 @@ -2820,13 +2972,13 @@
1.1976 {
1.1977 BranchObj *bo=((BranchObj*)selection);
1.1978
1.1979 - QFileDialog *fd=new QFileDialog( this);
1.1980 - fd->setMode (QFileDialog::ExistingFiles);
1.1981 + Q3FileDialog *fd=new Q3FileDialog( this);
1.1982 + fd->setMode (Q3FileDialog::ExistingFiles);
1.1983 fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
1.1984 ImagePreview *p =new ImagePreview (fd);
1.1985 fd->setContentsPreviewEnabled( TRUE );
1.1986 fd->setContentsPreview( p, p );
1.1987 - fd->setPreviewMode( QFileDialog::Contents );
1.1988 + fd->setPreviewMode( Q3FileDialog::Contents );
1.1989 fd->setCaption(__VYM " - " +tr("Load image"));
1.1990 fd->setDir (lastImageDir);
1.1991 fd->show();
1.1992 @@ -2834,8 +2986,9 @@
1.1993 QString fn;
1.1994 if ( fd->exec() == QDialog::Accepted )
1.1995 {
1.1996 - saveState(selection, QString("Add floatimage to %1").arg(getName(selection)));
1.1997 - lastImageDir=fn.left(fn.findRev ("/"));
1.1998 + saveStatePart(selection, QString("Add floatimage to %1").arg(getName(selection)));
1.1999 + // FIXME in QT4 use: lastImageDir=fd->directory();
1.2000 + lastImageDir=QDir (fd->dirPath());
1.2001 QStringList flist = fd->selectedFiles();
1.2002 QStringList::Iterator it = flist.begin();
1.2003 while( it != flist.end() )
1.2004 @@ -2857,26 +3010,18 @@
1.2005 }
1.2006 }
1.2007
1.2008 -void MapEditor::saveFloatImage (int item)
1.2009 +void MapEditor::saveFloatImage ()
1.2010 {
1.2011 if (selection &&
1.2012 (typeid(*selection) == typeid(FloatImageObj)) )
1.2013 {
1.2014 FloatImageObj *fio=((FloatImageObj*)selection);
1.2015 - const char* fmt = saveImageFormatMenu->text(item);
1.2016 -
1.2017 - QFileDialog *fd=new QFileDialog( this, tr("vym - save image as") + fmt);
1.2018 - fd->addFilter ("PNG (*.png)");
1.2019 - fd->addFilter ("BMP (*.bmp)");
1.2020 - fd->addFilter ("XBM (*.xbm)");
1.2021 - fd->addFilter ("JPG (*.jpg)");
1.2022 - fd->addFilter ("XPM (*.xpm)");
1.2023 - fd->addFilter ("GIF (*.gif)");
1.2024 - fd->addFilter ("PNM (*.pnm)");
1.2025 - fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
1.2026 - fd->setCaption(__VYM " - " +tr("Save image as %1").arg(fmt));
1.2027 - fd->setMode( QFileDialog::AnyFile );
1.2028 - fd->setSelection (fio->getOriginalFilename());
1.2029 + QFileDialog *fd=new QFileDialog( this);
1.2030 + fd->setFilters (imageIO.getFilters());
1.2031 + fd->setCaption(__VYM " - " +tr("Save image"));
1.2032 + fd->setFileMode( QFileDialog::AnyFile );
1.2033 + fd->setDirectory (lastImageDir);
1.2034 +// fd->setSelection (fio->getOriginalFilename());
1.2035 fd->show();
1.2036
1.2037 QString fn;
1.2038 @@ -2905,7 +3050,7 @@
1.2039 break;
1.2040 }
1.2041 }
1.2042 - fio->save (fd->selectedFile(),fmt);
1.2043 + fio->save (fd->selectedFile(),imageIO.getType (fd->selectedFilter() ) );
1.2044 }
1.2045 }
1.2046 }
1.2047 @@ -2949,7 +3094,7 @@
1.2048 selection->setHideLinkUnselected(b);
1.2049 }
1.2050
1.2051 -void MapEditor::importDir(BranchObj *dst, QDir d)
1.2052 +void MapEditor::importDirInt(BranchObj *dst, QDir d)
1.2053 {
1.2054 if (selection &&
1.2055 (typeid(*selection) == typeid(BranchObj)) ||
1.2056 @@ -2959,45 +3104,42 @@
1.2057
1.2058 // Traverse directories
1.2059 d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
1.2060 - const QFileInfoList *dirlist = d.entryInfoList();
1.2061 - QFileInfoListIterator itdir( *dirlist );
1.2062 - QFileInfo *fi;
1.2063 -
1.2064 - while ( (fi = itdir.current()) != 0 )
1.2065 + QFileInfoList list = d.entryInfoList();
1.2066 + QFileInfo fi;
1.2067 +
1.2068 + for (int i = 0; i < list.size(); ++i)
1.2069 {
1.2070 - if (fi->fileName() != "." && fi->fileName() != ".." )
1.2071 + fi=list.at(i);
1.2072 + if (fi.fileName() != "." && fi.fileName() != ".." )
1.2073 {
1.2074 dst->addBranch();
1.2075 bo=dst->getLastBranch();
1.2076 - bo->setHeading (fi->fileName() );
1.2077 + bo->setHeading (fi.fileName() );
1.2078 bo->setColor (QColor("blue"));
1.2079 bo->toggleScroll();
1.2080 - if ( !d.cd(fi->fileName()) )
1.2081 - QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi->fileName()));
1.2082 + if ( !d.cd(fi.fileName()) )
1.2083 + QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi.fileName()));
1.2084 else
1.2085 {
1.2086 // Recursively add subdirs
1.2087 - importDir (bo,d);
1.2088 + importDirInt (bo,d);
1.2089 d.cdUp();
1.2090 }
1.2091 }
1.2092 - ++itdir;
1.2093 }
1.2094 // Traverse files
1.2095 d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
1.2096 - const QFileInfoList *filelist = d.entryInfoList();
1.2097 - QFileInfoListIterator itfile( *filelist );
1.2098 -
1.2099 - while ( (fi = itfile.current()) != 0 )
1.2100 + list = d.entryInfoList();
1.2101 +
1.2102 + for (int i = 0; i < list.size(); ++i)
1.2103 {
1.2104 + fi=list.at(i);
1.2105 dst->addBranch();
1.2106 bo=dst->getLastBranch();
1.2107 - bo->setHeading (fi->fileName() );
1.2108 + bo->setHeading (fi.fileName() );
1.2109 bo->setColor (QColor("black"));
1.2110 - if (fi->fileName().right(4) == ".vym" )
1.2111 - bo->setVymLink (fi->filePath());
1.2112 -
1.2113 - ++itfile;
1.2114 + if (fi.fileName().right(4) == ".vym" )
1.2115 + bo->setVymLink (fi.filePath());
1.2116 }
1.2117 }
1.2118 }
1.2119 @@ -3008,8 +3150,8 @@
1.2120 (typeid(*selection) == typeid(BranchObj)) ||
1.2121 (typeid(*selection) == typeid(MapCenterObj)) )
1.2122 {
1.2123 - QFileDialog *fd=new QFileDialog( this,__VYM " - " +tr("Choose directory structure to import"));
1.2124 - fd->setMode (QFileDialog::DirectoryOnly);
1.2125 + Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Choose directory structure to import"));
1.2126 + fd->setMode (Q3FileDialog::DirectoryOnly);
1.2127 fd->addFilter (QString (tr("vym map") + " (*.vym)"));
1.2128 fd->setCaption(__VYM " - " +tr("Choose directory structure to import"));
1.2129 fd->show();
1.2130 @@ -3018,7 +3160,7 @@
1.2131 if ( fd->exec() == QDialog::Accepted )
1.2132 {
1.2133 BranchObj *bo=((BranchObj*)selection);
1.2134 - importDir (bo,QDir(fd->selectedFile()) );
1.2135 + importDirInt (bo,QDir(fd->selectedFile()) );
1.2136 mapCenter->reposition();
1.2137 adjustCanvasSize();
1.2138 canvas()->update();
1.2139 @@ -3045,6 +3187,7 @@
1.2140
1.2141 void MapEditor::editXLink(int i)
1.2142 {
1.2143 + qDebug ("ko."); //FIXME Huh?
1.2144 if (selection &&
1.2145 (typeid(*selection) == typeid(BranchObj)) ||
1.2146 (typeid(*selection) == typeid(MapCenterObj)) )
1.2147 @@ -3064,7 +3207,7 @@
1.2148 }
1.2149 if (dia.deleteXLink())
1.2150 ((BranchObj*)selection)->deleteXLinkAt(i);
1.2151 - saveState("Edit xLink"); //TODO undoCommand
1.2152 + saveStateComplete("Edit xLink"); //TODO undoCommand
1.2153 }
1.2154 }
1.2155 }
1.2156 @@ -3074,33 +3217,44 @@
1.2157 {
1.2158 cout << "MapEditor::testFunction() called\n";
1.2159
1.2160 - mapCenter->positionBBox();
1.2161 +/*
1.2162 + bool ok;
1.2163 + QString text = QInputDialog::getText(
1.2164 + this,
1.2165 + tr("QInputDialog::getText()"),
1.2166 + tr("User name:"), QLineEdit::Normal,
1.2167 + QDir::home().dirName(), &ok, Qt::FramelessWindowHint);
1.2168 +*/
1.2169 +
1.2170 + QDialog *d =new QDialog(NULL);
1.2171 + QLineEdit *le=new QLineEdit (d);
1.2172 +// d->setModal (true);
1.2173 + d->setWindowFlags (Qt::FramelessWindowHint);
1.2174 + le->setFocus();
1.2175 + le->setText ("Foo");
1.2176 + le->selectAll();
1.2177 + connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
1.2178 + d->exec();
1.2179 + qWarning( le->text());
1.2180 return;
1.2181 -
1.2182 +
1.2183 +
1.2184 +
1.2185 +/*
1.2186 WarningDialog dia;
1.2187 dia.setCancelButton (true);
1.2188 dia.setText("This is a longer \nWarning");
1.2189 dia.setCaption("Warning: Flux problem");
1.2190 - dia.setShowAgainName("/vym/warnings/mapeditor");
1.2191 + dia.setShowAgainName("/warnings/mapeditor");
1.2192 + dia.setWindowFlags (Qt::FramelessWindowHint);
1.2193 if (dia.exec()==QDialog::Accepted)
1.2194 cout << "accepted!\n";
1.2195 else
1.2196 cout << "canceled!\n";
1.2197 return;
1.2198 -
1.2199 - QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
1.2200 - QProcess *proc = new QProcess( this );
1.2201 - proc->addArgument(ub);
1.2202 -
1.2203 - if ( !proc->start() )
1.2204 - {
1.2205 - QMessageBox::warning(0,
1.2206 - tr("Warning"),
1.2207 - tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
1.2208 - }
1.2209 -
1.2210 -
1.2211 -/*
1.2212 +*/
1.2213 +
1.2214 +/* Hide hidden stuff temporary, maybe add this as regular function somewhere
1.2215 if (hidemode==HideNone)
1.2216 {
1.2217 setHideTmpMode (HideExport);
1.2218 @@ -3199,15 +3353,12 @@
1.2219 void MapEditor::contentsMousePressEvent(QMouseEvent* e)
1.2220 {
1.2221 // Ignore right clicks, these will go to context menus
1.2222 - if (e->button() == QMouseEvent::RightButton )
1.2223 + if (e->button() == Qt::RightButton )
1.2224 {
1.2225 e->ignore();
1.2226 return;
1.2227 }
1.2228
1.2229 - // Finish open lineEdits
1.2230 - if (lineedit) finishedLineEdit();
1.2231 -
1.2232 QPoint p = inverseWorldMatrix().map(e->pos());
1.2233 LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
1.2234
1.2235 @@ -3222,10 +3373,10 @@
1.2236 if (!foname.isEmpty())
1.2237 {
1.2238 // systemFlag clicked
1.2239 - select (lmo);
1.2240 + selectInt (lmo);
1.2241 if (foname=="url")
1.2242 {
1.2243 - if (e->state() & QMouseEvent::ControlButton)
1.2244 + if (e->state() & Qt::ControlModifier)
1.2245 mainWindow->editOpenURLTab();
1.2246 else
1.2247 mainWindow->editOpenURL();
1.2248 @@ -3245,7 +3396,7 @@
1.2249 // No system flag clicked, take care of modmodes
1.2250
1.2251 // Special case: CTRL is pressed
1.2252 - if (e->state() & QMouseEvent::ControlButton)
1.2253 + if (e->state() & Qt::ControlModifier)
1.2254 {
1.2255 if (actionModModeColor->isOn())
1.2256 {
1.2257 @@ -3280,19 +3431,20 @@
1.2258 }
1.2259 if (lmo)
1.2260 {
1.2261 - select (lmo);
1.2262 + selectInt (lmo);
1.2263 // Left Button Move Branches
1.2264 - if (e->button() == QMouseEvent::LeftButton )
1.2265 + if (e->button() == Qt::LeftButton )
1.2266 {
1.2267 movingObj_start.setX( p.x() - selection->x() );
1.2268 movingObj_start.setY( p.y() - selection->y() );
1.2269 movingObj_orgPos.setX (lmo->x() );
1.2270 movingObj_orgPos.setY (lmo->y() );
1.2271 + movingObj_orgRelPos=lmo->getRelPos();
1.2272
1.2273 // If modMode==copy, then we want to "move" the _new_ object around
1.2274 // then we need the offset from p to the _old_ selection, because of tmp
1.2275 if (actionModModeCopy->isOn() &&
1.2276 - e->state() & QMouseEvent::ControlButton)
1.2277 + e->state() & Qt::ControlModifier)
1.2278 {
1.2279 if (typeid(*selection)==typeid(BranchObj) )
1.2280 {
1.2281 @@ -3309,13 +3461,13 @@
1.2282 // Middle Button Toggle Scroll
1.2283 // (On Mac OS X this won't work, but we still have
1.2284 // a button in the toolbar)
1.2285 - if (e->button() == QMouseEvent::MidButton )
1.2286 + if (e->button() == Qt::MidButton )
1.2287 toggleScroll();
1.2288 updateActions();
1.2289 } else
1.2290 { // No MapObj found, we are on the Canvas itself
1.2291 // Left Button move Pos of CanvasView
1.2292 - if (e->button() == QMouseEvent::LeftButton )
1.2293 + if (e->button() == Qt::LeftButton )
1.2294 {
1.2295 movingObj=NULL; // move Content not Obj
1.2296 movingObj_start=e->globalPos();
1.2297 @@ -3353,16 +3505,13 @@
1.2298 if (typeid(*selection) == typeid(FloatImageObj))
1.2299 {
1.2300 FloatObj *fo=(FloatObj*)selection;
1.2301 - saveState(
1.2302 - "move "+qpointToString(movingObj_orgPos),fo->getSelectString() ,
1.2303 - QString("Move %1").arg(getName(selection)));
1.2304 fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.2305 fo->setRelPos();
1.2306 fo->reposition();
1.2307
1.2308 // Relink float to new mapcenter or branch, if shift is pressed
1.2309 // Only relink, if selection really has a new parent
1.2310 - if ( (e->state() & QMouseEvent::ShiftButton) && lmo &&
1.2311 + if ( (e->state() & Qt::ShiftModifier) && lmo &&
1.2312 ( (typeid(*lmo)==typeid(BranchObj)) ||
1.2313 (typeid(*lmo)==typeid(MapCenterObj)) ) &&
1.2314 ( lmo != fo->getParObj())
1.2315 @@ -3370,7 +3519,8 @@
1.2316 {
1.2317 if (typeid(*fo) == typeid(FloatImageObj))
1.2318 {
1.2319 - saveState(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
1.2320 + //TODO undocom
1.2321 + saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
1.2322 FloatImageObj *fio=(FloatImageObj*)(fo);
1.2323 ((BranchObj*)(lmo))->addFloatImage (fio);
1.2324 fio->unselect();
1.2325 @@ -3387,7 +3537,7 @@
1.2326 {
1.2327 if (lmosel->getDepth()==0)
1.2328 {
1.2329 - if (e->state() == (LeftButton | !ShiftButton))
1.2330 + if (e->state() == Qt::LeftButton && e->modifiers()==Qt::ShiftModifier)
1.2331 // If mapCenter is moved, move all the rest by default, too.
1.2332 mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.2333 else
1.2334 @@ -3417,12 +3567,12 @@
1.2335 (typeid(*lmo) == typeid(MapCenterObj) )
1.2336 ) )
1.2337 {
1.2338 - if (e->state() & QMouseEvent::ControlButton)
1.2339 + if (e->state() & Qt::ControlModifier)
1.2340 {
1.2341 // Special case: CTRL to link below lmo
1.2342 lmosel->setParObjTmp (lmo,p,+1);
1.2343 }
1.2344 - else if (e->state() & QMouseEvent::ShiftButton)
1.2345 + else if (e->state() & Qt::ShiftModifier)
1.2346 lmosel->setParObjTmp (lmo,p,-1);
1.2347 else
1.2348 lmosel->setParObjTmp (lmo,p,0);
1.2349 @@ -3466,12 +3616,12 @@
1.2350 if (pickingColor)
1.2351 {
1.2352 pickingColor=false;
1.2353 - setCursor (ArrowCursor);
1.2354 + setCursor (Qt::ArrowCursor);
1.2355 // Check if we are over another branch
1.2356 dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL);
1.2357 if (dst && selection)
1.2358 {
1.2359 - if (e->state() & QMouseEvent::ShiftButton)
1.2360 + if (e->state() & Qt::ShiftModifier)
1.2361 {
1.2362 ((BranchObj*)selection)->setColor (((BranchObj*)(dst))->getColor());
1.2363 ((BranchObj*)selection)->setLinkColor ();
1.2364 @@ -3496,7 +3646,7 @@
1.2365 tmpXLink->setEnd ( ((BranchObj*)(dst)) );
1.2366 tmpXLink->updateXLink();
1.2367 tmpXLink->activate();
1.2368 - saveState(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand
1.2369 + saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand
1.2370 } else
1.2371 {
1.2372 delete(tmpXLink);
1.2373 @@ -3511,6 +3661,14 @@
1.2374 // Moved FloatObj? Maybe we need to reposition
1.2375 if(typeid(*selection)==typeid (FloatImageObj))
1.2376 {
1.2377 + FloatImageObj *fo=(FloatImageObj*)selection;
1.2378 + QString pold=qpointToString(movingObj_orgRelPos);
1.2379 + QString pnow=qpointToString(fo->getRelPos());
1.2380 + saveStateConstSelection(
1.2381 + "moveRel "+pold,
1.2382 + "moveRel "+pnow,
1.2383 + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow));
1.2384 +
1.2385 selection->getParObj()->requestReposition();
1.2386 mapCenter->reposition();
1.2387 }
1.2388 @@ -3532,41 +3690,64 @@
1.2389 // Reset the temporary drawn link to the original one
1.2390 ((LinkableMapObj*)selection)->unsetParObjTmp();
1.2391
1.2392 + // For Redo we may need to save original selection
1.2393 + QString preSelStr=selection->getSelectString();
1.2394
1.2395 copyingObj=false;
1.2396 if (dst )
1.2397 {
1.2398 - BranchObj* bs=((BranchObj*)selection);
1.2399 + BranchObj* bsel=(BranchObj*)selection;
1.2400 + BranchObj* bdst=(BranchObj*)dst;
1.2401 +
1.2402 + QString preParStr=(bsel->getParObj())->getSelectString();
1.2403 + QString preNum=QString::number (bsel->getNum(),10);
1.2404 + QString preDstParStr;
1.2405 +
1.2406 + if (e->state() & Qt::ShiftModifier && dst->getParObj())
1.2407 + { // Link above dst
1.2408 + preDstParStr=dst->getParObj()->getSelectString();
1.2409 + bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum());
1.2410 + } else
1.2411 + if (e->state() & Qt::ControlModifier && dst->getParObj())
1.2412 + {
1.2413 + // Link below dst
1.2414 + preDstParStr=dst->getParObj()->getSelectString();
1.2415 + bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()+1);
1.2416 + } else
1.2417 + { // Append to dst
1.2418 + preDstParStr=dst->getSelectString();
1.2419 + bsel->moveBranchTo (bdst,-1);
1.2420 + if (dst->getDepth()==0) bsel->move (savePos);
1.2421 + }
1.2422 + QString postSelStr=selection->getSelectString();
1.2423 + QString postNum=QString::number (bsel->getNum(),10);
1.2424 +
1.2425 QString undoCom="linkBranchToPos (\""+
1.2426 - (bs->getParObj())->getSelectString()+
1.2427 - "\","+
1.2428 - QString("%1").arg(bs->getNum())+
1.2429 - ","+
1.2430 - QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+
1.2431 - ")";
1.2432 - // TODO we also could check, if dest and src are on same branch,
1.2433 - // then it would be sufficient to saveState of this branch
1.2434 -
1.2435 - // Modifiers allow to insert above/below dst
1.2436 - if (e->state() & QMouseEvent::ShiftButton)
1.2437 - {
1.2438 - bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum());
1.2439 - } else
1.2440 - if (e->state() & QMouseEvent::ControlButton)
1.2441 - {
1.2442 - bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum()+1);
1.2443 - } else
1.2444 - {
1.2445 - bs->moveBranchTo ((BranchObj*)(dst),-1);
1.2446 - if (dst->getDepth()==0)
1.2447 - bs->move (savePos);
1.2448 - }
1.2449 - saveState (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) );
1.2450 + preParStr+ "\"," + preNum +"," +
1.2451 + QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")";
1.2452 +
1.2453 + QString redoCom="linkBranchToPos (\""+
1.2454 + preDstParStr + "\"," + postNum + "," +
1.2455 + QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")";
1.2456 +
1.2457 + saveState (
1.2458 + postSelStr,undoCom,
1.2459 + preSelStr, redoCom,
1.2460 + QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) );
1.2461 } else
1.2462 if (selection->getDepth()==1)
1.2463 - // If we have moved mainbranch only save endposition
1.2464 - saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos)));
1.2465 + {
1.2466 + // The select string might be different _after_ moving around.
1.2467 + // Therefor reposition and then use string of old selection, too
1.2468 + mapCenter->reposition();
1.2469 +
1.2470 + QString ps=qpointToString ( ((BranchObj*)selection)->getRelPos() );
1.2471 + saveState(
1.2472 + selection->getSelectString(), "moveRel "+qpointToString(movingObj_orgRelPos),
1.2473 + preSelStr, "moveRel "+ps,
1.2474 + QString("Move %1 to relative position %2").arg(getName(selection)).arg(ps));
1.2475
1.2476 + }
1.2477 // Draw the original link, before selection was moved around
1.2478 mapCenter->reposition();
1.2479 }
1.2480 @@ -3574,18 +3755,18 @@
1.2481 adjustCanvasSize();
1.2482 canvas()->update();
1.2483 movingObj=NULL;
1.2484 +
1.2485 + // Just make sure, that actions are still ok,e.g. the move branch up/down buttons...
1.2486 + updateActions();
1.2487 } else
1.2488 // maybe we moved View: set old cursor
1.2489 - setCursor (ArrowCursor);
1.2490 + setCursor (Qt::ArrowCursor);
1.2491
1.2492 }
1.2493
1.2494 void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e)
1.2495 {
1.2496 - // Finish open lineEdits
1.2497 - if (lineedit) finishedLineEdit();
1.2498 -
1.2499 - if (e->button() == QMouseEvent::LeftButton )
1.2500 + if (e->button() == Qt::LeftButton )
1.2501 {
1.2502 QPoint p = inverseWorldMatrix().map(e->pos());
1.2503 LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL);
1.2504 @@ -3594,14 +3775,14 @@
1.2505 if (selection) selection->unselect();
1.2506 selection=lmo;
1.2507 selection->select();
1.2508 - editHeading();
1.2509 + mainWindow->editHeading();
1.2510 }
1.2511 }
1.2512 }
1.2513
1.2514 void MapEditor::resizeEvent (QResizeEvent* e)
1.2515 {
1.2516 - QCanvasView::resizeEvent( e );
1.2517 + Q3CanvasView::resizeEvent( e );
1.2518 adjustCanvasSize();
1.2519 }
1.2520
1.2521 @@ -3616,7 +3797,7 @@
1.2522 (typeid(*selection) == typeid(MapCenterObj))) {
1.2523
1.2524 // If QImageDrag can decode mime type
1.2525 - if (QImageDrag::canDecode(event)) {
1.2526 + if (Q3ImageDrag::canDecode(event)) {
1.2527 event->accept();
1.2528 return;
1.2529 }
1.2530 @@ -3629,7 +3810,7 @@
1.2531 }
1.2532
1.2533 // If QUriDrag can decode mime type
1.2534 - if (QUriDrag::canDecode(event)) {
1.2535 + if (Q3UriDrag::canDecode(event)) {
1.2536 event->accept();
1.2537 return;
1.2538 }
1.2539 @@ -3641,7 +3822,7 @@
1.2540 }
1.2541
1.2542 // If QTextDrag can decode mime type
1.2543 - if (QTextDrag::canDecode(event)) {
1.2544 + if (Q3TextDrag::canDecode(event)) {
1.2545 event->accept();
1.2546 return;
1.2547 }
1.2548 @@ -3667,12 +3848,12 @@
1.2549 (typeid(*selection) == typeid(MapCenterObj)))
1.2550 {
1.2551 bool update=false;
1.2552 - QStrList uris;
1.2553 + Q3StrList uris;
1.2554 QString heading;
1.2555 if (event->provides("image/png"))
1.2556 {
1.2557 QPixmap pix;
1.2558 - if (QImageDrag::decode(event, pix))
1.2559 + if (Q3ImageDrag::decode(event, pix))
1.2560 {
1.2561 addFloatImage(pix);
1.2562 event->accept();
1.2563 @@ -3691,7 +3872,7 @@
1.2564 update=true;
1.2565 } else if (event->provides ("text/uri-list"))
1.2566 { // Uris provided e.g. by konqueror
1.2567 - QUriDrag::decode (event,uris);
1.2568 + Q3UriDrag::decode (event,uris);
1.2569 } else if (event->provides ("_NETSCAPE_URL"))
1.2570 { // Uris provided by Mozilla
1.2571 QStringList l = QStringList::split("\n", event->encodedData("_NETSCAPE_URL"));
1.2572 @@ -3737,8 +3918,9 @@
1.2573 bo=((BranchObj*)selection)->addBranch();
1.2574 if (bo)
1.2575 {
1.2576 - s=QUriDrag::uriToLocalFile(u);
1.2577 - if (s) {
1.2578 + s=Q3UriDrag::uriToLocalFile(u);
1.2579 + if (!s.isEmpty())
1.2580 + {
1.2581 QString file = QDir::convertSeparators(s);
1.2582 heading = QFileInfo(file).baseName();
1.2583 files.append(file);
1.2584 @@ -3746,12 +3928,13 @@
1.2585 bo->setVymLink(file);
1.2586 else
1.2587 bo->setURL(u);
1.2588 - } else {
1.2589 + } else
1.2590 + {
1.2591 urls.append (u);
1.2592 bo->setURL(u);
1.2593 }
1.2594
1.2595 - if (heading)
1.2596 + if (!heading.isEmpty())
1.2597 bo->setHeading(heading);
1.2598 else
1.2599 bo->setHeading(u);
1.2600 @@ -3763,7 +3946,7 @@
1.2601 if (update)
1.2602 {
1.2603 //FIXME saveState has to be called earlier for each of the drops...
1.2604 - saveState("Drop Event"); //TODO undo Command
1.2605 + saveStateComplete("Drop Event"); //TODO undo Command
1.2606 mapCenter->reposition();
1.2607 adjustCanvasSize();
1.2608 canvas()->update();
1.2609 @@ -3778,7 +3961,7 @@
1.2610 (typeid(*selection) == typeid(MapCenterObj)) )
1.2611 {
1.2612 BranchObj *bo=((BranchObj*)selection);
1.2613 - saveState(selection,QString("Add floatimage to %1").arg(getName(bo)));
1.2614 + saveStatePart(selection,QString("Add floatimage to %1").arg(getName(bo)));
1.2615 //QString fn=fd->selectedFile();
1.2616 //lastImageDir=fn.left(fn.findRev ("/"));
1.2617 bo->addFloatImage();
1.2618 @@ -3792,19 +3975,19 @@
1.2619 }
1.2620
1.2621
1.2622 -void MapEditor::imageDataFetched(const QByteArray &a, QNetworkOperation */*nop*/)
1.2623 +void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation */*nop*/)
1.2624 {
1.2625 if (!imageBuffer) imageBuffer = new QBuffer();
1.2626 if (!imageBuffer->isOpen()) {
1.2627 - imageBuffer->open(IO_WriteOnly | IO_Append);
1.2628 + imageBuffer->open(QIODevice::WriteOnly | QIODevice::Append);
1.2629 }
1.2630 imageBuffer->at(imageBuffer->at()+imageBuffer->writeBlock(a));
1.2631 }
1.2632
1.2633
1.2634 -void MapEditor::imageDataFinished(QNetworkOperation *nop)
1.2635 +void MapEditor::imageDataFinished(Q3NetworkOperation *nop)
1.2636 {
1.2637 - if (nop->state()==QNetworkProtocol::StDone) {
1.2638 + if (nop->state()==Q3NetworkProtocol::StDone) {
1.2639 QPixmap img(imageBuffer->buffer());
1.2640 addFloatImage(img);
1.2641 }
1.2642 @@ -3827,11 +4010,11 @@
1.2643 delete urlOperator;
1.2644 }
1.2645
1.2646 - urlOperator = new QUrlOperator(url);
1.2647 - connect(urlOperator, SIGNAL(finished(QNetworkOperation *)),
1.2648 - this, SLOT(imageDataFinished(QNetworkOperation*)));
1.2649 -
1.2650 - connect(urlOperator, SIGNAL(data(const QByteArray &, QNetworkOperation *)),
1.2651 - this, SLOT(imageDataFetched(const QByteArray &, QNetworkOperation *)));
1.2652 + urlOperator = new Q3UrlOperator(url);
1.2653 + connect(urlOperator, SIGNAL(finished(Q3NetworkOperation *)),
1.2654 + this, SLOT(imageDataFinished(Q3NetworkOperation*)));
1.2655 +
1.2656 + connect(urlOperator, SIGNAL(data(const QByteArray &, Q3NetworkOperation *)),
1.2657 + this, SLOT(imageDataFetched(const QByteArray &, Q3NetworkOperation *)));
1.2658 urlOperator->get();
1.2659 }