diff -r 32b71ba642aa -r 9817b292f4a9 mapeditor.cpp --- a/mapeditor.cpp Fri Jun 29 15:12:04 2007 +0000 +++ b/mapeditor.cpp Mon Jul 23 12:42:02 2007 +0000 @@ -482,7 +482,8 @@ { BranchObj *selb=xelection.getBranch(); QString s,t; - int x,y; + double x,y; + int n; bool b,ok; // Split string s into command and parameters @@ -506,11 +507,11 @@ if (parser.checkParCount(pl)) { if (parser.parCount()==0) - addNewBranchInt (-2); + addNewBranch (0); else { - y=parser.parInt (ok,0); - if (ok ) addNewBranchInt (y); + n=parser.parInt (ok,0); + if (ok ) addNewBranch (n); } } } @@ -560,9 +561,9 @@ if (parser.checkParCount(2)) { t=parser.parString (ok,0); // path to map - y=parser.parInt(ok,1); // position + n=parser.parInt(ok,1); // position if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t); - addMapInsertInt(t,y); + addMapInsertInt(t,n); } } ///////////////////////////////////////////////////////////////////// @@ -773,20 +774,20 @@ if (typeid(*dst) == typeid(BranchObj) ) { // Get number in parent - x=parser.parInt (ok,1); + n=parser.parInt (ok,1); if (ok) { - selb->linkTo ((BranchObj*)(dst),x); + selb->linkTo ((BranchObj*)(dst),n); xelection.update(); } } else if (typeid(*dst) == typeid(MapCenterObj) ) { selb->linkTo ((BranchObj*)(dst),-1); // Get coordinates of mainbranch - x=parser.parInt (ok,2); + x=parser.parDouble(ok,2); if (ok) { - y=parser.parInt (ok,3); + y=parser.parDouble(ok,3); if (ok) { selb->move (x,y); @@ -866,10 +867,10 @@ parser.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (parser.checkParCount(2)) { - x=parser.parInt (ok,0); + x=parser.parDouble (ok,0); if (ok) { - y=parser.parInt (ok,1); + y=parser.parDouble (ok,1); if (ok) move (x,y); } } @@ -886,10 +887,10 @@ parser.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (parser.checkParCount(2)) { - x=parser.parInt (ok,0); + x=parser.parDouble (ok,0); if (ok) { - y=parser.parInt (ok,1); + y=parser.parDouble (ok,1); if (ok) moveRel (x,y); } } @@ -907,8 +908,8 @@ parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) { - x=parser.parInt (ok,0); - if (ok) pasteNoSave(x); + n=parser.parInt (ok,0); + if (ok) pasteNoSave(n); } ///////////////////////////////////////////////////////////////////// } else if (com=="qa") @@ -1049,6 +1050,17 @@ } ///////////////////////////////////////////////////////////////////// + } else if (com=="selectLatestAdded") + { + if (latestSelection.isEmpty() ) + { + parser.setError (Aborted,"No latest added object"); + } else + { + if (!select (latestSelection)) + parser.setError (Aborted,"Could not select latest added object "+latestSelection); + } + ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameType") { if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage) @@ -1093,8 +1105,8 @@ } else if (parser.checkParCount(1)) { - x=parser.parInt(ok,0); - if (ok) setFramePadding(x); + n=parser.parInt(ok,0); + if (ok) setFramePadding(n); } ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameBorderWidth") @@ -1105,8 +1117,8 @@ } else if (parser.checkParCount(1)) { - x=parser.parInt(ok,0); - if (ok) setFrameBorderWidth (x); + n=parser.parInt(ok,0); + if (ok) setFrameBorderWidth (n); } ///////////////////////////////////////////////////////////////////// } else if (com=="setMapAuthor") @@ -2239,7 +2251,7 @@ } } -void MapEditor::move(const int &x, const int &y) +void MapEditor::move(const double &x, const double &y) { LinkableMapObj *sel=xelection.single(); if (sel) @@ -2257,7 +2269,7 @@ } -void MapEditor::moveRel (const int &x, const int &y) +void MapEditor::moveRel (const double &x, const double &y) { LinkableMapObj *sel=xelection.single(); if (sel) @@ -2411,19 +2423,20 @@ { // save scroll state. If scrolled, automatically select // new branch in order to tmp unscroll parent... - return bo->addBranch(); + newbo=bo->addBranch(); }else if (num==-1) { num=bo->getNum()+1; bo=(BranchObj*)bo->getParObj(); + if (bo) newbo=bo->insertBranch(num); }else if (num==-3) { num=bo->getNum(); bo=(BranchObj*)bo->getParObj(); + if (bo) newbo=bo->insertBranch(num); } - if (!bo) return bo; - newbo=bo->insertBranch(num); + if (!newbo) return NULL; } return newbo; } @@ -2449,18 +2462,19 @@ newbo, "delete ()", bo, - QString ("addBranch (%1)").arg(pos-2), + QString ("addBranch (%1)").arg(pos), QString ("Add new branch to %1").arg(getName(bo))); mapCenter->reposition(); + xelection.update(); + latestSelection=newbo->getSelectString(); // In Network mode, the client needs to know where the new branch is, // so we have to pass on this information via saveState. // TODO: Get rid of this positioning workaround QString ps=qpointfToString (newbo->getAbsPos()); - sendData ("selectLastBranch ()"); + sendData ("selectLatestAdded ()"); sendData (QString("move %1").arg(ps)); sendSelection(); - xelection.update(); } } return newbo; @@ -2495,6 +2509,7 @@ xelection.update(); } } + latestSelection=xelection.getSelectString(); return newbo; } @@ -4837,6 +4852,8 @@ void MapEditor::sendData(const QString &s) { + if (clientList.size()==0) return; + // Create bytearray to send QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); @@ -4856,7 +4873,8 @@ quint16 bs=(quint16)(block.size() - 2*sizeof(quint16)); out << bs; - cout << "ME::sendData bs="<