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)
163 move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
166 void OrnamentedObj::move2RelPos(QPoint p)
168 move2RelPos (p.x(),p.y());
171 void OrnamentedObj::setNote(QString s)
175 systemFlags->activate("note");
177 systemFlags->deactivate("note");
180 move (absPos.x(), absPos.y() );
184 void OrnamentedObj::setNote(NoteObj n)
188 systemFlags->activate("note");
190 systemFlags->deactivate("note");
193 move (absPos.x(), absPos.y() );
198 QString OrnamentedObj::getNote()
200 return note.getNote();
203 QString OrnamentedObj::getNoteASCII()
205 return note.getNoteASCII();
208 QString OrnamentedObj::getNoteOpenDoc()
210 return note.getNoteOpenDoc();
213 void OrnamentedObj::setURL(QString s)
217 systemFlags->activate("url");
219 systemFlags->deactivate("url");
220 calcBBoxSize(); // recalculate bbox
221 positionBBox(); // rearrange contents
225 QString OrnamentedObj::getURL()
230 void OrnamentedObj::setVymLink(QString s)
234 // We need the relative (from loading)
235 // or absolute path (from User event)
236 // and build the absolute path.
237 // Note: If we have relative, use path of
238 // current map to build absolute path
240 if (!d.path().startsWith ("/"))
242 QString p=mapEditor->getDestPath();
243 int i=p.findRev("/",-1);
244 d.setPath(p.left(i)+"/"+s);
248 systemFlags->activate("vymLink");
252 systemFlags->deactivate("vymLink");
255 calcBBoxSize(); // recalculate bbox
256 positionBBox(); // rearrange contents
260 QString OrnamentedObj::getVymLink()
266 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
268 standardFlags->toggle(f,exclusive);
271 move (absPos.x(), absPos.y() );
275 void OrnamentedObj::activateStandardFlag(QString f)
277 standardFlags->activate(f);
280 move (absPos.x(), absPos.y() );
284 bool OrnamentedObj::isSetStandardFlag (QString f)
286 return standardFlags->isActive(f);
289 QString OrnamentedObj::getSystemFlagName(const QPoint &p)
291 return systemFlags->getFlagName(p);
294 bool OrnamentedObj::isActiveFlag (const QString & fname)
296 if (standardFlags->isActive (fname) ) return true;
300 void OrnamentedObj::updateNoteFlag()
304 // text in NoteEditor has changed, notify MapEditor
305 mapEditor->setChanged();
308 setNote( textEditor->getText() );
311 note.setFontHint (textEditor->getFontHint() );
315 void OrnamentedObj::setHideInExport(bool b)
319 // Don't allow to MapCenter to be hidden
322 systemFlags->activate("hideInExport");
324 systemFlags->deactivate("hideInExport");
331 bool OrnamentedObj::hideInExport()
336 bool OrnamentedObj::isHidden()
341 QString OrnamentedObj::getOrnAttr()
346 posAttr=attribut("relPosX",QString().setNum(relPos.x(),10)) +
347 attribut("relPosY",QString().setNum(relPos.y(),10));
350 if (depth==0 || depth==1) posAttr=
351 attribut("absPosX",QString().setNum(absPos.x(),10)) +
352 attribut("absPosY",QString().setNum(absPos.y(),10));
359 urlAttr=attribut ("url",url);
362 if (!vymLink.isEmpty())
363 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
367 hideExpAttr= attribut("hideInExport","true");
371 return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;