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@0
|
163 |
}
|
insilmaril@0
|
164 |
|
insilmaril@0
|
165 |
void OrnamentedObj::move2RelPos(QPoint p)
|
insilmaril@0
|
166 |
{
|
insilmaril@218
|
167 |
move2RelPos (p.x(),p.y());
|
insilmaril@0
|
168 |
}
|
insilmaril@0
|
169 |
|
insilmaril@0
|
170 |
void OrnamentedObj::setNote(QString s)
|
insilmaril@0
|
171 |
{
|
insilmaril@0
|
172 |
note.setNote(s);
|
insilmaril@0
|
173 |
if (!note.isEmpty())
|
insilmaril@0
|
174 |
systemFlags->activate("note");
|
insilmaril@0
|
175 |
else
|
insilmaril@0
|
176 |
systemFlags->deactivate("note");
|
insilmaril@0
|
177 |
calcBBoxSize();
|
insilmaril@0
|
178 |
positionBBox();
|
insilmaril@0
|
179 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
180 |
forceReposition();
|
insilmaril@0
|
181 |
}
|
insilmaril@0
|
182 |
|
insilmaril@0
|
183 |
void OrnamentedObj::setNote(NoteObj n)
|
insilmaril@0
|
184 |
{
|
insilmaril@0
|
185 |
note=n;
|
insilmaril@0
|
186 |
if (!note.isEmpty())
|
insilmaril@0
|
187 |
systemFlags->activate("note");
|
insilmaril@0
|
188 |
else
|
insilmaril@0
|
189 |
systemFlags->deactivate("note");
|
insilmaril@0
|
190 |
calcBBoxSize();
|
insilmaril@0
|
191 |
positionBBox();
|
insilmaril@0
|
192 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
193 |
forceReposition();
|
insilmaril@0
|
194 |
|
insilmaril@0
|
195 |
}
|
insilmaril@0
|
196 |
|
insilmaril@0
|
197 |
QString OrnamentedObj::getNote()
|
insilmaril@0
|
198 |
{
|
insilmaril@0
|
199 |
return note.getNote();
|
insilmaril@0
|
200 |
}
|
insilmaril@0
|
201 |
|
insilmaril@187
|
202 |
QString OrnamentedObj::getNoteASCII()
|
insilmaril@187
|
203 |
{
|
insilmaril@187
|
204 |
return note.getNoteASCII();
|
insilmaril@187
|
205 |
}
|
insilmaril@187
|
206 |
|
insilmaril@187
|
207 |
QString OrnamentedObj::getNoteOpenDoc()
|
insilmaril@187
|
208 |
{
|
insilmaril@187
|
209 |
return note.getNoteOpenDoc();
|
insilmaril@187
|
210 |
}
|
insilmaril@187
|
211 |
|
insilmaril@243
|
212 |
void OrnamentedObj::setURL(QString s)
|
insilmaril@243
|
213 |
{
|
insilmaril@243
|
214 |
url=s;
|
insilmaril@243
|
215 |
if (!url.isEmpty())
|
insilmaril@243
|
216 |
systemFlags->activate("url");
|
insilmaril@243
|
217 |
else
|
insilmaril@243
|
218 |
systemFlags->deactivate("url");
|
insilmaril@243
|
219 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@243
|
220 |
positionBBox(); // rearrange contents
|
insilmaril@243
|
221 |
forceReposition();
|
insilmaril@243
|
222 |
}
|
insilmaril@243
|
223 |
|
insilmaril@243
|
224 |
QString OrnamentedObj::getURL()
|
insilmaril@243
|
225 |
{
|
insilmaril@243
|
226 |
return url;
|
insilmaril@243
|
227 |
}
|
insilmaril@243
|
228 |
|
insilmaril@243
|
229 |
void OrnamentedObj::setVymLink(QString s)
|
insilmaril@243
|
230 |
{
|
insilmaril@243
|
231 |
if (!s.isEmpty())
|
insilmaril@243
|
232 |
{
|
insilmaril@243
|
233 |
// We need the relative (from loading)
|
insilmaril@243
|
234 |
// or absolute path (from User event)
|
insilmaril@243
|
235 |
// and build the absolute path.
|
insilmaril@243
|
236 |
// Note: If we have relative, use path of
|
insilmaril@243
|
237 |
// current map to build absolute path
|
insilmaril@243
|
238 |
QDir d(s);
|
insilmaril@243
|
239 |
if (!d.path().startsWith ("/"))
|
insilmaril@243
|
240 |
{
|
insilmaril@243
|
241 |
QString p=mapEditor->getDestPath();
|
insilmaril@243
|
242 |
int i=p.findRev("/",-1);
|
insilmaril@243
|
243 |
d.setPath(p.left(i)+"/"+s);
|
insilmaril@243
|
244 |
d.convertToAbs();
|
insilmaril@243
|
245 |
}
|
insilmaril@243
|
246 |
vymLink=d.path();
|
insilmaril@243
|
247 |
systemFlags->activate("vymLink");
|
insilmaril@243
|
248 |
}
|
insilmaril@243
|
249 |
else
|
insilmaril@243
|
250 |
{
|
insilmaril@243
|
251 |
systemFlags->deactivate("vymLink");
|
insilmaril@243
|
252 |
vymLink="";
|
insilmaril@243
|
253 |
}
|
insilmaril@243
|
254 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@243
|
255 |
positionBBox(); // rearrange contents
|
insilmaril@243
|
256 |
forceReposition();
|
insilmaril@243
|
257 |
}
|
insilmaril@243
|
258 |
|
insilmaril@243
|
259 |
QString OrnamentedObj::getVymLink()
|
insilmaril@243
|
260 |
{
|
insilmaril@243
|
261 |
return vymLink;
|
insilmaril@243
|
262 |
}
|
insilmaril@243
|
263 |
|
insilmaril@243
|
264 |
|
insilmaril@103
|
265 |
void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
|
insilmaril@0
|
266 |
{
|
insilmaril@103
|
267 |
standardFlags->toggle(f,exclusive);
|
insilmaril@0
|
268 |
calcBBoxSize();
|
insilmaril@0
|
269 |
positionBBox();
|
insilmaril@0
|
270 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
271 |
forceReposition();
|
insilmaril@0
|
272 |
}
|
insilmaril@0
|
273 |
|
insilmaril@0
|
274 |
void OrnamentedObj::activateStandardFlag(QString f)
|
insilmaril@0
|
275 |
{
|
insilmaril@0
|
276 |
standardFlags->activate(f);
|
insilmaril@0
|
277 |
calcBBoxSize();
|
insilmaril@0
|
278 |
positionBBox();
|
insilmaril@0
|
279 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
280 |
forceReposition();
|
insilmaril@0
|
281 |
}
|
insilmaril@0
|
282 |
|
insilmaril@366
|
283 |
void OrnamentedObj::deactivateStandardFlag(QString f)
|
insilmaril@366
|
284 |
{
|
insilmaril@366
|
285 |
standardFlags->deactivate(f);
|
insilmaril@366
|
286 |
calcBBoxSize();
|
insilmaril@366
|
287 |
positionBBox();
|
insilmaril@366
|
288 |
move (absPos.x(), absPos.y() );
|
insilmaril@366
|
289 |
forceReposition();
|
insilmaril@366
|
290 |
}
|
insilmaril@366
|
291 |
|
insilmaril@296
|
292 |
bool OrnamentedObj::isSetStandardFlag (QString f)
|
insilmaril@296
|
293 |
{
|
insilmaril@296
|
294 |
return standardFlags->isActive(f);
|
insilmaril@296
|
295 |
}
|
insilmaril@296
|
296 |
|
insilmaril@0
|
297 |
QString OrnamentedObj::getSystemFlagName(const QPoint &p)
|
insilmaril@0
|
298 |
{
|
insilmaril@0
|
299 |
return systemFlags->getFlagName(p);
|
insilmaril@0
|
300 |
}
|
insilmaril@0
|
301 |
|
insilmaril@236
|
302 |
bool OrnamentedObj::isActiveFlag (const QString & fname)
|
insilmaril@236
|
303 |
{
|
insilmaril@236
|
304 |
if (standardFlags->isActive (fname) ) return true;
|
insilmaril@236
|
305 |
return false;
|
insilmaril@236
|
306 |
}
|
insilmaril@236
|
307 |
|
insilmaril@0
|
308 |
void OrnamentedObj::updateNoteFlag()
|
insilmaril@0
|
309 |
{
|
insilmaril@160
|
310 |
if (selected)
|
insilmaril@160
|
311 |
{
|
insilmaril@160
|
312 |
// text in NoteEditor has changed, notify MapEditor
|
insilmaril@160
|
313 |
mapEditor->setChanged();
|
insilmaril@0
|
314 |
|
insilmaril@160
|
315 |
// save text
|
insilmaril@160
|
316 |
setNote( textEditor->getText() );
|
insilmaril@0
|
317 |
|
insilmaril@160
|
318 |
// save font
|
insilmaril@160
|
319 |
note.setFontHint (textEditor->getFontHint() );
|
insilmaril@160
|
320 |
}
|
insilmaril@0
|
321 |
}
|
insilmaril@0
|
322 |
|
insilmaril@366
|
323 |
void OrnamentedObj::updateFlagsToolbar()
|
insilmaril@366
|
324 |
{
|
insilmaril@366
|
325 |
standardFlags->updateToolbar();
|
insilmaril@366
|
326 |
}
|
insilmaril@366
|
327 |
|
insilmaril@243
|
328 |
void OrnamentedObj::setHideInExport(bool b)
|
insilmaril@243
|
329 |
{
|
insilmaril@260
|
330 |
if (parObj)
|
insilmaril@260
|
331 |
{
|
insilmaril@260
|
332 |
// Don't allow to MapCenter to be hidden
|
insilmaril@260
|
333 |
hideExport=b;
|
insilmaril@260
|
334 |
if (b)
|
insilmaril@260
|
335 |
systemFlags->activate("hideInExport");
|
insilmaril@260
|
336 |
else
|
insilmaril@260
|
337 |
systemFlags->deactivate("hideInExport");
|
insilmaril@260
|
338 |
calcBBoxSize();
|
insilmaril@260
|
339 |
positionBBox();
|
insilmaril@260
|
340 |
requestReposition();
|
insilmaril@260
|
341 |
}
|
insilmaril@243
|
342 |
}
|
insilmaril@243
|
343 |
|
insilmaril@243
|
344 |
bool OrnamentedObj::hideInExport()
|
insilmaril@243
|
345 |
{
|
insilmaril@243
|
346 |
return hideExport;
|
insilmaril@243
|
347 |
}
|
insilmaril@243
|
348 |
|
insilmaril@260
|
349 |
bool OrnamentedObj::isHidden()
|
insilmaril@260
|
350 |
{
|
insilmaril@260
|
351 |
return hidden;
|
insilmaril@260
|
352 |
}
|
insilmaril@260
|
353 |
|
insilmaril@243
|
354 |
QString OrnamentedObj::getOrnAttr()
|
insilmaril@243
|
355 |
{
|
insilmaril@243
|
356 |
QString posAttr;
|
insilmaril@252
|
357 |
|
insilmaril@252
|
358 |
if (useRelPos)
|
insilmaril@252
|
359 |
posAttr=attribut("relPosX",QString().setNum(relPos.x(),10)) +
|
insilmaril@252
|
360 |
attribut("relPosY",QString().setNum(relPos.y(),10));
|
insilmaril@243
|
361 |
else
|
insilmaril@252
|
362 |
{
|
insilmaril@252
|
363 |
if (depth==0 || depth==1) posAttr=
|
insilmaril@252
|
364 |
attribut("absPosX",QString().setNum(absPos.x(),10)) +
|
insilmaril@252
|
365 |
attribut("absPosY",QString().setNum(absPos.y(),10));
|
insilmaril@252
|
366 |
else
|
insilmaril@252
|
367 |
posAttr="";
|
insilmaril@252
|
368 |
}
|
insilmaril@243
|
369 |
|
insilmaril@243
|
370 |
QString urlAttr;
|
insilmaril@243
|
371 |
if (!url.isEmpty())
|
insilmaril@243
|
372 |
urlAttr=attribut ("url",url);
|
insilmaril@243
|
373 |
|
insilmaril@243
|
374 |
QString vymLinkAttr;
|
insilmaril@243
|
375 |
if (!vymLink.isEmpty())
|
insilmaril@243
|
376 |
vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
|
insilmaril@243
|
377 |
|
insilmaril@243
|
378 |
QString hideExpAttr;
|
insilmaril@243
|
379 |
if (hideExport)
|
insilmaril@243
|
380 |
hideExpAttr= attribut("hideInExport","true");
|
insilmaril@243
|
381 |
else
|
insilmaril@243
|
382 |
hideExpAttr="";
|
insilmaril@243
|
383 |
|
insilmaril@243
|
384 |
return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;
|
insilmaril@243
|
385 |
}
|
insilmaril@243
|
386 |
|