diff -r 9eb7767c2dfa -r 608f976aa7bb flagrowobj.cpp --- a/flagrowobj.cpp Sun Jan 30 12:58:47 2005 +0000 +++ b/flagrowobj.cpp Tue Jun 06 14:58:11 2006 +0000 @@ -5,11 +5,11 @@ ///////////////////////////////////////////////////////////////// FlagRowObj::FlagRowObj() { - cout << "Const FlagRowObj ()\n"; +// cout << "Const FlagRowObj ()\n"; init (); } -FlagRowObj::FlagRowObj(QCanvas* c):MapObj(c) +FlagRowObj::FlagRowObj(Q3Canvas* c):MapObj(c) { // cout << "Const FlagRowObj\n"; init (); @@ -25,6 +25,7 @@ { flag.setAutoDelete (true); parentRow=NULL; + showFlags=true; } void FlagRowObj::copy (FlagRowObj* other) @@ -86,8 +87,8 @@ void FlagRowObj::positionBBox() { - bbox.setX (absPos.x() ); - bbox.setY (absPos.y() ); + bbox.moveTopLeft(absPos ); + clickBox.moveTopLeft(absPos ); } void FlagRowObj::calcBBoxSize() @@ -104,15 +105,16 @@ if (size.height() > boxsize.height() ) boxsize.setHeight(size.height() ); } - bbox.setSize (QSize(boxsize.width(), boxsize.height() )); + bbox.setSize (boxsize); + clickBox.setSize (boxsize); } QString FlagRowObj::getFlagName (const QPoint &p) { - if (!inBBox (p)) return ""; + if (!inBox (p)) return ""; FlagObj *fo; for (fo=flag.first();fo; fo=flag.next() ) - if (fo->inBBox (p)) return fo->getName(); + if (fo->inBox (p)) return fo->getName(); return ""; @@ -121,19 +123,14 @@ bool FlagRowObj::isActive (const QString &foname) { FlagObj *fo=findFlag (foname); - if (parentRow) - { - if (fo) - return fo->isActive(); - else - qWarning ("FlagRowObj::isActive of "+name+" couldn't find "+foname); - - } else + if (parentRow && fo) + return fo->isActive(); + else if (fo) return true; return false; } -void FlagRowObj::toggle (const QString &foname) +void FlagRowObj::toggle (const QString &foname, bool exclusive) { FlagObj *fo=findFlag (foname); if (fo) @@ -150,6 +147,11 @@ { fo=addFlag (fo); fo->activate(); + if (exclusive) + { + deactivateGroup (fo); + updateToolbar(); + } } else qWarning ("FlagRowObj ("+name+")::toggle ("+foname+") failed - could not find it in parentRow"); } @@ -159,6 +161,8 @@ void FlagRowObj::activate (const QString &foname) { + // Note: "activate" is also called during loading of a map + // Here we do not check for exclusive flags! FlagObj *fo=findFlag (foname); if (parentRow) { @@ -171,9 +175,11 @@ { fo=addFlag (fo); fo->activate(); - fo->setVisibility (visible); + if (showFlags) + fo->setVisibility (visible); + else + fo->setVisibility (false); calcBBoxSize(); - positionBBox(); } else qWarning ("FlagRowObj ("+name+")::activate ("+foname+") failed - could not find it in parentRow"); } @@ -190,6 +196,7 @@ } } + void FlagRowObj::deactivate (const QString &foname) { FlagObj *fo=findFlag (foname); @@ -204,13 +211,27 @@ { FlagObj *fo; for (fo=flag.first();fo; fo=flag.next() ) - { fo->deactivate(); - } } else qWarning ("FlagRowObj::deactivateAll mustn't be called for ordinary rows"); } +void FlagRowObj::deactivateGroup (FlagObj *keepfo) +{ + // deactivate all flags in keepof, but keep keepfo [sic!] + if (keepfo) + { + QString g=keepfo->getGroup(); + if (g!="undefined") + { + FlagObj *fo; + for (fo=flag.first();fo; fo=flag.next() ) + if (g==fo->getGroup() && keepfo!=fo) + flag.remove(fo); + } + } +} + void FlagRowObj::setEnabled (bool b) { // If we have no parent, we are the default FlagRowObj @@ -223,6 +244,11 @@ } } +void FlagRowObj::setShowFlags (bool b) +{ + showFlags=b; +} + void FlagRowObj::resetUsedCounter() { FlagObj *fo; @@ -260,26 +286,28 @@ name=n; } -void FlagRowObj::makeToolbar (QMainWindow *w, const QString &n) +void FlagRowObj::makeToolbar (Q3MainWindow *w, const QString &n) { + //Only make toolbar for the parentrow, not each row in branches if (!parentRow) { // create bar and buttons - QToolBar* tb = new QToolBar( w); + Q3ToolBar* tb = new Q3ToolBar( w); tb->setLabel (n); QAction *a; FlagObj *fo; for (fo=flag.first();fo; fo=flag.next() ) { a=new QAction ( - fo->getToolTip(), +// FIXME was in QT3: fo->getToolTip(), fo->getPixmap(), fo->getName(), - 0, - w, - fo->getName() +// 0, + w +// fo->getName() ); a->setToggleAction(true); +// a->setTooltip (fo->getToolTip()); // FIXME should not be enabled by default, later in updateToolbar a->setEnabled(true); a->addTo (tb); @@ -288,10 +316,10 @@ w, SLOT( standardFlagChanged() ) ); } } else - qWarning ("FlagRowObj::makeToolbar mustn't be called for ordinary rows"); + qWarning ("FlagRowObj::makeToolbar must not be called for ordinary rows"); } -void FlagRowObj::updateToolBar() +void FlagRowObj::updateToolbar() { FlagObj *fo; if (parentRow) @@ -301,7 +329,7 @@ // In parentRow activate all existing (==active) flags for (fo=flag.first();fo; fo=flag.next() ) parentRow->activate(fo->getName()); - parentRow->updateToolBar(); + parentRow->updateToolbar(); } else { // We are the toolbar default