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