1.1 --- a/mapeditor.cpp Fri Jun 29 15:12:04 2007 +0000
1.2 +++ b/mapeditor.cpp Mon Jul 23 12:42:02 2007 +0000
1.3 @@ -482,7 +482,8 @@
1.4 {
1.5 BranchObj *selb=xelection.getBranch();
1.6 QString s,t;
1.7 - int x,y;
1.8 + double x,y;
1.9 + int n;
1.10 bool b,ok;
1.11
1.12 // Split string s into command and parameters
1.13 @@ -506,11 +507,11 @@
1.14 if (parser.checkParCount(pl))
1.15 {
1.16 if (parser.parCount()==0)
1.17 - addNewBranchInt (-2);
1.18 + addNewBranch (0);
1.19 else
1.20 {
1.21 - y=parser.parInt (ok,0);
1.22 - if (ok ) addNewBranchInt (y);
1.23 + n=parser.parInt (ok,0);
1.24 + if (ok ) addNewBranch (n);
1.25 }
1.26 }
1.27 }
1.28 @@ -560,9 +561,9 @@
1.29 if (parser.checkParCount(2))
1.30 {
1.31 t=parser.parString (ok,0); // path to map
1.32 - y=parser.parInt(ok,1); // position
1.33 + n=parser.parInt(ok,1); // position
1.34 if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
1.35 - addMapInsertInt(t,y);
1.36 + addMapInsertInt(t,n);
1.37 }
1.38 }
1.39 /////////////////////////////////////////////////////////////////////
1.40 @@ -773,20 +774,20 @@
1.41 if (typeid(*dst) == typeid(BranchObj) )
1.42 {
1.43 // Get number in parent
1.44 - x=parser.parInt (ok,1);
1.45 + n=parser.parInt (ok,1);
1.46 if (ok)
1.47 {
1.48 - selb->linkTo ((BranchObj*)(dst),x);
1.49 + selb->linkTo ((BranchObj*)(dst),n);
1.50 xelection.update();
1.51 }
1.52 } else if (typeid(*dst) == typeid(MapCenterObj) )
1.53 {
1.54 selb->linkTo ((BranchObj*)(dst),-1);
1.55 // Get coordinates of mainbranch
1.56 - x=parser.parInt (ok,2);
1.57 + x=parser.parDouble(ok,2);
1.58 if (ok)
1.59 {
1.60 - y=parser.parInt (ok,3);
1.61 + y=parser.parDouble(ok,3);
1.62 if (ok)
1.63 {
1.64 selb->move (x,y);
1.65 @@ -866,10 +867,10 @@
1.66 parser.setError (Aborted,"Type of selection is not a branch or floatimage");
1.67 } else if (parser.checkParCount(2))
1.68 {
1.69 - x=parser.parInt (ok,0);
1.70 + x=parser.parDouble (ok,0);
1.71 if (ok)
1.72 {
1.73 - y=parser.parInt (ok,1);
1.74 + y=parser.parDouble (ok,1);
1.75 if (ok) move (x,y);
1.76 }
1.77 }
1.78 @@ -886,10 +887,10 @@
1.79 parser.setError (Aborted,"Type of selection is not a branch or floatimage");
1.80 } else if (parser.checkParCount(2))
1.81 {
1.82 - x=parser.parInt (ok,0);
1.83 + x=parser.parDouble (ok,0);
1.84 if (ok)
1.85 {
1.86 - y=parser.parInt (ok,1);
1.87 + y=parser.parDouble (ok,1);
1.88 if (ok) moveRel (x,y);
1.89 }
1.90 }
1.91 @@ -907,8 +908,8 @@
1.92 parser.setError (Aborted,"Type of selection is not a branch");
1.93 } else if (parser.checkParCount(1))
1.94 {
1.95 - x=parser.parInt (ok,0);
1.96 - if (ok) pasteNoSave(x);
1.97 + n=parser.parInt (ok,0);
1.98 + if (ok) pasteNoSave(n);
1.99 }
1.100 /////////////////////////////////////////////////////////////////////
1.101 } else if (com=="qa")
1.102 @@ -1049,6 +1050,17 @@
1.103
1.104 }
1.105 /////////////////////////////////////////////////////////////////////
1.106 + } else if (com=="selectLatestAdded")
1.107 + {
1.108 + if (latestSelection.isEmpty() )
1.109 + {
1.110 + parser.setError (Aborted,"No latest added object");
1.111 + } else
1.112 + {
1.113 + if (!select (latestSelection))
1.114 + parser.setError (Aborted,"Could not select latest added object "+latestSelection);
1.115 + }
1.116 + /////////////////////////////////////////////////////////////////////
1.117 } else if (com=="setFrameType")
1.118 {
1.119 if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
1.120 @@ -1093,8 +1105,8 @@
1.121 }
1.122 else if (parser.checkParCount(1))
1.123 {
1.124 - x=parser.parInt(ok,0);
1.125 - if (ok) setFramePadding(x);
1.126 + n=parser.parInt(ok,0);
1.127 + if (ok) setFramePadding(n);
1.128 }
1.129 /////////////////////////////////////////////////////////////////////
1.130 } else if (com=="setFrameBorderWidth")
1.131 @@ -1105,8 +1117,8 @@
1.132 }
1.133 else if (parser.checkParCount(1))
1.134 {
1.135 - x=parser.parInt(ok,0);
1.136 - if (ok) setFrameBorderWidth (x);
1.137 + n=parser.parInt(ok,0);
1.138 + if (ok) setFrameBorderWidth (n);
1.139 }
1.140 /////////////////////////////////////////////////////////////////////
1.141 } else if (com=="setMapAuthor")
1.142 @@ -2239,7 +2251,7 @@
1.143 }
1.144 }
1.145
1.146 -void MapEditor::move(const int &x, const int &y)
1.147 +void MapEditor::move(const double &x, const double &y)
1.148 {
1.149 LinkableMapObj *sel=xelection.single();
1.150 if (sel)
1.151 @@ -2257,7 +2269,7 @@
1.152
1.153 }
1.154
1.155 -void MapEditor::moveRel (const int &x, const int &y)
1.156 +void MapEditor::moveRel (const double &x, const double &y)
1.157 {
1.158 LinkableMapObj *sel=xelection.single();
1.159 if (sel)
1.160 @@ -2411,19 +2423,20 @@
1.161 {
1.162 // save scroll state. If scrolled, automatically select
1.163 // new branch in order to tmp unscroll parent...
1.164 - return bo->addBranch();
1.165 + newbo=bo->addBranch();
1.166
1.167 }else if (num==-1)
1.168 {
1.169 num=bo->getNum()+1;
1.170 bo=(BranchObj*)bo->getParObj();
1.171 + if (bo) newbo=bo->insertBranch(num);
1.172 }else if (num==-3)
1.173 {
1.174 num=bo->getNum();
1.175 bo=(BranchObj*)bo->getParObj();
1.176 + if (bo) newbo=bo->insertBranch(num);
1.177 }
1.178 - if (!bo) return bo;
1.179 - newbo=bo->insertBranch(num);
1.180 + if (!newbo) return NULL;
1.181 }
1.182 return newbo;
1.183 }
1.184 @@ -2449,18 +2462,19 @@
1.185 newbo,
1.186 "delete ()",
1.187 bo,
1.188 - QString ("addBranch (%1)").arg(pos-2),
1.189 + QString ("addBranch (%1)").arg(pos),
1.190 QString ("Add new branch to %1").arg(getName(bo)));
1.191
1.192 mapCenter->reposition();
1.193 + xelection.update();
1.194 + latestSelection=newbo->getSelectString();
1.195 // In Network mode, the client needs to know where the new branch is,
1.196 // so we have to pass on this information via saveState.
1.197 // TODO: Get rid of this positioning workaround
1.198 QString ps=qpointfToString (newbo->getAbsPos());
1.199 - sendData ("selectLastBranch ()");
1.200 + sendData ("selectLatestAdded ()");
1.201 sendData (QString("move %1").arg(ps));
1.202 sendSelection();
1.203 - xelection.update();
1.204 }
1.205 }
1.206 return newbo;
1.207 @@ -2495,6 +2509,7 @@
1.208 xelection.update();
1.209 }
1.210 }
1.211 + latestSelection=xelection.getSelectString();
1.212 return newbo;
1.213 }
1.214
1.215 @@ -4837,6 +4852,8 @@
1.216
1.217 void MapEditor::sendData(const QString &s)
1.218 {
1.219 + if (clientList.size()==0) return;
1.220 +
1.221 // Create bytearray to send
1.222 QByteArray block;
1.223 QDataStream out(&block, QIODevice::WriteOnly);
1.224 @@ -4856,7 +4873,8 @@
1.225 quint16 bs=(quint16)(block.size() - 2*sizeof(quint16));
1.226 out << bs;
1.227
1.228 - cout << "ME::sendData bs="<<bs<<" counter="<<sendCounter<<" s="<<s.ascii()<<endl;
1.229 + if (debug)
1.230 + cout << "ME::sendData bs="<<bs<<" counter="<<sendCounter<<" s="<<s.ascii()<<endl;
1.231
1.232 for (int i=0; i<clientList.size(); ++i)
1.233 {
1.234 @@ -4869,7 +4887,8 @@
1.235 {
1.236 while (clientSocket->bytesAvailable() >=(int)sizeof(quint16) )
1.237 {
1.238 - cout <<"readData bytesAvail="<<clientSocket->bytesAvailable();
1.239 + if (debug)
1.240 + cout <<"readData bytesAvail="<<clientSocket->bytesAvailable();
1.241 quint16 recCounter;
1.242 quint16 blockSize;
1.243
1.244 @@ -4881,7 +4900,8 @@
1.245
1.246 QString t;
1.247 in >>t;
1.248 - cout << " t="<<t.ascii()<<endl;
1.249 + if (debug)
1.250 + cout << " t="<<t.ascii()<<endl;
1.251 parseAtom (t);
1.252 }
1.253 return;