# 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 @@ <rect> <x>0</x> <y>0</y> - <width>570</width> - <height>91</height> + <width>607</width> + <height>206</height> </rect> </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="caption"> - <string>Edit Link</string> + <string>Edit XLink</string> </property> - <grid> + <vbox> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QPushButton" row="0" column="0"> + <widget class="QLayoutWidget"> <property name="name"> - <cstring>deleteButton</cstring> + <cstring>layout5</cstring> </property> - <property name="text"> - <string>Delete XLink</string> - </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="0" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>462</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Line width:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <spacer row="1" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>463</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QCheckBox" row="2" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>useSettings</cstring> + </property> + <property name="text"> + <string>(use settings as default for new xlinks)</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="1"> + <property name="name"> + <cstring>colorButton</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="maximumSize"> + <size> + <width>50</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="QSpinBox" row="0" column="1"> + <property name="name"> + <cstring>widthBox</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maxValue"> + <number>15</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Line color:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Default:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <spacer row="2" column="3"> + <property name="name"> + <cstring>spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>110</width> + <height>21</height> + </size> + </property> + </spacer> + </grid> </widget> - <spacer row="0" column="1"> + <spacer> <property name="name"> - <cstring>spacer11</cstring> + <cstring>spacer4</cstring> </property> <property name="orientation"> - <enum>Horizontal</enum> + <enum>Vertical</enum> </property> <property name="sizeType"> <enum>Expanding</enum> </property> <property name="sizeHint"> <size> - <width>180</width> - <height>20</height> + <width>20</width> + <height>40</height> </size> </property> </spacer> - <widget class="QPushButton" row="0" column="3"> + <widget class="QLayoutWidget"> <property name="name"> - <cstring>okButton</cstring> + <cstring>layout4</cstring> </property> - <property name="text"> - <string>Ok</string> - </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>deleteButton</cstring> + </property> + <property name="text"> + <string>Delete XLink</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer11</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>okButton</cstring> + </property> + <property name="text"> + <string>Ok</string> + </property> + </widget> + </hbox> </widget> - <widget class="QPushButton" row="0" column="2"> - <property name="name"> - <cstring>cancelButton</cstring> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </grid> + </vbox> </widget> <connections> <connection> @@ -70,30 +235,43 @@ <slot>accept()</slot> </connection> <connection> - <sender>cancelButton</sender> - <signal>clicked()</signal> - <receiver>EditXLinkDialog</receiver> - <slot>reject()</slot> - </connection> - <connection> <sender>deleteButton</sender> <signal>clicked()</signal> <receiver>EditXLinkDialog</receiver> <slot>deleteButtonPressed()</slot> </connection> + <connection> + <sender>colorButton</sender> + <signal>clicked()</signal> + <receiver>EditXLinkDialog</receiver> + <slot>colorButtonPressed()</slot> + </connection> + <connection> + <sender>widthBox</sender> + <signal>valueChanged(int)</signal> + <receiver>EditXLinkDialog</receiver> + <slot>widthChanged(int)</slot> + </connection> </connections> <includes> + <include location="global" impldecl="in implementation">qcolordialog.h</include> + <include location="local" impldecl="in declaration">xlinkobj.h</include> <include location="local" impldecl="in implementation">editxlinkdialog.ui.h</include> </includes> <variables> <variable access="private">bool delink;</variable> + <variable access="private">XLinkObj *xlo;</variable> </variables> <slots> <slot access="protected">deleteButtonPressed()</slot> + <slot access="protected">widthChanged( int w )</slot> + <slot>setXLink( XLinkObj * xo )</slot> + <slot access="protected">colorButtonPressed()</slot> </slots> <functions> <function access="private" specifier="non virtual">init()</function> <function returnType="bool">deleteXLink()</function> + <function returnType="bool">useSettingsGlobal()</function> </functions> <pixmapinproject/> <layoutdefaults spacing="6" margin="11"/> 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="<<absPos<<endl; - cout << " LMO::updateLink childPos="<<childPos<<endl; - cout << " LMO::updateLink parPos="<<parPos<<endl; - cout << " LMO::updateLink offset="<<offset<<endl; - cout << " LMO::updateLink bbox.w="<<bbox.width()<<endl; - cout << " LMO::updateLink bbox.h="<<bbox.height()<<endl; - */ double p1x=parPos.x(); // Link is drawn from P1 to P2 double p1y=parPos.y(); diff -r 598768200cfa -r 0b048b6bb6f4 mapeditor.cpp --- a/mapeditor.cpp Mon Apr 18 06:37:48 2005 +0000 +++ b/mapeditor.cpp Thu Apr 21 19:14:38 2005 +0000 @@ -283,7 +283,8 @@ lineedit->hide(); actColor=black; setColor (actColor); - deflinkcolor=QColor (0,0,255); + defLinkColor=QColor (0,0,255); + defXLinkColor=QColor (180,180,180); linkcolorhint=DefaultColor; linkstyle=StylePolyParabel; mapCanvas->setBackgroundColor (white); @@ -506,7 +507,9 @@ attribut("date",mapCenter->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() )