readded flag as xpm. png are not (easily) found
1 #include "ornamentedobj.h"
2 #include "texteditor.h"
4 #include "linkablemapobj.h"
6 extern TextEditor *textEditor;
7 extern FlagRowObj *systemFlagsDefault;
8 extern FlagRowObj *standardFlagsDefault;
11 /////////////////////////////////////////////////////////////////
13 /////////////////////////////////////////////////////////////////
15 OrnamentedObj::OrnamentedObj():LinkableMapObj()
17 // cout << "Const OrnamentedObj ()\n";
21 OrnamentedObj::OrnamentedObj(QCanvas* c) :LinkableMapObj(c)
23 // cout << "Const OrnamentedObj\n";
27 OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->canvas)
32 OrnamentedObj::~OrnamentedObj()
36 delete (standardFlags);
41 void OrnamentedObj::init ()
43 heading = new HeadingObj(canvas);
44 heading->move (absPos.x(), absPos.y());
47 note.setFontHint (textEditor->getFontHintDefault() );
49 systemFlags=new FlagRowObj(canvas);
50 systemFlags->clone(systemFlagsDefault);
51 systemFlags->setName ("systemFlags");
53 standardFlags=new FlagRowObj(canvas);
54 standardFlags->clone(standardFlagsDefault);
55 standardFlags->setName ("standardFlags");
64 void OrnamentedObj::copy (OrnamentedObj* other)
66 LinkableMapObj::copy(other);
67 heading->copy(other->heading);
68 setColor (other->heading->getColor());
70 note.copy (other->note);
71 systemFlags->copy (other->systemFlags);
72 standardFlags->copy (other->standardFlags);
74 ornamentsBBox=other->ornamentsBBox;
76 hideExport=other->hideExport;
78 vymLink=other->vymLink;
81 QString OrnamentedObj::getHeading()
83 return heading->text();
86 void OrnamentedObj::setLinkColor()
88 if (mapEditor->getLinkColorHint()==HeadingColor)
89 LinkableMapObj::setLinkColor (heading->getColor());
91 LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
94 void OrnamentedObj::setColor (QColor col)
96 heading->setColor(col);
100 QColor OrnamentedObj::getColor ()
102 return heading->getColor();
106 void OrnamentedObj::positionContents()
108 double d=frame->getBorder()/2;
112 double ox,oy; // Offset due to padding
117 systemFlags-> move (ox +x , oy + y );
119 // vertical align heading to bottom
120 heading->move (ox + x + systemFlags->getBBox().width(),
121 oy + y + ornamentsBBox.height() - heading->getHeight()
123 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
125 ornamentsBBox.moveTopLeft ( QPoint ((int)(ox+x),(int)(oy+y)));
126 clickBox.moveTopLeft (QPoint ((int)(ox + x), (int)(oy + y)));
130 void OrnamentedObj::move (double x, double y)
138 void OrnamentedObj::move (QPoint p)
143 void OrnamentedObj::moveBy (double x, double y)
146 MapObj::moveBy (x,y);
148 systemFlags->moveBy (x,y);
149 standardFlags->moveBy (x,y);
150 heading->moveBy (x,y);
155 void OrnamentedObj::moveBy (QPoint p)
157 moveBy (p.x(), p.y());
160 void OrnamentedObj::move2RelPos(double x, double y)
163 move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
166 void OrnamentedObj::move2RelPos(QPoint p)
168 move2RelPos (p.x(),p.y());
171 void OrnamentedObj::setNote(QString s)
175 systemFlags->activate("note");
177 systemFlags->deactivate("note");
180 move (absPos.x(), absPos.y() );
184 void OrnamentedObj::setNote(NoteObj n)
188 systemFlags->activate("note");
190 systemFlags->deactivate("note");
193 move (absPos.x(), absPos.y() );
198 QString OrnamentedObj::getNote()
200 return note.getNote();
203 QString OrnamentedObj::getNoteASCII()
205 return note.getNoteASCII();
208 QString OrnamentedObj::getNoteOpenDoc()
210 return note.getNoteOpenDoc();
213 void OrnamentedObj::setURL(QString s)
217 systemFlags->activate("url");
219 systemFlags->deactivate("url");
220 calcBBoxSize(); // recalculate bbox
221 positionBBox(); // rearrange contents
225 QString OrnamentedObj::getURL()
230 void OrnamentedObj::setVymLink(QString s)
234 // We need the relative (from loading)
235 // or absolute path (from User event)
236 // and build the absolute path.
237 // Note: If we have relative, use path of
238 // current map to build absolute path
240 if (!d.path().startsWith ("/"))
242 QString p=mapEditor->getDestPath();
243 int i=p.findRev("/",-1);
244 d.setPath(p.left(i)+"/"+s);
248 systemFlags->activate("vymLink");
252 systemFlags->deactivate("vymLink");
255 calcBBoxSize(); // recalculate bbox
256 positionBBox(); // rearrange contents
260 QString OrnamentedObj::getVymLink()
266 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
268 standardFlags->toggle(f,exclusive);
271 move (absPos.x(), absPos.y() );
275 void OrnamentedObj::activateStandardFlag(QString f)
277 standardFlags->activate(f);
280 move (absPos.x(), absPos.y() );
284 QString OrnamentedObj::getSystemFlagName(const QPoint &p)
286 return systemFlags->getFlagName(p);
289 bool OrnamentedObj::isActiveFlag (const QString & fname)
291 if (standardFlags->isActive (fname) ) return true;
295 void OrnamentedObj::updateNoteFlag()
299 // text in NoteEditor has changed, notify MapEditor
300 mapEditor->setChanged();
303 setNote( textEditor->getText() );
306 note.setFontHint (textEditor->getFontHint() );
310 void OrnamentedObj::setHideInExport(bool b)
314 systemFlags->activate("hideInExport");
316 systemFlags->deactivate("hideInExport");
322 bool OrnamentedObj::hideInExport()
327 QString OrnamentedObj::getOrnAttr()
332 posAttr=attribut("relPosX",QString().setNum(relPos.x(),10)) +
333 attribut("relPosY",QString().setNum(relPos.y(),10));
336 if (depth==0 || depth==1) posAttr=
337 attribut("absPosX",QString().setNum(absPos.x(),10)) +
338 attribut("absPosY",QString().setNum(absPos.y(),10));
345 urlAttr=attribut ("url",url);
348 if (!vymLink.isEmpty())
349 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
353 hideExpAttr= attribut("hideInExport","true");
357 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;