diff -r 7a71a914afdb -r 988f1908a7c4 flagrowobj.cpp --- a/flagrowobj.cpp Thu May 07 08:48:53 2009 +0000 +++ b/flagrowobj.cpp Fri Jul 23 16:43:49 2010 +0000 @@ -3,6 +3,7 @@ #include using namespace std; +#include "flag.h" #include "flagrowobj.h" #include "geometry.h" @@ -31,30 +32,17 @@ void FlagRowObj::init () { - parentRow=NULL; showFlags=true; } void FlagRowObj::copy (FlagRowObj* other) { MapObj::copy(other); - parentRow=other->parentRow; flag.clear(); for (int i=0; igetName()); + return list; +} + void FlagRowObj::positionBBox() { bbox.moveTopLeft(absPos ); @@ -124,84 +120,28 @@ bool FlagRowObj::isActive (const QString &foname) { + FlagObj *fo=findFlag (foname); - if (parentRow && fo) - return fo->isActive(); + if (fo) + return true; else - if (fo) return true; - return false; + return false; } -void FlagRowObj::toggle (const QString &foname) +void FlagRowObj::activate (Flag *flag) { - FlagObj *fo=findFlag (foname); - if (fo) + if (flag) { - // FlagObj is here, it will be active, too. - // Deactivate it by removing it from this row. - flag.remove (fo); - delete (fo); - } else - { - // FlagObj is not present in this row. - // Copy it from parentRow - fo=parentRow->findFlag (foname); - if (fo) - { - fo=addFlag (fo); - fo->activate(); - /*FIXME-0 move to VM if (exclusive) - { - deactivateGroup (fo); - updateToolbar(); - } - */ - } else - qWarning ("FlagRowObj ("+name+")::toggle ("+foname+") failed - could not find it in parentRow"); - } - calcBBoxSize(); - positionBBox(); -} - -void FlagRowObj::activate (const QString &foname) -{ - cout << "FRO::activate "<findFlag (foname); - if (fo) - { - fo=addFlag (fo); - fo->activate(); - if (showFlags) - fo->setVisibility (visible); - else - fo->setVisibility (false); - calcBBoxSize(); - } else - qWarning ("FlagRowObj ("+name+")::activate ("+foname+") failed - could not find it in parentRow"); - } - } else - { - // I am the parentRow, mark flag as used - if (fo) - { - fo->setUsed(true); - fo->activate(); - } + FlagObj *fo=addFlag (new FlagObj (flag)); + fo->activate(); + if (showFlags) // FIXME-3 necessary? only called from FIO::init + fo->setVisibility (visible); else - qWarning ("FlagRowObj::activate no FlagObj \""+foname+"\" found in parentRow"); + fo->setVisibility (false); + calcBBoxSize(); } } - void FlagRowObj::deactivate (const QString &foname) { FlagObj *fo=findFlag (foname); @@ -214,116 +154,11 @@ positionBBox(); } -void FlagRowObj::deactivateAll () -{ - if (!parentRow) - { - for (int i=0; iisActive()) flag.at(i)->deactivate(); - } else - { - while (!flag.isEmpty()) - delete flag.takeFirst(); - calcBBoxSize(); - positionBBox(); - } -} - -void FlagRowObj::deactivateGroup (FlagObj *keepfo) //FIXME-0 move to VM -{ - // deactivate all flags in keepof, but keep keepfo [sic!] - if (keepfo) - { - QString g=keepfo->getGroup(); - if (g!="undefined") - { - for (int i=0; igetGroup() && keepfo!=flag.at(i)) - { - FlagObj *fo=flag.at(i); - flag.remove (fo); - delete (fo); - } - } - } -} - -void FlagRowObj::setToolBar(QToolBar *tb) -{ - toolbar=tb; -} - -void FlagRowObj::setEnabled (bool b) -{ - if (toolbar) - { - toolbar->setEnabled (b); - } -} - void FlagRowObj::setShowFlags (bool b) { showFlags=b; } -void FlagRowObj::resetUsedCounter() -{ - for (int i=0; isetUsed (false); -} - -QString FlagRowObj::saveToDir (const QString &tmpdir,const QString &prefix, bool writeflags) -{ - // Build xml string - QString s; - if (parentRow) - for (int i=0; igetName() ); - - // and tell parentRow, that this flag is used - parentRow->activate(flag.at(i)->getName() ); - } - else - // Save icons to dir, if verbose is set (xml export) - // and I am a parentRow - // and this flag is really used somewhere - if (writeflags) - for (int i=0; iisUsed()) flag.at(i)->saveToDir (tmpdir,prefix); - return s; - -} - -void FlagRowObj::setName (const QString &n) -{ - name=n; -} - -void FlagRowObj::updateToolbar() //FIXME-2 this needs to be changed with VM -{ - if (parentRow) - { - // We are just a branch, not the toolbar default - // but state has to be copied from ourselves to parentrow! - parentRow->deactivateAll(); - // In parentRow activate all existing (==active) flags - for (int i=0; iactivate(flag.at(i)->getName()); - parentRow->updateToolbar(); - } else - { - // We are the toolbar default - if (toolbar) - { - // Update state of actions in toolbar - for (int i=0; iupdateAction(); - } - } -} - FlagObj* FlagRowObj::findFlag (const QString &name) { for (int i=0; i