diff -r cac93797c580 -r d922fb6ea482 vymmodel.cpp --- a/vymmodel.cpp Wed Sep 09 12:57:06 2009 +0000 +++ b/vymmodel.cpp Fri Sep 11 12:56:15 2009 +0000 @@ -1135,7 +1135,11 @@ QString bakMapDir(QString(tmpMapDir+"/undo-%1").arg(curStep)); // select object before undo - select (undoSelection); + if (!select (undoSelection)) + { + qWarning ("VymModel::undo() Could not select object for undo"); + return; + } if (debug) { @@ -1424,11 +1428,12 @@ parts.removeFirst(); if (typ=="mc" || typ=="bo") ti=ti->getBranchNum (n); - /* FIXME-2 add other types to getSelectionString and findBy... - else - if (typ="fi") - ti=ti->getImageNum (n); - */ + else if (typ=="fi") + ti=ti->getImageNum (n); + else if (typ=="ai") + ti=ti->getAttributeNum (n); + else if (typ=="xl") + ti=ti->getXLinkNum (n); if(!ti) return NULL; } return ti; @@ -2347,7 +2352,12 @@ select (pi); reposition(); emitShowSelection(); - } + } else if (ti->getType()==TreeItem::XLink) + { + //FIXME-2 savestate missing + deleteItem (ti); + } else + qWarning ("VymmModel::deleteSelection() unknown type?!"); } } @@ -2427,7 +2437,7 @@ TreeItem* VymModel::deleteItem (TreeItem *ti) { - cout << "VM::deleteItem "<parent(); @@ -2950,6 +2960,34 @@ } else parser.setError (Aborted,"Wrong number of parameters"); ///////////////////////////////////////////////////////////////////// + } else if (com==QString("addXLink")) + { + if (parser.parCount()>1) + { + s=parser.parString (ok,0); // begin + t=parser.parString (ok,1); // end + BranchItem *begin=(BranchItem*)findBySelectString(s); + BranchItem *end=(BranchItem*)findBySelectString(t); + if (begin && end) + { + 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"); + } + else + parser.setError (Aborted,"begin or end of xLink are not branch or mapcenter"); + + } else + 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") { if (!selti ) @@ -4306,64 +4344,59 @@ return defXLinkWidth; } -void VymModel::move(const double &x, const double &y) // FIXME-3 +void VymModel::move(const double &x, const double &y) { int i=x; i=y; -/* - BranchObj *bo = getSelectedBranch(); - if (bo && - (selectionType()==TreeItem::Branch || - selectionType()==TreeItem::MapCenter || - selectionType()==TreeItem::Image - )) + MapItem *seli = (MapItem*)getSelectedItem(); + if (seli && (seli->isBranchLikeType() || seli->getType()==TreeItem::Image)) { - QPointF ap(bo->getAbsPos()); - QPointF to(x, y); - if (ap != to) - { - QString ps=qpointfToString(ap); - QString s=getSelectString(); - saveState( - s, "move "+ps, - s, "move "+qpointfToString(to), - QString("Move %1 to %2").arg(getObjectName(bo)).arg(ps)); - bo->move(x,y); - reposition(); - emitSelectionChanged(); - } + LinkableMapObj *lmo=seli->getLMO(); + if (lmo) + { + QPointF ap(lmo->getAbsPos()); + QPointF to(x, y); + if (ap != to) + { + QString ps=qpointFToString(ap); + QString s=getSelectString(seli); + saveState( + s, "move "+ps, + s, "move "+qpointFToString(to), + QString("Move %1 to %2").arg(getObjectName(seli)).arg(ps)); + lmo->move(x,y); + reposition(); + emitSelectionChanged(); + } + } } -*/ } -void VymModel::moveRel (const double &x, const double &y) // FIXME-3 +void VymModel::moveRel (const double &x, const double &y) { int i=x; i=y; -/* - BranchObj *bo = getSelectedBranch(); - if (bo && - (selectionType()==TreeItem::Branch || - selectionType()==TreeItem::MapCenter || - selectionType()==TreeItem::Image - )) - if (bo) + MapItem *seli = (MapItem*)getSelectedItem(); + if (seli && (seli->isBranchLikeType() || seli->getType()==TreeItem::Image)) { - QPointF rp(bo->getRelPos()); - QPointF to(x, y); - if (rp != to) - { - QString ps=qpointfToString (bo->getRelPos()); - QString s=getSelectString(bo); - saveState( - s, "moveRel "+ps, - s, "moveRel "+qpointfToString(to), - QString("Move %1 to relative position %2").arg(getObjectName(bo)).arg(ps)); - ((OrnamentedObj*)bo)->move2RelPos (x,y); - reposition(); - bo->updateLinkGeometry(); - emitSelectionChanged(); - } + LinkableMapObj *lmo=seli->getLMO(); + if (lmo) + { + QPointF rp(lmo->getRelPos()); + QPointF to(x, y); + if (rp != to) + { + QString ps=qpointFToString (lmo->getRelPos()); + QString s=getSelectString(seli); + saveState( + s, "moveRel "+ps, + s, "moveRel "+qpointFToString(to), + QString("Move %1 to relative position %2").arg(getObjectName(seli)).arg(ps)); + ((OrnamentedObj*)lmo)->move2RelPos (x,y); + reposition(); + lmo->updateLinkGeometry(); + emitSelectionChanged(); + } + } } -*/ } @@ -4900,7 +4933,10 @@ case TreeItem::Branch: s="bo:";break; case TreeItem::Image: s="fi:";break; case TreeItem::Attribute: s="ai:";break; - default:break; + case TreeItem::XLink: s="xl:";break; + default: + s="unknown type in VymModel::getSelectString()"; + break; } s= s + QString("%1").arg(ti->num()); if (ti->depth() >0)