# HG changeset patch # User insilmaril # Date 1127391263 0 # Node ID d442a66e91212332cdd4ec9d1ed0e661377aa185 # Parent 30b22f7bd009c3acaa761de1f47c40f67e32b590 new way to handle tmpdir, minor changes diff -r 30b22f7bd009 -r d442a66e9121 branchobj.cpp --- a/branchobj.cpp Mon Sep 12 19:52:51 2005 +0000 +++ b/branchobj.cpp Thu Sep 22 12:14:23 2005 +0000 @@ -201,19 +201,9 @@ // ignore mapcenter and mainbranch if (lmo->getDepth()<2) off=0; if (off==0) - { link2ParPos=false; - // parObj=o; - } else - { link2ParPos=true; - // if (off>0) - // parObj=o->getParObj(); - // else - // parObj=o->getParObj(); - // parObj=o; - } parObj=o; depth=parObj->getDepth()+1; @@ -400,10 +390,11 @@ // Overloaded from LinkableMapObj // BranchObj can use color of heading - if (mapEditor->getLinkColorHint()==HeadingColor) - LinkableMapObj::setLinkColor (heading->getColor() ); - else - LinkableMapObj::setLinkColor (); + if (mapEditor) + if (mapEditor->getLinkColorHint()==HeadingColor) + LinkableMapObj::setLinkColor (heading->getColor() ); + else + LinkableMapObj::setLinkColor (); } void BranchObj::setColor (QColor col, bool colorChilds) @@ -578,7 +569,7 @@ void BranchObj::positionBBox() { - // FIXME testing (optimization) + // TODO testing (optimization) /* QString h=getHeading(); if (!h.isEmpty()) @@ -663,12 +654,6 @@ void BranchObj::setHeading(QString s) { - /*FIXME - // Adjusting font size - QFont font=heading->getFont(); - font.setPointSize(getDefHeadingSize() ); - heading->setFont(font); - */ heading->setText(s); // set new heading calcBBoxSize(); // recalculate bbox positionBBox(); // rearrange contents @@ -1140,7 +1125,7 @@ void BranchObj::alignRelativeTo (QPoint ref) { -/* FIXME testing +/* TODO testing if (!getHeading().isEmpty()) cout << "BO::alignRelTo "< Couldn't save - Diese Datei konnte nicht gespeichert werden: + Diese Datei konnte nicht gespeichert werden: Saved @@ -1269,18 +1269,6 @@ Set application to open external links... Anwendung zum Öffnen externer Verweise... - - Hide link - Link nicht anzeigen - - - Hide link if object is not selected - Link nicht anzeigen, falls Objekt nicht selektiert ist - - - Couldn't save %1 - Konnte %1 nicht speichern - MapEditor @@ -1671,7 +1659,7 @@ The file %1 exists already. Do you want to overwrite it? - Die Datei %1 gibt es bereits. + Die Datei %1 gibt es bereits. Wollen Sie sie überschreiben? diff -r 30b22f7bd009 -r d442a66e9121 lang/vym_en.ts --- a/lang/vym_en.ts Mon Sep 12 19:52:51 2005 +0000 +++ b/lang/vym_en.ts Thu Sep 22 12:14:23 2005 +0000 @@ -860,6 +860,10 @@ + Couldn't save + + + Export XML to directory @@ -1044,18 +1048,6 @@ Set application to open external links... - - Hide link - - - - Hide link if object is not selected - - - - Couldn't save %1 - - MapEditor @@ -1267,6 +1259,10 @@ + The file %1 exists already. Do you want to overwrite it? + + + Cannot find the directory %1 diff -r 30b22f7bd009 -r d442a66e9121 lang/vym_es.ts --- a/lang/vym_es.ts Mon Sep 12 19:52:51 2005 +0000 +++ b/lang/vym_es.ts Thu Sep 22 12:14:23 2005 +0000 @@ -939,7 +939,7 @@ Couldn't save - No pudo guardar + No pudo guardar The file @@ -1159,18 +1159,6 @@ Set application to open external links... - - Hide link - - - - Hide link if object is not selected - - - - Couldn't save %1 - - MapEditor @@ -1422,6 +1410,10 @@ + The file %1 exists already. Do you want to overwrite it? + + + Cannot find the directory %1 diff -r 30b22f7bd009 -r d442a66e9121 linkablemapobj.cpp --- a/linkablemapobj.cpp Mon Sep 12 19:52:51 2005 +0000 +++ b/linkablemapobj.cpp Thu Sep 22 12:14:23 2005 +0000 @@ -62,6 +62,7 @@ void LinkableMapObj::init () { depth=-1; + mapEditor=NULL; childObj=NULL; parObj=NULL; parObjTmpBuf=NULL; @@ -126,8 +127,16 @@ { } +bool LinkableMapObj::hasParObjTmp() +{ + if (parObjTmpBuf) return true; + return false; +} + LinkStyle LinkableMapObj::getDefLinkStyle () { + if (!mapEditor) return StyleUndef; + LinkStyle ls=mapEditor->getLinkStyle(); switch (ls) { @@ -204,8 +213,7 @@ else p->hide(); pa0.resize (3); - // TODO - // a bit awkward: draw the lines additionally to polygon, to avoid + // TODO a bit awkward: draw the lines additionally to polygon, to avoid // missing pixels, when polygon is extremly flat l = new QCanvasLine(canvas); l->setPen( QPen(linkcolor, 1) ); @@ -227,8 +235,7 @@ pa1.resize (arcsegs+1); pa2.resize (arcsegs+1); - // TODO - // a bit awkward: draw the lines additionally + // TODO a bit awkward: draw the lines additionally // to polygon, to avoid missing pixels, // if polygon is extremly flat for (i=0;igetDefLinkColor()); + if (mapEditor) + setLinkColor (mapEditor->getDefLinkColor()); } void LinkableMapObj::setLinkColor(QColor col) @@ -650,8 +653,8 @@ void LinkableMapObj::alignRelativeTo (QPoint ref) { + // TODO testing, seems not to be used right now... cout << "LMO::alignRelTo ref="<fileLoadFromTmp (flist); //returnCode=1; // Silently forget this attempt to load qWarning ("MainWindow::load (fn) multimap found..."); diff -r 30b22f7bd009 -r d442a66e9121 mapcenterobj.cpp --- a/mapcenterobj.cpp Mon Sep 12 19:52:51 2005 +0000 +++ b/mapcenterobj.cpp Thu Sep 22 12:14:23 2005 +0000 @@ -27,7 +27,6 @@ void MapCenterObj::clear() { BranchObj::clear(); - init(); } void MapCenterObj::init () @@ -37,10 +36,11 @@ absPos=QPoint (canvas->width()/2, canvas->height()/2); // FIXME this should be done in TextObj later... - QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0"); - heading->setFont(font); + //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0"); + //heading->setFont(font); + depth=0; + setDefAttr(MovedBranch); - depth=0; frame->setFrameType (Rectangle); move (absPos.x(), absPos.y() ); diff -r 30b22f7bd009 -r d442a66e9121 mapeditor.cpp --- a/mapeditor.cpp Mon Sep 12 19:52:51 2005 +0000 +++ b/mapeditor.cpp Thu Sep 22 12:14:23 2005 +0000 @@ -62,6 +62,7 @@ extern TextEditor *textEditor; extern int statusbarTime; extern Main *mainWindow; +extern QString tmpVymDir; extern FlagRowObj *systemFlagsDefault; extern FlagRowObj *standardFlagsDefault; extern MapEditor *clipboardME; @@ -139,6 +140,7 @@ extern Settings settings; +int MapEditor::mapNum=0; // make instance /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// @@ -147,6 +149,7 @@ QCanvasView(parent,name,f), urlOperator(0), imageBuffer(0) { //cout << "Constructor ME "<setAcceptDrops(true); @@ -355,8 +358,7 @@ fileName="unnamed"; mapName=""; - - undosTotal=15; + undosTotal=settings.readNumEntry("/vym/mapeditor/undoLevels",50); undosAvail=0; undoNum=0; @@ -389,7 +391,6 @@ } //cout <<"Destructor MapEditor\n"; - if (isInteractive) delTmpDirs(); // Save Settings //settings.writeEntry( "/vym/mapeditor/editmode/autoselect", ); @@ -484,15 +485,9 @@ void MapEditor::makeTmpDirs() { // Create unique temporary directories - char tmpdir[]="/tmp/vym-XXXXXX"; - // TODO set permissions and maybe use QT method for portability - tmpMapDir=mkdtemp(tmpdir); - QString bakMapDir; - for (int i=undosTotal;i>0;i--) - { - bakMapDir=tmpMapDir+QString("/undo-%1").arg(i); - makeSubDirs(bakMapDir); - } + tmpMapDir=tmpVymDir+QString("/mapeditor-%1").arg(mapNum); + QDir d; + d.mkdir (tmpMapDir,true); } void MapEditor::delTmpDirs() @@ -639,8 +634,12 @@ QString backupXML; QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum)); - QString bakMapPath=bakMapDir+"/map.xml"; - + QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml"); + + // Create bakMapDir if not available + QDir d(bakMapDir); + if (!d.exists()) + makeSubDirs (bakMapDir); // Save current selection QString redoSelection=""; @@ -1222,7 +1221,7 @@ void MapEditor::exportASCII() { - // FIXME still experimental + // TODO still experimental Export ex; ex.setMapCenter(mapCenter); @@ -1264,7 +1263,7 @@ void MapEditor::exportLaTeX() { - // FIXME still experimental + // TODO still experimental QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (LaTex)")); fd->addFilter ("TEX (*.tex)"); fd->setCaption("VYM - Export (LaTex) (still experimental)"); @@ -1306,7 +1305,7 @@ void MapEditor::exportOOPresentation() { - // FIXME still experimental + // TODO still experimental /* QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (Open Office 1.3.x Presentation)")); fd->addFilter ("Open Office 1.3.x presentation (*.sxi)"); @@ -1416,9 +1415,7 @@ // repositioning makes testing nicer, // but is not needed usually: if (clipboardME->isVisible()) - { clipboardME->getMapCenter()->reposition(); - } else clipboardME->hide(); } @@ -1491,8 +1488,6 @@ parseAtom (undoCommand); mapCenter->reposition(); - //mapChanged=false; FIXME still needed??? - //if (!redoSelection.isEmpty()) // select (redoSelection); @@ -1538,7 +1533,7 @@ if (!undoSelection.isEmpty()) select (undoSelection); -/* TODO remove testing +/* TODO testing cout << "ME::undo() begin\n"; cout << " undosTotal="<addFloatImage(); - // FIXME check if load was successful + // TODO check if load was successful bo->getLastFloatImage()->load(fn); bo->getLastFloatImage()->setOriginalFilename(fn); mapCenter->reposition(); @@ -3240,7 +3233,7 @@ } if (dia.deleteXLink()) ((BranchObj*)selection)->deleteXLinkAt(i); - saveState(); //FIXME undoCommand + saveState(); //TODO undoCommand } } } @@ -3249,12 +3242,8 @@ void MapEditor::testFunction() { cout << "MapEditor::testFunction() called\n"; - if (selection && - (typeid(*selection) == typeid(BranchObj)) ) - { - QString s=((BranchObj*)selection)->getHeading(); - parseAtom(s); - } + QDir d("/fasl"); + removeDir (d); } void MapEditor::ensureSelectionVisible() @@ -3458,7 +3447,10 @@ // Move the selected MapObj if ( selection && movingObj) { - ensureSelectionVisible (); + // To avoid jumping of the CanvasView, only + // ensureSelectionVisible, if not tmp linked + if (!selection->hasParObjTmp()) + ensureSelectionVisible (); // Now move the selection, but add relative position // (movingObj_start) where selection was chosen with @@ -3633,7 +3625,7 @@ tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); tmpXLink->activate(); - saveState(); //FIXME undoCommand + saveState(); //TODO undoCommand } else { delete(tmpXLink); @@ -3787,7 +3779,7 @@ bool isUnicode16(const QByteArray &d) { - // FIXME: make more precise check for unicode 16. + // TODO: make more precise check for unicode 16. // Guess unicode16 if any of second bytes are zero unsigned int length = max(0,d.size()-2)/2; for (unsigned int i = 0; ireposition(); adjustCanvasSize(); canvas()->update(); diff -r 30b22f7bd009 -r d442a66e9121 mapeditor.h --- a/mapeditor.h Mon Sep 12 19:52:51 2005 +0000 +++ b/mapeditor.h Thu Sep 22 12:14:23 2005 +0000 @@ -216,6 +216,7 @@ bool printFooter; // Print footer below map bool zipped; // should map be zipped +static int mapNum; // unique number for Editor QString fileName; // short name of file (for tab) QString filePath; // path to file which will be saved QString fileDir; // dir where file is saved diff -r 30b22f7bd009 -r d442a66e9121 misc.cpp --- a/misc.cpp Mon Sep 12 19:52:51 2005 +0000 +++ b/misc.cpp Thu Sep 22 12:14:23 2005 +0000 @@ -2,6 +2,7 @@ #include #include +#include #include "misc.h" @@ -123,8 +124,29 @@ return d; } +QString makeUniqueDir (QString s) +{ + char *p; + int bytes=s.length(); + p=(char*) malloc (bytes+1); + int i; + for (i=0;i