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(QCanvas* 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)));
131 void OrnamentedObj::move (double x, double y)
139 void OrnamentedObj::move (QPoint p)
144 void OrnamentedObj::moveBy (double x, double y)
147 MapObj::moveBy (x,y);
149 systemFlags->moveBy (x,y);
150 standardFlags->moveBy (x,y);
151 heading->moveBy (x,y);
156 void OrnamentedObj::moveBy (QPoint p)
158 moveBy (p.x(), p.y());
161 void OrnamentedObj::move2RelPos(double x, double y)
164 move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
167 void OrnamentedObj::move2RelPos(QPoint p)
169 move2RelPos (p.x(),p.y());
172 void OrnamentedObj::setNote(QString s)
176 systemFlags->activate("note");
178 systemFlags->deactivate("note");
181 move (absPos.x(), absPos.y() );
185 void OrnamentedObj::setNote(NoteObj n)
189 systemFlags->activate("note");
191 systemFlags->deactivate("note");
194 move (absPos.x(), absPos.y() );
199 QString OrnamentedObj::getNote()
201 return note.getNote();
204 QString OrnamentedObj::getNoteASCII()
206 return note.getNoteASCII();
209 QString OrnamentedObj::getNoteOpenDoc()
211 return note.getNoteOpenDoc();
214 void OrnamentedObj::setURL(QString s)
218 systemFlags->activate("url");
220 systemFlags->deactivate("url");
221 calcBBoxSize(); // recalculate bbox
222 positionBBox(); // rearrange contents
226 QString OrnamentedObj::getURL()
231 void OrnamentedObj::setVymLink(QString s)
235 // We need the relative (from loading)
236 // or absolute path (from User event)
237 // and build the absolute path.
238 // Note: If we have relative, use path of
239 // current map to build absolute path
241 if (!d.path().startsWith ("/"))
243 QString p=mapEditor->getDestPath();
244 int i=p.findRev("/",-1);
245 d.setPath(p.left(i)+"/"+s);
249 systemFlags->activate("vymLink");
253 systemFlags->deactivate("vymLink");
256 calcBBoxSize(); // recalculate bbox
257 positionBBox(); // rearrange contents
261 QString OrnamentedObj::getVymLink()
267 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
269 standardFlags->toggle(f,exclusive);
272 move (absPos.x(), absPos.y() );
276 void OrnamentedObj::activateStandardFlag(QString f)
278 standardFlags->activate(f);
281 move (absPos.x(), absPos.y() );
285 bool OrnamentedObj::isSetStandardFlag (QString f)
287 return standardFlags->isActive(f);
290 QString OrnamentedObj::getSystemFlagName(const QPoint &p)
292 return systemFlags->getFlagName(p);
295 bool OrnamentedObj::isActiveFlag (const QString & fname)
297 if (standardFlags->isActive (fname) ) return true;
301 void OrnamentedObj::updateNoteFlag()
305 // text in NoteEditor has changed, notify MapEditor
306 mapEditor->setChanged();
309 setNote( textEditor->getText() );
312 note.setFontHint (textEditor->getFontHint() );
316 void OrnamentedObj::setHideInExport(bool b)
320 // Don't allow to MapCenter to be hidden
323 systemFlags->activate("hideInExport");
325 systemFlags->deactivate("hideInExport");
332 bool OrnamentedObj::hideInExport()
337 bool OrnamentedObj::isHidden()
342 QString OrnamentedObj::getOrnAttr()
347 posAttr=attribut("relPosX",QString().setNum(relPos.x(),10)) +
348 attribut("relPosY",QString().setNum(relPos.y(),10));
351 if (depth==0 || depth==1) posAttr=
352 attribut("absPosX",QString().setNum(absPos.x(),10)) +
353 attribut("absPosY",QString().setNum(absPos.y(),10));
360 urlAttr=attribut ("url",url);
363 if (!vymLink.isEmpty())
364 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
368 hideExpAttr= attribut("hideInExport","true");
372 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;