diff -r a6499713d8ae -r c58b3973337c mapeditor.cpp --- a/mapeditor.cpp Thu May 17 20:19:03 2007 +0000 +++ b/mapeditor.cpp Thu May 17 20:19:03 2007 +0000 @@ -26,6 +26,7 @@ extern Main *mainWindow; extern QString tmpVymDir; extern QString clipboardDir; +extern QString clipboardFile; extern bool clipboardEmpty; extern bool debug; extern FlagRowObj *standardFlagsDefault; @@ -115,6 +116,7 @@ stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",100); undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal)); + mainWindow->updateHistory (undoSet); // Initialize find routine itFind=NULL; @@ -160,6 +162,21 @@ return mapScene; } +MapEditor::State MapEditor::getState() +{ + return state; +} + +void MapEditor::setStateEditHeading(bool s) +{ + if (s) + { + if (state==Idle) state=EditHeading; + } + else + state=Idle; +} + bool MapEditor::isRepositionBlocked() { return blockReposition; @@ -170,6 +187,14 @@ blockSaveState=b; } +bool MapEditor::isSelectBlocked() +{ + if (state==EditHeading) + return true; + else + return false; +} + QString MapEditor::getName (const LinkableMapObj *lmo) { QString s; @@ -287,8 +312,6 @@ if (blockSaveState) return; - /* TODO remove after testing - */ if (debug) cout << "ME::saveState() for "<undosAvail) - for (int j=undosAvail; jreposition(); } } @@ -1871,18 +1925,20 @@ void MapEditor::cut() { LinkableMapObj *sel=xelection.single(); - if ( sel && (xelection.type() == Branch || - xelection.type()==MapCenter || - xelection.type()==FloatImage)) + if ( sel && (xelection.type() == Selection::Branch || + xelection.type()==Selection::MapCenter || + xelection.type()==Selection::FloatImage)) { + /* No savestate! savestate is called in cutNoSave saveStateChangingPart( sel->getParObj(), sel, "cut ()", QString("Cut %1").arg(getName(sel )) ); + */ copy(); - cutNoSave(); + deleteSelection(); mapCenter->reposition(); } } @@ -1957,7 +2013,7 @@ } } -void MapEditor::linkTo(const QString &dstString) // FIXME needed? only for FIO ?? +void MapEditor::linkTo(const QString &dstString) { FloatImageObj *fio=xelection.getFloatImage(); if (fio) @@ -2018,19 +2074,6 @@ } } -void MapEditor::setURLInt (const QString &s) -{ - // Internal function, no saveState needed - BranchObj *bo=xelection.getBranch(); - if (bo) - { - bo->setURL(s); - mapCenter->reposition(); - xelection.update(); - ensureSelectionVisible(); - } -} - void MapEditor::setHeadingInt(const QString &s) { BranchObj *bo=xelection.getBranch(); @@ -2051,6 +2094,7 @@ { bo->setVymLink(s); mapCenter->reposition(); + updateActions(); xelection.update(); ensureSelectionVisible(); } @@ -2124,7 +2168,7 @@ { BranchObj *newbo=NULL; BranchObj *bo = xelection.getBranch(); - if (bo && xelection.type()==Branch) + if (bo && xelection.type()==Selection::Branch) // We accept no MapCenterObj here, so we _have_ a parent { QPointF p=bo->getRelPos(); @@ -2154,7 +2198,7 @@ void MapEditor::deleteSelection() { BranchObj *bo = xelection.getBranch(); - if (bo && xelection.type()==Branch) + if (bo && xelection.type()==Selection::Branch) { BranchObj* par=(BranchObj*)(bo->getParObj()); xelection.unselect(); @@ -2235,7 +2279,7 @@ void MapEditor::selectInt (LinkableMapObj *lmo) { - if (lmo && xelection.single()!= lmo) + if (lmo && xelection.single()!= lmo && isSelectBlocked()==false ) { xelection.select(lmo); xelection.update(); @@ -2406,8 +2450,10 @@ void MapEditor::selectUpperBranch() { + if (isSelectBlocked() ) return; + BranchObj *bo=xelection.getBranch(); - if (bo && xelection.type()==Branch) + if (bo && xelection.type()==Selection::Branch) { if (bo->getOrientation()==LinkableMapObj::RightOfCenter) selectPrevBranchInt(); @@ -2421,8 +2467,10 @@ void MapEditor::selectLowerBranch() { + if (isSelectBlocked() ) return; + BranchObj *bo=xelection.getBranch(); - if (bo && xelection.type()==Branch) + if (bo && xelection.type()==Selection::Branch) if (bo->getOrientation()==LinkableMapObj::RightOfCenter) selectNextBranchInt(); else @@ -2435,12 +2483,14 @@ void MapEditor::selectLeftBranch() { + if (isSelectBlocked() ) return; + BranchObj* bo; BranchObj* par; LinkableMapObj *sel=xelection.single(); if (sel) { - if (xelection.type()== MapCenter) + if (xelection.type()== Selection::MapCenter) { par=xelection.getBranch(); bo=par->getLastSelectedBranch(); @@ -2462,8 +2512,8 @@ par=(BranchObj*)(sel->getParObj()); if (sel->getOrientation()==LinkableMapObj::RightOfCenter) { - if (xelection.type() == Branch || - xelection.type() == FloatImage) + if (xelection.type() == Selection::Branch || + xelection.type() == Selection::FloatImage) { xelection.select(par); xelection.update(); @@ -2471,7 +2521,7 @@ } } else { - if (xelection.type() == Branch ) + if (xelection.type() == Selection::Branch ) { bo=xelection.getBranch()->getLastSelectedBranch(); if (bo) @@ -2488,12 +2538,14 @@ void MapEditor::selectRightBranch() { + if (isSelectBlocked() ) return; + BranchObj* bo; BranchObj* par; LinkableMapObj *sel=xelection.single(); if (sel) { - if (xelection.type()==MapCenter) + if (xelection.type()==Selection::MapCenter) { par=xelection.getBranch(); bo=par->getLastSelectedBranch(); @@ -2514,8 +2566,8 @@ par=(BranchObj*)(xelection.single()->getParObj()); if (xelection.single()->getOrientation()==LinkableMapObj::LeftOfCenter) { - if (xelection.type() == Branch || - xelection.type() == FloatImage) + if (xelection.type() == Selection::Branch || + xelection.type() == Selection::FloatImage) { xelection.select(par); xelection.update(); @@ -2523,7 +2575,7 @@ } } else { - if (xelection.type() == Branch) + if (xelection.type() == Selection::Branch) { bo=xelection.getBranch()->getLastSelectedBranch(); if (bo) @@ -2776,6 +2828,9 @@ QString ("set URL of %1 to %2").arg(getName(bo)).arg(url) ); updateActions(); + mapCenter->reposition(); + xelection.update(); + ensureSelectionVisible(); } } @@ -2881,10 +2936,7 @@ "setVymLink (\""+fd->selectedFile()+"\")", QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()) ); - bo->setVymLink (fd->selectedFile() ); - updateActions(); - mapCenter->reposition(); - scene()->update(); + setVymLinkInt (fd->selectedFile() ); } } } @@ -2926,6 +2978,7 @@ ); updateActions(); mapCenter->reposition(); + xelection.update(); scene()->update(); } } @@ -2995,7 +3048,7 @@ if (bo) { saveStateChangingPart( - bo->getParObj(), + bo, bo, "deleteChilds ()", QString( "Remove childs of branch %1").arg(getName(bo)) @@ -3264,6 +3317,7 @@ QString ("%1 %2").arg(r).arg(getName(bo)) ); bo->toggleScroll(); + xelection.update(); scene()->update(); return true; } @@ -3288,6 +3342,7 @@ QString ("%1 %2").arg(r).arg(getName(bo)) ); bo->toggleScroll(); + xelection.update(); scene()->update(); return true; } @@ -3297,7 +3352,7 @@ void MapEditor::toggleScroll() { BranchObj *bo=xelection.getBranch(); - if (xelection.type()==Branch ) + if (xelection.type()==Selection::Branch ) { if (bo->isScrolled()) unscrollBranch (bo); @@ -3355,7 +3410,7 @@ if ( fd->exec() == QDialog::Accepted ) { - // FIXME loadFIO in QT4 use: lastImageDir=fd->directory(); + // TODO loadFIO in QT4 use: lastImageDir=fd->directory(); lastImageDir=QDir (fd->dirPath()); QString s; FloatImageObj *fio; @@ -3372,7 +3427,7 @@ QString("Add image %1 to %2").arg(s).arg(getName(bo)) ); else - // FIXME loadFIO error handling + // TODO loadFIO error handling qWarning ("Failed to load "+s); } } @@ -3548,17 +3603,29 @@ } } -void MapEditor::setHideLinkUnselected (bool b) // FIXME missing saveState +void MapEditor::setHideLinkUnselected (bool b) { LinkableMapObj *sel=xelection.single(); if (sel && - (xelection.type() == Branch || - xelection.type() == MapCenter || - xelection.type() == FloatImage )) + (xelection.type() == Selection::Branch || + xelection.type() == Selection::MapCenter || + xelection.type() == Selection::FloatImage )) + { + QString u= b ? "false" : "true"; + QString r=!b ? "false" : "true"; + + saveState( + sel, + QString("setHideLinkUnselected (%1)").arg(u), + sel, + QString("setHideLinkUnselected (%1)").arg(r), + QString("Hide link of %1 if unselected").arg(getName(sel)) + ); sel->setHideLinkUnselected(b); + } } -void MapEditor::importDirInt(BranchObj *dst, QDir d) // FIXME missing saveState +void MapEditor::importDirInt(BranchObj *dst, QDir d) { BranchObj *bo=xelection.getBranch(); if (bo) @@ -3605,6 +3672,18 @@ } } +void MapEditor::importDirInt (const QString &s) +{ + BranchObj *bo=xelection.getBranch(); + if (bo) + { + saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s)); + + QDir d(s); + importDirInt (bo,d); + } +} + void MapEditor::importDir() { BranchObj *bo=xelection.getBranch(); @@ -3621,7 +3700,7 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - importDirInt (bo,QDir(fd->selectedFile()) ); + importDirInt (fd->selectedFile() ); mapCenter->reposition(); scene()->update(); } @@ -3790,6 +3869,13 @@ return; } + //Ignore clicks while editing heading + if (isSelectBlocked() ) + { + e->ignore(); + return; + } + QPointF p = mapToScene(e->pos()); LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL); @@ -3880,7 +3966,7 @@ if (mainWindow->getModMode()==Main::ModModeCopy && e->state() & Qt::ControlModifier) { - if (xelection.type()==Branch) + if (xelection.type()==Selection::Branch) { copyingObj=true; mapCenter->addBranch ((BranchObj*)xelection.single()); @@ -4081,7 +4167,7 @@ } // Have we been drawing a link? - if (drawingLink) //FIXME savestate missing + if (drawingLink) { drawingLink=false; // Check if we are over another branch @@ -4090,7 +4176,7 @@ { tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); - tmpXLink->activate(); + tmpXLink->activate(); //FIXME savestate missing //saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); } else { @@ -4127,11 +4213,11 @@ if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) dst=NULL; - if (xelection.type() == MapCenter ) + if (xelection.type() == Selection::MapCenter ) { // FIXME The MapCenter was moved, no savestate yet } - if (xelection.type() == Branch ) + if (xelection.type() == Selection::Branch ) { // A branch was moved // save the position in case we link to mapcenter @@ -4216,6 +4302,12 @@ void MapEditor::mouseDoubleClickEvent(QMouseEvent* e) { + if (isSelectBlocked() ) + { + e->ignore(); + return; + } + if (e->button() == Qt::LeftButton ) { QPointF p = mapToScene(e->pos()); @@ -4310,7 +4402,7 @@ event->acceptProposedAction(); } -void MapEditor::timerEvent(QTimerEvent *event) //FIXME testing +void MapEditor::timerEvent(QTimerEvent *event) //TODO animation { Q_UNUSED(event); @@ -4326,12 +4418,12 @@ void MapEditor::autosave() { - if (mapUnsaved &&mapChanged && settings.value ("/mapeditor/autosave/used",true).toBool() ) + if (mapUnsaved &&mapChanged && settings.value ("/mapeditor/autosave/use",true).toBool() ) mainWindow->fileSave (this); } -/*FIXME not needed? void MapEditor::contentsDropEvent(QDropEvent *event) +/*TODO not needed? void MapEditor::contentsDropEvent(QDropEvent *event) { } else if (event->provides("application/x-moz-file-promise-url") && @@ -4401,7 +4493,7 @@ { FloatImageObj *fio=bo->addFloatImage(); fio->load(img); - fio->setOriginalFilename("Image added by Drag and Drop"); // FIXME savestate + fio->setOriginalFilename("Image added by Drag and Drop"); // FIXME savestate missing mapCenter->reposition(); scene()->update(); }