minor fixes in mmap2vym.xsl and repaired todo.vym (every includeImagesHor was set)
1 #include "flagrowobj.h"
3 /////////////////////////////////////////////////////////////////
5 /////////////////////////////////////////////////////////////////
6 FlagRowObj::FlagRowObj()
8 // cout << "Const FlagRowObj ()\n";
12 FlagRowObj::FlagRowObj(QCanvas* c):MapObj(c)
14 // cout << "Const FlagRowObj\n";
18 FlagRowObj::~FlagRowObj()
20 // cout << "Destr FlagRowObj\n";
24 void FlagRowObj::init ()
26 flag.setAutoDelete (true);
30 void FlagRowObj::copy (FlagRowObj* other)
33 parentRow=other->parentRow;
36 for (fo=other->flag.first(); fo; fo=other->flag.next() )
40 void FlagRowObj::clone (FlagRowObj* pr)
42 // Difference to copy:
43 // We don't copy the flags here, they
44 // are created on the fly by toggle and activate
45 // This saves lots of canvas objects.
51 void FlagRowObj::move(double x, double y)
56 for (fo=flag.first(); fo; fo=flag.next() )
59 dx+=QSize(fo->getSize() ).width();
63 void FlagRowObj::moveBy(double x, double y)
65 move (x+absPos.x(),y+absPos.y() );
68 void FlagRowObj::setVisibility (bool v)
70 MapObj::setVisibility(v);
72 for (fo=flag.first(); fo; fo=flag.next() )
73 fo->setVisibility (v);
76 FlagObj* FlagRowObj::addFlag (FlagObj *fo)
78 FlagObj *newfo=new FlagObj (canvas);
79 newfo->move (absPos.x() + bbox.width(), absPos.y() );
80 newfo->copy (fo); // create a deep copy of fo
87 void FlagRowObj::positionBBox()
89 bbox.moveTopLeft(absPos );
90 clickBox.moveTopLeft(absPos );
93 void FlagRowObj::calcBBoxSize()
98 for (fo=flag.first(); fo; fo=flag.next() )
102 boxsize.setWidth(boxsize.width() + size.width() );
104 if (size.height() > boxsize.height() )
105 boxsize.setHeight(size.height() );
107 bbox.setSize (boxsize);
108 clickBox.setSize (boxsize);
111 QString FlagRowObj::getFlagName (const QPoint &p)
113 if (!inBox (p)) return "";
115 for (fo=flag.first();fo; fo=flag.next() )
117 cout << " "<<fo->getName()<<endl;
118 if (fo->inBox (p)) return fo->getName();
125 bool FlagRowObj::isActive (const QString &foname)
127 FlagObj *fo=findFlag (foname);
131 return fo->isActive();
133 qWarning ("FlagRowObj::isActive of "+name+" couldn't find "+foname);
140 void FlagRowObj::toggle (const QString &foname, bool exclusive)
142 FlagObj *fo=findFlag (foname);
145 // FlagObj is here, it will be active, too.
146 // Deactivate it by removing it from this row.
150 // FlagObj is not present in this row.
151 // Copy it from parentRow
152 fo=parentRow->findFlag (foname);
159 deactivateGroup (fo);
163 qWarning ("FlagRowObj ("+name+")::toggle ("+foname+") failed - could not find it in parentRow");
169 void FlagRowObj::activate (const QString &foname)
171 FlagObj *fo=findFlag (foname);
176 // FlagObj is not present in this row.
177 // Copy it from parentRow and activate there
178 fo=parentRow->findFlag (foname);
183 fo->setVisibility (visible);
186 qWarning ("FlagRowObj ("+name+")::activate ("+foname+") failed - could not find it in parentRow");
190 // I am the parentRow, mark flag as used
197 qWarning ("FlagRowObj::activate no FlagObj \""+foname+"\" found in parentRow");
202 void FlagRowObj::deactivate (const QString &foname)
204 FlagObj *fo=findFlag (foname);
205 if (fo) flag.remove(fo);
210 void FlagRowObj::deactivateAll ()
215 for (fo=flag.first();fo; fo=flag.next() )
218 qWarning ("FlagRowObj::deactivateAll mustn't be called for ordinary rows");
221 void FlagRowObj::deactivateGroup (FlagObj *keepfo)
223 // deactivate all flags in keepof, but keep keepfo [sic!]
227 for (fo=flag.first();fo; fo=flag.next() )
228 if (keepfo->getGroup()==fo->getGroup() && keepfo!=fo)
233 void FlagRowObj::setEnabled (bool b)
235 // If we have no parent, we are the default FlagRowObj
236 // and have QToolbarButtons
240 for (fo=flag.first();fo; fo=flag.next() )
245 void FlagRowObj::resetUsedCounter()
248 for (fo=flag.first();fo; fo=flag.next() )
252 QString FlagRowObj::saveToDir (const QString &tmpdir,const QString &prefix, bool writeflags)
258 for (fo=flag.first();fo; fo=flag.next() )
260 // save flag to xml, if flag is set
261 s+=valueElement("standardflag",fo->getName() );
263 // and tell parentRow, that this flag is used
264 parentRow->activate(fo->getName() );
267 // Save icons to dir, if verbose is set (xml export)
268 // and I am a parentRow
269 // and this flag is really used somewhere
271 for (fo=flag.first();fo; fo=flag.next() )
272 if (fo->isUsed()) fo->saveToDir (tmpdir,prefix);
277 void FlagRowObj::setName (const QString &n)
282 void FlagRowObj::makeToolbar (QMainWindow *w, const QString &n)
284 //Only make toolbar for the parentrow, not each row in branches
287 // create bar and buttons
288 QToolBar* tb = new QToolBar( w);
292 for (fo=flag.first();fo; fo=flag.next() )
302 a->setToggleAction(true);
303 // FIXME should not be enabled by default, later in updateToolbar
307 connect(a, SIGNAL( activated() ),
308 w, SLOT( standardFlagChanged() ) );
311 qWarning ("FlagRowObj::makeToolbar must not be called for ordinary rows");
314 void FlagRowObj::updateToolbar()
319 // We are just a branch, not the toolbar default
320 parentRow->deactivateAll();
321 // In parentRow activate all existing (==active) flags
322 for (fo=flag.first();fo; fo=flag.next() )
323 parentRow->activate(fo->getName());
324 parentRow->updateToolbar();
327 // We are the toolbar default
328 for (fo=flag.first();fo; fo=flag.next() )
333 FlagObj* FlagRowObj::findFlag (const QString &name)
336 for (fo=flag.first();fo; fo=flag.next() )
338 if (fo->getName()==name) return fo;