# HG changeset patch # User insilmaril # Date 1114110878 0 # Node ID 0b048b6bb6f403f8cda11f56f5114a5c0963b15a # Parent 598768200cfa4cb65971e2b810fedfa9a0e1ba5c xlink color, width and defaults can be saved/ restored now diff -r 598768200cfa -r 0b048b6bb6f4 branchobj.cpp --- a/branchobj.cpp Mon Apr 18 06:37:48 2005 +0000 +++ b/branchobj.cpp Thu Apr 21 19:14:38 2005 +0000 @@ -828,6 +828,11 @@ if (!xlo->isUsed()) delete(xlo); } +XLinkObj* BranchObj::XLinkAt (int i) +{ + return xlink.at(i); +} + int BranchObj::countXLink() { return xlink.count(); diff -r 598768200cfa -r 0b048b6bb6f4 branchobj.h --- a/branchobj.h Mon Apr 18 06:37:48 2005 +0000 +++ b/branchobj.h Thu Apr 21 19:14:38 2005 +0000 @@ -67,6 +67,7 @@ virtual void removeXLinkRef (XLinkObj*); // Remove ref in list virtual void deleteXLink (XLinkObj*); // remove references and delete XLinkObj virtual void deleteXLinkAt (int); // remove references and delete XLinkObj + virtual XLinkObj* XLinkAt (int); // return reference of XLinkObj virtual int countXLink (); virtual BranchObj* XLinkTargetAt (int); virtual LinkableMapObj* addFloatImage(); diff -r 598768200cfa -r 0b048b6bb6f4 editxlinkdialog.ui --- a/editxlinkdialog.ui Mon Apr 18 06:37:48 2005 +0000 +++ b/editxlinkdialog.ui Thu Apr 21 19:14:38 2005 +0000 @@ -8,59 +8,224 @@ 0 0 - 570 - 91 + 607 + 206 + + + 5 + 5 + 0 + 0 + + - Edit Link + Edit XLink - + unnamed - + - deleteButton + layout5 - - Delete XLink - + + + unnamed + + + + spacer2 + + + Horizontal + + + Expanding + + + + 462 + 20 + + + + + + textLabel1 + + + Line width: + + + AlignVCenter|AlignRight + + + + + spacer3 + + + Horizontal + + + Expanding + + + + 463 + 21 + + + + + + useSettings + + + (use settings as default for new xlinks) + + + + + colorButton + + + true + + + + 50 + 20 + + + + + + + + + widthBox + + + + 0 + 0 + 0 + 0 + + + + 15 + + + 1 + + + + + textLabel2 + + + Line color: + + + AlignVCenter|AlignRight + + + + + textLabel1_2 + + + Default: + + + AlignVCenter|AlignRight + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 110 + 21 + + + + - + - spacer11 + spacer4 - Horizontal + Vertical Expanding - 180 - 20 + 20 + 40 - + - okButton + layout4 - - Ok - + + + unnamed + + + + deleteButton + + + Delete XLink + + + + + spacer11 + + + Horizontal + + + Expanding + + + + 100 + 20 + + + + + + okButton + + + Ok + + + - - - cancelButton - - - Cancel - - - + @@ -70,30 +235,43 @@ accept() - cancelButton - clicked() - EditXLinkDialog - reject() - - deleteButton clicked() EditXLinkDialog deleteButtonPressed() + + colorButton + clicked() + EditXLinkDialog + colorButtonPressed() + + + widthBox + valueChanged(int) + EditXLinkDialog + widthChanged(int) + + qcolordialog.h + xlinkobj.h editxlinkdialog.ui.h bool delink; + XLinkObj *xlo; deleteButtonPressed() + widthChanged( int w ) + setXLink( XLinkObj * xo ) + colorButtonPressed() init() deleteXLink() + useSettingsGlobal() diff -r 598768200cfa -r 0b048b6bb6f4 editxlinkdialog.ui.h --- a/editxlinkdialog.ui.h Mon Apr 18 06:37:48 2005 +0000 +++ b/editxlinkdialog.ui.h Thu Apr 21 19:14:38 2005 +0000 @@ -9,6 +9,7 @@ void EditXLinkDialog::init() { delink=false; + xlo=false; } void EditXLinkDialog::deleteButtonPressed() @@ -21,3 +22,32 @@ { return delink; } + + +void EditXLinkDialog::widthChanged( int w) +{ + xlo->setWidth(w); +} + +void EditXLinkDialog::setXLink( XLinkObj * xo) +{ + xlo=xo; + colorButton->setPaletteBackgroundColor (xlo->getColor() ); + widthBox->setValue(xlo->getWidth()); +} + +void EditXLinkDialog::colorButtonPressed() +{ + if (xlo) + { + QColor col = QColorDialog::getColor(xlo->getColor(), this ); + if ( !col.isValid() ) return; + xlo->setColor( col ); + colorButton->setPaletteBackgroundColor (col); + } +} + +bool EditXLinkDialog::useSettingsGlobal () +{ + return useSettings->isChecked(); +} diff -r 598768200cfa -r 0b048b6bb6f4 linkablemapobj.cpp --- a/linkablemapobj.cpp Mon Apr 18 06:37:48 2005 +0000 +++ b/linkablemapobj.cpp Thu Apr 21 19:14:38 2005 +0000 @@ -441,14 +441,6 @@ childPos=QPoint (absPos.x()+ bbox.width(), absPos.y() + offset ); parPos=QPoint (absPos.x(),absPos.y()+offset); } - /* FIXME - cout << " LMO::updateLink absPos="<getDate()) + attribut("backgroundColor", mapCanvas->backgroundColor().name() ) + attribut("linkStyle", ls ) + - attribut("linkColor", deflinkcolor.name() ) + + attribut("linkColor", defLinkColor.name() ) + + attribut("xlinkColor", defXLinkColor.name() ) + + attribut("xlinkWidth", QString().setNum(defXLinkWidth,10) ) + colhint; s+=beginElement("vymmap",mapAttr); incIndent(); @@ -2193,7 +2196,7 @@ QPixmap pix( 16, 16 ); pix.fill( mapCanvas->backgroundColor() ); actionFormatBackColor->setIconSet( pix ); - pix.fill( deflinkcolor ); + pix.fill( defLinkColor ); actionFormatLinkColor->setIconSet( pix ); actionEditUndo->setEnabled( mapChanged ); @@ -2377,7 +2380,7 @@ void MapEditor::setLinkColor(QColor c) { - deflinkcolor=c; + defLinkColor=c; updateActions(); } @@ -2421,7 +2424,27 @@ QColor MapEditor::getDefLinkColor() { - return deflinkcolor; + return defLinkColor; +} + +void MapEditor::setDefXLinkColor(QColor col) +{ + defXLinkColor=col; +} + +QColor MapEditor::getDefXLinkColor() +{ + return defXLinkColor; +} + +void MapEditor::setDefXLinkWidth (int w) +{ + defXLinkWidth=w; +} + +int MapEditor::getDefXLinkWidth() +{ + return defXLinkWidth; } void MapEditor::selectLinkColor() @@ -2429,7 +2452,7 @@ // Finish open lineEdits if (lineedit) finishedLineEditNoSave(); - QColor col = QColorDialog::getColor( deflinkcolor, this ); + QColor col = QColorDialog::getColor( defLinkColor, this ); if ( !col.isValid() ) return; setLinkColor( col ); setChanged(); @@ -2649,29 +2672,45 @@ void MapEditor::followXLink(int i) { - BranchObj *bo=((BranchObj*)(selection))->XLinkTargetAt(i); - if (bo) + if (selection && + (typeid(*selection) == typeid(BranchObj)) || + (typeid(*selection) == typeid(MapCenterObj)) ) { - selection->unselect(); - selection=bo; - selection->select(); - ensureSelectionVisible(); + BranchObj *bo=((BranchObj*)(selection))->XLinkTargetAt(i); + if (bo) + { + selection->unselect(); + selection=bo; + selection->select(); + ensureSelectionVisible(); + } } } void MapEditor::editXLink(int i) { - BranchObj *bo=((BranchObj*)(selection))->XLinkTargetAt(i); - if (bo) + if (selection && + (typeid(*selection) == typeid(BranchObj)) || + (typeid(*selection) == typeid(MapCenterObj)) ) { - EditXLinkDialog dia; - if (dia.exec() == QDialog::Accepted) + XLinkObj *xlo=((BranchObj*)(selection))->XLinkAt(i); + if (xlo) { - if (dia.deleteXLink()) - ((BranchObj*)(selection))->deleteXLinkAt(i); - setChanged(); - } - } + EditXLinkDialog dia; + dia.setXLink (xlo); + if (dia.exec() == QDialog::Accepted) + { + if (dia.useSettingsGlobal() ) + { + setDefXLinkColor (xlo->getColor() ); + setDefXLinkWidth (xlo->getWidth() ); + } + if (dia.deleteXLink()) + ((BranchObj*)(selection))->deleteXLinkAt(i); + setChanged(); + } + } + } } void MapEditor::testFunction() @@ -2784,6 +2823,8 @@ tmpXLink=new XLinkObj (mapCanvas); tmpXLink->setBegin (bo_begin); tmpXLink->setEnd (p); + tmpXLink->setColor(defXLinkColor); + tmpXLink->setWidth(defXLinkWidth); tmpXLink->updateXLink(); tmpXLink->setVisibility (true); return; diff -r 598768200cfa -r 0b048b6bb6f4 mapeditor.h --- a/mapeditor.h Mon Apr 18 06:37:48 2005 +0000 +++ b/mapeditor.h Thu Apr 21 19:14:38 2005 +0000 @@ -115,6 +115,10 @@ void setLinkColorHint(LinkColorHint); // color of links LinkColorHint getLinkColorHint(); QColor getDefLinkColor(); + void setDefXLinkColor(QColor); + QColor getDefXLinkColor(); + void setDefXLinkWidth (int); + int getDefXLinkWidth(); void toggleLinkColorHint(); // after changing linkStyles void selectLinkColor(); void toggleScroll(); @@ -149,7 +153,9 @@ QLineEdit* lineedit; QColor actColor; // actual color - QColor deflinkcolor; // default color for links + QColor defLinkColor; // default color for links + QColor defXLinkColor; // default color for xlinks + int defXLinkWidth; // default width for xlinks LinkColorHint linkcolorhint;// use heading color or own color LinkStyle linkstyle; // default style for links diff -r 598768200cfa -r 0b048b6bb6f4 misc.h --- a/misc.h Mon Apr 18 06:37:48 2005 +0000 +++ b/misc.h Thu Apr 21 19:14:38 2005 +0000 @@ -7,6 +7,7 @@ using namespace std; #define Z_BBOX 0 +#define Z_XLINK 10 #define Z_LINK 20 #define Z_FRAME 50 #define Z_SELBOX 60 diff -r 598768200cfa -r 0b048b6bb6f4 version.h --- a/version.h Mon Apr 18 06:37:48 2005 +0000 +++ b/version.h Thu Apr 21 19:14:38 2005 +0000 @@ -2,6 +2,6 @@ #define VERSION_H #define __VYM_VERSION__ "1.6.4" -#define __BUILD_DATE__ "April 15, 2005" +#define __BUILD_DATE__ "April 21, 2005" #endif diff -r 598768200cfa -r 0b048b6bb6f4 vym.pro --- a/vym.pro Mon Apr 18 06:37:48 2005 +0000 +++ b/vym.pro Thu Apr 21 19:14:38 2005 +0000 @@ -1,3 +1,8 @@ + + + + + TARGET = vym TRANSLATIONS += lang/vym_de.ts TRANSLATIONS += lang/vym_en.ts @@ -22,6 +27,42 @@ INSTALLS += demo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TEMPLATE = app LANGUAGE = C++ diff -r 598768200cfa -r 0b048b6bb6f4 xlinkobj.cpp --- a/xlinkobj.cpp Mon Apr 18 06:37:48 2005 +0000 +++ b/xlinkobj.cpp Thu Apr 21 19:14:38 2005 +0000 @@ -1,5 +1,6 @@ #include "xlinkobj.h" #include "branchobj.h" +#include "mapeditor.h" ///////////////////////////////////////////////////////////////// @@ -7,7 +8,6 @@ ///////////////////////////////////////////////////////////////// int XLinkObj::arrowSize=10; // make instances -QColor XLinkObj::defXLinkColor=QColor(180,180,180); XLinkObj::XLinkObj ():MapObj() { @@ -38,13 +38,16 @@ visBranch=NULL; xLinkState=undefinedXLink; - xLinkColor=defXLinkColor; + width=1; + color=QColor (180,180,180); line=new QCanvasLine (canvas); line->setPoints (0,0,200,200); - line->setPen (QPen(xLinkColor, 1)); + line->setPen (QPen(color, 1)); + line->setZ (Z_XLINK); poly=new QCanvasPolygon (canvas); - poly->setBrush( xLinkColor ); + poly->setBrush( color ); + poly->setZ (Z_XLINK); setVisibility (false); } @@ -79,9 +82,27 @@ } } +void XLinkObj::setWidth (int w) +{ + width=w; + setColor (color); +} + +int XLinkObj::getWidth() +{ + return width; +} + void XLinkObj::setColor(QColor c) { - xLinkColor=c; + color=c; + line->setPen (QPen(color, width)); + poly->setBrush( color ); +} + +QColor XLinkObj::getColor() +{ + return color; } void XLinkObj::setEnd (QPoint p) @@ -249,10 +270,11 @@ QString s; if (beginBranch && endBranch) { - QString colAttr=attribut ("color",xLinkColor.name()); + QString colAttr=attribut ("color",color.name()); + QString widAttr=attribut ("width",QString().setNum(width,10)); QString begSelAttr=attribut ("beginBranch",beginBranch->getSelectString()); QString endSelAttr=attribut ("endBranch", endBranch->getSelectString()); - s=beginElement ("xlink", colAttr +begSelAttr +endSelAttr); + s=beginElement ("xlink", colAttr +widAttr +begSelAttr +endSelAttr); s+=endElement ("xlink"); } diff -r 598768200cfa -r 0b048b6bb6f4 xlinkobj.h --- a/xlinkobj.h Mon Apr 18 06:37:48 2005 +0000 +++ b/xlinkobj.h Thu Apr 21 19:14:38 2005 +0000 @@ -17,6 +17,9 @@ void setEnd (BranchObj*); void setEnd (QPoint); void setColor(QColor); + QColor getColor(); + void setWidth (int); + int getWidth (); bool activate (); // Sets pointers in branchObjects void deactivate(); // removes those pointers bool isUsed(); // true, if at least on branch uses it @@ -30,8 +33,8 @@ private: static int arrowSize; - static QColor defXLinkColor; - QColor xLinkColor; + QColor color; + int width; QCanvasLine *line; QCanvasPolygon *poly; BranchObj *beginBranch; diff -r 598768200cfa -r 0b048b6bb6f4 xml.cpp --- a/xml.cpp Mon Apr 18 06:37:48 2005 +0000 +++ b/xml.cpp Thu Apr 21 19:14:38 2005 +0000 @@ -106,6 +106,15 @@ col.setNamedColor(atts.value("linkColor")); me->setLinkColor(col); } + if (!atts.value( "xlinkColor").isEmpty() ) + { + col.setNamedColor(atts.value("xlinkColor")); + me->setDefXLinkColor(col); + } + if (!atts.value( "xlinkWidth").isEmpty() ) + { + me->setDefXLinkWidth(atts.value("xlinkWidth").toInt ()); + } } } else if ( eName == "select" && state == StateMap ) { @@ -513,13 +522,19 @@ bool mapBuilderHandler::readXLinkAttr (const QXmlAttributes& a) { QColor col; + bool okx; XLinkObj *xlo=new XLinkObj (mc->getCanvas()); - if (!a.value( "xLinkColor").isEmpty() ) + if (!a.value( "color").isEmpty() ) { - col.setNamedColor(a.value("xLinkColor")); + col.setNamedColor(a.value("color")); xlo->setColor (col); } + if (!a.value( "width").isEmpty() ) + { + xlo->setWidth(a.value ("width").toInt (&okx, 10)); + } + if (!a.value( "beginBranch").isEmpty() ) { if (!a.value( "endBranch").isEmpty() )