diff -r b7447adddc9a -r 5522d1da7e37 mapeditor.cpp --- a/mapeditor.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/mapeditor.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -1,8 +1,5 @@ #include "mapeditor.h" -#include -#include -#include #include #include @@ -51,13 +48,14 @@ extern QString iconPath; extern QDir vymBaseDir; extern QDir lastImageDir; +extern QDir lastFileDir; int MapEditor::mapNum=0; // make instance /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// MapEditor::MapEditor( QWidget* parent) : - QGraphicsView(parent), urlOperator(0), imageBuffer(0) + QGraphicsView(parent) { //cout << "Constructor ME "<stop(); - delete urlOperator; - } - //cout <<"Destructor MapEditor\n"; } @@ -601,66 +594,59 @@ { deleteChilds(); } - } else if (com=="linkBranchToPos") - { - if (!selection) - { - api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj)) ) - { - api.setError (Aborted,"Type of selection is not a branch"); - } else if (api.checkParamCount(4)) - { - // 0 selectstring of parent - // 1 num in parent (for branches) - // 2,3 x,y of mainbranch or mapcenter - s=api.parString(ok,0); - LinkableMapObj *dst=mapCenter->findObjBySelect (s); - if (dst) - { - if (typeid(*dst) == typeid(BranchObj) ) - { - // Get number in parent - x=api.parInt (ok,1); - if (ok) - ((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),x); - } else if (typeid(*dst) == typeid(MapCenterObj) ) - { - ((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),-1); - // Get coordinates of mainbranch - x=api.parInt (ok,2); - if (ok) - { - y=api.parInt (ok,3); - if (ok) ((BranchObj*)selection)->move (x,y); - } - } - } - } } else if (com=="linkTo") { if (!selection) { api.setError (Aborted,"Nothing selected"); - } else if ( (typeid(*selection) != typeid(BranchObj) && - typeid(*selection) != typeid(MapCenterObj) && - typeid(*selection) != typeid(FloatImageObj))) - { - api.setError (Aborted,"Type of selection is not a floatimage"); - } else if (api.checkParamCount(1)) + } else if ( (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj)) ) { - // 0 selectstring of parent - s=api.parString(ok,0); - LinkableMapObj *dst=mapCenter->findObjBySelect (s); - if (dst) - { - if (typeid(*dst) == typeid(BranchObj) || - typeid(*dst) == typeid(MapCenterObj)) - linkTo (dst->getSelectString()); - } else - api.setError (Aborted,"Destination is not a branch"); - } + if (api.checkParamCount(4)) + { + // 0 selectstring of parent + // 1 num in parent (for branches) + // 2,3 x,y of mainbranch or mapcenter + s=api.parString(ok,0); + LinkableMapObj *dst=mapCenter->findObjBySelect (s); + if (dst) + { + if (typeid(*dst) == typeid(BranchObj) ) + { + // Get number in parent + x=api.parInt (ok,1); + if (ok) + ((BranchObj*)selection)->linkTo ((BranchObj*)(dst),x); + } else if (typeid(*dst) == typeid(MapCenterObj) ) + { + ((BranchObj*)selection)->linkTo ((BranchObj*)(dst),-1); + // Get coordinates of mainbranch + x=api.parInt (ok,2); + if (ok) + { + y=api.parInt (ok,3); + if (ok) ((BranchObj*)selection)->move (x,y); + } + } + } + } + } else if ( typeid(*selection) != typeid(FloatImageObj)) + { + if (api.checkParamCount(1)) + { + // 0 selectstring of parent + s=api.parString(ok,0); + LinkableMapObj *dst=mapCenter->findObjBySelect (s); + if (dst) + { + if (typeid(*dst) == typeid(BranchObj) || + typeid(*dst) == typeid(MapCenterObj)) + linkTo (dst->getSelectString()); + } else + api.setError (Aborted,"Destination is not a branch"); + } + } else + api.setError (Aborted,"Type of selection is not a floatimage or branch"); } else if (com=="moveBranchUp") { if (!selection) @@ -892,9 +878,7 @@ } } } else - { api.setError (Aborted,"Unknown command"); - } // Any errors? if (api.errorLevel()==NoError) @@ -1128,6 +1112,8 @@ printer->setOutputFileName(settings.value("/mainwindow/printerFileName",printer->outputFileName()).toString()); } + // FIXME testing cout << "ME::print printProgram="<printProgram().ascii()<getTotalBBox(); // Try to set orientation automagically @@ -1639,7 +1625,7 @@ handler.errorProtocol()); } if (selection!=mapCenter) - ((BranchObj*)selection)->getLastBranch()->moveBranchTo ((BranchObj*)(selection),pos); + ((BranchObj*)selection)->getLastBranch()->linkTo ((BranchObj*)(selection),pos); } else QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path)); } @@ -1795,7 +1781,6 @@ typeid(*selection) == typeid(MapCenterObj) ) ) { ok=true; - ensureSelectionVisible(); p=mapFromScene(selection->getAbsPos()); return ((BranchObj*)selection)->getHeading(); } @@ -1908,6 +1893,8 @@ (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { + setCursor (Qt::ArrowCursor); + newbo=addNewBranchInt (pos-2); if (newbo) @@ -1946,7 +1933,7 @@ newbo->move2RelPos (p); // Move selection to new branch - ((BranchObj*)selection)->moveBranchTo (newbo,-1); + ((BranchObj*)selection)->linkTo (newbo,-1); saveState (newbo, "deleteKeepChilds ()", newbo, "addBranchBefore ()", QString ("Add branch before %1").arg(getName(bo))); @@ -1990,6 +1977,7 @@ ensureSelectionVisible(); mapCenter->reposition(); } + mapScene->update(); } LinkableMapObj* MapEditor::getSelection() @@ -3197,7 +3185,7 @@ } } -void MapEditor::setFrame(const FrameType &t) +void MapEditor::setFrame(const FrameType &t) // FIXME missing saveState { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -3209,7 +3197,7 @@ } } -void MapEditor::setIncludeImagesVer(bool b) +void MapEditor::setIncludeImagesVer(bool b) // FIXME missing saveState { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -3218,7 +3206,7 @@ mapCenter->reposition(); } -void MapEditor::setIncludeImagesHor(bool b) +void MapEditor::setIncludeImagesHor(bool b) // FIXME missing saveState { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -3227,7 +3215,7 @@ mapCenter->reposition(); } -void MapEditor::setHideLinkUnselected (bool b) +void MapEditor::setHideLinkUnselected (bool b) // FIXME missing saveState { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -3236,7 +3224,7 @@ selection->setHideLinkUnselected(b); } -void MapEditor::importDirInt(BranchObj *dst, QDir d) +void MapEditor::importDirInt(BranchObj *dst, QDir d) // FIXME missing saveState { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -3328,7 +3316,7 @@ } } -void MapEditor::editXLink(int i) +void MapEditor::editXLink(int i) // FIXME missing saveState { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -3349,7 +3337,6 @@ } if (dia.deleteXLink()) ((BranchObj*)selection)->deleteXLinkAt(i); - //saveStateComplete("Edit xLink"); //FIXME editXLink undoCommand } } } @@ -3357,6 +3344,8 @@ void MapEditor::testFunction() { + // This is the playground + WarningDialog dia; dia.showCancelButton (true); dia.setText("This is a longer \nWarning"); @@ -3402,13 +3391,7 @@ if (selection) { LinkableMapObj* lmo= dynamic_cast (selection); - QPointF p; - if (selection->getOrientation() == OrientLeftOfCenter) - p= matrix().map(QPointF (lmo->x(),lmo->y())); - else - p= matrix().map(QPointF (lmo->x()+lmo->width(),lmo->y()+lmo->height())); - ensureVisible (QRectF(p.x(), p.y(),0,0 )); - + ensureVisible (lmo->getBBox()); } } @@ -3589,7 +3572,8 @@ selection->select(); mapCenter->reposition(); } - } + } + movingObj=selection; } else // Middle Button Toggle Scroll @@ -3621,6 +3605,10 @@ // Move the selected MapObj if ( selection && movingObj) { + // reset cursor if we are moving and don't copy + if (mainWindow->getModMode()!=ModModeCopy) + setCursor (Qt::ArrowCursor); + // To avoid jumping of the sceneView, only // ensureSelectionVisible, if not tmp linked if (!selection->hasParObjTmp()) @@ -3854,27 +3842,27 @@ if (e->state() & Qt::ShiftModifier && dst->getParObj()) { // Link above dst preDstParStr=dst->getParObj()->getSelectString(); - bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()); + bsel->linkTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()); } else if (e->state() & Qt::ControlModifier && dst->getParObj()) { // Link below dst preDstParStr=dst->getParObj()->getSelectString(); - bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()+1); + bsel->linkTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()+1); } else { // Append to dst preDstParStr=dst->getSelectString(); - bsel->moveBranchTo (bdst,-1); + bsel->linkTo (bdst,-1); if (dst->getDepth()==0) bsel->move (savePos); } QString postSelStr=selection->getSelectString(); QString postNum=QString::number (bsel->getNum(),10); - QString undoCom="linkBranchToPos (\""+ + QString undoCom="linkTo (\""+ preParStr+ "\"," + preNum +"," + QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")"; - QString redoCom="linkBranchToPos (\""+ + QString redoCom="linkTo (\""+ preDstParStr + "\"," + postNum + "," + QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")";