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(QGraphicsScene* s) :LinkableMapObj(s)
23 // cout << "Const OrnamentedObj (s)\n";
27 OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->scene)
32 OrnamentedObj::~OrnamentedObj()
36 delete (standardFlags);
40 void OrnamentedObj::init ()
42 heading = new HeadingObj(scene);
43 heading->move (absPos.x(), absPos.y());
46 note.setFontHint (textEditor->getFontHintDefault() );
49 systemFlags=new FlagRowObj(scene);
50 systemFlags->clone(systemFlagsDefault);
51 systemFlags->setName ("systemFlags");
53 standardFlags=new FlagRowObj(scene);
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->getMapLinkColorHint()==HeadingColor)
90 LinkableMapObj::setLinkColor (heading->getColor());
92 LinkableMapObj::setLinkColor (mapEditor->getMapDefLinkColor());
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 ( QPointF ((int)(ox+x),(int)(oy+y)));
127 clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
130 void OrnamentedObj::move (double x, double y)
138 void OrnamentedObj::move (QPointF 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 (QPointF p)
157 moveBy (p.x(), p.y());
160 void OrnamentedObj::move2RelPos(double x, double y)
162 setRelPos (QPointF((int)x,(int)y));
165 QPointF p=parObj->getChildPos();
166 move (p.x()+x, p.y() +y);
170 void OrnamentedObj::move2RelPos(QPointF p)
172 move2RelPos (p.x(),p.y());
175 void OrnamentedObj::setNote(QString s)
181 void OrnamentedObj::setNote(NoteObj n)
187 QString OrnamentedObj::getNote()
189 return note.getNote();
192 QString OrnamentedObj::getNoteASCII()
194 return note.getNoteASCII();
197 QString OrnamentedObj::getNoteOpenDoc()
199 return note.getNoteOpenDoc();
202 void OrnamentedObj::setURL(QString s)
206 systemFlags->activate("url");
208 systemFlags->deactivate("url");
209 calcBBoxSize(); // recalculate bbox
210 positionBBox(); // rearrange contents
214 QString OrnamentedObj::getURL()
219 void OrnamentedObj::setVymLink(QString s)
223 // We need the relative (from loading)
224 // or absolute path (from User event)
225 // and build the absolute path.
226 // Note: If we have relative, use path of
227 // current map to build absolute path
229 if (!d.path().startsWith ("/"))
231 QString p=mapEditor->getDestPath();
232 int i=p.findRev("/",-1);
233 d.setPath(p.left(i)+"/"+s);
237 systemFlags->activate("vymLink");
241 systemFlags->deactivate("vymLink");
244 calcBBoxSize(); // recalculate bbox
245 positionBBox(); // rearrange contents
249 QString OrnamentedObj::getVymLink()
255 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
257 standardFlags->toggle(f,exclusive);
260 move (absPos.x(), absPos.y() );
264 void OrnamentedObj::activateStandardFlag(QString f)
266 standardFlags->activate(f);
269 move (absPos.x(), absPos.y() );
273 void OrnamentedObj::deactivateStandardFlag(QString f)
275 standardFlags->deactivate(f);
278 move (absPos.x(), absPos.y() );
282 bool OrnamentedObj::isSetStandardFlag (QString f)
284 return standardFlags->isActive(f);
287 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
289 return systemFlags->getFlagName(p);
292 bool OrnamentedObj::isActiveFlag (const QString & fname)
294 if (standardFlags->isActive (fname) ) return true;
298 void OrnamentedObj::getNoteFromTextEditor ()
300 note.setFilenameHint (textEditor->getFilename());
301 note.setFontHint (textEditor->getFontHint() );
302 setNote( textEditor->getText() );
305 void OrnamentedObj::updateNoteFlag()
309 noteEmpty=textEditor->isEmpty();
311 noteEmpty=note.isEmpty();
315 if (systemFlags->isActive ("note")) return;
316 systemFlags->activate("note");
320 if (!systemFlags->isActive ("note")) return;
321 systemFlags->deactivate("note");
323 mapEditor->setChanged();
326 move (absPos.x(), absPos.y() );
331 void OrnamentedObj::updateFlagsToolbar()
333 standardFlags->updateToolbar();
336 void OrnamentedObj::setHideInExport(bool b)
340 // Don't allow to MapCenter to be hidden
343 systemFlags->activate("hideInExport");
345 systemFlags->deactivate("hideInExport");
352 bool OrnamentedObj::hideInExport()
357 bool OrnamentedObj::isHidden()
362 QString OrnamentedObj::getOrnAttr()
368 attribut("absPosX",QString().setNum(absPos.x())) +
369 attribut("absPosY",QString().setNum(absPos.y()));
372 if (depth==1 || typeid (*this)==typeid (FloatImageObj))
374 attribut("relPosX",QString().setNum(relPos.x())) +
375 attribut("relPosY",QString().setNum(relPos.y()));
382 urlAttr=attribut ("url",url);
385 if (!vymLink.isEmpty())
386 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
390 hideExpAttr= attribut("hideInExport","true");
394 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;