1.1 --- a/mapeditor.cpp Thu Sep 14 11:38:17 2006 +0000
1.2 +++ b/mapeditor.cpp Thu Sep 14 11:38:18 2006 +0000
1.3 @@ -209,7 +209,7 @@
1.4 fileName=tr("unnamed");
1.5 mapName="";
1.6
1.7 - stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",5);
1.8 + stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",50);
1.9 undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
1.10
1.11 // Initialize find routine
1.12 @@ -546,7 +546,7 @@
1.13
1.14 /* TODO remove after testing
1.15 */
1.16 - cout << "ME::saveState() begin"<<endl;
1.17 + cout << "ME::saveState() "<<endl;
1.18
1.19 setChanged();
1.20
1.21 @@ -559,7 +559,8 @@
1.22 if (curStep>stepsTotal) curStep=1;
1.23
1.24 QString backupXML;
1.25 - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
1.26 + QString bakMapName=QDir::convertSeparators (QString("history-%1").arg(curStep));
1.27 + QString bakMapDir=QDir::convertSeparators (tmpMapDir +"/"+bakMapName);
1.28 QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml");
1.29
1.30 // Create bakMapDir if not available
1.31 @@ -589,7 +590,13 @@
1.32 // Write XML Data to disk
1.33 saveStringToDisk (QString(bakMapPath),backupXML);
1.34
1.35 + // We would have to save all actions in a tree, to keep track of
1.36 + // possible redos after a action. Too complex, forget about redos.
1.37 + redosAvail=0;
1.38 +
1.39 + // Write the current state to disk
1.40 undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
1.41 + undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
1.42 undoSet.setEntry ("/history/curStep",QString::number(curStep));
1.43 undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand);
1.44 undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection);
1.45 @@ -771,6 +778,8 @@
1.46 {
1.47 s=api.parString (ok,0); // undo selection
1.48 t=api.parString (ok,1); // backup dir
1.49 + if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
1.50 + cout <<t.ascii()<<endl;
1.51 undoXML(s,t);
1.52 }
1.53 } else if (com=="select")
1.54 @@ -1429,16 +1438,19 @@
1.55 {
1.56 // Restore variables
1.57 int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
1.58 + int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
1.59 +
1.60 + cout << "ME::goto "<<i<<endl;
1.61
1.62 - if (i<0) return;
1.63 -
1.64 - // Clicking above current steps let's us undo things
1.65 + if (i<0) i=undosAvail+redosAvail;
1.66 +
1.67 + // Clicking above current step makes us undo things
1.68 if (i<undosAvail)
1.69 {
1.70 for (int j=0; j<undosAvail-i; j++) undo();
1.71 return;
1.72 }
1.73 - // Clicking below current steps let's us rendo things
1.74 + // Clicking below current step makes us redo things
1.75 if (i>undosAvail)
1.76 for (int j=undosAvail; j<i; j++) redo();
1.77
1.78 @@ -1542,7 +1554,9 @@
1.79
1.80 void MapEditor::moveRel (const int &x, const int &y)
1.81 {
1.82 - if (selection)
1.83 + if (selection && (typeid(*selection) == typeid(BranchObj) ||
1.84 + typeid(*selection) == typeid(MapCenterObj) ||
1.85 + typeid(*selection) == typeid (FloatImageObj)))
1.86 {
1.87 QString ps=qpointToString (selection->getRelPos());
1.88 QString s=selection->getSelectString();
1.89 @@ -1550,7 +1564,7 @@
1.90 s, "moveRel "+ps,
1.91 s, "moveRel "+qpointToString (QPoint (x,y)),
1.92 QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps));
1.93 - selection->setRelPos (QPoint(x,y));
1.94 + ((OrnamentedObj*)selection)->move2RelPos (x,y);
1.95 mapCenter->reposition();
1.96 adjustCanvasSize();
1.97 }
1.98 @@ -3217,7 +3231,6 @@
1.99
1.100 void MapEditor::editXLink(int i)
1.101 {
1.102 - qDebug ("ko."); //FIXME Huh?
1.103 if (selection &&
1.104 (typeid(*selection) == typeid(BranchObj)) ||
1.105 (typeid(*selection) == typeid(MapCenterObj)) )
1.106 @@ -3247,42 +3260,18 @@
1.107 {
1.108 cout << "MapEditor::testFunction() called\n";
1.109
1.110 -/*
1.111 - bool ok;
1.112 - QString text = QInputDialog::getText(
1.113 - this,
1.114 - tr("QInputDialog::getText()"),
1.115 - tr("User name:"), QLineEdit::Normal,
1.116 - QDir::home().dirName(), &ok, Qt::FramelessWindowHint);
1.117 -*/
1.118 -
1.119 - QDialog *d =new QDialog(NULL);
1.120 - QLineEdit *le=new QLineEdit (d);
1.121 -// d->setModal (true);
1.122 - d->setWindowFlags (Qt::FramelessWindowHint);
1.123 - le->setFocus();
1.124 - le->setText ("Foo");
1.125 - le->selectAll();
1.126 - connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
1.127 - d->exec();
1.128 - qWarning( le->text());
1.129 - return;
1.130 -
1.131 -
1.132 -
1.133 -/*
1.134 WarningDialog dia;
1.135 - dia.setCancelButton (true);
1.136 + dia.showCancelButton (true);
1.137 dia.setText("This is a longer \nWarning");
1.138 + /*
1.139 dia.setCaption("Warning: Flux problem");
1.140 dia.setShowAgainName("/warnings/mapeditor");
1.141 - dia.setWindowFlags (Qt::FramelessWindowHint);
1.142 + */
1.143 if (dia.exec()==QDialog::Accepted)
1.144 cout << "accepted!\n";
1.145 else
1.146 cout << "canceled!\n";
1.147 return;
1.148 -*/
1.149
1.150 /* Hide hidden stuff temporary, maybe add this as regular function somewhere
1.151 if (hidemode==HideNone)
1.152 @@ -3541,7 +3530,7 @@
1.153
1.154 // Relink float to new mapcenter or branch, if shift is pressed
1.155 // Only relink, if selection really has a new parent
1.156 - if ( (e->state() & Qt::ShiftModifier) && lmo &&
1.157 + if ( (e->modifiers()==Qt::ShiftModifier) && lmo &&
1.158 ( (typeid(*lmo)==typeid(BranchObj)) ||
1.159 (typeid(*lmo)==typeid(MapCenterObj)) ) &&
1.160 ( lmo != fo->getParObj())
1.161 @@ -3563,24 +3552,26 @@
1.162 movingObj=(MapObj*)(fio);
1.163 }
1.164 }
1.165 - } else // selection != a FloatObj
1.166 - {
1.167 + } else
1.168 + { // selection != a FloatObj
1.169 if (lmosel->getDepth()==0)
1.170 {
1.171 - if (e->state() == Qt::LeftButton && e->modifiers()==Qt::ShiftModifier)
1.172 - // If mapCenter is moved, move all the rest by default, too.
1.173 + // Move MapCenter
1.174 + if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier)
1.175 mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.176 else
1.177 mapCenter->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.178 + mapCenter->updateRelPositions();
1.179 } else
1.180 {
1.181 if (lmosel->getDepth()==1)
1.182 {
1.183 - // depth==1, mainbranch
1.184 + // Move mainbranch
1.185 lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.186 + lmosel->setRelPos();
1.187 } else
1.188 {
1.189 - // depth>1
1.190 + // Move ordinary branch
1.191 if (lmosel->getOrientation() == OrientLeftOfCenter)
1.192 // Add width of bbox here, otherwise alignRelTo will cause jumping around
1.193 lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(),
1.194 @@ -3590,19 +3581,18 @@
1.195 }
1.196 // reposition subbranch
1.197 lmosel->reposition();
1.198 - //ensureSelectionVisible();
1.199
1.200 if (lmo && (lmo!=selection) &&
1.201 (typeid(*lmo) == typeid(BranchObj) ||
1.202 (typeid(*lmo) == typeid(MapCenterObj) )
1.203 ) )
1.204 {
1.205 - if (e->state() & Qt::ControlModifier)
1.206 + if (e->modifiers()==Qt::ControlModifier)
1.207 {
1.208 // Special case: CTRL to link below lmo
1.209 lmosel->setParObjTmp (lmo,p,+1);
1.210 }
1.211 - else if (e->state() & Qt::ShiftModifier)
1.212 + else if (e->modifiers()==Qt::ShiftModifier)
1.213 lmosel->setParObjTmp (lmo,p,-1);
1.214 else
1.215 lmosel->setParObjTmp (lmo,p,0);
1.216 @@ -3688,9 +3678,9 @@
1.217 // Have we been moving something?
1.218 if ( selection && movingObj )
1.219 {
1.220 - // Moved FloatObj? Maybe we need to reposition
1.221 if(typeid(*selection)==typeid (FloatImageObj))
1.222 {
1.223 + // Moved FloatObj. Maybe we need to reposition
1.224 FloatImageObj *fo=(FloatImageObj*)selection;
1.225 QString pold=qpointToString(movingObj_orgRelPos);
1.226 QString pnow=qpointToString(fo->getRelPos());
1.227 @@ -3699,6 +3689,7 @@
1.228 "moveRel "+pnow,
1.229 QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow));
1.230
1.231 + // FIXME Why calling parObj here?
1.232 selection->getParObj()->requestReposition();
1.233 mapCenter->reposition();
1.234 }
1.235 @@ -3711,9 +3702,14 @@
1.236 if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj)))
1.237 dst=NULL;
1.238
1.239 - // Now check, if we have been moving a branch
1.240 + if (typeid(*selection) == typeid(MapCenterObj) )
1.241 + { // The MapCenter was moved
1.242 + cout << "FIXME missing savestate...\n";
1.243 + }
1.244 +
1.245 if (typeid(*selection) == typeid(BranchObj) )
1.246 - {
1.247 + { // A branch was moved
1.248 +
1.249 // save the position in case we link to mapcenter
1.250 QPoint savePos=QPoint (selection->x(),selection->y() );
1.251