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 FrameType OrnamentedObj::getFrameType()
111 return frame->getFrameType();
114 void OrnamentedObj::setFrameType(const FrameType &t)
116 frame->setFrameType(t);
127 void OrnamentedObj::setFrameType(const QString &t)
129 frame->setFrameType(t);
130 if (frame->getFrameType() == NoFrame)
140 void OrnamentedObj::setFramePenColor(QColor col)
142 frame->setPenColor (col);
145 QColor OrnamentedObj::getFramePenColor()
147 return frame->getPenColor ();
150 void OrnamentedObj::setFrameBrushColor(QColor col)
152 frame->setBrushColor (col);
155 QColor OrnamentedObj::getFrameBrushColor()
157 return frame->getBrushColor ();
160 void OrnamentedObj::positionContents()
162 double d=frame->getBorder()/2;
166 double ox,oy; // Offset due to padding
171 systemFlags-> move (ox +x , oy + y );
173 // vertical align heading to bottom
174 heading->move (ox + x + systemFlags->getBBox().width(),
175 oy + y + ornamentsBBox.height() - heading->getHeight()
177 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
179 ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
180 clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
183 void OrnamentedObj::move (double x, double y)
191 void OrnamentedObj::move (QPointF p)
196 void OrnamentedObj::moveBy (double x, double y)
199 MapObj::moveBy (x,y);
201 systemFlags->moveBy (x,y);
202 standardFlags->moveBy (x,y);
203 heading->moveBy (x,y);
208 void OrnamentedObj::moveBy (QPointF p)
210 moveBy (p.x(), p.y());
213 void OrnamentedObj::move2RelPos(double x, double y)
215 setRelPos (QPointF((int)x,(int)y));
218 QPointF p=parObj->getChildPos();
219 move (p.x()+x, p.y() +y);
223 void OrnamentedObj::move2RelPos(QPointF p)
225 move2RelPos (p.x(),p.y());
228 void OrnamentedObj::setNote(QString s)
234 void OrnamentedObj::setNote(NoteObj n)
240 QString OrnamentedObj::getNote()
242 return note.getNote();
245 QString OrnamentedObj::getNoteASCII()
247 return note.getNoteASCII();
250 QString OrnamentedObj::getNoteOpenDoc()
252 return note.getNoteOpenDoc();
255 void OrnamentedObj::setURL(QString s)
259 systemFlags->activate("url");
261 systemFlags->deactivate("url");
262 calcBBoxSize(); // recalculate bbox
263 positionBBox(); // rearrange contents
267 QString OrnamentedObj::getURL()
272 void OrnamentedObj::setVymLink(QString s)
276 // We need the relative (from loading)
277 // or absolute path (from User event)
278 // and build the absolute path.
279 // Note: If we have relative, use path of
280 // current map to build absolute path
282 if (!d.path().startsWith ("/"))
284 QString p=mapEditor->getDestPath();
285 int i=p.findRev("/",-1);
286 d.setPath(p.left(i)+"/"+s);
290 systemFlags->activate("vymLink");
294 systemFlags->deactivate("vymLink");
297 calcBBoxSize(); // recalculate bbox
298 positionBBox(); // rearrange contents
302 QString OrnamentedObj::getVymLink()
308 void OrnamentedObj::clearStandardFlags()
310 standardFlags->deactivateAll();
313 move (absPos.x(), absPos.y() );
317 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
319 standardFlags->toggle(f,exclusive);
322 move (absPos.x(), absPos.y() );
326 void OrnamentedObj::activateStandardFlag(QString f)
328 standardFlags->activate(f);
331 move (absPos.x(), absPos.y() );
335 void OrnamentedObj::deactivateStandardFlag(QString f)
337 standardFlags->deactivate(f);
340 move (absPos.x(), absPos.y() );
344 bool OrnamentedObj::isSetStandardFlag (QString f)
346 return standardFlags->isActive(f);
349 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
351 return systemFlags->getFlagName(p);
354 bool OrnamentedObj::isActiveFlag (const QString & fname)
356 if (standardFlags->isActive (fname) ) return true;
360 void OrnamentedObj::getNoteFromTextEditor ()
362 note.setFilenameHint (textEditor->getFilename());
363 note.setFontHint (textEditor->getFontHint() );
364 setNote( textEditor->getText() );
367 void OrnamentedObj::updateNoteFlag()
371 noteEmpty=textEditor->isEmpty();
373 noteEmpty=note.isEmpty();
377 if (systemFlags->isActive ("note")) return;
378 systemFlags->activate("note");
382 if (!systemFlags->isActive ("note")) return;
383 systemFlags->deactivate("note");
385 mapEditor->setChanged();
388 move (absPos.x(), absPos.y() );
393 void OrnamentedObj::updateFlagsToolbar()
395 standardFlags->updateToolbar();
398 void OrnamentedObj::setHideInExport(bool b)
402 // Don't allow to MapCenter to be hidden
405 systemFlags->activate("hideInExport");
407 systemFlags->deactivate("hideInExport");
414 bool OrnamentedObj::hideInExport()
419 bool OrnamentedObj::isHidden()
424 QString OrnamentedObj::getOrnAttr()
430 attribut("absPosX",QString().setNum(absPos.x())) +
431 attribut("absPosY",QString().setNum(absPos.y()));
434 if (depth==1 || typeid (*this)==typeid (FloatImageObj))
436 attribut("relPosX",QString().setNum(relPos.x())) +
437 attribut("relPosY",QString().setNum(relPos.y()));
444 urlAttr=attribut ("url",url);
447 if (!vymLink.isEmpty())
448 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
452 hideExpAttr= attribut("hideInExport","true");
456 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;