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");
62 frame = new FrameObj (scene);
72 void OrnamentedObj::copy (OrnamentedObj* other)
74 LinkableMapObj::copy(other);
75 heading->copy(other->heading);
76 setColor (other->heading->getColor());
78 note.copy (other->note);
79 systemFlags->copy (other->systemFlags);
80 standardFlags->copy (other->standardFlags);
82 ornamentsBBox=other->ornamentsBBox;
84 hideExport=other->hideExport;
86 vymLink=other->vymLink;
89 QString OrnamentedObj::getHeading()
91 return heading->text();
94 void OrnamentedObj::setLinkColor()
96 if (mapEditor->getMapLinkColorHint()==HeadingColor)
97 LinkableMapObj::setLinkColor (heading->getColor());
99 LinkableMapObj::setLinkColor (mapEditor->getMapDefLinkColor());
102 void OrnamentedObj::setColor (QColor col)
104 heading->setColor(col);
108 QColor OrnamentedObj::getColor ()
110 return heading->getColor();
113 FrameObj::FrameType OrnamentedObj::getFrameType()
115 return frame->getFrameType();
118 QString OrnamentedObj::getFrameTypeName()
120 return frame->getFrameTypeName();
123 void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
125 frame->setFrameType(t);
126 if (t == FrameObj::NoFrame)
127 linkpos=LinkableMapObj::Bottom;
129 linkpos=LinkableMapObj::Middle;
136 void OrnamentedObj::setFrameType(const QString &t)
138 frame->setFrameType(t);
139 if (frame->getFrameType() == FrameObj::NoFrame)
140 linkpos=LinkableMapObj::Bottom;
142 linkpos=LinkableMapObj::Middle;
149 void OrnamentedObj::setFramePadding (const int &i)
151 frame->setPadding (i);
157 int OrnamentedObj::getFramePadding ()
159 return frame->getPadding();
162 void OrnamentedObj::setFrameBorderWidth (const int &i)
164 frame->setBorderWidth(i);
170 int OrnamentedObj::getFrameBorderWidth()
172 return frame->getBorderWidth();
175 void OrnamentedObj::setFramePenColor(QColor col)
177 frame->setPenColor (col);
180 QColor OrnamentedObj::getFramePenColor()
182 return frame->getPenColor ();
185 void OrnamentedObj::setFrameBrushColor(QColor col)
187 frame->setBrushColor (col);
190 QColor OrnamentedObj::getFrameBrushColor()
192 return frame->getBrushColor ();
195 void OrnamentedObj::positionContents()
197 double d=frame->getPadding()/2;
201 double ox,oy; // Offset due to padding
206 systemFlags-> move (ox +x , oy + y );
208 // vertical align heading to bottom
209 heading->move (ox + x + systemFlags->getBBox().width(),
210 oy + y + ornamentsBBox.height() - heading->getHeight()
212 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
214 ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
215 clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
218 void OrnamentedObj::move (double x, double y)
226 void OrnamentedObj::move (QPointF p)
231 void OrnamentedObj::moveBy (double x, double y)
234 MapObj::moveBy (x,y);
236 systemFlags->moveBy (x,y);
237 standardFlags->moveBy (x,y);
238 heading->moveBy (x,y);
243 void OrnamentedObj::moveBy (QPointF p)
245 moveBy (p.x(), p.y());
248 void OrnamentedObj::move2RelPos(double x, double y)
250 setRelPos (QPointF(x,y));
253 QPointF p=parObj->getChildPos();
254 move (p.x()+x, p.y() +y);
258 void OrnamentedObj::move2RelPos(QPointF p)
260 move2RelPos (p.x(),p.y());
263 void OrnamentedObj::setNote(QString s)
269 void OrnamentedObj::setNote(NoteObj n)
275 QString OrnamentedObj::getNote()
277 return note.getNote();
280 QString OrnamentedObj::getNoteASCII(const QString &indent, const int &width)
282 return note.getNoteASCII(indent,width);
285 QString OrnamentedObj::getNoteASCII()
287 return note.getNoteASCII();
290 QString OrnamentedObj::getNoteOpenDoc()
292 return note.getNoteOpenDoc();
295 void OrnamentedObj::setURL(QString s)
299 systemFlags->activate("url");
301 systemFlags->deactivate("url");
302 calcBBoxSize(); // recalculate bbox
303 positionBBox(); // rearrange contents
307 QString OrnamentedObj::getURL()
312 void OrnamentedObj::setVymLink(QString s)
316 // We need the relative (from loading)
317 // or absolute path (from User event)
318 // and build the absolute path.
319 // Note: If we have relative, use path of
320 // current map to build absolute path
322 if (!d.path().startsWith ("/"))
324 QString p=mapEditor->getDestPath();
325 int i=p.findRev("/",-1);
326 d.setPath(p.left(i)+"/"+s);
330 systemFlags->activate("vymLink");
334 systemFlags->deactivate("vymLink");
337 calcBBoxSize(); // recalculate bbox
338 positionBBox(); // rearrange contents
342 QString OrnamentedObj::getVymLink()
348 void OrnamentedObj::setAttributes (const QList <Attribute> &al)
353 QList <Attribute> OrnamentedObj::getAttributes()
358 void OrnamentedObj::clearStandardFlags()
360 standardFlags->deactivateAll();
363 move (absPos.x(), absPos.y() );
367 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
369 standardFlags->toggle(f,exclusive);
372 move (absPos.x(), absPos.y() );
376 void OrnamentedObj::activateStandardFlag(QString f)
378 standardFlags->activate(f);
381 move (absPos.x(), absPos.y() );
385 void OrnamentedObj::deactivateStandardFlag(QString f)
387 standardFlags->deactivate(f);
390 move (absPos.x(), absPos.y() );
394 bool OrnamentedObj::isSetStandardFlag (QString f)
396 return standardFlags->isActive(f);
399 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
401 return systemFlags->getFlagName(p);
404 bool OrnamentedObj::isActiveFlag (const QString & fname)
406 if (standardFlags->isActive (fname) ) return true;
410 void OrnamentedObj::getNoteFromTextEditor ()
412 note.setFilenameHint (textEditor->getFilename());
413 note.setFontHint (textEditor->getFontHint() );
414 setNote( textEditor->getText() );
417 void OrnamentedObj::updateNoteFlag()
421 noteEmpty=textEditor->isEmpty();
423 noteEmpty=note.isEmpty();
427 if (systemFlags->isActive ("note")) return;
428 systemFlags->activate("note");
432 if (!systemFlags->isActive ("note")) return;
433 systemFlags->deactivate("note");
435 mapEditor->setChanged();
438 move (absPos.x(), absPos.y() );
443 void OrnamentedObj::updateFlagsToolbar()
445 standardFlags->updateToolbar();
448 void OrnamentedObj::setHideInExport(bool b)
452 // Don't allow to MapCenter to be hidden
455 systemFlags->activate("hideInExport");
457 systemFlags->deactivate("hideInExport");
464 bool OrnamentedObj::hideInExport()
469 bool OrnamentedObj::isHidden()
474 QString OrnamentedObj::getOrnXMLAttr()
480 attribut("absPosX",QString().setNum(absPos.x())) +
481 attribut("absPosY",QString().setNum(absPos.y()));
484 if (depth==1 || typeid (*this)==typeid (FloatImageObj))
486 if (relPos.x()==0 && relPos.y()==0)
489 attribut("relPosX",QString().setNum(relPos.x())) +
490 attribut("relPosY",QString().setNum(relPos.y()));
497 urlAttr=attribut ("url",url);
500 if (!vymLink.isEmpty())
501 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
505 hideExpAttr= attribut("hideInExport","true");
509 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;