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@0
|
21 |
OrnamentedObj::OrnamentedObj(QCanvas* 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@0
|
56 |
}
|
insilmaril@0
|
57 |
|
insilmaril@0
|
58 |
void OrnamentedObj::copy (OrnamentedObj* other)
|
insilmaril@0
|
59 |
{
|
insilmaril@0
|
60 |
LinkableMapObj::copy(other);
|
insilmaril@0
|
61 |
heading->copy(other->heading);
|
insilmaril@0
|
62 |
setColor (other->heading->getColor(),false);
|
insilmaril@0
|
63 |
|
insilmaril@0
|
64 |
note.copy (other->note);
|
insilmaril@0
|
65 |
systemFlags->copy (other->systemFlags);
|
insilmaril@0
|
66 |
standardFlags->copy (other->standardFlags);
|
insilmaril@0
|
67 |
|
insilmaril@227
|
68 |
ornamentsBBox=other->ornamentsBBox;
|
insilmaril@227
|
69 |
|
insilmaril@0
|
70 |
}
|
insilmaril@0
|
71 |
|
insilmaril@0
|
72 |
QString OrnamentedObj::getHeading()
|
insilmaril@0
|
73 |
{
|
insilmaril@0
|
74 |
return heading->text();
|
insilmaril@0
|
75 |
}
|
insilmaril@0
|
76 |
|
insilmaril@0
|
77 |
void OrnamentedObj::setLinkColor()
|
insilmaril@0
|
78 |
{
|
insilmaril@0
|
79 |
if (mapEditor->getLinkColorHint()==HeadingColor)
|
insilmaril@0
|
80 |
LinkableMapObj::setLinkColor (heading->getColor());
|
insilmaril@0
|
81 |
else
|
insilmaril@0
|
82 |
LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
|
insilmaril@0
|
83 |
}
|
insilmaril@0
|
84 |
|
insilmaril@0
|
85 |
QColor OrnamentedObj::getColor ()
|
insilmaril@0
|
86 |
{
|
insilmaril@0
|
87 |
return heading->getColor();
|
insilmaril@0
|
88 |
}
|
insilmaril@0
|
89 |
|
insilmaril@0
|
90 |
|
insilmaril@177
|
91 |
void OrnamentedObj::positionContents()
|
insilmaril@0
|
92 |
{
|
insilmaril@177
|
93 |
double d=frame->getBorder()/2;
|
insilmaril@177
|
94 |
double x=absPos.x();
|
insilmaril@177
|
95 |
double y=absPos.y();
|
insilmaril@227
|
96 |
|
insilmaril@227
|
97 |
double ox,oy; // Offset due to padding
|
insilmaril@227
|
98 |
|
insilmaril@227
|
99 |
ox=leftPad + d;
|
insilmaril@227
|
100 |
oy=topPad + d;
|
insilmaril@227
|
101 |
|
insilmaril@227
|
102 |
systemFlags-> move (ox +x , oy + y );
|
insilmaril@0
|
103 |
|
insilmaril@0
|
104 |
// vertical align heading to bottom
|
insilmaril@227
|
105 |
heading->move (ox + x + systemFlags->getBBox().width(),
|
insilmaril@227
|
106 |
oy + y + ornamentsBBox.height() - heading->getHeight()
|
insilmaril@0
|
107 |
);
|
insilmaril@227
|
108 |
standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
|
insilmaril@227
|
109 |
|
insilmaril@236
|
110 |
ornamentsBBox.moveTopLeft ( QPoint ((int)(ox+x),(int)(oy+y)));
|
insilmaril@236
|
111 |
clickBox.moveTopLeft (QPoint ((int)(ox + x), (int)(oy + y)));
|
insilmaril@227
|
112 |
|
insilmaril@177
|
113 |
}
|
insilmaril@0
|
114 |
|
insilmaril@177
|
115 |
void OrnamentedObj::move (double x, double y)
|
insilmaril@177
|
116 |
{
|
insilmaril@177
|
117 |
MapObj::move (x,y);
|
insilmaril@177
|
118 |
positionContents();
|
insilmaril@0
|
119 |
updateLink();
|
insilmaril@0
|
120 |
requestReposition();
|
insilmaril@0
|
121 |
}
|
insilmaril@0
|
122 |
|
insilmaril@0
|
123 |
void OrnamentedObj::move (QPoint p)
|
insilmaril@0
|
124 |
{
|
insilmaril@0
|
125 |
move (p.x(), p.y());
|
insilmaril@0
|
126 |
}
|
insilmaril@0
|
127 |
|
insilmaril@0
|
128 |
void OrnamentedObj::moveBy (double x, double y)
|
insilmaril@0
|
129 |
{
|
insilmaril@0
|
130 |
|
insilmaril@0
|
131 |
MapObj::moveBy (x,y);
|
insilmaril@0
|
132 |
frame->moveBy (x,y);
|
insilmaril@0
|
133 |
systemFlags->moveBy (x,y);
|
insilmaril@0
|
134 |
standardFlags->moveBy (x,y);
|
insilmaril@0
|
135 |
heading->moveBy (x,y);
|
insilmaril@0
|
136 |
updateLink();
|
insilmaril@0
|
137 |
requestReposition();
|
insilmaril@0
|
138 |
}
|
insilmaril@0
|
139 |
|
insilmaril@0
|
140 |
void OrnamentedObj::moveBy (QPoint p)
|
insilmaril@0
|
141 |
{
|
insilmaril@0
|
142 |
moveBy (p.x(), p.y());
|
insilmaril@0
|
143 |
}
|
insilmaril@0
|
144 |
|
insilmaril@0
|
145 |
void OrnamentedObj::move2RelPos(double x, double y)
|
insilmaril@0
|
146 |
{
|
insilmaril@0
|
147 |
if (!parObj) return;
|
insilmaril@0
|
148 |
move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
|
insilmaril@0
|
149 |
}
|
insilmaril@0
|
150 |
|
insilmaril@0
|
151 |
void OrnamentedObj::move2RelPos(QPoint p)
|
insilmaril@0
|
152 |
{
|
insilmaril@218
|
153 |
move2RelPos (p.x(),p.y());
|
insilmaril@0
|
154 |
}
|
insilmaril@0
|
155 |
|
insilmaril@0
|
156 |
void OrnamentedObj::setNote(QString s)
|
insilmaril@0
|
157 |
{
|
insilmaril@0
|
158 |
note.setNote(s);
|
insilmaril@0
|
159 |
if (!note.isEmpty())
|
insilmaril@0
|
160 |
systemFlags->activate("note");
|
insilmaril@0
|
161 |
else
|
insilmaril@0
|
162 |
systemFlags->deactivate("note");
|
insilmaril@0
|
163 |
calcBBoxSize();
|
insilmaril@0
|
164 |
positionBBox();
|
insilmaril@0
|
165 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
166 |
forceReposition();
|
insilmaril@0
|
167 |
}
|
insilmaril@0
|
168 |
|
insilmaril@0
|
169 |
void OrnamentedObj::setNote(NoteObj n)
|
insilmaril@0
|
170 |
{
|
insilmaril@0
|
171 |
note=n;
|
insilmaril@0
|
172 |
if (!note.isEmpty())
|
insilmaril@0
|
173 |
systemFlags->activate("note");
|
insilmaril@0
|
174 |
else
|
insilmaril@0
|
175 |
systemFlags->deactivate("note");
|
insilmaril@0
|
176 |
calcBBoxSize();
|
insilmaril@0
|
177 |
positionBBox();
|
insilmaril@0
|
178 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
179 |
forceReposition();
|
insilmaril@0
|
180 |
|
insilmaril@0
|
181 |
}
|
insilmaril@0
|
182 |
|
insilmaril@0
|
183 |
QString OrnamentedObj::getNote()
|
insilmaril@0
|
184 |
{
|
insilmaril@0
|
185 |
return note.getNote();
|
insilmaril@0
|
186 |
}
|
insilmaril@0
|
187 |
|
insilmaril@187
|
188 |
QString OrnamentedObj::getNoteASCII()
|
insilmaril@187
|
189 |
{
|
insilmaril@187
|
190 |
return note.getNoteASCII();
|
insilmaril@187
|
191 |
}
|
insilmaril@187
|
192 |
|
insilmaril@187
|
193 |
QString OrnamentedObj::getNoteOpenDoc()
|
insilmaril@187
|
194 |
{
|
insilmaril@187
|
195 |
return note.getNoteOpenDoc();
|
insilmaril@187
|
196 |
}
|
insilmaril@187
|
197 |
|
insilmaril@103
|
198 |
void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
|
insilmaril@0
|
199 |
{
|
insilmaril@103
|
200 |
standardFlags->toggle(f,exclusive);
|
insilmaril@0
|
201 |
calcBBoxSize();
|
insilmaril@0
|
202 |
positionBBox();
|
insilmaril@0
|
203 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
204 |
forceReposition();
|
insilmaril@0
|
205 |
}
|
insilmaril@0
|
206 |
|
insilmaril@0
|
207 |
void OrnamentedObj::activateStandardFlag(QString f)
|
insilmaril@0
|
208 |
{
|
insilmaril@0
|
209 |
standardFlags->activate(f);
|
insilmaril@0
|
210 |
calcBBoxSize();
|
insilmaril@0
|
211 |
positionBBox();
|
insilmaril@0
|
212 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
213 |
forceReposition();
|
insilmaril@0
|
214 |
}
|
insilmaril@0
|
215 |
|
insilmaril@0
|
216 |
QString OrnamentedObj::getSystemFlagName(const QPoint &p)
|
insilmaril@0
|
217 |
{
|
insilmaril@0
|
218 |
return systemFlags->getFlagName(p);
|
insilmaril@0
|
219 |
}
|
insilmaril@0
|
220 |
|
insilmaril@236
|
221 |
bool OrnamentedObj::isActiveFlag (const QString & fname)
|
insilmaril@236
|
222 |
{
|
insilmaril@236
|
223 |
if (standardFlags->isActive (fname) ) return true;
|
insilmaril@236
|
224 |
return false;
|
insilmaril@236
|
225 |
}
|
insilmaril@236
|
226 |
|
insilmaril@0
|
227 |
void OrnamentedObj::updateNoteFlag()
|
insilmaril@0
|
228 |
{
|
insilmaril@160
|
229 |
if (selected)
|
insilmaril@160
|
230 |
{
|
insilmaril@160
|
231 |
// text in NoteEditor has changed, notify MapEditor
|
insilmaril@160
|
232 |
mapEditor->setChanged();
|
insilmaril@0
|
233 |
|
insilmaril@160
|
234 |
// save text
|
insilmaril@160
|
235 |
setNote( textEditor->getText() );
|
insilmaril@0
|
236 |
|
insilmaril@160
|
237 |
// save font
|
insilmaril@160
|
238 |
note.setFontHint (textEditor->getFontHint() );
|
insilmaril@160
|
239 |
}
|
insilmaril@0
|
240 |
}
|
insilmaril@0
|
241 |
|