insilmaril@0
|
1 |
#include "ornamentedobj.h"
|
insilmaril@0
|
2 |
#include "texteditor.h"
|
insilmaril@0
|
3 |
#include "mapeditor.h"
|
insilmaril@0
|
4 |
#include "linkablemapobj.h"
|
insilmaril@0
|
5 |
|
insilmaril@0
|
6 |
extern TextEditor *textEditor;
|
insilmaril@0
|
7 |
extern FlagRowObj *systemFlagsDefault;
|
insilmaril@0
|
8 |
extern FlagRowObj *standardFlagsDefault;
|
insilmaril@0
|
9 |
|
insilmaril@0
|
10 |
|
insilmaril@0
|
11 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
12 |
// OrnamentedObj
|
insilmaril@0
|
13 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
14 |
|
insilmaril@0
|
15 |
OrnamentedObj::OrnamentedObj():LinkableMapObj()
|
insilmaril@0
|
16 |
{
|
insilmaril@0
|
17 |
// cout << "Const OrnamentedObj ()\n";
|
insilmaril@0
|
18 |
init ();
|
insilmaril@0
|
19 |
}
|
insilmaril@0
|
20 |
|
insilmaril@366
|
21 |
OrnamentedObj::OrnamentedObj(Q3Canvas* c) :LinkableMapObj(c)
|
insilmaril@0
|
22 |
{
|
insilmaril@0
|
23 |
// cout << "Const OrnamentedObj\n";
|
insilmaril@0
|
24 |
init ();
|
insilmaril@0
|
25 |
}
|
insilmaril@0
|
26 |
|
insilmaril@0
|
27 |
OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->canvas)
|
insilmaril@0
|
28 |
{
|
insilmaril@0
|
29 |
copy (lmo);
|
insilmaril@0
|
30 |
}
|
insilmaril@0
|
31 |
|
insilmaril@0
|
32 |
OrnamentedObj::~OrnamentedObj()
|
insilmaril@0
|
33 |
{
|
insilmaril@0
|
34 |
delete (heading);
|
insilmaril@0
|
35 |
delete (systemFlags);
|
insilmaril@0
|
36 |
delete (standardFlags);
|
insilmaril@0
|
37 |
|
insilmaril@0
|
38 |
}
|
insilmaril@0
|
39 |
|
insilmaril@0
|
40 |
|
insilmaril@0
|
41 |
void OrnamentedObj::init ()
|
insilmaril@0
|
42 |
{
|
insilmaril@0
|
43 |
heading = new HeadingObj(canvas);
|
insilmaril@0
|
44 |
heading->move (absPos.x(), absPos.y());
|
insilmaril@0
|
45 |
|
insilmaril@0
|
46 |
note.setNote("");
|
insilmaril@0
|
47 |
note.setFontHint (textEditor->getFontHintDefault() );
|
insilmaril@0
|
48 |
|
insilmaril@0
|
49 |
systemFlags=new FlagRowObj(canvas);
|
insilmaril@0
|
50 |
systemFlags->clone(systemFlagsDefault);
|
insilmaril@0
|
51 |
systemFlags->setName ("systemFlags");
|
insilmaril@0
|
52 |
|
insilmaril@0
|
53 |
standardFlags=new FlagRowObj(canvas);
|
insilmaril@0
|
54 |
standardFlags->clone(standardFlagsDefault);
|
insilmaril@0
|
55 |
standardFlags->setName ("standardFlags");
|
insilmaril@243
|
56 |
|
insilmaril@243
|
57 |
hideExport=false;
|
insilmaril@260
|
58 |
hidden=false;
|
insilmaril@243
|
59 |
|
insilmaril@243
|
60 |
url="";
|
insilmaril@243
|
61 |
vymLink="";
|
insilmaril@243
|
62 |
|
insilmaril@0
|
63 |
}
|
insilmaril@0
|
64 |
|
insilmaril@0
|
65 |
void OrnamentedObj::copy (OrnamentedObj* other)
|
insilmaril@0
|
66 |
{
|
insilmaril@0
|
67 |
LinkableMapObj::copy(other);
|
insilmaril@0
|
68 |
heading->copy(other->heading);
|
insilmaril@243
|
69 |
setColor (other->heading->getColor());
|
insilmaril@0
|
70 |
|
insilmaril@0
|
71 |
note.copy (other->note);
|
insilmaril@0
|
72 |
systemFlags->copy (other->systemFlags);
|
insilmaril@0
|
73 |
standardFlags->copy (other->standardFlags);
|
insilmaril@0
|
74 |
|
insilmaril@227
|
75 |
ornamentsBBox=other->ornamentsBBox;
|
insilmaril@227
|
76 |
|
insilmaril@243
|
77 |
hideExport=other->hideExport;
|
insilmaril@243
|
78 |
url=other->url;
|
insilmaril@243
|
79 |
vymLink=other->vymLink;
|
insilmaril@0
|
80 |
}
|
insilmaril@0
|
81 |
|
insilmaril@0
|
82 |
QString OrnamentedObj::getHeading()
|
insilmaril@0
|
83 |
{
|
insilmaril@0
|
84 |
return heading->text();
|
insilmaril@0
|
85 |
}
|
insilmaril@0
|
86 |
|
insilmaril@0
|
87 |
void OrnamentedObj::setLinkColor()
|
insilmaril@0
|
88 |
{
|
insilmaril@0
|
89 |
if (mapEditor->getLinkColorHint()==HeadingColor)
|
insilmaril@0
|
90 |
LinkableMapObj::setLinkColor (heading->getColor());
|
insilmaril@0
|
91 |
else
|
insilmaril@0
|
92 |
LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
|
insilmaril@0
|
93 |
}
|
insilmaril@0
|
94 |
|
insilmaril@243
|
95 |
void OrnamentedObj::setColor (QColor col)
|
insilmaril@243
|
96 |
{
|
insilmaril@243
|
97 |
heading->setColor(col);
|
insilmaril@243
|
98 |
setLinkColor();
|
insilmaril@243
|
99 |
}
|
insilmaril@243
|
100 |
|
insilmaril@0
|
101 |
QColor OrnamentedObj::getColor ()
|
insilmaril@0
|
102 |
{
|
insilmaril@0
|
103 |
return heading->getColor();
|
insilmaril@0
|
104 |
}
|
insilmaril@0
|
105 |
|
insilmaril@0
|
106 |
|
insilmaril@177
|
107 |
void OrnamentedObj::positionContents()
|
insilmaril@0
|
108 |
{
|
insilmaril@177
|
109 |
double d=frame->getBorder()/2;
|
insilmaril@177
|
110 |
double x=absPos.x();
|
insilmaril@177
|
111 |
double y=absPos.y();
|
insilmaril@227
|
112 |
|
insilmaril@227
|
113 |
double ox,oy; // Offset due to padding
|
insilmaril@227
|
114 |
|
insilmaril@227
|
115 |
ox=leftPad + d;
|
insilmaril@227
|
116 |
oy=topPad + d;
|
insilmaril@227
|
117 |
|
insilmaril@227
|
118 |
systemFlags-> move (ox +x , oy + y );
|
insilmaril@0
|
119 |
|
insilmaril@0
|
120 |
// vertical align heading to bottom
|
insilmaril@227
|
121 |
heading->move (ox + x + systemFlags->getBBox().width(),
|
insilmaril@227
|
122 |
oy + y + ornamentsBBox.height() - heading->getHeight()
|
insilmaril@0
|
123 |
);
|
insilmaril@227
|
124 |
standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
|
insilmaril@227
|
125 |
|
insilmaril@236
|
126 |
ornamentsBBox.moveTopLeft ( QPoint ((int)(ox+x),(int)(oy+y)));
|
insilmaril@236
|
127 |
clickBox.moveTopLeft (QPoint ((int)(ox + x), (int)(oy + y)));
|
insilmaril@177
|
128 |
}
|
insilmaril@0
|
129 |
|
insilmaril@177
|
130 |
void OrnamentedObj::move (double x, double y)
|
insilmaril@177
|
131 |
{
|
insilmaril@177
|
132 |
MapObj::move (x,y);
|
insilmaril@177
|
133 |
positionContents();
|
insilmaril@0
|
134 |
updateLink();
|
insilmaril@0
|
135 |
requestReposition();
|
insilmaril@0
|
136 |
}
|
insilmaril@0
|
137 |
|
insilmaril@0
|
138 |
void OrnamentedObj::move (QPoint p)
|
insilmaril@0
|
139 |
{
|
insilmaril@0
|
140 |
move (p.x(), p.y());
|
insilmaril@0
|
141 |
}
|
insilmaril@0
|
142 |
|
insilmaril@0
|
143 |
void OrnamentedObj::moveBy (double x, double y)
|
insilmaril@0
|
144 |
{
|
insilmaril@0
|
145 |
|
insilmaril@0
|
146 |
MapObj::moveBy (x,y);
|
insilmaril@0
|
147 |
frame->moveBy (x,y);
|
insilmaril@0
|
148 |
systemFlags->moveBy (x,y);
|
insilmaril@0
|
149 |
standardFlags->moveBy (x,y);
|
insilmaril@0
|
150 |
heading->moveBy (x,y);
|
insilmaril@0
|
151 |
updateLink();
|
insilmaril@0
|
152 |
requestReposition();
|
insilmaril@0
|
153 |
}
|
insilmaril@0
|
154 |
|
insilmaril@0
|
155 |
void OrnamentedObj::moveBy (QPoint p)
|
insilmaril@0
|
156 |
{
|
insilmaril@0
|
157 |
moveBy (p.x(), p.y());
|
insilmaril@0
|
158 |
}
|
insilmaril@0
|
159 |
|
insilmaril@0
|
160 |
void OrnamentedObj::move2RelPos(double x, double y)
|
insilmaril@0
|
161 |
{
|
insilmaril@377
|
162 |
setRelPos (QPoint((int)x,(int)y));
|
insilmaril@388
|
163 |
if (parObj)
|
insilmaril@388
|
164 |
{
|
insilmaril@388
|
165 |
QPoint p=parObj->getChildPos();
|
insilmaril@388
|
166 |
move (p.x()+x, p.y() +y);
|
insilmaril@388
|
167 |
}
|
insilmaril@0
|
168 |
}
|
insilmaril@0
|
169 |
|
insilmaril@0
|
170 |
void OrnamentedObj::move2RelPos(QPoint p)
|
insilmaril@0
|
171 |
{
|
insilmaril@218
|
172 |
move2RelPos (p.x(),p.y());
|
insilmaril@0
|
173 |
}
|
insilmaril@0
|
174 |
|
insilmaril@0
|
175 |
void OrnamentedObj::setNote(QString s)
|
insilmaril@0
|
176 |
{
|
insilmaril@0
|
177 |
note.setNote(s);
|
insilmaril@0
|
178 |
if (!note.isEmpty())
|
insilmaril@0
|
179 |
systemFlags->activate("note");
|
insilmaril@0
|
180 |
else
|
insilmaril@0
|
181 |
systemFlags->deactivate("note");
|
insilmaril@0
|
182 |
calcBBoxSize();
|
insilmaril@0
|
183 |
positionBBox();
|
insilmaril@0
|
184 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
185 |
forceReposition();
|
insilmaril@0
|
186 |
}
|
insilmaril@0
|
187 |
|
insilmaril@0
|
188 |
void OrnamentedObj::setNote(NoteObj n)
|
insilmaril@0
|
189 |
{
|
insilmaril@0
|
190 |
note=n;
|
insilmaril@0
|
191 |
if (!note.isEmpty())
|
insilmaril@0
|
192 |
systemFlags->activate("note");
|
insilmaril@0
|
193 |
else
|
insilmaril@0
|
194 |
systemFlags->deactivate("note");
|
insilmaril@0
|
195 |
calcBBoxSize();
|
insilmaril@0
|
196 |
positionBBox();
|
insilmaril@0
|
197 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
198 |
forceReposition();
|
insilmaril@0
|
199 |
|
insilmaril@0
|
200 |
}
|
insilmaril@0
|
201 |
|
insilmaril@0
|
202 |
QString OrnamentedObj::getNote()
|
insilmaril@0
|
203 |
{
|
insilmaril@0
|
204 |
return note.getNote();
|
insilmaril@0
|
205 |
}
|
insilmaril@0
|
206 |
|
insilmaril@187
|
207 |
QString OrnamentedObj::getNoteASCII()
|
insilmaril@187
|
208 |
{
|
insilmaril@187
|
209 |
return note.getNoteASCII();
|
insilmaril@187
|
210 |
}
|
insilmaril@187
|
211 |
|
insilmaril@187
|
212 |
QString OrnamentedObj::getNoteOpenDoc()
|
insilmaril@187
|
213 |
{
|
insilmaril@187
|
214 |
return note.getNoteOpenDoc();
|
insilmaril@187
|
215 |
}
|
insilmaril@187
|
216 |
|
insilmaril@243
|
217 |
void OrnamentedObj::setURL(QString s)
|
insilmaril@243
|
218 |
{
|
insilmaril@243
|
219 |
url=s;
|
insilmaril@243
|
220 |
if (!url.isEmpty())
|
insilmaril@243
|
221 |
systemFlags->activate("url");
|
insilmaril@243
|
222 |
else
|
insilmaril@243
|
223 |
systemFlags->deactivate("url");
|
insilmaril@243
|
224 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@243
|
225 |
positionBBox(); // rearrange contents
|
insilmaril@243
|
226 |
forceReposition();
|
insilmaril@243
|
227 |
}
|
insilmaril@243
|
228 |
|
insilmaril@243
|
229 |
QString OrnamentedObj::getURL()
|
insilmaril@243
|
230 |
{
|
insilmaril@243
|
231 |
return url;
|
insilmaril@243
|
232 |
}
|
insilmaril@243
|
233 |
|
insilmaril@243
|
234 |
void OrnamentedObj::setVymLink(QString s)
|
insilmaril@243
|
235 |
{
|
insilmaril@243
|
236 |
if (!s.isEmpty())
|
insilmaril@243
|
237 |
{
|
insilmaril@243
|
238 |
// We need the relative (from loading)
|
insilmaril@243
|
239 |
// or absolute path (from User event)
|
insilmaril@243
|
240 |
// and build the absolute path.
|
insilmaril@243
|
241 |
// Note: If we have relative, use path of
|
insilmaril@243
|
242 |
// current map to build absolute path
|
insilmaril@243
|
243 |
QDir d(s);
|
insilmaril@243
|
244 |
if (!d.path().startsWith ("/"))
|
insilmaril@243
|
245 |
{
|
insilmaril@243
|
246 |
QString p=mapEditor->getDestPath();
|
insilmaril@243
|
247 |
int i=p.findRev("/",-1);
|
insilmaril@243
|
248 |
d.setPath(p.left(i)+"/"+s);
|
insilmaril@243
|
249 |
d.convertToAbs();
|
insilmaril@243
|
250 |
}
|
insilmaril@243
|
251 |
vymLink=d.path();
|
insilmaril@243
|
252 |
systemFlags->activate("vymLink");
|
insilmaril@243
|
253 |
}
|
insilmaril@243
|
254 |
else
|
insilmaril@243
|
255 |
{
|
insilmaril@243
|
256 |
systemFlags->deactivate("vymLink");
|
insilmaril@243
|
257 |
vymLink="";
|
insilmaril@243
|
258 |
}
|
insilmaril@243
|
259 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@243
|
260 |
positionBBox(); // rearrange contents
|
insilmaril@243
|
261 |
forceReposition();
|
insilmaril@243
|
262 |
}
|
insilmaril@243
|
263 |
|
insilmaril@243
|
264 |
QString OrnamentedObj::getVymLink()
|
insilmaril@243
|
265 |
{
|
insilmaril@243
|
266 |
return vymLink;
|
insilmaril@243
|
267 |
}
|
insilmaril@243
|
268 |
|
insilmaril@243
|
269 |
|
insilmaril@103
|
270 |
void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
|
insilmaril@0
|
271 |
{
|
insilmaril@103
|
272 |
standardFlags->toggle(f,exclusive);
|
insilmaril@0
|
273 |
calcBBoxSize();
|
insilmaril@0
|
274 |
positionBBox();
|
insilmaril@0
|
275 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
276 |
forceReposition();
|
insilmaril@0
|
277 |
}
|
insilmaril@0
|
278 |
|
insilmaril@0
|
279 |
void OrnamentedObj::activateStandardFlag(QString f)
|
insilmaril@0
|
280 |
{
|
insilmaril@0
|
281 |
standardFlags->activate(f);
|
insilmaril@0
|
282 |
calcBBoxSize();
|
insilmaril@0
|
283 |
positionBBox();
|
insilmaril@0
|
284 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
285 |
forceReposition();
|
insilmaril@0
|
286 |
}
|
insilmaril@0
|
287 |
|
insilmaril@366
|
288 |
void OrnamentedObj::deactivateStandardFlag(QString f)
|
insilmaril@366
|
289 |
{
|
insilmaril@366
|
290 |
standardFlags->deactivate(f);
|
insilmaril@366
|
291 |
calcBBoxSize();
|
insilmaril@366
|
292 |
positionBBox();
|
insilmaril@366
|
293 |
move (absPos.x(), absPos.y() );
|
insilmaril@366
|
294 |
forceReposition();
|
insilmaril@366
|
295 |
}
|
insilmaril@366
|
296 |
|
insilmaril@296
|
297 |
bool OrnamentedObj::isSetStandardFlag (QString f)
|
insilmaril@296
|
298 |
{
|
insilmaril@296
|
299 |
return standardFlags->isActive(f);
|
insilmaril@296
|
300 |
}
|
insilmaril@296
|
301 |
|
insilmaril@0
|
302 |
QString OrnamentedObj::getSystemFlagName(const QPoint &p)
|
insilmaril@0
|
303 |
{
|
insilmaril@0
|
304 |
return systemFlags->getFlagName(p);
|
insilmaril@0
|
305 |
}
|
insilmaril@0
|
306 |
|
insilmaril@236
|
307 |
bool OrnamentedObj::isActiveFlag (const QString & fname)
|
insilmaril@236
|
308 |
{
|
insilmaril@236
|
309 |
if (standardFlags->isActive (fname) ) return true;
|
insilmaril@236
|
310 |
return false;
|
insilmaril@236
|
311 |
}
|
insilmaril@236
|
312 |
|
insilmaril@0
|
313 |
void OrnamentedObj::updateNoteFlag()
|
insilmaril@0
|
314 |
{
|
insilmaril@160
|
315 |
if (selected)
|
insilmaril@160
|
316 |
{
|
insilmaril@160
|
317 |
// text in NoteEditor has changed, notify MapEditor
|
insilmaril@160
|
318 |
mapEditor->setChanged();
|
insilmaril@0
|
319 |
|
insilmaril@160
|
320 |
// save text
|
insilmaril@160
|
321 |
setNote( textEditor->getText() );
|
insilmaril@0
|
322 |
|
insilmaril@160
|
323 |
// save font
|
insilmaril@160
|
324 |
note.setFontHint (textEditor->getFontHint() );
|
insilmaril@160
|
325 |
}
|
insilmaril@0
|
326 |
}
|
insilmaril@0
|
327 |
|
insilmaril@366
|
328 |
void OrnamentedObj::updateFlagsToolbar()
|
insilmaril@366
|
329 |
{
|
insilmaril@366
|
330 |
standardFlags->updateToolbar();
|
insilmaril@366
|
331 |
}
|
insilmaril@366
|
332 |
|
insilmaril@243
|
333 |
void OrnamentedObj::setHideInExport(bool b)
|
insilmaril@243
|
334 |
{
|
insilmaril@260
|
335 |
if (parObj)
|
insilmaril@260
|
336 |
{
|
insilmaril@260
|
337 |
// Don't allow to MapCenter to be hidden
|
insilmaril@260
|
338 |
hideExport=b;
|
insilmaril@260
|
339 |
if (b)
|
insilmaril@260
|
340 |
systemFlags->activate("hideInExport");
|
insilmaril@260
|
341 |
else
|
insilmaril@260
|
342 |
systemFlags->deactivate("hideInExport");
|
insilmaril@260
|
343 |
calcBBoxSize();
|
insilmaril@260
|
344 |
positionBBox();
|
insilmaril@260
|
345 |
requestReposition();
|
insilmaril@260
|
346 |
}
|
insilmaril@243
|
347 |
}
|
insilmaril@243
|
348 |
|
insilmaril@243
|
349 |
bool OrnamentedObj::hideInExport()
|
insilmaril@243
|
350 |
{
|
insilmaril@243
|
351 |
return hideExport;
|
insilmaril@243
|
352 |
}
|
insilmaril@243
|
353 |
|
insilmaril@260
|
354 |
bool OrnamentedObj::isHidden()
|
insilmaril@260
|
355 |
{
|
insilmaril@260
|
356 |
return hidden;
|
insilmaril@260
|
357 |
}
|
insilmaril@260
|
358 |
|
insilmaril@243
|
359 |
QString OrnamentedObj::getOrnAttr()
|
insilmaril@243
|
360 |
{
|
insilmaril@243
|
361 |
QString posAttr;
|
insilmaril@252
|
362 |
|
insilmaril@388
|
363 |
if (depth==0)
|
insilmaril@388
|
364 |
posAttr=
|
insilmaril@388
|
365 |
attribut("absPosX",QString().setNum(absPos.x(),10)) +
|
insilmaril@388
|
366 |
attribut("absPosY",QString().setNum(absPos.y(),10));
|
insilmaril@243
|
367 |
else
|
insilmaril@252
|
368 |
{
|
insilmaril@388
|
369 |
if (depth==1)
|
insilmaril@388
|
370 |
posAttr=
|
insilmaril@388
|
371 |
attribut("relPosX",QString().setNum(relPos.x(),10)) +
|
insilmaril@388
|
372 |
attribut("relPosY",QString().setNum(relPos.y(),10));
|
insilmaril@252
|
373 |
else
|
insilmaril@252
|
374 |
posAttr="";
|
insilmaril@252
|
375 |
}
|
insilmaril@243
|
376 |
|
insilmaril@243
|
377 |
QString urlAttr;
|
insilmaril@243
|
378 |
if (!url.isEmpty())
|
insilmaril@243
|
379 |
urlAttr=attribut ("url",url);
|
insilmaril@243
|
380 |
|
insilmaril@243
|
381 |
QString vymLinkAttr;
|
insilmaril@243
|
382 |
if (!vymLink.isEmpty())
|
insilmaril@243
|
383 |
vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
|
insilmaril@243
|
384 |
|
insilmaril@243
|
385 |
QString hideExpAttr;
|
insilmaril@243
|
386 |
if (hideExport)
|
insilmaril@243
|
387 |
hideExpAttr= attribut("hideInExport","true");
|
insilmaril@243
|
388 |
else
|
insilmaril@243
|
389 |
hideExpAttr="";
|
insilmaril@243
|
390 |
|
insilmaril@243
|
391 |
return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;
|
insilmaril@243
|
392 |
}
|
insilmaril@243
|
393 |
|