# HG changeset patch # User insilmaril # Date 1169553053 0 # Node ID 5522d1da7e37f9cfcfc602f25d489982e504bb3c # Parent b7447adddc9ae3e5c2b8384eccd8444904eddc19 1.8.65 Various fixes diff -r b7447adddc9a -r 5522d1da7e37 branchobj.cpp --- a/branchobj.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/branchobj.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -16,6 +16,11 @@ BranchObj* BranchObj::itFirst=NULL; +HeadingObj* BranchObj::getHO() //FIXME testing only +{ + return heading; +} + BranchObj::BranchObj () :OrnamentedObj() { // cout << "Const BranchObj ()\n"; @@ -744,12 +749,6 @@ else scrolledAttr=""; - QString frameAttr; - if (frame->getFrameType()!=NoFrame) - frameAttr=attribut ("frameType",frame->getFrameTypeName()); - else - frameAttr=""; - // save area, if not scrolled QString areaAttr; if (!((BranchObj*)(parObj))->isScrolled() ) @@ -773,21 +772,19 @@ s=beginElement ("branch" +getOrnAttr() +scrolledAttr - +frameAttr +areaAttr +idAttr +getIncludeImageAttr() ); incIndent(); - /* Testing - for (int i=1; igetColor()).name())); + // Save frame + if (frame->getFrameType()!=NoFrame) + s+=frame->saveToDir (); + // save names of flags set s+=standardFlags->saveToDir(tmpdir,prefix,0); @@ -1082,7 +1079,7 @@ int pos=borem->getNum(); while (bo) { - bo->moveBranchTo (this,pos+1); + bo->linkTo (this,pos+1); bo=borem->getLastBranch(); } removeBranch (borem); @@ -1210,7 +1207,7 @@ return NULL; } -BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos) +BranchObj* BranchObj::linkTo (BranchObj* dst, int pos) { // Find current parent and // remove pointer to myself there diff -r b7447adddc9a -r 5522d1da7e37 branchobj.h --- a/branchobj.h Wed Jan 10 13:26:12 2007 +0000 +++ b/branchobj.h Tue Jan 23 11:50:53 2007 +0000 @@ -15,6 +15,7 @@ ///////////////////////////////////////////////////////////////////////////// class BranchObj:public OrnamentedObj { public: + HeadingObj* getHO(); //FIXME testing BranchObj (); BranchObj (QGraphicsScene*); BranchObj (QGraphicsScene*, LinkableMapObj* parent); @@ -106,7 +107,7 @@ virtual BranchObj* moveBranchUp(BranchObj*); virtual bool canMoveBranchDown(); virtual BranchObj* moveBranchDown(BranchObj*); - virtual BranchObj* moveBranchTo (BranchObj*, int); + virtual BranchObj* linkTo (BranchObj*, int); virtual void alignRelativeTo(const QPointF ); virtual void reposition(); virtual void unsetAllRepositionRequests(); diff -r b7447adddc9a -r 5522d1da7e37 branchpropwindow.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/branchpropwindow.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -0,0 +1,64 @@ +#include "branchpropwindow.h" + +#include "frameobj.h" + + +BranchPropertyWindow::BranchPropertyWindow (QWidget *parent):QDialog(parent) +{ + ui.setupUi (this); + + branch=NULL; + mapEditor=NULL; + + connect ( ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)), this, SLOT (frameTypeChanged (int))); + connect ( ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)), this, SLOT (linkHideUnselectedChanged (int))); +} + +void BranchPropertyWindow::setBranch (BranchObj *bo) +{ + if (!bo) return; + branch=bo; + + // Frame + switch (branch->getFrameType()) + { + case NoFrame: + ui.frameTypeCombo->setCurrentIndex (0); + break; + case Rectangle: + ui.frameTypeCombo->setCurrentIndex (1); + break; + case Ellipse: + ui.frameTypeCombo->setCurrentIndex (2); + break; + } + + // Link + if (branch->getHideLinkUnselected()) + ui.hideLinkIfUnselected->setCheckState (Qt::Checked); + else + ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked); +} + +void BranchPropertyWindow::setMapEditor (MapEditor *me) +{ + if (me) mapEditor=me; +} + +void BranchPropertyWindow::frameTypeChanged (int i) +{ + if (mapEditor) + switch (i) + { + case 0: mapEditor->setFrame (NoFrame); break; + case 1: mapEditor->setFrame (Rectangle); break; + case 2: mapEditor->setFrame (Ellipse); break; + } +} + +void BranchPropertyWindow::linkHideUnselectedChanged (int i) +{ + if (!branch) return; + branch->setHideLinkUnselected(i); +} + diff -r b7447adddc9a -r 5522d1da7e37 branchpropwindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/branchpropwindow.h Tue Jan 23 11:50:53 2007 +0000 @@ -0,0 +1,28 @@ +#ifndef BRANCHPROPERTYWINDOW_H +#define BRANCHPROPERTYWINDOW_H + +#include "ui_branchpropwindow.h" + +#include "branchobj.h" +#include "mapeditor.h" + +class BranchPropertyWindow:public QDialog +{ + Q_OBJECT +public: + BranchPropertyWindow (QWidget *parent=0); + void setBranch (BranchObj *); + void setMapEditor (MapEditor *); + +private slots: + void frameTypeChanged (int); + void linkHideUnselectedChanged (int); + +private: + Ui::BranchPropertyWindow ui; + + BranchObj *branch; + MapEditor *mapEditor; +}; + +#endif // diff -r b7447adddc9a -r 5522d1da7e37 branchpropwindow.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/branchpropwindow.ui Tue Jan 23 11:50:53 2007 +0000 @@ -0,0 +1,128 @@ + + BranchPropertyWindow + + + + 0 + 0 + 343 + 208 + + + + Form + + + + 9 + + + 6 + + + + + 0 + + + + Frame + + + + + 10 + 10 + 301 + 22 + + + + + No Frame + + + + + Rectangle + + + + + Ellipse + + + + + + + Link + + + + + 20 + 10 + 231 + 21 + + + + Hide link if unselected + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 251 + 20 + + + + + + + + Close + + + + + + + + + + + closeButton + clicked() + BranchPropertyWindow + hide() + + + 315 + 173 + + + 171 + 103 + + + + + diff -r b7447adddc9a -r 5522d1da7e37 frameobj.cpp --- a/frameobj.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/frameobj.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -37,6 +37,9 @@ case Rectangle: delete rectFrame; break; + case Ellipse: + delete ellipseFrame; + break; } type=NoFrame; border=0; @@ -51,6 +54,9 @@ case Rectangle: rectFrame->setPos (x,y); break; + case Ellipse: + ellipseFrame->setPos (x,y); + break; } } @@ -77,6 +83,9 @@ case Rectangle: rectFrame->setRect (QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() )); break; + case Ellipse: + ellipseFrame->setRect (QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() )); + break; } } @@ -97,6 +106,9 @@ case Rectangle: return "Rectangle"; break; + case Ellipse: + return "Ellipse"; + break; default: return "NoFrame"; } @@ -117,7 +129,11 @@ border=10; rectFrame = scene->addRect(QRectF(0,0,0,0), QPen(QColor("black") ), QColor("white")); rectFrame->setZValue(Z_FRAME); - + break; + case Ellipse: + border=10; + ellipseFrame = scene->addEllipse(QRectF(0,0,0,0), QPen(QColor("black") ), QColor("white")); + ellipseFrame->setZValue(Z_FRAME); break; } setVisibility (visible); @@ -128,6 +144,8 @@ { if (t=="Rectangle") FrameObj::setFrameType (Rectangle); + else if (t=="Ellipse") + FrameObj::setFrameType (Ellipse); else FrameObj::setFrameType (NoFrame); } @@ -145,6 +163,18 @@ else rectFrame->hide(); break; + case Ellipse: + if (visible) + ellipseFrame->show(); + else + ellipseFrame->hide(); + break; } } +QString FrameObj::saveToDir () +{ + QString frameTypeAttr=attribut ("frameType",getFrameTypeName()); + return singleElement ("frame",frameTypeAttr); +} + diff -r b7447adddc9a -r 5522d1da7e37 frameobj.h --- a/frameobj.h Wed Jan 10 13:26:12 2007 +0000 +++ b/frameobj.h Tue Jan 23 11:50:53 2007 +0000 @@ -3,7 +3,7 @@ #include "mapobj.h" -enum FrameType {NoFrame,Rectangle}; +enum FrameType {NoFrame,Rectangle,Ellipse}; class FrameObj:public MapObj { public: @@ -23,10 +23,12 @@ void setFrameType (const FrameType &); void setFrameType (const QString &); void setVisibility(bool); + QString saveToDir (); protected: FrameType type; QGraphicsRectItem * rectFrame; + QGraphicsEllipseItem * ellipseFrame; int border; // distance text - frame }; #endif diff -r b7447adddc9a -r 5522d1da7e37 headingobj.cpp --- a/headingobj.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/headingobj.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -92,13 +92,10 @@ QGraphicsTextItem* HeadingObj::newLine(QString s) { - QGraphicsTextItem *t=scene->addText(""); + QGraphicsTextItem *t=scene->addText(s); t->setFont (font); t->setZValue(Z_TEXT); t->setDefaultTextColor(color); - t->setPlainText(s); - //t->setTextFlags(Qt::AlignLeft); - t->show(); return t; } diff -r b7447adddc9a -r 5522d1da7e37 historywindow.cpp --- a/historywindow.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/historywindow.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -39,19 +39,19 @@ for (int i=0; i<3; ++i) ui.historyTable->setColumnWidth (i,settings.value( QString("/historywindow/geometry/columnWidth/%1").arg(i),150).toInt()); -/* + if (settings.value ( "/historywindow/showWithMain",false).toBool()) setShowWithMain(true); else setShowWithMain(false); -*/ + } HistoryWindow::~HistoryWindow() { settings.setValue( "/historywindow/geometry/size", size() ); settings.setValue( "/historywindow/geometry/pos", pos() ); - //settings.setValue( "/historywindow/showWithMain",showWithMain()); + settings.setValue( "/historywindow/showWithMain",showWithMain()); for (int i=0; i<3; ++i) settings.setValue( QString("/historywindow/geometry/columnWidth/%1").arg(i), ui.historyTable->columnWidth (i) ); } @@ -153,6 +153,16 @@ } +void HistoryWindow::setShowWithMain (bool v) +{ + showwithmain=v; +} + +bool HistoryWindow::showWithMain() +{ + return showwithmain; +} + void HistoryWindow::undo() { mainWindow->editUndo(); diff -r b7447adddc9a -r 5522d1da7e37 historywindow.h --- a/historywindow.h Wed Jan 10 13:26:12 2007 +0000 +++ b/historywindow.h Tue Jan 23 11:50:53 2007 +0000 @@ -15,6 +15,8 @@ ~HistoryWindow(); void update (SimpleSettings &); void setStepsTotal (int); + void setShowWithMain (bool); + bool showWithMain (); private slots: void undo(); @@ -25,6 +27,7 @@ void clearRow (int); void updateRow (int, int, SimpleSettings &); Ui::HistoryWindow ui; + bool showwithmain; }; diff -r b7447adddc9a -r 5522d1da7e37 imageobj.cpp --- a/imageobj.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/imageobj.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -36,7 +36,7 @@ void ImageObj::save(const QString &fn, const char *format) { - pixmap().save (fn,format,-1); + pixmap().save (fn,format,100); } bool ImageObj::load (const QString &fn) diff -r b7447adddc9a -r 5522d1da7e37 mainwindow.cpp --- a/mainwindow.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/mainwindow.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -5,6 +5,7 @@ #include #include "aboutdialog.h" +#include "branchpropwindow.h" #include "exportoofiledialog.h" #include "exports.h" #include "exportxhtmldialog.h" @@ -93,6 +94,10 @@ // Initialize history window; historyWindow=new HistoryWindow(); + // Initialize properties window + branchPropertyWindow = new BranchPropertyWindow(); + branchPropertyWindow->move (20,20); + // Initialize some settings, which are platform dependant QString p,s; @@ -763,6 +768,10 @@ connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); actionEditLoadImage=a; + a = new QAction( tr( "Properties","Context menu for images and branches" )+QString ("..."), this); + a->setStatusTip (tr( "Set properties for object" )); + connect( a, SIGNAL( triggered() ), this, SLOT( showPropertyDialog() ) ); + actionOpenPropertyDialog=a; } // Format Actions @@ -840,19 +849,6 @@ formatMenu->addAction (a); actionFormatLinkStylePolyParabel=a; - actionGroupFormatFrameTypes=new QActionGroup ( this); - actionGroupFormatFrameTypes->setExclusive (true); - a = new QAction( tr( "No Frame","Branch attribute" ), actionGroupFormatFrameTypes ); - a->setStatusTip (tr("No Frame")); - a->setToggleAction(true); - connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) ); - actionFormatFrameNone=a; - a = new QAction( tr( "Rectangle""Branch attribute" ), actionGroupFormatFrameTypes); - a->setStatusTip (tr( "Rectangle" )); - a->setToggleAction(true); - connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) ); - actionFormatFrameRectangle=a; - a = new QAction( tr( "Include images vertically","Branch attribute" ), this); a->setStatusTip ( tr ("Include top and bottom position of images into branch")); a->setToggleAction(true); @@ -1444,6 +1440,9 @@ // Context Menu for branch or mapcenter branchContextMenu =new QMenu (this); + actionOpenPropertyDialog->addTo (branchContextMenu); + branchContextMenu->addSeparator(); + // Submenu "Add" branchAddContextMenu =branchContextMenu->addMenu (tr("Add")); branchAddContextMenu->addAction (actionEditPaste ); @@ -1466,11 +1465,6 @@ actionEditSaveBranch->addTo( branchContextMenu ); branchContextMenu->addSeparator(); - branchContextMenu->addAction ( actionFormatFrameNone ); - branchContextMenu->addAction ( actionFormatFrameRectangle); - branchContextMenu->addAction ( actionFormatHideLinkUnselected ); - - branchContextMenu->addSeparator(); branchContextMenu->addAction ( actionEditLoadImage); branchContextMenu->addAction ( actionFormatIncludeImagesVer ); branchContextMenu->addAction ( actionFormatIncludeImagesHor ); @@ -1605,6 +1599,7 @@ QFileDialog fd(this,caption); fd.setMode (QFileDialog::DirectoryOnly); fd.setCaption(vymName+ " - "+caption); + fd.setDir (lastFileDir); fd.show(); if ( fd.exec() == QDialog::Accepted ) @@ -2626,17 +2621,24 @@ { // only called from editHeading(), so there is a currentME MapEditor *me=currentMapEditor(); + if (me) + { + QPoint p; //Not used here, only to find out pos of branch + bool ok; + QString s=me->getHeading(ok,p); #if defined(Q_OS_MACX) #else - me->setHeading(lineedit->text()); - - lineedit->releaseKeyboard(); - lineedit->hide(); - setFocus(); + if (ok && s!=lineedit->text()) + me->setHeading(lineedit->text()); + + lineedit->releaseKeyboard(); + lineedit->hide(); + setFocus(); #endif - if (!prevSelection.isEmpty()) me->select(prevSelection); - prevSelection=""; + if (!prevSelection.isEmpty()) me->select(prevSelection); + prevSelection=""; + } } void Main::editHeading() @@ -2767,10 +2769,8 @@ void Main::editMoveUp() { - cout << "Main editMoveUp begin\n"; if (currentMapEditor()) currentMapEditor()->moveBranchUp(); - cout << "Main editMoveUp end\n"; } void Main::editMoveDown() @@ -3058,17 +3058,6 @@ currentMapEditor()->toggleMapLinkColorHint(); } -void Main::formatFrameNone() -{ - if (currentMapEditor()) - currentMapEditor()->setFrame(NoFrame); -} - -void Main::formatFrameRectangle() -{ - if (currentMapEditor()) - currentMapEditor()->setFrame(Rectangle); -} void Main::formatIncludeImagesVer() { @@ -3082,7 +3071,7 @@ currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn()); } -void Main::formatHideLinkUnselected() +void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog { if (currentMapEditor()) currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn()); @@ -3340,17 +3329,6 @@ for (int i=0; isetEnabled(true); actionEditDelete->setEnabled (true); - switch (selection->getFrameType()) - { - case NoFrame: - actionFormatFrameNone->setOn(true); - break; - case Rectangle: - actionFormatFrameRectangle->setOn(true); - break; - default: - break; - } actionFormatIncludeImagesVer->setOn ( ((BranchObj*)selection)->getIncludeImagesVer()); actionFormatIncludeImagesHor->setOn @@ -3438,6 +3416,23 @@ actionViewToggleNoteEditor->setOn (false); } +void Main::showPropertyDialog() +{ + if(currentMapEditor()) + { + LinkableMapObj *sel=currentMapEditor()->getSelection(); + if (sel && typeid(*sel) == typeid(BranchObj)) + { + branchPropertyWindow->show(); + branchPropertyWindow->setMapEditor(currentMapEditor()); + branchPropertyWindow->setBranch((BranchObj*)sel); + return; + } + + } + branchPropertyWindow->setBranch(NULL); +} + void Main::windowNextEditor() { if (tabWidget->currentPageIndex() < tabWidget->count()) @@ -3452,7 +3447,8 @@ void Main::standardFlagChanged() { - currentMapEditor()->toggleStandardFlag(sender()->name()); + if (currentMapEditor()) + currentMapEditor()->toggleStandardFlag(sender()->name()); } void Main::testFunction() diff -r b7447adddc9a -r 5522d1da7e37 mainwindow.h --- a/mainwindow.h Wed Jan 10 13:26:12 2007 +0000 +++ b/mainwindow.h Tue Jan 23 11:50:53 2007 +0000 @@ -3,6 +3,7 @@ #include +#include "branchpropwindow.h" #include "file.h" #include "findwindow.h" #include "historywindow.h" @@ -146,8 +147,6 @@ void formatSelectBackImage(); void formatSelectLinkColor(); void formatToggleLinkColorHint(); - void formatFrameNone(); - void formatFrameRectangle(); void formatIncludeImagesVer(); void formatIncludeImagesHor(); void formatHideLinkUnselected(); @@ -174,6 +173,7 @@ bool useFlagGroups(); private slots: + void showPropertyDialog(); void windowNextEditor(); void windowPreviousEditor(); void windowShowNoteEditor(); @@ -200,6 +200,8 @@ HistoryWindow *historyWindow; + BranchPropertyWindow *branchPropertyWindow; + QList actionListBranches; QColor currentColor; @@ -263,8 +265,8 @@ QAction* actionModModeCopy; QActionGroup *actionGroupFormatFrameTypes; - QAction *actionFormatFrameNone; - QAction *actionFormatFrameRectangle; + + QAction *actionOpenPropertyDialog; QActionGroup *actionGroupFormatLinkStyles; QAction *actionFormatLinkStyleLine; diff -r b7447adddc9a -r 5522d1da7e37 mapcenterobj.cpp --- a/mapcenterobj.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/mapcenterobj.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -20,7 +20,7 @@ MapCenterObj::~MapCenterObj() { - cout << "Destr MapCenterObj\n"; +// cout << "Destr MapCenterObj\n"; } void MapCenterObj::clear() @@ -138,7 +138,6 @@ s=beginElement ("mapcenter" +getOrnAttr() - +attribut("frameType",frame->getFrameTypeName()) +areaAttr +idAttr +getIncludeImageAttr() ); @@ -151,7 +150,12 @@ // Save flags. If verbose is set (export to xml dir), also write // the flags as picture s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose); - s=s+valueElement("heading", getHeading(),a); + + // Save heading + s+=valueElement("heading", getHeading(),a); + + // Save frame + s+=frame->saveToDir (); // add link to file in s if (!note.isEmpty() ) 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())+ ")"; diff -r b7447adddc9a -r 5522d1da7e37 mapeditor.h --- a/mapeditor.h Wed Jan 10 13:26:12 2007 +0000 +++ b/mapeditor.h Tue Jan 23 11:50:53 2007 +0000 @@ -10,8 +10,6 @@ #include "selection.h" #include "settings.h" -class Q3NetworkOperation; -class Q3UrlOperator; class MapEditor : public QGraphicsView, public xmlObj { Q_OBJECT @@ -37,13 +35,6 @@ private: void addFloatImageInt(const QPixmap &img); -/* - private slots: - void fetchImage(const QString &img); - void imageDataFetched(const QByteArray &, Q3NetworkOperation *); - void imageDataFinished(Q3NetworkOperation *); - */ - public: bool isDefault(); // false, if map was changed once bool isUnsaved(); // save necessary @@ -222,7 +213,7 @@ bool copyingObj; // true while creating a link XLinkObj* tmpXLink; - Selection xelection; + Selection xelection; // FIXME not used (yet) LinkableMapObj* selection; // select a LinkableMapObj LinkableMapObj* selectionLast; // last selection MapObj* movingObj; // moving a MapObj @@ -263,10 +254,6 @@ HideTmpMode hidemode; // true while exporting to hide some stuff void resizeEvent( QResizeEvent * ); - - Q3UrlOperator *urlOperator; - QDataStream *imageData; - QBuffer *imageBuffer; }; #endif diff -r b7447adddc9a -r 5522d1da7e37 selection.cpp --- a/selection.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/selection.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -18,21 +18,23 @@ { mapCenter=other.mapCenter; selectList=other.selectList; + lastSelectList=other.lastSelectList; } void Selection::clear() { selectList.clear(); + lastSelectList.clear(); } -bool Selection::select(LinkableMapObj *lmo) +bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet { clear(); selectList.append (lmo); return false; } -bool Selection::select (const QString &s) +bool Selection::select (const QString &s) // TODO no multiselections yet { LinkableMapObj *lmo=mapCenter->findObjBySelect(s); @@ -47,9 +49,21 @@ } +bool Selection::reselect () // TODO no multiselections yet +{ + if (!lastSelectList.isEmpty()) + { + select (lastSelectList.first()); + return true; + } + return false; + +} + void Selection::unselect() { - clear(); + lastSelectList=selectList; + selectList.clear(); } bool Selection::isEmpty() @@ -62,9 +76,20 @@ return selectList.count(); } -QString Selection::getSelectString() +SelectionType Selection::type() // TODO no multiselections yet { - // TODO multiselection (maybe separated by ";") + if (!selectList.isEmpty()) + { + LinkableMapObj *sel=selectList.first(); + if (typeid (*sel)==typeid (BranchObj)) return Branch; + if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter; + if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage; + } + return Undefined; +} + +QString Selection::getSelectString()// TODO no multiselections yet +{ if (selectList.count()==1) return selectList.first()->getSelectString(); else diff -r b7447adddc9a -r 5522d1da7e37 selection.h --- a/selection.h Wed Jan 10 13:26:12 2007 +0000 +++ b/selection.h Tue Jan 23 11:50:53 2007 +0000 @@ -4,6 +4,8 @@ #include "linkablemapobj.h" #include "mapcenterobj.h" +enum SelectionType {Undefined,Branch,MapCenter,FloatImage}; + class Selection { public: @@ -15,15 +17,18 @@ bool select (LinkableMapObj*); bool select (const QString &); + bool reselect (); void unselect (); bool isEmpty(); uint count(); + SelectionType type(); QString getSelectString(); private: void init(); QList selectList; + QList lastSelectList; MapCenterObj *mapCenter; }; #endif diff -r b7447adddc9a -r 5522d1da7e37 xml.cpp --- a/xml.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/xml.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -28,6 +28,8 @@ errorProt = ""; state = StateInit; laststate = StateInit; + stateStack.clear(); + stateStack.append(StateInit); branchDepth=0; htmldata=""; isVymPart=false; @@ -52,9 +54,10 @@ /* Testing cout << "startElement <"<< eName.ascii()<< "> state="<setColor(col ); } - } else if ( eName == "note" && state == StateMapCenter) + } else if ( eName == "note" && + (state == StateMapCenter ||state==StateBranch)) { // only for backward compatibility (<1.4.6). Use htmlnote now. - state=StateMapCenterNote; + state=StateNote; if (!readNoteAttr (atts) ) return false; } else if ( eName == "htmlnote" && state == StateMapCenter) { laststate=state; state=StateHtmlNote; - } else if ( eName == "floatimage" && state == StateMapCenter ) + } else if ( eName == "floatimage" && + (state == StateMapCenter ||state==StateBranch)) { - state=StateMapCenterFloatImage; + state=StateFloatImage; lastBranch->addFloatImage(); lastFloat=lastBranch->getLastFloatImage(); if (!readFloatImageAttr(atts)) return false; @@ -217,21 +225,6 @@ lastBranch->addBranch(); lastBranch=lastBranch->getLastBranch(); readBranchAttr (atts); - } else if ( (eName=="standardflag" ||eName == "standardFlag") && state == StateBranch) - { - state=StateBranchStandardFlag; - } else if ( eName == "heading" && state == StateBranch) - { - state=StateBranchHeading; - if (!atts.value( "textColor").isEmpty() ) - { - col.setNamedColor(atts.value("textColor")); - lastBranch->setColor(col ); - } - } else if ( eName == "note" && state == StateBranch) - { - state=StateBranchNote; - if (!readNoteAttr (atts) ) return false; } else if ( eName == "htmlnote" && state == StateBranch) { laststate=state; @@ -239,12 +232,11 @@ no.clear(); if (!atts.value( "fonthint").isEmpty() ) no.setFontHint(atts.value ("fonthint") ); - } else if ( eName == "floatimage" && state == StateBranch ) + } else if ( eName == "frame" && (state == StateBranch||state==StateMapCenter)) { - state=StateBranchFloatImage; - lastBranch->addFloatImage(); - lastFloat=lastBranch->getLastFloatImage(); - if (!readFloatImageAttr(atts)) return false; + laststate=state; + state=StateFrame; + if (!readFrameAttr(atts)) return false; } else if ( eName == "xlink" && state == StateBranch ) { state=StateBranchXLink; @@ -274,38 +266,18 @@ bool mapBuilderHandler::endElement ( const QString&, const QString&, const QString &eName) { -// cout << "endElement state="< state=" <"; if (eName=="html") @@ -314,16 +286,13 @@ htmldata.replace ("

","
"); no.setNote (htmldata); lastBranch->setNote (no); - return true; - } else - { - return true; } - case StateMap: state=StateInit; return true; - default : - // even for HTML includes, this should never be reached - return false; - } + break; + default: + break; + } + state=stateStack.takeLast(); + return true; } bool mapBuilderHandler::characters ( const QString& ch) @@ -343,30 +312,21 @@ break; case StateMapSetting:break; case StateMapCenter: break; - case StateMapCenterStandardFlag: - lastBranch->activateStandardFlag(ch_simplified); - break; - case StateMapCenterHeading: - lastBranch->setHeading(ch_simplified); - break; - case StateMapCenterNote: + case StateNote: lastBranch->setNote(ch_simplified); break; case StateBranch: break; - case StateBranchStandardFlag: + case StateStandardFlag: lastBranch->activateStandardFlag(ch_simplified); break; - case StateBranchHeading: - lastBranch->setHeading(ch_simplified); - break; - case StateBranchNote: - lastBranch->setNote(ch_simplified); - break; - case StateBranchFloatImage: break; + case StateFloatImage: break; case StateHtmlNote: break; case StateHtml: htmldata+=ch_org; break; + case StateHeading: + lastBranch->setHeading(ch_simplified); + break; default: return false; } @@ -452,6 +412,16 @@ return true; } +bool mapBuilderHandler::readFrameAttr (const QXmlAttributes& a) +{ + if (lastOO) + { + if (!a.value( "frameType").isEmpty() ) + lastOO->setFrameType (a.value("frameType")); + } + return true; +} + bool mapBuilderHandler::readOOAttr (const QXmlAttributes& a) { if (lastOO) @@ -532,10 +502,7 @@ } if (!a.value( "fonthint").isEmpty() ) no.setFontHint(a.value ("fonthint") ); - if (state == StateMapCenterNote) - mc->setNote(no); - else - lastBranch->setNote(no); + lastBranch->setNote(no); return true; } diff -r b7447adddc9a -r 5522d1da7e37 xml.h --- a/xml.h Wed Jan 10 13:26:12 2007 +0000 +++ b/xml.h Tue Jan 23 11:50:53 2007 +0000 @@ -29,6 +29,7 @@ void setInputFile (QString); void setLoadMode (const LoadMode &); bool readBranchAttr (const QXmlAttributes&); + bool readFrameAttr (const QXmlAttributes&); bool readOOAttr (const QXmlAttributes&); bool readNoteAttr (const QXmlAttributes&); bool readFloatImageAttr (const QXmlAttributes&); @@ -40,17 +41,20 @@ QString errorProt; enum State { - StateInit, StateMap, StateMapSelect, + StateInit, + StateMap, + StateMapSelect, StateMapSetting, + StateMapCenter, + StateBranch, + StateBranchXLink, // + StateHtmlNote, + StateHtml, + StateFrame, + StateStandardFlag, + StateNote, StateFloatImage, - StateMapCenter, StateMapCenterStandardFlag, - StateMapCenterHeading, StateMapCenterNote, - StateMapCenterFloatImage, - - StateBranch, StateBranchStandardFlag, - StateBranchHeading, StateBranchNote, - StateBranchFloatImage, StateBranchXLink, - StateHtmlNote, StateHtml + StateHeading }; @@ -58,6 +62,7 @@ bool isVymPart; State state; State laststate; + QList stateStack; QString htmldata; int branchDepth; NoteObj no;