3 /////////////////////////////////////////////////////////////////
5 /////////////////////////////////////////////////////////////////
8 // cout << "Const FlagObj ()\n";
12 FlagObj::FlagObj(QGraphicsScene* s):MapObj(s)
14 // cout << "Const FlagObj this="<<this<<" scene="<<s<<endl;
18 FlagObj::FlagObj (FlagObj* io)
25 // cout << "Destr FlagObj this="<<this <<" " << name.ascii() << "\n";
26 if (icon) delete (icon);
35 icon=new ImageObj (scene);
36 icon->setPos (absPos.x(), absPos.y() );
41 void FlagObj::copy (FlagObj* other)
46 tooltip=other->tooltip;
48 icon->copy(other->icon);
50 setVisibility (other->isVisibleObj() );
53 void FlagObj::move(double x, double y)
60 void FlagObj::moveBy(double x, double y)
62 move (x+absPos.x(),y+absPos.y() );
65 void FlagObj::setVisibility (bool v)
67 MapObj::setVisibility(v);
69 icon->setVisibility(true);
71 icon->setVisibility(false);
74 void FlagObj::load (const QString &fn)
81 void FlagObj::load (const QPixmap &pm)
88 void FlagObj::setName(const QString &n)
93 const QString FlagObj::getName()
98 void FlagObj::setGroup (const QString &n)
103 const QString FlagObj::getGroup()
108 void FlagObj::setToolTip(const QString &n)
113 const QString FlagObj::getToolTip()
118 QPixmap FlagObj::getPixmap()
120 return icon->pixmap();
123 void FlagObj::setAction (QAction* a)
128 void FlagObj::updateAction ()
130 if (action) action->setChecked(state);
133 bool FlagObj::isActive()
138 void FlagObj::toggle()
146 void FlagObj::activate()
149 // only show icon, if flag itself is visible
152 icon->setVisibility (true);
153 //icon->setPos (100,100);
154 //icon->setPos (rand()%100,rand()%130);
159 void FlagObj::deactivate()
162 // if flag itself is invisible we don't need to call
165 icon->setVisibility (false);
170 void FlagObj::setUsed (bool b)
175 bool FlagObj::isUsed()
180 void FlagObj::saveToDir (const QString &tmpdir, const QString &prefix)
182 QString fn=tmpdir + prefix + name + ".png";
183 icon->save (fn,"PNG");
186 void FlagObj::positionBBox()
188 bbox.moveTopLeft (absPos );
189 clickBox.moveTopLeft (absPos );
192 void FlagObj::calcBBoxSize()
194 if (visible && state)
196 bbox.setSize ( QSizeF(
197 icon->boundingRect().width(),
198 icon->boundingRect().height() ) );
201 bbox.setSize (QSizeF(0,0));
203 clickBox.setSize (bbox.size());