1.1 --- a/flagrowobj.cpp Thu Nov 23 16:18:26 2006 +0000
1.2 +++ b/flagrowobj.cpp Fri Dec 08 20:18:56 2006 +0000
1.3 @@ -11,9 +11,9 @@
1.4 init ();
1.5 }
1.6
1.7 -FlagRowObj::FlagRowObj(Q3Canvas* c):MapObj(c)
1.8 +FlagRowObj::FlagRowObj(QGraphicsScene* s):MapObj(s)
1.9 {
1.10 -// cout << "Const FlagRowObj\n";
1.11 +// cout << "Const FlagRowObj (s)\n";
1.12 init ();
1.13 }
1.14
1.15 @@ -53,11 +53,11 @@
1.16 void FlagRowObj::move(double x, double y)
1.17 {
1.18 MapObj::move(x,y);
1.19 - int dx=0;
1.20 + qreal dx=0;
1.21 for (int i=0; i<flag.size(); ++i)
1.22 {
1.23 flag.at(i)->move(x+dx,y);
1.24 - dx+=QSize(flag.at(i)->getSize() ).width();
1.25 + dx+=QSizeF(flag.at(i)->getSize() ).width();
1.26 }
1.27 }
1.28
1.29 @@ -75,9 +75,9 @@
1.30
1.31 FlagObj* FlagRowObj::addFlag (FlagObj *fo)
1.32 {
1.33 - FlagObj *newfo=new FlagObj (canvas);
1.34 + FlagObj *newfo=new FlagObj (scene);
1.35 + newfo->copy (fo); // create a deep copy of fo
1.36 newfo->move (absPos.x() + bbox.width(), absPos.y() );
1.37 - newfo->copy (fo); // create a deep copy of fo
1.38 flag.append(newfo);
1.39 calcBBoxSize();
1.40 positionBBox();
1.41 @@ -92,8 +92,8 @@
1.42
1.43 void FlagRowObj::calcBBoxSize()
1.44 {
1.45 - QSize size(0,0);
1.46 - QSize boxsize(0,0);
1.47 + QSizeF size(0,0);
1.48 + QSizeF boxsize(0,0);
1.49 for (int i=0; i<flag.size(); ++i)
1.50 {
1.51 size=flag.at(i)->getSize();
1.52 @@ -107,7 +107,7 @@
1.53 clickBox.setSize (boxsize);
1.54 }
1.55
1.56 -QString FlagRowObj::getFlagName (const QPoint &p)
1.57 +QString FlagRowObj::getFlagName (const QPointF &p)
1.58 {
1.59 if (!inBox (p)) return "";
1.60 for (int i=0; i<flag.size(); ++i)
1.61 @@ -135,6 +135,7 @@
1.62 // FlagObj is here, it will be active, too.
1.63 // Deactivate it by removing it from this row.
1.64 flag.remove (fo);
1.65 + delete (fo);
1.66 } else
1.67 {
1.68 // FlagObj is not present in this row.
1.69 @@ -197,7 +198,11 @@
1.70 void FlagRowObj::deactivate (const QString &foname)
1.71 {
1.72 FlagObj *fo=findFlag (foname);
1.73 - if (fo) flag.remove(fo);
1.74 + if (fo)
1.75 + {
1.76 + flag.remove(fo);
1.77 + delete (fo);
1.78 + }
1.79 calcBBoxSize();
1.80 positionBBox();
1.81 }
1.82 @@ -207,7 +212,7 @@
1.83 if (!parentRow)
1.84 {
1.85 for (int i=0; i<flag.size(); ++i)
1.86 - flag.at(i)->deactivate();
1.87 + if (flag.at(i)->isActive()) flag.at(i)->deactivate();
1.88 } else
1.89 qWarning ("FlagRowObj::deactivateAll mustn't be called for ordinary rows");
1.90 }
1.91 @@ -222,7 +227,11 @@
1.92 {
1.93 for (int i=0; i<flag.size(); ++i)
1.94 if (g==flag.at(i)->getGroup() && keepfo!=flag.at(i))
1.95 + {
1.96 flag.remove(flag.at(i));
1.97 + //FIXME also delete flags
1.98 + //and better only delete flags that are really set
1.99 + }
1.100 }
1.101 }
1.102 }