7 #include "flagrowobj.h"
11 /////////////////////////////////////////////////////////////////
13 /////////////////////////////////////////////////////////////////
14 FlagRowObj::FlagRowObj()
16 // cout << "Const FlagRowObj ()\n";
20 FlagRowObj::FlagRowObj(QGraphicsScene* s):MapObj(s)
22 // cout << "Const FlagRowObj (s)\n";
26 FlagRowObj::~FlagRowObj()
28 //cout << "Destr FlagRowObj\n";
29 while (!flag.isEmpty())
30 delete (flag.takeFirst() );
33 void FlagRowObj::init ()
38 void FlagRowObj::copy (FlagRowObj* other)
42 for (int i=0; i<flag.size(); ++i)
46 void FlagRowObj::move(double x, double y)
50 for (int i=0; i<flag.size(); ++i)
52 flag.at(i)->move(x+dx,y);
53 dx+=QSizeF(flag.at(i)->getSize() ).width();
57 void FlagRowObj::moveBy(double x, double y)
59 move (x+absPos.x(),y+absPos.y() );
62 void FlagRowObj::setVisibility (bool v)
64 MapObj::setVisibility(v);
65 for (int i=0; i<flag.size(); ++i)
66 flag.at(i)->setVisibility (v);
69 FlagObj* FlagRowObj::addFlag (FlagObj *fo)
71 FlagObj *newfo=new FlagObj (scene);
72 newfo->copy (fo); // create a deep copy of fo
73 newfo->move (absPos.x() + bbox.width(), absPos.y() );
80 QStringList FlagRowObj::activeFlagNames()
83 for (int i=0; i<flag.size(); ++i)
84 list.append (flag.at(i)->getName());
88 void FlagRowObj::positionBBox()
90 bbox.moveTopLeft(absPos );
91 clickBox.moveTopLeft(absPos );
94 void FlagRowObj::calcBBoxSize()
98 for (int i=0; i<flag.size(); ++i)
100 size=flag.at(i)->getSize();
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 QPointF &p)
113 if (!isInBox (p,clickBox)) return "";
114 for (int i=0; i<flag.size(); ++i)
115 if (isInBox (p,flag.at(i)->getClickBox ())) return flag.at(i)->getName();
121 bool FlagRowObj::isActive (const QString &foname)
124 FlagObj *fo=findFlag (foname);
131 void FlagRowObj::activate (Flag *flag)
135 FlagObj *fo=addFlag (new FlagObj (flag));
137 if (showFlags) // FIXME-3 necessary? only called from FIO::init
138 fo->setVisibility (visible);
140 fo->setVisibility (false);
145 void FlagRowObj::deactivate (const QString &foname)
147 FlagObj *fo=findFlag (foname);
157 void FlagRowObj::setShowFlags (bool b)
162 FlagObj* FlagRowObj::findFlag (const QString &name)
164 for (int i=0; i<flag.size(); ++i)
165 if (flag.at(i)->getName()==name) return flag.at(i);