1.1 --- a/mapeditor.cpp Mon Sep 12 19:52:51 2005 +0000
1.2 +++ b/mapeditor.cpp Thu Sep 22 12:14:23 2005 +0000
1.3 @@ -62,6 +62,7 @@
1.4 extern TextEditor *textEditor;
1.5 extern int statusbarTime;
1.6 extern Main *mainWindow;
1.7 +extern QString tmpVymDir;
1.8 extern FlagRowObj *systemFlagsDefault;
1.9 extern FlagRowObj *standardFlagsDefault;
1.10 extern MapEditor *clipboardME;
1.11 @@ -139,6 +140,7 @@
1.12
1.13 extern Settings settings;
1.14
1.15 +int MapEditor::mapNum=0; // make instance
1.16
1.17 ///////////////////////////////////////////////////////////////////////
1.18 ///////////////////////////////////////////////////////////////////////
1.19 @@ -147,6 +149,7 @@
1.20 QCanvasView(parent,name,f), urlOperator(0), imageBuffer(0)
1.21 {
1.22 //cout << "Constructor ME "<<this<<endl;
1.23 + mapNum++;
1.24
1.25 viewport()->setAcceptDrops(true);
1.26
1.27 @@ -355,8 +358,7 @@
1.28 fileName="unnamed";
1.29 mapName="";
1.30
1.31 -
1.32 - undosTotal=15;
1.33 + undosTotal=settings.readNumEntry("/vym/mapeditor/undoLevels",50);
1.34 undosAvail=0;
1.35 undoNum=0;
1.36
1.37 @@ -389,7 +391,6 @@
1.38 }
1.39
1.40 //cout <<"Destructor MapEditor\n";
1.41 - if (isInteractive) delTmpDirs();
1.42
1.43 // Save Settings
1.44 //settings.writeEntry( "/vym/mapeditor/editmode/autoselect", );
1.45 @@ -484,15 +485,9 @@
1.46 void MapEditor::makeTmpDirs()
1.47 {
1.48 // Create unique temporary directories
1.49 - char tmpdir[]="/tmp/vym-XXXXXX";
1.50 - // TODO set permissions and maybe use QT method for portability
1.51 - tmpMapDir=mkdtemp(tmpdir);
1.52 - QString bakMapDir;
1.53 - for (int i=undosTotal;i>0;i--)
1.54 - {
1.55 - bakMapDir=tmpMapDir+QString("/undo-%1").arg(i);
1.56 - makeSubDirs(bakMapDir);
1.57 - }
1.58 + tmpMapDir=tmpVymDir+QString("/mapeditor-%1").arg(mapNum);
1.59 + QDir d;
1.60 + d.mkdir (tmpMapDir,true);
1.61 }
1.62
1.63 void MapEditor::delTmpDirs()
1.64 @@ -639,8 +634,12 @@
1.65
1.66 QString backupXML;
1.67 QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
1.68 - QString bakMapPath=bakMapDir+"/map.xml";
1.69 -
1.70 + QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml");
1.71 +
1.72 + // Create bakMapDir if not available
1.73 + QDir d(bakMapDir);
1.74 + if (!d.exists())
1.75 + makeSubDirs (bakMapDir);
1.76
1.77 // Save current selection
1.78 QString redoSelection="";
1.79 @@ -1222,7 +1221,7 @@
1.80
1.81 void MapEditor::exportASCII()
1.82 {
1.83 - // FIXME still experimental
1.84 + // TODO still experimental
1.85 Export ex;
1.86 ex.setMapCenter(mapCenter);
1.87
1.88 @@ -1264,7 +1263,7 @@
1.89
1.90 void MapEditor::exportLaTeX()
1.91 {
1.92 - // FIXME still experimental
1.93 + // TODO still experimental
1.94 QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (LaTex)"));
1.95 fd->addFilter ("TEX (*.tex)");
1.96 fd->setCaption("VYM - Export (LaTex) (still experimental)");
1.97 @@ -1306,7 +1305,7 @@
1.98
1.99 void MapEditor::exportOOPresentation()
1.100 {
1.101 - // FIXME still experimental
1.102 + // TODO still experimental
1.103 /*
1.104 QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (Open Office 1.3.x Presentation)"));
1.105 fd->addFilter ("Open Office 1.3.x presentation (*.sxi)");
1.106 @@ -1416,9 +1415,7 @@
1.107 // repositioning makes testing nicer,
1.108 // but is not needed usually:
1.109 if (clipboardME->isVisible())
1.110 - {
1.111 clipboardME->getMapCenter()->reposition();
1.112 - }
1.113 else
1.114 clipboardME->hide();
1.115 }
1.116 @@ -1491,8 +1488,6 @@
1.117 parseAtom (undoCommand);
1.118 mapCenter->reposition();
1.119
1.120 - //mapChanged=false; FIXME still needed???
1.121 -
1.122 //if (!redoSelection.isEmpty())
1.123 // select (redoSelection);
1.124
1.125 @@ -1538,7 +1533,7 @@
1.126 if (!undoSelection.isEmpty())
1.127 select (undoSelection);
1.128
1.129 -/* TODO remove testing
1.130 +/* TODO testing
1.131 cout << "ME::undo() begin\n";
1.132 cout << " undosTotal="<<undosTotal<<endl;
1.133 cout << " undosAvail="<<undosAvail<<endl;
1.134 @@ -1554,8 +1549,6 @@
1.135 parseAtom (undoCommand);
1.136 mapCenter->reposition();
1.137
1.138 - //mapChanged=false; FIXME still needed???
1.139 -
1.140 //if (!redoSelection.isEmpty())
1.141 // select (redoSelection);
1.142
1.143 @@ -1701,7 +1694,7 @@
1.144
1.145 void MapEditor::move(const int &x, const int &y)
1.146 {
1.147 - // FIXME no saveState, because this is only internal at undo so far
1.148 + // TODO no saveState, because this is only internal at undo so far
1.149 if (selection) selection->move(x,y);
1.150 if (typeid(*selection) == typeid(FloatImageObj))
1.151 ((FloatImageObj*)selection)->setRelPos();
1.152 @@ -1824,7 +1817,7 @@
1.153 (typeid(*selection) == typeid(BranchObj) ||
1.154 typeid(*selection) == typeid(MapCenterObj) ) )
1.155 {
1.156 - saveState(selection); //FIXME undoCommand
1.157 + saveState(selection); //TODO undoCommand
1.158
1.159 BranchObj* bo1 = (BranchObj*) selection;
1.160 bool wasScrolled=false;
1.161 @@ -1942,7 +1935,7 @@
1.162 saveState(selection->getParObj());
1.163 else
1.164 // Mainbranch, save whole map
1.165 - // FIXME Better would be to insert mainbranch again at pos
1.166 + // TODO Better would be to insert mainbranch again at pos
1.167 // But undoCommand is missing right now
1.168 saveState();
1.169 BranchObj* bo=dynamic_cast <BranchObj*> (selection);
1.170 @@ -2428,7 +2421,7 @@
1.171 if (typeid(*selection) == typeid(BranchObj) ||
1.172 typeid(*selection) == typeid(MapCenterObj))
1.173 {
1.174 - saveState(selection); //FIXME undoCommand
1.175 + saveState(selection); //TODO undoCommand
1.176 BranchObj *bo=(BranchObj*)selection;
1.177 bo->setColor(actColor, false); // color links, color childs
1.178 }
1.179 @@ -2454,7 +2447,7 @@
1.180 {
1.181 if (selection)
1.182 {
1.183 - saveState(selection);// FIXME undoCommand
1.184 + saveState(selection);// TODO undoCommand
1.185 ((BranchObj*)selection)->toggleStandardFlag (f,actionSettingsUseFlagGroups);
1.186 }
1.187 }
1.188 @@ -2658,7 +2651,7 @@
1.189 if (bo->getDepth()==1)
1.190 saveState();
1.191 else
1.192 - saveState(selection->getParObj()); // FIXME undoCommand
1.193 + saveState(selection->getParObj()); // TODO undoCommand
1.194 QString sel=selection->getSelectString();
1.195 unselect();
1.196 par->removeBranchHere(bo);
1.197 @@ -2715,7 +2708,7 @@
1.198 // Finally show dialog
1.199 if (dia.exec() == QDialog::Accepted)
1.200 {
1.201 - saveState(); //FIXME undoCommand
1.202 + saveState(); //TODO undoCommand
1.203 mapCenter->setAuthor (dia.getAuthor() );
1.204 mapCenter->setComment (dia.getComment() );
1.205 }
1.206 @@ -2882,7 +2875,7 @@
1.207 {
1.208 linkstyle=ls;
1.209
1.210 - saveState(); // FIXME undoCommand
1.211 + saveState(); // TODO undoCommand
1.212 BranchObj *bo;
1.213 bo=mapCenter->first();
1.214 bo=bo->next();
1.215 @@ -2976,7 +2969,7 @@
1.216 QColor col = QColorDialog::getColor( defLinkColor, this );
1.217 if ( !col.isValid() ) return;
1.218 setLinkColor( col );
1.219 - saveState(); //FIXME undoCommand
1.220 + saveState(); //TODO undoCommand
1.221
1.222 }
1.223
1.224 @@ -3030,7 +3023,7 @@
1.225 QString fn=fd->selectedFile();
1.226 lastImageDir=fn.left(fn.findRev ("/"));
1.227 bo->addFloatImage();
1.228 - // FIXME check if load was successful
1.229 + // TODO check if load was successful
1.230 bo->getLastFloatImage()->load(fn);
1.231 bo->getLastFloatImage()->setOriginalFilename(fn);
1.232 mapCenter->reposition();
1.233 @@ -3240,7 +3233,7 @@
1.234 }
1.235 if (dia.deleteXLink())
1.236 ((BranchObj*)selection)->deleteXLinkAt(i);
1.237 - saveState(); //FIXME undoCommand
1.238 + saveState(); //TODO undoCommand
1.239 }
1.240 }
1.241 }
1.242 @@ -3249,12 +3242,8 @@
1.243 void MapEditor::testFunction()
1.244 {
1.245 cout << "MapEditor::testFunction() called\n";
1.246 - if (selection &&
1.247 - (typeid(*selection) == typeid(BranchObj)) )
1.248 - {
1.249 - QString s=((BranchObj*)selection)->getHeading();
1.250 - parseAtom(s);
1.251 - }
1.252 + QDir d("/fasl");
1.253 + removeDir (d);
1.254 }
1.255
1.256 void MapEditor::ensureSelectionVisible()
1.257 @@ -3458,7 +3447,10 @@
1.258 // Move the selected MapObj
1.259 if ( selection && movingObj)
1.260 {
1.261 - ensureSelectionVisible ();
1.262 + // To avoid jumping of the CanvasView, only
1.263 + // ensureSelectionVisible, if not tmp linked
1.264 + if (!selection->hasParObjTmp())
1.265 + ensureSelectionVisible ();
1.266
1.267 // Now move the selection, but add relative position
1.268 // (movingObj_start) where selection was chosen with
1.269 @@ -3633,7 +3625,7 @@
1.270 tmpXLink->setEnd ( ((BranchObj*)(dst)) );
1.271 tmpXLink->updateXLink();
1.272 tmpXLink->activate();
1.273 - saveState(); //FIXME undoCommand
1.274 + saveState(); //TODO undoCommand
1.275 } else
1.276 {
1.277 delete(tmpXLink);
1.278 @@ -3787,7 +3779,7 @@
1.279
1.280 bool isUnicode16(const QByteArray &d)
1.281 {
1.282 - // FIXME: make more precise check for unicode 16.
1.283 + // TODO: make more precise check for unicode 16.
1.284 // Guess unicode16 if any of second bytes are zero
1.285 unsigned int length = max(0,d.size()-2)/2;
1.286 for (unsigned int i = 0; i<length ; i++)
1.287 @@ -3897,7 +3889,7 @@
1.288
1.289 if (update)
1.290 {
1.291 - saveState(); //FIXME undo Command
1.292 + saveState(); //TODO undo Command
1.293 mapCenter->reposition();
1.294 adjustCanvasSize();
1.295 canvas()->update();