1.1 --- a/mapeditor.cpp Fri Jan 05 11:17:33 2007 +0000
1.2 +++ b/mapeditor.cpp Wed Jan 10 13:26:12 2007 +0000
1.3 @@ -165,7 +165,7 @@
1.4 return blockReposition;
1.5 }
1.6
1.7 -QString MapEditor::getName (LinkableMapObj *lmo)
1.8 +QString MapEditor::getName (const LinkableMapObj *lmo)
1.9 {
1.10 QString s;
1.11 if (!lmo) return QString("Error: NULL has no name!");
1.12 @@ -638,6 +638,29 @@
1.13 }
1.14 }
1.15 }
1.16 + } else if (com=="linkTo")
1.17 + {
1.18 + if (!selection)
1.19 + {
1.20 + api.setError (Aborted,"Nothing selected");
1.21 + } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.22 + typeid(*selection) != typeid(MapCenterObj) &&
1.23 + typeid(*selection) != typeid(FloatImageObj)))
1.24 + {
1.25 + api.setError (Aborted,"Type of selection is not a floatimage");
1.26 + } else if (api.checkParamCount(1))
1.27 + {
1.28 + // 0 selectstring of parent
1.29 + s=api.parString(ok,0);
1.30 + LinkableMapObj *dst=mapCenter->findObjBySelect (s);
1.31 + if (dst)
1.32 + {
1.33 + if (typeid(*dst) == typeid(BranchObj) ||
1.34 + typeid(*dst) == typeid(MapCenterObj))
1.35 + linkTo (dst->getSelectString());
1.36 + } else
1.37 + api.setError (Aborted,"Destination is not a branch");
1.38 + }
1.39 } else if (com=="moveBranchUp")
1.40 {
1.41 if (!selection)
1.42 @@ -1208,10 +1231,12 @@
1.43
1.44 QPixmap MapEditor::getPixmap()
1.45 {
1.46 -/* FIXME getPixmap not ported yet to QT4
1.47 QRectF mapRect=mapCenter->getTotalBBox();
1.48 - QPixmap pix ();
1.49 + QPixmap pix((int)mapRect.width(),(int)mapRect.height());
1.50 + cout << "w.h="<<(int)mapRect.width()<<","<<(int)mapRect.height()<<endl;
1.51 QPainter pp (&pix);
1.52 +
1.53 + pp.setRenderHints(renderHints());
1.54
1.55 // Don't print the visualisation of selection
1.56 LinkableMapObj *oldselection=NULL;
1.57 @@ -1221,10 +1246,11 @@
1.58 selection->unselect();
1.59 }
1.60
1.61 - pp.setWindow (mapRect);
1.62 -
1.63 - //mapScene->drawArea(mapRect, &pp); // draw scene to painter
1.64 - mapScene->render(&pp); // draw scene to painter
1.65 + mapScene->render ( &pp,
1.66 + QRectF(0,0,mapRect.width(),mapRect.height()),
1.67 + QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
1.68 +
1.69 +// mapScene->render(&pp); // draw scene to painter
1.70
1.71
1.72
1.73 @@ -1236,7 +1262,6 @@
1.74 }
1.75
1.76 return pix;
1.77 -*/
1.78 }
1.79
1.80 void MapEditor::setHideTmpMode (HideTmpMode mode)
1.81 @@ -1513,6 +1538,7 @@
1.82
1.83 mainWindow->updateHistory (undoSet);
1.84 updateActions();
1.85 + ensureSelectionVisible();
1.86 }
1.87
1.88 bool MapEditor::isUndoAvailable()
1.89 @@ -1689,6 +1715,7 @@
1.90 QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps));
1.91 ((OrnamentedObj*)selection)->move2RelPos (x,y);
1.92 mapCenter->reposition();
1.93 + selection->updateLink();
1.94 }
1.95 }
1.96
1.97 @@ -1706,6 +1733,7 @@
1.98 selection->select();
1.99 saveState (selection,"moveBranchDown ()",bo,"moveBranchUp ()",QString("Move up %1").arg(getName(bo)));
1.100 mapCenter->reposition();
1.101 + scene()->update();
1.102 ensureSelectionVisible();
1.103 }
1.104 }
1.105 @@ -1724,10 +1752,42 @@
1.106 selection->select();
1.107 saveState(selection,"moveBranchUp ()",bo,"moveBranchDown ()",QString("Move down %1").arg(getName(bo)));
1.108 mapCenter->reposition();
1.109 + scene()->update();
1.110 ensureSelectionVisible();
1.111 }
1.112 }
1.113
1.114 +void MapEditor::linkTo(const QString &dstString)
1.115 +{
1.116 + BranchObj *dst=(BranchObj*)(mapCenter->findObjBySelect(dstString));
1.117 + if (dst && (typeid(*dst)==typeid (BranchObj) ||
1.118 + typeid(*dst)==typeid (MapCenterObj)))
1.119 + {
1.120 + LinkableMapObj *dstPar=dst->getParObj();
1.121 + QString parString=dstPar->getSelectString();
1.122 + if (typeid(*selection)==typeid(FloatImageObj))
1.123 + {
1.124 + FloatImageObj *fio=(FloatImageObj*)selection;
1.125 + QString fioPreSelectString=fio->getSelectString();
1.126 + QString fioPreParentSelectString=fio->getParObj()->getSelectString();
1.127 + ((BranchObj*)(dst))->addFloatImage (fio);
1.128 + fio->unselect();
1.129 + ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
1.130 + fio=((BranchObj*)(dst))->getLastFloatImage();
1.131 + fio->setRelPos();
1.132 + fio->reposition();
1.133 + selection=(LinkableMapObj*)fio;
1.134 + selection->select();
1.135 + saveState(
1.136 + fio->getSelectString(),
1.137 + QString("linkTo (\"%1\")").arg(fioPreParentSelectString),
1.138 + fioPreSelectString,
1.139 + QString ("linkTo (\"%1\")").arg(dstString),
1.140 + QString ("Link floatimage to %1").arg(getName(dst)));
1.141 + }
1.142 + }
1.143 +}
1.144 +
1.145 QString MapEditor::getHeading(bool &ok, QPoint &p)
1.146 {
1.147 if (selection &&
1.148 @@ -3310,7 +3370,7 @@
1.149 cout << "canceled!\n";
1.150 return;
1.151
1.152 -/* Hide hidden stuff temporary, maybe add this as regular function somewhere
1.153 +/* TODO Hide hidden stuff temporary, maybe add this as regular function somewhere
1.154 if (hidemode==HideNone)
1.155 {
1.156 setHideTmpMode (HideExport);
1.157 @@ -3593,21 +3653,32 @@
1.158 ( lmo != fo->getParObj())
1.159 )
1.160 {
1.161 - if (typeid(*fo) == typeid(FloatImageObj))
1.162 + if (typeid(*fo) == typeid(FloatImageObj) &&
1.163 + ( (typeid(*lmo)==typeid(BranchObj) ||
1.164 + typeid(*lmo)==typeid(MapCenterObj)) ))
1.165 {
1.166 - //FIXME undocom for relinking of floats
1.167 -
1.168 - //saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
1.169 - FloatImageObj *fio=(FloatImageObj*)(fo);
1.170 - ((BranchObj*)(lmo))->addFloatImage (fio);
1.171 - fio->unselect();
1.172 - ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio);
1.173 - fio=((BranchObj*)(lmo))->getLastFloatImage();
1.174 - fio->setRelPos();
1.175 - fio->reposition();
1.176 - selection=(LinkableMapObj*)(fio);
1.177 - selection->select();
1.178 - movingObj=(MapObj*)(fio);
1.179 +
1.180 + // Also save the move which was done so far
1.181 + FloatImageObj *fio=(FloatImageObj*)selection;
1.182 + QString pold=qpointfToString(movingObj_orgRelPos);
1.183 + QString pnow=qpointfToString(fio->getRelPos());
1.184 + saveState(
1.185 + selection,
1.186 + "moveRel "+pold,
1.187 + selection,
1.188 + "moveRel "+pnow,
1.189 + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow));
1.190 + fio->getParObj()->requestReposition();
1.191 + mapCenter->reposition();
1.192 +
1.193 + cout << "current relPos="<<movingObj_orgRelPos<<endl;
1.194 + linkTo (lmo->getSelectString());
1.195 + cout << "setting movingObj\n";
1.196 + movingObj=(MapObj*)selection;
1.197 + movingObj_orgRelPos=selection->getRelPos();
1.198 + cout <<"ok 0\n";
1.199 +
1.200 + mapCenter->reposition();
1.201 }
1.202 }
1.203 } else
1.204 @@ -3929,7 +4000,7 @@
1.205 bo->setHeading(uris.at(i).toString());
1.206 }
1.207 }
1.208 - mapCenter->reposition();
1.209 + mapCenter->reposition();
1.210 }
1.211 }
1.212 event->acceptProposedAction();