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@408
|
21 |
OrnamentedObj::OrnamentedObj(QGraphicsScene* s) :LinkableMapObj(s)
|
insilmaril@0
|
22 |
{
|
insilmaril@408
|
23 |
// cout << "Const OrnamentedObj (s)\n";
|
insilmaril@0
|
24 |
init ();
|
insilmaril@0
|
25 |
}
|
insilmaril@0
|
26 |
|
insilmaril@408
|
27 |
OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->scene)
|
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 |
void OrnamentedObj::init ()
|
insilmaril@0
|
41 |
{
|
insilmaril@408
|
42 |
heading = new HeadingObj(scene);
|
insilmaril@0
|
43 |
heading->move (absPos.x(), absPos.y());
|
insilmaril@0
|
44 |
|
insilmaril@0
|
45 |
note.setNote("");
|
insilmaril@0
|
46 |
note.setFontHint (textEditor->getFontHintDefault() );
|
insilmaril@417
|
47 |
isNoteInEditor=false;
|
insilmaril@0
|
48 |
|
insilmaril@408
|
49 |
systemFlags=new FlagRowObj(scene);
|
insilmaril@0
|
50 |
systemFlags->clone(systemFlagsDefault);
|
insilmaril@0
|
51 |
systemFlags->setName ("systemFlags");
|
insilmaril@0
|
52 |
|
insilmaril@408
|
53 |
standardFlags=new FlagRowObj(scene);
|
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@398
|
89 |
if (mapEditor->getMapLinkColorHint()==HeadingColor)
|
insilmaril@0
|
90 |
LinkableMapObj::setLinkColor (heading->getColor());
|
insilmaril@0
|
91 |
else
|
insilmaril@398
|
92 |
LinkableMapObj::setLinkColor (mapEditor->getMapDefLinkColor());
|
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@408
|
126 |
ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
|
insilmaril@408
|
127 |
clickBox.moveTopLeft (QPointF ((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@408
|
138 |
void OrnamentedObj::move (QPointF 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@408
|
155 |
void OrnamentedObj::moveBy (QPointF 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@408
|
162 |
setRelPos (QPointF((int)x,(int)y));
|
insilmaril@388
|
163 |
if (parObj)
|
insilmaril@388
|
164 |
{
|
insilmaril@408
|
165 |
QPointF p=parObj->getChildPos();
|
insilmaril@388
|
166 |
move (p.x()+x, p.y() +y);
|
insilmaril@388
|
167 |
}
|
insilmaril@0
|
168 |
}
|
insilmaril@0
|
169 |
|
insilmaril@408
|
170 |
void OrnamentedObj::move2RelPos(QPointF 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@417
|
178 |
updateNoteFlag();
|
insilmaril@0
|
179 |
}
|
insilmaril@0
|
180 |
|
insilmaril@0
|
181 |
void OrnamentedObj::setNote(NoteObj n)
|
insilmaril@0
|
182 |
{
|
insilmaril@0
|
183 |
note=n;
|
insilmaril@417
|
184 |
updateNoteFlag();
|
insilmaril@0
|
185 |
}
|
insilmaril@0
|
186 |
|
insilmaril@0
|
187 |
QString OrnamentedObj::getNote()
|
insilmaril@0
|
188 |
{
|
insilmaril@0
|
189 |
return note.getNote();
|
insilmaril@0
|
190 |
}
|
insilmaril@0
|
191 |
|
insilmaril@187
|
192 |
QString OrnamentedObj::getNoteASCII()
|
insilmaril@187
|
193 |
{
|
insilmaril@187
|
194 |
return note.getNoteASCII();
|
insilmaril@187
|
195 |
}
|
insilmaril@187
|
196 |
|
insilmaril@187
|
197 |
QString OrnamentedObj::getNoteOpenDoc()
|
insilmaril@187
|
198 |
{
|
insilmaril@187
|
199 |
return note.getNoteOpenDoc();
|
insilmaril@187
|
200 |
}
|
insilmaril@187
|
201 |
|
insilmaril@243
|
202 |
void OrnamentedObj::setURL(QString s)
|
insilmaril@243
|
203 |
{
|
insilmaril@243
|
204 |
url=s;
|
insilmaril@243
|
205 |
if (!url.isEmpty())
|
insilmaril@243
|
206 |
systemFlags->activate("url");
|
insilmaril@243
|
207 |
else
|
insilmaril@243
|
208 |
systemFlags->deactivate("url");
|
insilmaril@243
|
209 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@243
|
210 |
positionBBox(); // rearrange contents
|
insilmaril@243
|
211 |
forceReposition();
|
insilmaril@243
|
212 |
}
|
insilmaril@243
|
213 |
|
insilmaril@243
|
214 |
QString OrnamentedObj::getURL()
|
insilmaril@243
|
215 |
{
|
insilmaril@243
|
216 |
return url;
|
insilmaril@243
|
217 |
}
|
insilmaril@243
|
218 |
|
insilmaril@243
|
219 |
void OrnamentedObj::setVymLink(QString s)
|
insilmaril@243
|
220 |
{
|
insilmaril@243
|
221 |
if (!s.isEmpty())
|
insilmaril@243
|
222 |
{
|
insilmaril@243
|
223 |
// We need the relative (from loading)
|
insilmaril@243
|
224 |
// or absolute path (from User event)
|
insilmaril@243
|
225 |
// and build the absolute path.
|
insilmaril@243
|
226 |
// Note: If we have relative, use path of
|
insilmaril@243
|
227 |
// current map to build absolute path
|
insilmaril@243
|
228 |
QDir d(s);
|
insilmaril@243
|
229 |
if (!d.path().startsWith ("/"))
|
insilmaril@243
|
230 |
{
|
insilmaril@243
|
231 |
QString p=mapEditor->getDestPath();
|
insilmaril@243
|
232 |
int i=p.findRev("/",-1);
|
insilmaril@243
|
233 |
d.setPath(p.left(i)+"/"+s);
|
insilmaril@243
|
234 |
d.convertToAbs();
|
insilmaril@243
|
235 |
}
|
insilmaril@243
|
236 |
vymLink=d.path();
|
insilmaril@243
|
237 |
systemFlags->activate("vymLink");
|
insilmaril@243
|
238 |
}
|
insilmaril@243
|
239 |
else
|
insilmaril@243
|
240 |
{
|
insilmaril@243
|
241 |
systemFlags->deactivate("vymLink");
|
insilmaril@243
|
242 |
vymLink="";
|
insilmaril@243
|
243 |
}
|
insilmaril@243
|
244 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@243
|
245 |
positionBBox(); // rearrange contents
|
insilmaril@243
|
246 |
forceReposition();
|
insilmaril@243
|
247 |
}
|
insilmaril@243
|
248 |
|
insilmaril@243
|
249 |
QString OrnamentedObj::getVymLink()
|
insilmaril@243
|
250 |
{
|
insilmaril@243
|
251 |
return vymLink;
|
insilmaril@243
|
252 |
}
|
insilmaril@243
|
253 |
|
insilmaril@243
|
254 |
|
insilmaril@103
|
255 |
void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
|
insilmaril@0
|
256 |
{
|
insilmaril@103
|
257 |
standardFlags->toggle(f,exclusive);
|
insilmaril@0
|
258 |
calcBBoxSize();
|
insilmaril@0
|
259 |
positionBBox();
|
insilmaril@0
|
260 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
261 |
forceReposition();
|
insilmaril@0
|
262 |
}
|
insilmaril@0
|
263 |
|
insilmaril@0
|
264 |
void OrnamentedObj::activateStandardFlag(QString f)
|
insilmaril@0
|
265 |
{
|
insilmaril@0
|
266 |
standardFlags->activate(f);
|
insilmaril@0
|
267 |
calcBBoxSize();
|
insilmaril@0
|
268 |
positionBBox();
|
insilmaril@0
|
269 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
270 |
forceReposition();
|
insilmaril@0
|
271 |
}
|
insilmaril@0
|
272 |
|
insilmaril@366
|
273 |
void OrnamentedObj::deactivateStandardFlag(QString f)
|
insilmaril@366
|
274 |
{
|
insilmaril@366
|
275 |
standardFlags->deactivate(f);
|
insilmaril@366
|
276 |
calcBBoxSize();
|
insilmaril@366
|
277 |
positionBBox();
|
insilmaril@366
|
278 |
move (absPos.x(), absPos.y() );
|
insilmaril@366
|
279 |
forceReposition();
|
insilmaril@366
|
280 |
}
|
insilmaril@366
|
281 |
|
insilmaril@296
|
282 |
bool OrnamentedObj::isSetStandardFlag (QString f)
|
insilmaril@296
|
283 |
{
|
insilmaril@296
|
284 |
return standardFlags->isActive(f);
|
insilmaril@296
|
285 |
}
|
insilmaril@296
|
286 |
|
insilmaril@408
|
287 |
QString OrnamentedObj::getSystemFlagName(const QPointF &p)
|
insilmaril@0
|
288 |
{
|
insilmaril@0
|
289 |
return systemFlags->getFlagName(p);
|
insilmaril@0
|
290 |
}
|
insilmaril@0
|
291 |
|
insilmaril@236
|
292 |
bool OrnamentedObj::isActiveFlag (const QString & fname)
|
insilmaril@236
|
293 |
{
|
insilmaril@236
|
294 |
if (standardFlags->isActive (fname) ) return true;
|
insilmaril@236
|
295 |
return false;
|
insilmaril@236
|
296 |
}
|
insilmaril@236
|
297 |
|
insilmaril@417
|
298 |
void OrnamentedObj::getNoteFromTextEditor ()
|
insilmaril@417
|
299 |
{
|
insilmaril@417
|
300 |
note.setFilenameHint (textEditor->getFilename());
|
insilmaril@417
|
301 |
note.setFontHint (textEditor->getFontHint() );
|
insilmaril@417
|
302 |
setNote( textEditor->getText() );
|
insilmaril@417
|
303 |
}
|
insilmaril@417
|
304 |
|
insilmaril@0
|
305 |
void OrnamentedObj::updateNoteFlag()
|
insilmaril@0
|
306 |
{
|
insilmaril@417
|
307 |
bool noteEmpty;
|
insilmaril@417
|
308 |
if (isNoteInEditor)
|
insilmaril@417
|
309 |
noteEmpty=textEditor->isEmpty();
|
insilmaril@417
|
310 |
else
|
insilmaril@417
|
311 |
noteEmpty=note.isEmpty();
|
insilmaril@0
|
312 |
|
insilmaril@417
|
313 |
if (!noteEmpty)
|
insilmaril@417
|
314 |
{
|
insilmaril@417
|
315 |
if (systemFlags->isActive ("note")) return;
|
insilmaril@417
|
316 |
systemFlags->activate("note");
|
insilmaril@417
|
317 |
}
|
insilmaril@417
|
318 |
else
|
insilmaril@417
|
319 |
{
|
insilmaril@417
|
320 |
if (!systemFlags->isActive ("note")) return;
|
insilmaril@417
|
321 |
systemFlags->deactivate("note");
|
insilmaril@417
|
322 |
}
|
insilmaril@417
|
323 |
mapEditor->setChanged();
|
insilmaril@417
|
324 |
calcBBoxSize();
|
insilmaril@417
|
325 |
positionBBox();
|
insilmaril@417
|
326 |
move (absPos.x(), absPos.y() );
|
insilmaril@417
|
327 |
forceReposition();
|
insilmaril@0
|
328 |
|
insilmaril@417
|
329 |
}
|
insilmaril@0
|
330 |
|
insilmaril@366
|
331 |
void OrnamentedObj::updateFlagsToolbar()
|
insilmaril@366
|
332 |
{
|
insilmaril@366
|
333 |
standardFlags->updateToolbar();
|
insilmaril@366
|
334 |
}
|
insilmaril@366
|
335 |
|
insilmaril@243
|
336 |
void OrnamentedObj::setHideInExport(bool b)
|
insilmaril@243
|
337 |
{
|
insilmaril@260
|
338 |
if (parObj)
|
insilmaril@260
|
339 |
{
|
insilmaril@260
|
340 |
// Don't allow to MapCenter to be hidden
|
insilmaril@260
|
341 |
hideExport=b;
|
insilmaril@260
|
342 |
if (b)
|
insilmaril@260
|
343 |
systemFlags->activate("hideInExport");
|
insilmaril@260
|
344 |
else
|
insilmaril@260
|
345 |
systemFlags->deactivate("hideInExport");
|
insilmaril@260
|
346 |
calcBBoxSize();
|
insilmaril@260
|
347 |
positionBBox();
|
insilmaril@260
|
348 |
requestReposition();
|
insilmaril@260
|
349 |
}
|
insilmaril@243
|
350 |
}
|
insilmaril@243
|
351 |
|
insilmaril@243
|
352 |
bool OrnamentedObj::hideInExport()
|
insilmaril@243
|
353 |
{
|
insilmaril@243
|
354 |
return hideExport;
|
insilmaril@243
|
355 |
}
|
insilmaril@243
|
356 |
|
insilmaril@260
|
357 |
bool OrnamentedObj::isHidden()
|
insilmaril@260
|
358 |
{
|
insilmaril@260
|
359 |
return hidden;
|
insilmaril@260
|
360 |
}
|
insilmaril@260
|
361 |
|
insilmaril@243
|
362 |
QString OrnamentedObj::getOrnAttr()
|
insilmaril@243
|
363 |
{
|
insilmaril@243
|
364 |
QString posAttr;
|
insilmaril@252
|
365 |
|
insilmaril@388
|
366 |
if (depth==0)
|
insilmaril@388
|
367 |
posAttr=
|
insilmaril@408
|
368 |
attribut("absPosX",QString().setNum(absPos.x())) +
|
insilmaril@408
|
369 |
attribut("absPosY",QString().setNum(absPos.y()));
|
insilmaril@243
|
370 |
else
|
insilmaril@252
|
371 |
{
|
insilmaril@395
|
372 |
if (depth==1 || typeid (*this)==typeid (FloatImageObj))
|
insilmaril@388
|
373 |
posAttr=
|
insilmaril@408
|
374 |
attribut("relPosX",QString().setNum(relPos.x())) +
|
insilmaril@408
|
375 |
attribut("relPosY",QString().setNum(relPos.y()));
|
insilmaril@252
|
376 |
else
|
insilmaril@252
|
377 |
posAttr="";
|
insilmaril@252
|
378 |
}
|
insilmaril@243
|
379 |
|
insilmaril@243
|
380 |
QString urlAttr;
|
insilmaril@243
|
381 |
if (!url.isEmpty())
|
insilmaril@243
|
382 |
urlAttr=attribut ("url",url);
|
insilmaril@243
|
383 |
|
insilmaril@243
|
384 |
QString vymLinkAttr;
|
insilmaril@243
|
385 |
if (!vymLink.isEmpty())
|
insilmaril@243
|
386 |
vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
|
insilmaril@243
|
387 |
|
insilmaril@243
|
388 |
QString hideExpAttr;
|
insilmaril@243
|
389 |
if (hideExport)
|
insilmaril@243
|
390 |
hideExpAttr= attribut("hideInExport","true");
|
insilmaril@243
|
391 |
else
|
insilmaril@243
|
392 |
hideExpAttr="";
|
insilmaril@243
|
393 |
|
insilmaril@243
|
394 |
return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;
|
insilmaril@243
|
395 |
}
|
insilmaril@243
|
396 |
|