diff -r a40af6315ac6 -r 3a58c9ef4a18 mapeditor.cpp --- a/mapeditor.cpp Thu Sep 14 11:38:17 2006 +0000 +++ b/mapeditor.cpp Thu Sep 14 11:38:18 2006 +0000 @@ -209,7 +209,7 @@ fileName=tr("unnamed"); mapName=""; - stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",5); + stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",50); undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal)); // Initialize find routine @@ -546,7 +546,7 @@ /* TODO remove after testing */ - cout << "ME::saveState() begin"<stepsTotal) curStep=1; QString backupXML; - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); + QString bakMapName=QDir::convertSeparators (QString("history-%1").arg(curStep)); + QString bakMapDir=QDir::convertSeparators (tmpMapDir +"/"+bakMapName); QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml"); // Create bakMapDir if not available @@ -589,7 +590,13 @@ // Write XML Data to disk saveStringToDisk (QString(bakMapPath),backupXML); + // We would have to save all actions in a tree, to keep track of + // possible redos after a action. Too complex, forget about redos. + redosAvail=0; + + // Write the current state to disk undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); + undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail)); undoSet.setEntry ("/history/curStep",QString::number(curStep)); undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand); undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection); @@ -771,6 +778,8 @@ { s=api.parString (ok,0); // undo selection t=api.parString (ok,1); // backup dir + if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t); + cout <undosAvail) for (int j=undosAvail; jgetRelPos()); QString s=selection->getSelectString(); @@ -1550,7 +1564,7 @@ s, "moveRel "+ps, s, "moveRel "+qpointToString (QPoint (x,y)), QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps)); - selection->setRelPos (QPoint(x,y)); + ((OrnamentedObj*)selection)->move2RelPos (x,y); mapCenter->reposition(); adjustCanvasSize(); } @@ -3217,7 +3231,6 @@ void MapEditor::editXLink(int i) { - qDebug ("ko."); //FIXME Huh? if (selection && (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj)) ) @@ -3247,42 +3260,18 @@ { cout << "MapEditor::testFunction() called\n"; -/* - bool ok; - QString text = QInputDialog::getText( - this, - tr("QInputDialog::getText()"), - tr("User name:"), QLineEdit::Normal, - QDir::home().dirName(), &ok, Qt::FramelessWindowHint); -*/ - - QDialog *d =new QDialog(NULL); - QLineEdit *le=new QLineEdit (d); -// d->setModal (true); - d->setWindowFlags (Qt::FramelessWindowHint); - le->setFocus(); - le->setText ("Foo"); - le->selectAll(); - connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); - d->exec(); - qWarning( le->text()); - return; - - - -/* WarningDialog dia; - dia.setCancelButton (true); + dia.showCancelButton (true); dia.setText("This is a longer \nWarning"); + /* dia.setCaption("Warning: Flux problem"); dia.setShowAgainName("/warnings/mapeditor"); - dia.setWindowFlags (Qt::FramelessWindowHint); + */ if (dia.exec()==QDialog::Accepted) cout << "accepted!\n"; else cout << "canceled!\n"; return; -*/ /* Hide hidden stuff temporary, maybe add this as regular function somewhere if (hidemode==HideNone) @@ -3541,7 +3530,7 @@ // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent - if ( (e->state() & Qt::ShiftModifier) && lmo && + if ( (e->modifiers()==Qt::ShiftModifier) && lmo && ( (typeid(*lmo)==typeid(BranchObj)) || (typeid(*lmo)==typeid(MapCenterObj)) ) && ( lmo != fo->getParObj()) @@ -3563,24 +3552,26 @@ movingObj=(MapObj*)(fio); } } - } else // selection != a FloatObj - { + } else + { // selection != a FloatObj if (lmosel->getDepth()==0) { - if (e->state() == Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) - // If mapCenter is moved, move all the rest by default, too. + // Move MapCenter + if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); else mapCenter->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); + mapCenter->updateRelPositions(); } else { if (lmosel->getDepth()==1) { - // depth==1, mainbranch + // Move mainbranch lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); + lmosel->setRelPos(); } else { - // depth>1 + // Move ordinary branch if (lmosel->getOrientation() == OrientLeftOfCenter) // Add width of bbox here, otherwise alignRelTo will cause jumping around lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(), @@ -3590,19 +3581,18 @@ } // reposition subbranch lmosel->reposition(); - //ensureSelectionVisible(); if (lmo && (lmo!=selection) && (typeid(*lmo) == typeid(BranchObj) || (typeid(*lmo) == typeid(MapCenterObj) ) ) ) { - if (e->state() & Qt::ControlModifier) + if (e->modifiers()==Qt::ControlModifier) { // Special case: CTRL to link below lmo lmosel->setParObjTmp (lmo,p,+1); } - else if (e->state() & Qt::ShiftModifier) + else if (e->modifiers()==Qt::ShiftModifier) lmosel->setParObjTmp (lmo,p,-1); else lmosel->setParObjTmp (lmo,p,0); @@ -3688,9 +3678,9 @@ // Have we been moving something? if ( selection && movingObj ) { - // Moved FloatObj? Maybe we need to reposition if(typeid(*selection)==typeid (FloatImageObj)) { + // Moved FloatObj. Maybe we need to reposition FloatImageObj *fo=(FloatImageObj*)selection; QString pold=qpointToString(movingObj_orgRelPos); QString pnow=qpointToString(fo->getRelPos()); @@ -3699,6 +3689,7 @@ "moveRel "+pnow, QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow)); + // FIXME Why calling parObj here? selection->getParObj()->requestReposition(); mapCenter->reposition(); } @@ -3711,9 +3702,14 @@ if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) dst=NULL; - // Now check, if we have been moving a branch + if (typeid(*selection) == typeid(MapCenterObj) ) + { // The MapCenter was moved + cout << "FIXME missing savestate...\n"; + } + if (typeid(*selection) == typeid(BranchObj) ) - { + { // A branch was moved + // save the position in case we link to mapcenter QPoint savePos=QPoint (selection->x(),selection->y() );