3 #include "ornamentedobj.h"
4 #include "texteditor.h"
6 #include "linkablemapobj.h"
8 extern TextEditor *textEditor;
9 extern FlagRowObj *systemFlagsDefault;
10 extern FlagRowObj *standardFlagsDefault;
13 /////////////////////////////////////////////////////////////////
15 /////////////////////////////////////////////////////////////////
17 OrnamentedObj::OrnamentedObj():LinkableMapObj()
19 // cout << "Const OrnamentedObj ()\n";
23 OrnamentedObj::OrnamentedObj(QGraphicsScene* s) :LinkableMapObj(s)
25 // cout << "Const OrnamentedObj (s)\n";
29 OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->scene)
34 OrnamentedObj::~OrnamentedObj()
43 void OrnamentedObj::init ()
45 heading = new HeadingObj(scene);
46 heading->move (absPos.x(), absPos.y());
49 note.setFontHint (textEditor->getFontHintDefault() );
52 systemFlags=new FlagRowObj(scene);
53 systemFlags->clone(systemFlagsDefault);
54 systemFlags->setName ("systemFlags");
56 standardFlags=new FlagRowObj(scene);
57 standardFlags->clone(standardFlagsDefault);
58 standardFlags->setName ("standardFlags");
60 frame = new FrameObj (scene);
70 void OrnamentedObj::copy (OrnamentedObj* other)
72 LinkableMapObj::copy(other);
73 heading->copy(other->heading);
74 setColor (other->heading->getColor());
76 note.copy (other->note);
77 systemFlags->copy (other->systemFlags);
78 standardFlags->copy (other->standardFlags);
80 ornamentsBBox=other->ornamentsBBox;
82 hideExport=other->hideExport;
84 vymLink=other->vymLink;
87 QString OrnamentedObj::getHeading()
89 return heading->text();
92 void OrnamentedObj::setLinkColor()
94 if (mapEditor->getMapLinkColorHint()==HeadingColor)
95 LinkableMapObj::setLinkColor (heading->getColor());
97 LinkableMapObj::setLinkColor (mapEditor->getMapDefLinkColor());
100 void OrnamentedObj::setColor (QColor col)
102 heading->setColor(col);
106 QColor OrnamentedObj::getColor ()
108 return heading->getColor();
111 FrameObj::FrameType OrnamentedObj::getFrameType()
113 return frame->getFrameType();
116 QString OrnamentedObj::getFrameTypeName()
118 return frame->getFrameTypeName();
121 void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
123 frame->setFrameType(t);
124 if (t == FrameObj::NoFrame)
125 linkpos=LinkableMapObj::Bottom;
127 linkpos=LinkableMapObj::Middle;
134 void OrnamentedObj::setFrameType(const QString &t)
136 frame->setFrameType(t);
137 if (frame->getFrameType() == FrameObj::NoFrame)
138 linkpos=LinkableMapObj::Bottom;
140 linkpos=LinkableMapObj::Middle;
147 void OrnamentedObj::setFramePadding (const int &i)
149 frame->setPadding (i);
155 int OrnamentedObj::getFramePadding ()
157 return frame->getPadding();
160 void OrnamentedObj::setFrameBorderWidth (const int &i)
162 frame->setBorderWidth(i);
168 int OrnamentedObj::getFrameBorderWidth()
170 return frame->getBorderWidth();
173 void OrnamentedObj::setFramePenColor(QColor col)
175 frame->setPenColor (col);
178 QColor OrnamentedObj::getFramePenColor()
180 return frame->getPenColor ();
183 void OrnamentedObj::setFrameBrushColor(QColor col)
185 frame->setBrushColor (col);
188 QColor OrnamentedObj::getFrameBrushColor()
190 return frame->getBrushColor ();
193 void OrnamentedObj::positionContents()
195 double d=frame->getPadding()/2;
199 double ox,oy; // Offset due to padding
204 systemFlags-> move (ox +x , oy + y );
206 // vertical align heading to bottom
207 heading->move (ox + x + systemFlags->getBBox().width(),
208 oy + y + ornamentsBBox.height() - heading->getHeight()
210 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
212 ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
213 clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
216 void OrnamentedObj::move (double x, double y)
224 void OrnamentedObj::move (QPointF p)
229 void OrnamentedObj::moveBy (double x, double y)
232 MapObj::moveBy (x,y);
234 systemFlags->moveBy (x,y);
235 standardFlags->moveBy (x,y);
236 heading->moveBy (x,y);
241 void OrnamentedObj::moveBy (QPointF p)
243 moveBy (p.x(), p.y());
246 void OrnamentedObj::move2RelPos(double x, double y)
248 setRelPos (QPointF((int)x,(int)y));
251 QPointF p=parObj->getChildPos();
252 move (p.x()+x, p.y() +y);
256 void OrnamentedObj::move2RelPos(QPointF p)
258 move2RelPos (p.x(),p.y());
261 void OrnamentedObj::setNote(QString s)
267 void OrnamentedObj::setNote(NoteObj n)
273 QString OrnamentedObj::getNote()
275 return note.getNote();
278 QString OrnamentedObj::getNoteASCII()
280 return note.getNoteASCII();
283 QString OrnamentedObj::getNoteOpenDoc()
285 return note.getNoteOpenDoc();
288 void OrnamentedObj::setURL(QString s)
292 systemFlags->activate("url");
294 systemFlags->deactivate("url");
295 calcBBoxSize(); // recalculate bbox
296 positionBBox(); // rearrange contents
300 QString OrnamentedObj::getURL()
305 void OrnamentedObj::setVymLink(QString s)
309 // We need the relative (from loading)
310 // or absolute path (from User event)
311 // and build the absolute path.
312 // Note: If we have relative, use path of
313 // current map to build absolute path
315 if (!d.path().startsWith ("/"))
317 QString p=mapEditor->getDestPath();
318 int i=p.findRev("/",-1);
319 d.setPath(p.left(i)+"/"+s);
323 systemFlags->activate("vymLink");
327 systemFlags->deactivate("vymLink");
330 calcBBoxSize(); // recalculate bbox
331 positionBBox(); // rearrange contents
335 QString OrnamentedObj::getVymLink()
341 void OrnamentedObj::clearStandardFlags()
343 standardFlags->deactivateAll();
346 move (absPos.x(), absPos.y() );
350 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
352 standardFlags->toggle(f,exclusive);
355 move (absPos.x(), absPos.y() );
359 void OrnamentedObj::activateStandardFlag(QString f)
361 standardFlags->activate(f);
364 move (absPos.x(), absPos.y() );
368 void OrnamentedObj::deactivateStandardFlag(QString f)
370 standardFlags->deactivate(f);
373 move (absPos.x(), absPos.y() );
377 bool OrnamentedObj::isSetStandardFlag (QString f)
379 return standardFlags->isActive(f);
382 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
384 return systemFlags->getFlagName(p);
387 bool OrnamentedObj::isActiveFlag (const QString & fname)
389 if (standardFlags->isActive (fname) ) return true;
393 void OrnamentedObj::getNoteFromTextEditor ()
395 note.setFilenameHint (textEditor->getFilename());
396 note.setFontHint (textEditor->getFontHint() );
397 setNote( textEditor->getText() );
400 void OrnamentedObj::updateNoteFlag()
404 noteEmpty=textEditor->isEmpty();
406 noteEmpty=note.isEmpty();
410 if (systemFlags->isActive ("note")) return;
411 systemFlags->activate("note");
415 if (!systemFlags->isActive ("note")) return;
416 systemFlags->deactivate("note");
418 mapEditor->setChanged();
421 move (absPos.x(), absPos.y() );
426 void OrnamentedObj::updateFlagsToolbar()
428 standardFlags->updateToolbar();
431 void OrnamentedObj::setHideInExport(bool b)
435 // Don't allow to MapCenter to be hidden
438 systemFlags->activate("hideInExport");
440 systemFlags->deactivate("hideInExport");
447 bool OrnamentedObj::hideInExport()
452 bool OrnamentedObj::isHidden()
457 QString OrnamentedObj::getOrnAttr()
463 attribut("absPosX",QString().setNum(absPos.x())) +
464 attribut("absPosY",QString().setNum(absPos.y()));
467 if (depth==1 || typeid (*this)==typeid (FloatImageObj))
469 attribut("relPosX",QString().setNum(relPos.x())) +
470 attribut("relPosY",QString().setNum(relPos.y()));
477 urlAttr=attribut ("url",url);
480 if (!vymLink.isEmpty())
481 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
485 hideExpAttr= attribut("hideInExport","true");
489 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;