GPL V2. Added settings to documentation
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(QGraphicsScene* s) :LinkableMapObj(s)
23 // cout << "Const OrnamentedObj (s)\n";
27 OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->scene)
32 OrnamentedObj::~OrnamentedObj()
41 void OrnamentedObj::init ()
43 heading = new HeadingObj(scene);
44 heading->move (absPos.x(), absPos.y());
47 note.setFontHint (textEditor->getFontHintDefault() );
50 systemFlags=new FlagRowObj(scene);
51 systemFlags->clone(systemFlagsDefault);
52 systemFlags->setName ("systemFlags");
54 standardFlags=new FlagRowObj(scene);
55 standardFlags->clone(standardFlagsDefault);
56 standardFlags->setName ("standardFlags");
58 frame = new FrameObj (scene);
68 void OrnamentedObj::copy (OrnamentedObj* other)
70 LinkableMapObj::copy(other);
71 heading->copy(other->heading);
72 setColor (other->heading->getColor());
74 note.copy (other->note);
75 systemFlags->copy (other->systemFlags);
76 standardFlags->copy (other->standardFlags);
78 ornamentsBBox=other->ornamentsBBox;
80 hideExport=other->hideExport;
82 vymLink=other->vymLink;
85 QString OrnamentedObj::getHeading()
87 return heading->text();
90 void OrnamentedObj::setLinkColor()
92 if (mapEditor->getMapLinkColorHint()==HeadingColor)
93 LinkableMapObj::setLinkColor (heading->getColor());
95 LinkableMapObj::setLinkColor (mapEditor->getMapDefLinkColor());
98 void OrnamentedObj::setColor (QColor col)
100 heading->setColor(col);
104 QColor OrnamentedObj::getColor ()
106 return heading->getColor();
109 FrameObj::FrameType OrnamentedObj::getFrameType()
111 return frame->getFrameType();
114 QString OrnamentedObj::getFrameTypeName()
116 return frame->getFrameTypeName();
119 void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
121 frame->setFrameType(t);
122 if (t == FrameObj::NoFrame)
123 linkpos=LinkableMapObj::Bottom;
125 linkpos=LinkableMapObj::Middle;
132 void OrnamentedObj::setFrameType(const QString &t)
134 frame->setFrameType(t);
135 if (frame->getFrameType() == FrameObj::NoFrame)
136 linkpos=LinkableMapObj::Bottom;
138 linkpos=LinkableMapObj::Middle;
145 void OrnamentedObj::setFramePadding (const int &i)
147 frame->setPadding (i);
153 int OrnamentedObj::getFramePadding ()
155 return frame->getPadding();
158 void OrnamentedObj::setFrameBorderWidth (const int &i)
160 frame->setBorderWidth(i);
166 int OrnamentedObj::getFrameBorderWidth()
168 return frame->getBorderWidth();
171 void OrnamentedObj::setFramePenColor(QColor col)
173 frame->setPenColor (col);
176 QColor OrnamentedObj::getFramePenColor()
178 return frame->getPenColor ();
181 void OrnamentedObj::setFrameBrushColor(QColor col)
183 frame->setBrushColor (col);
186 QColor OrnamentedObj::getFrameBrushColor()
188 return frame->getBrushColor ();
191 void OrnamentedObj::positionContents()
193 double d=frame->getPadding()/2;
197 double ox,oy; // Offset due to padding
202 systemFlags-> move (ox +x , oy + y );
204 // vertical align heading to bottom
205 heading->move (ox + x + systemFlags->getBBox().width(),
206 oy + y + ornamentsBBox.height() - heading->getHeight()
208 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
210 ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
211 clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
214 void OrnamentedObj::move (double x, double y)
222 void OrnamentedObj::move (QPointF p)
227 void OrnamentedObj::moveBy (double x, double y)
230 MapObj::moveBy (x,y);
232 systemFlags->moveBy (x,y);
233 standardFlags->moveBy (x,y);
234 heading->moveBy (x,y);
239 void OrnamentedObj::moveBy (QPointF p)
241 moveBy (p.x(), p.y());
244 void OrnamentedObj::move2RelPos(double x, double y)
246 setRelPos (QPointF((int)x,(int)y));
249 QPointF p=parObj->getChildPos();
250 move (p.x()+x, p.y() +y);
254 void OrnamentedObj::move2RelPos(QPointF p)
256 move2RelPos (p.x(),p.y());
259 void OrnamentedObj::setNote(QString s)
265 void OrnamentedObj::setNote(NoteObj n)
271 QString OrnamentedObj::getNote()
273 return note.getNote();
276 QString OrnamentedObj::getNoteASCII()
278 return note.getNoteASCII();
281 QString OrnamentedObj::getNoteOpenDoc()
283 return note.getNoteOpenDoc();
286 void OrnamentedObj::setURL(QString s)
290 systemFlags->activate("url");
292 systemFlags->deactivate("url");
293 calcBBoxSize(); // recalculate bbox
294 positionBBox(); // rearrange contents
298 QString OrnamentedObj::getURL()
303 void OrnamentedObj::setVymLink(QString s)
307 // We need the relative (from loading)
308 // or absolute path (from User event)
309 // and build the absolute path.
310 // Note: If we have relative, use path of
311 // current map to build absolute path
313 if (!d.path().startsWith ("/"))
315 QString p=mapEditor->getDestPath();
316 int i=p.findRev("/",-1);
317 d.setPath(p.left(i)+"/"+s);
321 systemFlags->activate("vymLink");
325 systemFlags->deactivate("vymLink");
328 calcBBoxSize(); // recalculate bbox
329 positionBBox(); // rearrange contents
333 QString OrnamentedObj::getVymLink()
339 void OrnamentedObj::clearStandardFlags()
341 standardFlags->deactivateAll();
344 move (absPos.x(), absPos.y() );
348 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
350 standardFlags->toggle(f,exclusive);
353 move (absPos.x(), absPos.y() );
357 void OrnamentedObj::activateStandardFlag(QString f)
359 standardFlags->activate(f);
362 move (absPos.x(), absPos.y() );
366 void OrnamentedObj::deactivateStandardFlag(QString f)
368 standardFlags->deactivate(f);
371 move (absPos.x(), absPos.y() );
375 bool OrnamentedObj::isSetStandardFlag (QString f)
377 return standardFlags->isActive(f);
380 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
382 return systemFlags->getFlagName(p);
385 bool OrnamentedObj::isActiveFlag (const QString & fname)
387 if (standardFlags->isActive (fname) ) return true;
391 void OrnamentedObj::getNoteFromTextEditor ()
393 note.setFilenameHint (textEditor->getFilename());
394 note.setFontHint (textEditor->getFontHint() );
395 setNote( textEditor->getText() );
398 void OrnamentedObj::updateNoteFlag()
402 noteEmpty=textEditor->isEmpty();
404 noteEmpty=note.isEmpty();
408 if (systemFlags->isActive ("note")) return;
409 systemFlags->activate("note");
413 if (!systemFlags->isActive ("note")) return;
414 systemFlags->deactivate("note");
416 mapEditor->setChanged();
419 move (absPos.x(), absPos.y() );
424 void OrnamentedObj::updateFlagsToolbar()
426 standardFlags->updateToolbar();
429 void OrnamentedObj::setHideInExport(bool b)
433 // Don't allow to MapCenter to be hidden
436 systemFlags->activate("hideInExport");
438 systemFlags->deactivate("hideInExport");
445 bool OrnamentedObj::hideInExport()
450 bool OrnamentedObj::isHidden()
455 QString OrnamentedObj::getOrnAttr()
461 attribut("absPosX",QString().setNum(absPos.x())) +
462 attribut("absPosY",QString().setNum(absPos.y()));
465 if (depth==1 || typeid (*this)==typeid (FloatImageObj))
467 attribut("relPosX",QString().setNum(relPos.x())) +
468 attribut("relPosY",QString().setNum(relPos.y()));
475 urlAttr=attribut ("url",url);
478 if (!vymLink.isEmpty())
479 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
483 hideExpAttr= attribut("hideInExport","true");
487 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;