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(const QString &indent, const int &width)
280 return note.getNoteASCII();
283 QString OrnamentedObj::getNoteASCII()
285 return note.getNoteASCII();
288 QString OrnamentedObj::getNoteOpenDoc()
290 return note.getNoteOpenDoc();
293 void OrnamentedObj::setURL(QString s)
297 systemFlags->activate("url");
299 systemFlags->deactivate("url");
300 calcBBoxSize(); // recalculate bbox
301 positionBBox(); // rearrange contents
305 QString OrnamentedObj::getURL()
310 void OrnamentedObj::setVymLink(QString s)
314 // We need the relative (from loading)
315 // or absolute path (from User event)
316 // and build the absolute path.
317 // Note: If we have relative, use path of
318 // current map to build absolute path
320 if (!d.path().startsWith ("/"))
322 QString p=mapEditor->getDestPath();
323 int i=p.findRev("/",-1);
324 d.setPath(p.left(i)+"/"+s);
328 systemFlags->activate("vymLink");
332 systemFlags->deactivate("vymLink");
335 calcBBoxSize(); // recalculate bbox
336 positionBBox(); // rearrange contents
340 QString OrnamentedObj::getVymLink()
346 void OrnamentedObj::clearStandardFlags()
348 standardFlags->deactivateAll();
351 move (absPos.x(), absPos.y() );
355 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
357 standardFlags->toggle(f,exclusive);
360 move (absPos.x(), absPos.y() );
364 void OrnamentedObj::activateStandardFlag(QString f)
366 standardFlags->activate(f);
369 move (absPos.x(), absPos.y() );
373 void OrnamentedObj::deactivateStandardFlag(QString f)
375 standardFlags->deactivate(f);
378 move (absPos.x(), absPos.y() );
382 bool OrnamentedObj::isSetStandardFlag (QString f)
384 return standardFlags->isActive(f);
387 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
389 return systemFlags->getFlagName(p);
392 bool OrnamentedObj::isActiveFlag (const QString & fname)
394 if (standardFlags->isActive (fname) ) return true;
398 void OrnamentedObj::getNoteFromTextEditor ()
400 note.setFilenameHint (textEditor->getFilename());
401 note.setFontHint (textEditor->getFontHint() );
402 setNote( textEditor->getText() );
405 void OrnamentedObj::updateNoteFlag()
409 noteEmpty=textEditor->isEmpty();
411 noteEmpty=note.isEmpty();
415 if (systemFlags->isActive ("note")) return;
416 systemFlags->activate("note");
420 if (!systemFlags->isActive ("note")) return;
421 systemFlags->deactivate("note");
423 mapEditor->setChanged();
426 move (absPos.x(), absPos.y() );
431 void OrnamentedObj::updateFlagsToolbar()
433 standardFlags->updateToolbar();
436 void OrnamentedObj::setHideInExport(bool b)
440 // Don't allow to MapCenter to be hidden
443 systemFlags->activate("hideInExport");
445 systemFlags->deactivate("hideInExport");
452 bool OrnamentedObj::hideInExport()
457 bool OrnamentedObj::isHidden()
462 QString OrnamentedObj::getOrnAttr()
468 attribut("absPosX",QString().setNum(absPos.x())) +
469 attribut("absPosY",QString().setNum(absPos.y()));
472 if (depth==1 || typeid (*this)==typeid (FloatImageObj))
474 attribut("relPosX",QString().setNum(relPos.x())) +
475 attribut("relPosY",QString().setNum(relPos.y()));
482 urlAttr=attribut ("url",url);
485 if (!vymLink.isEmpty())
486 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
490 hideExpAttr= attribut("hideInExport","true");
494 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;