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