# HG changeset patch # User insilmaril # Date 1276523957 0 # Node ID e265f07f2173a35e5542e870876dce9ef39cfe91 # Parent 43268373032d0a14deedf089f8da3938460bc1d5 Fixed tmp relink, colored headings in TreeView diff -r 43268373032d -r e265f07f2173 branchobj.cpp --- a/branchobj.cpp Wed Jun 09 13:14:08 2010 +0000 +++ b/branchobj.cpp Mon Jun 14 13:59:17 2010 +0000 @@ -108,7 +108,13 @@ qreal y; if (off==0) { + // Below is needed e.g. in a freshly loaded map, + // bboxTotal seems not to be correct yet + // relinking positions too far below then + calcBBoxSizeWithChildren(); + // new parent is just a branch, link to it + bodst->calcBBoxSizeWithChildren(); QRectF t=bodst->getBBoxSizeWithChildren(); if (dsti->getLastBranch()) y=t.y() + t.height() ; diff -r 43268373032d -r e265f07f2173 mainwindow.cpp --- a/mainwindow.cpp Wed Jun 09 13:14:08 2010 +0000 +++ b/mainwindow.cpp Mon Jun 14 13:59:17 2010 +0000 @@ -1984,7 +1984,7 @@ vv->initFocus(); // Create MapCenter for empty map - vm->addMapCenter(); + vm->addMapCenter(false); vm->makeDefault(); // For the very first map we do not have flagrows yet... diff -r 43268373032d -r e265f07f2173 mapeditor.cpp --- a/mapeditor.cpp Wed Jun 09 13:14:08 2010 +0000 +++ b/mapeditor.cpp Mon Jun 14 13:59:17 2010 +0000 @@ -1149,10 +1149,10 @@ if (bi) { copyingObj=true; - //FIXME-2 TreeItem::addBranch (BranchItem still missing) - //bi->addBranch (model->getSelectedBranch()); - model->unselect(); - model->select(bi->getLastBranch()); + //model->select(model->createBranch (bi)); + model->copy(); + model->paste(); + model->select (bi->getLastBranch()); model->reposition(); } } @@ -1200,10 +1200,11 @@ if (mainWindow->getModMode()!=Main::ModModeCopy) setCursor (Qt::ArrowCursor); - // Scroll if needed - // To avoid jumping of the sceneView, only - // show selection, if not tmp linked - model->emitShowSelection(); + if (!lmosel->hasParObjTmp()) + // Scroll if needed + // To avoid jumping of the sceneView, only + // show selection, if not tmp linked + model->emitShowSelection(); // Now move the selection, but add relative position // (movingObj_start) where selection was chosen with @@ -1292,27 +1293,30 @@ } } // depth>0 - // Maybe we can relink temporary? - if (dsti) + + // Maybe we can relink temporary? + if (dsti) + { + if (e->modifiers()==Qt::ControlModifier) { - if (e->modifiers()==Qt::ControlModifier) - { - // Special case: CTRL to link below dst - lmosel->setParObjTmp (dst,p,+1); - } else if (e->modifiers()==Qt::ShiftModifier) - lmosel->setParObjTmp (dst,p,-1); - else - lmosel->setParObjTmp (dst,p,0); - } else - { - lmosel->unsetParObjTmp(); - } - // reposition subbranch - lmosel->reposition(); + // Special case: CTRL to link below dst + lmosel->setParObjTmp (dst,p,+1); + } else if (e->modifiers()==Qt::ShiftModifier) + lmosel->setParObjTmp (dst,p,-1); + else + lmosel->setParObjTmp (dst,p,0); + } else + { + lmosel->unsetParObjTmp(); + } + // reposition subbranch + lmosel->reposition(); QItemSelection sel=model->getSelectionModel()->selection(); updateSelection(sel,sel); // position has changed + scrollTo (model->index (seli->parent())); + } // no FloatImageObj scene()->update(); @@ -1379,13 +1383,11 @@ tmpLink->setEndBranch ( ((BranchItem*)dsti) ); tmpLink->updateLink(); model->createLink (tmpLink); - /* FIXME-2 Link savestate missing, segfaulting on undo - model->saveState( - tmpXLink,QString("delete ()"), - dsti,QString("addXLink (\"%1\",\"%2\")").arg(model->getSelectString(tmpXLink->getBegin())).arg(model->getSelectString(dsti)), - QString("Add xLink from %1 to %2").arg(model->getObjectName(tmpXLink->getBegin())).arg(model->getObjectName(dsti)) + model->saveState( //FIXME-2 wrong order of paramters + dsti,QString("addXLink (\"%1\",\"%2\")").arg(model->getSelectString(tmpLink->getBeginLinkItem())).arg(model->getSelectString(dsti)), + dsti,QString("Add xLink from %1 to %2").arg(model->getObjectName(tmpLink->getBeginLinkItem())).arg(model->getObjectName(dsti)) , + QString("Adding XLink()") ); - */ } else { delete (tmpLink); @@ -1576,7 +1578,7 @@ void MapEditor::wheelEvent(QWheelEvent* e) { - //qDebug ()<<"ME::wheelEvent"; //FIXME-2 stop all animations in vymModel here + //qDebug ()<<"ME::wheelEvent"; //FIXME-3 stop all animations in vymModel here //model->stopAllAnimation(); QGraphicsView::wheelEvent (e); } diff -r 43268373032d -r e265f07f2173 treeitem.cpp --- a/treeitem.cpp Wed Jun 09 13:14:08 2010 +0000 +++ b/treeitem.cpp Mon Jun 14 13:59:17 2010 +0000 @@ -586,6 +586,22 @@ return NULL; } +ImageItem* TreeItem::getFirstImage() +{ + if (imageCounter>0) + return getImageNum (imageCounter-1); + else + return NULL; +} + +ImageItem* TreeItem::getLastImage() +{ + if (imageCounter>0) + return getImageNum (imageCounter-1); + else + return NULL; +} + BranchItem* TreeItem::getNextBranch(BranchItem *currentBranch) { if (!currentBranch) return NULL; diff -r 43268373032d -r e265f07f2173 treeitem.h --- a/treeitem.h Wed Jun 09 13:14:08 2010 +0000 +++ b/treeitem.h Mon Jun 14 13:59:17 2010 +0000 @@ -15,6 +15,7 @@ class FloatImageObj; class ImageItem; class LinkableMapObj; +class QModelIndex; class VymModel; class XLinkItem; class XLinkObj; @@ -70,7 +71,7 @@ virtual QString getTypeName (); // Accessing data - virtual QVariant data(int column) const; + virtual QVariant data (int column) const; protected: @@ -145,6 +146,8 @@ virtual TreeItem* getChildNum(const int &n); virtual BranchItem* getFirstBranch(); virtual BranchItem* getLastBranch(); + virtual ImageItem* getFirstImage(); + virtual ImageItem* getLastImage(); /*! Get next branch after current branch. Return NULL if there is no next branch */ diff -r 43268373032d -r e265f07f2173 treemodel.cpp --- a/treemodel.cpp Wed Jun 09 13:14:08 2010 +0000 +++ b/treemodel.cpp Mon Jun 14 13:59:17 2010 +0000 @@ -26,10 +26,15 @@ if (!index.isValid()) return QVariant(); + TreeItem *item = getItem (index); + if (role != Qt::DisplayRole) - return QVariant(); + { + if (role == Qt::ForegroundRole ) + return item->getHeadingColor(); + return QVariant(); + } - TreeItem *item = getItem (index); return item->data(index.column()); } diff -r 43268373032d -r e265f07f2173 version.h --- a/version.h Wed Jun 09 13:14:08 2010 +0000 +++ b/version.h Mon Jun 14 13:59:17 2010 +0000 @@ -4,10 +4,10 @@ #include #define __VYM_NAME "VYM" -#define __VYM_VERSION "1.13.4" +#define __VYM_VERSION "1.13.5" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version, not for production!" -#define __VYM_BUILD_DATE "2010-06-08" +#define __VYM_BUILD_DATE "2010-06-14" bool checkVersion(const QString &); diff -r 43268373032d -r e265f07f2173 vym.changelog --- a/vym.changelog Wed Jun 09 13:14:08 2010 +0000 +++ b/vym.changelog Mon Jun 14 13:59:17 2010 +0000 @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Mon Jun 14 15:11:46 CEST 2010 - vym@insilmaril.de + +- Version: 1.13.5 +- Bugfix: Temporary Relinking shows correct position again now +- Featzre: TreeEditor has colored headings + +------------------------------------------------------------------- +Thu Jun 10 11:18:32 CEST 2010 - vym@insilmaril.de + +- Bugfix: Segfault due to undo in new map + ------------------------------------------------------------------- Tue Jun 8 17:17:41 CEST 2010 - vym@insilmaril.de diff -r 43268373032d -r e265f07f2173 vymmodel.cpp --- a/vymmodel.cpp Wed Jun 09 13:14:08 2010 +0000 +++ b/vymmodel.cpp Mon Jun 14 13:59:17 2010 +0000 @@ -85,20 +85,14 @@ // Also no scene yet (should not be needed anyway) FIXME-3 VM mapScene=NULL; - // History + // States and IDs idLast++; mapID=idLast; mapChanged=false; mapDefault=true; mapUnsaved=false; - curStep=0; - redosAvail=0; - undosAvail=0; - - stepsTotal=settings.readNumEntry("/history/stepsTotal",100); - undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal)); - mainWindow->updateHistory (undoSet); + resetHistory(); // Create tmp dirs makeTmpDirectories(); @@ -516,6 +510,8 @@ // Reset timestamp to check for later updates of file fileChangedTime=QFileInfo (destPath).lastModified(); + + resetHistory(); } @@ -1062,7 +1058,7 @@ return false; } -void VymModel::undo() //FIXME-1 segfault when trying to undo in a brandnew map +void VymModel::undo() { // Can we undo at all? if (undosAvail<1) return; @@ -1180,6 +1176,17 @@ return (tmpMapDir+"/"+histName); } +void VymModel::resetHistory() +{ + curStep=0; + redosAvail=0; + undosAvail=0; + + stepsTotal=settings.readNumEntry("/history/stepsTotal",100); + undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal)); + mainWindow->updateHistory (undoSet); +} + void VymModel::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, TreeItem *saveSel) { sendData(redoCom); //FIXME-3 testing @@ -1732,9 +1739,9 @@ QString ("setURL (\"%1\")").arg(url), QString ("set URL of %1 to %2").arg(getObjectName(selti)).arg(url) ); + emitDataHasChanged (selti); reposition(); - emitDataHasChanged (selti); - emitShowSelection(); + emitSelectionChanged(); } } @@ -2274,12 +2281,12 @@ return NULL; } -BranchItem* VymModel::addMapCenter () +BranchItem* VymModel::addMapCenter (bool saveStateFlag) { BranchItem *bi=addMapCenter (contextPos); updateActions(); emitShowSelection(); - saveState ( + if (saveStateFlag) saveState ( bi, "delete()", NULL, @@ -3279,9 +3286,8 @@ } else parser.setError (Aborted,"Wrong number of parameters"); ///////////////////////////////////////////////////////////////////// - } else if (com==QString("addXLink")) //FIXME-2 not ported yet to Link - { - /* + } else if (com==QString("addXLink")) + { if (parser.parCount()>1) { s=parser.parString (ok,0); // begin @@ -3292,13 +3298,11 @@ { if (begin->isBranchLikeType() && end->isBranchLikeType()) { - XLinkItem *xl=createXLink (begin,true); - if (xl) - { - xl->setEnd (end); - xl->activate(); - } else - parser.setError (Aborted,"Failed to create xLink"); + Link *li=new Link (this); + li->setBeginBranch ( (BranchItem*)begin ); + li->setEndBranch ( (BranchItem*)end); + + createLink (li,true); // create MO by default } else parser.setError (Aborted,"begin or end of xLink are not branch or mapcenter"); @@ -3307,7 +3311,6 @@ parser.setError (Aborted,"Couldn't select begin or end of xLink"); } else parser.setError (Aborted,"Need at least 2 parameters for begin and end"); - */ ///////////////////////////////////////////////////////////////////// } else if (com=="clearFlags") { @@ -3319,7 +3322,11 @@ parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) { - selbi->deactivateAllStandardFlags(); //FIXME-2 this probably should emitDataChanged and also setChanged. Similar all other direct changes should be done... + selbi->deactivateAllStandardFlags(); + reposition(); + emitDataHasChanged(selbi); + emitSelectionChanged(); + setChanged(); } ///////////////////////////////////////////////////////////////////// } else if (com=="colorBranch") @@ -5156,6 +5163,21 @@ return false; } +bool VymModel::selectLastImage() +{ + TreeItem *ti=getSelectedBranch(); + if (ti) + { + TreeItem *par=ti->parent(); + if (par) + { + TreeItem *ti2=par->getLastImage(); + if (ti2) return select(ti2); + } + } + return false; +} + bool VymModel::selectParent() { TreeItem *ti=getSelectedItem(); diff -r 43268373032d -r e265f07f2173 vymmodel.h --- a/vymmodel.h Wed Jun 09 13:14:08 2010 +0000 +++ b/vymmodel.h Mon Jun 14 13:59:17 2010 +0000 @@ -179,6 +179,7 @@ QString getHistoryPath(); //!< Path to directory containing the history + void resetHistory(); //!< Initialize history /*! \brief Save the current changes in map @@ -335,7 +336,7 @@ Disclaimer: Still experimental, not fully supported yet. */ - BranchItem* addMapCenter(); + BranchItem* addMapCenter(bool saveStateFlag=true); private: BranchItem* addMapCenter(QPointF absPos); @@ -628,6 +629,7 @@ bool selectFirstBranch(); bool selectLastBranch(); bool selectLastSelectedBranch(); + bool selectLastImage(); bool selectParent(); public: