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(Q3Canvas* c) :LinkableMapObj(c)
23 // cout << "Const OrnamentedObj\n";
27 OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->canvas)
32 OrnamentedObj::~OrnamentedObj()
36 delete (standardFlags);
41 void OrnamentedObj::init ()
43 heading = new HeadingObj(canvas);
44 heading->move (absPos.x(), absPos.y());
47 note.setFontHint (textEditor->getFontHintDefault() );
49 systemFlags=new FlagRowObj(canvas);
50 systemFlags->clone(systemFlagsDefault);
51 systemFlags->setName ("systemFlags");
53 standardFlags=new FlagRowObj(canvas);
54 standardFlags->clone(standardFlagsDefault);
55 standardFlags->setName ("standardFlags");
65 void OrnamentedObj::copy (OrnamentedObj* other)
67 LinkableMapObj::copy(other);
68 heading->copy(other->heading);
69 setColor (other->heading->getColor());
71 note.copy (other->note);
72 systemFlags->copy (other->systemFlags);
73 standardFlags->copy (other->standardFlags);
75 ornamentsBBox=other->ornamentsBBox;
77 hideExport=other->hideExport;
79 vymLink=other->vymLink;
82 QString OrnamentedObj::getHeading()
84 return heading->text();
87 void OrnamentedObj::setLinkColor()
89 if (mapEditor->getLinkColorHint()==HeadingColor)
90 LinkableMapObj::setLinkColor (heading->getColor());
92 LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
95 void OrnamentedObj::setColor (QColor col)
97 heading->setColor(col);
101 QColor OrnamentedObj::getColor ()
103 return heading->getColor();
107 void OrnamentedObj::positionContents()
109 double d=frame->getBorder()/2;
113 double ox,oy; // Offset due to padding
118 systemFlags-> move (ox +x , oy + y );
120 // vertical align heading to bottom
121 heading->move (ox + x + systemFlags->getBBox().width(),
122 oy + y + ornamentsBBox.height() - heading->getHeight()
124 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
126 ornamentsBBox.moveTopLeft ( QPoint ((int)(ox+x),(int)(oy+y)));
127 clickBox.moveTopLeft (QPoint ((int)(ox + x), (int)(oy + y)));
130 void OrnamentedObj::move (double x, double y)
138 void OrnamentedObj::move (QPoint p)
143 void OrnamentedObj::moveBy (double x, double y)
146 MapObj::moveBy (x,y);
148 systemFlags->moveBy (x,y);
149 standardFlags->moveBy (x,y);
150 heading->moveBy (x,y);
155 void OrnamentedObj::moveBy (QPoint p)
157 moveBy (p.x(), p.y());
160 void OrnamentedObj::move2RelPos(double x, double y)
162 setRelPos (QPoint(x,y));
165 void OrnamentedObj::move2RelPos(QPoint p)
167 move2RelPos (p.x(),p.y());
170 void OrnamentedObj::setNote(QString s)
174 systemFlags->activate("note");
176 systemFlags->deactivate("note");
179 move (absPos.x(), absPos.y() );
183 void OrnamentedObj::setNote(NoteObj n)
187 systemFlags->activate("note");
189 systemFlags->deactivate("note");
192 move (absPos.x(), absPos.y() );
197 QString OrnamentedObj::getNote()
199 return note.getNote();
202 QString OrnamentedObj::getNoteASCII()
204 return note.getNoteASCII();
207 QString OrnamentedObj::getNoteOpenDoc()
209 return note.getNoteOpenDoc();
212 void OrnamentedObj::setURL(QString s)
216 systemFlags->activate("url");
218 systemFlags->deactivate("url");
219 calcBBoxSize(); // recalculate bbox
220 positionBBox(); // rearrange contents
224 QString OrnamentedObj::getURL()
229 void OrnamentedObj::setVymLink(QString s)
233 // We need the relative (from loading)
234 // or absolute path (from User event)
235 // and build the absolute path.
236 // Note: If we have relative, use path of
237 // current map to build absolute path
239 if (!d.path().startsWith ("/"))
241 QString p=mapEditor->getDestPath();
242 int i=p.findRev("/",-1);
243 d.setPath(p.left(i)+"/"+s);
247 systemFlags->activate("vymLink");
251 systemFlags->deactivate("vymLink");
254 calcBBoxSize(); // recalculate bbox
255 positionBBox(); // rearrange contents
259 QString OrnamentedObj::getVymLink()
265 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
267 standardFlags->toggle(f,exclusive);
270 move (absPos.x(), absPos.y() );
274 void OrnamentedObj::activateStandardFlag(QString f)
276 standardFlags->activate(f);
279 move (absPos.x(), absPos.y() );
283 void OrnamentedObj::deactivateStandardFlag(QString f)
285 standardFlags->deactivate(f);
288 move (absPos.x(), absPos.y() );
292 bool OrnamentedObj::isSetStandardFlag (QString f)
294 return standardFlags->isActive(f);
297 QString OrnamentedObj::getSystemFlagName(const QPoint &p)
299 return systemFlags->getFlagName(p);
302 bool OrnamentedObj::isActiveFlag (const QString & fname)
304 if (standardFlags->isActive (fname) ) return true;
308 void OrnamentedObj::updateNoteFlag()
312 // text in NoteEditor has changed, notify MapEditor
313 mapEditor->setChanged();
316 setNote( textEditor->getText() );
319 note.setFontHint (textEditor->getFontHint() );
323 void OrnamentedObj::updateFlagsToolbar()
325 standardFlags->updateToolbar();
328 void OrnamentedObj::setHideInExport(bool b)
332 // Don't allow to MapCenter to be hidden
335 systemFlags->activate("hideInExport");
337 systemFlags->deactivate("hideInExport");
344 bool OrnamentedObj::hideInExport()
349 bool OrnamentedObj::isHidden()
354 QString OrnamentedObj::getOrnAttr()
359 posAttr=attribut("relPosX",QString().setNum(relPos.x(),10)) +
360 attribut("relPosY",QString().setNum(relPos.y(),10));
363 if (depth==0 || depth==1) posAttr=
364 attribut("absPosX",QString().setNum(absPos.x(),10)) +
365 attribut("absPosY",QString().setNum(absPos.y(),10));
372 urlAttr=attribut ("url",url);
375 if (!vymLink.isEmpty())
376 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
380 hideExpAttr= attribut("hideInExport","true");
384 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;