diff -r 1cc73bd7ee1f -r e95081c21da2 flagrowobj.cpp --- a/flagrowobj.cpp Tue Sep 05 09:47:13 2006 +0000 +++ b/flagrowobj.cpp Tue Sep 05 09:47:14 2006 +0000 @@ -1,5 +1,7 @@ #include "flagrowobj.h" +#include + ///////////////////////////////////////////////////////////////// // FlagRowObj ///////////////////////////////////////////////////////////////// @@ -9,7 +11,7 @@ init (); } -FlagRowObj::FlagRowObj(QCanvas* c):MapObj(c) +FlagRowObj::FlagRowObj(Q3Canvas* c):MapObj(c) { // cout << "Const FlagRowObj\n"; init (); @@ -232,15 +234,16 @@ } } +void FlagRowObj::setToolBar(QToolBar *tb) +{ + toolbar=tb; +} + void FlagRowObj::setEnabled (bool b) { - // If we have no parent, we are the default FlagRowObj - // and have QToolbarButtons - if (!parentRow) + if (toolbar) { - FlagObj *fo; - for (fo=flag.first();fo; fo=flag.next() ) - fo->setEnabled (b); + toolbar->setEnabled (b); } } @@ -286,44 +289,13 @@ name=n; } -void FlagRowObj::makeToolbar (QMainWindow *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); - tb->setLabel (n); - QAction *a; - FlagObj *fo; - for (fo=flag.first();fo; fo=flag.next() ) - { - a=new QAction ( - fo->getToolTip(), - fo->getPixmap(), - fo->getName(), - 0, - w, - fo->getName() - ); - a->setToggleAction(true); - // FIXME should not be enabled by default, later in updateToolbar - a->setEnabled(true); - a->addTo (tb); - fo->setButton (a); - connect(a, SIGNAL( activated() ), - w, SLOT( standardFlagChanged() ) ); - } - } else - qWarning ("FlagRowObj::makeToolbar must not be called for ordinary rows"); -} - void FlagRowObj::updateToolbar() { FlagObj *fo; 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 (fo=flag.first();fo; fo=flag.next() ) @@ -332,8 +304,12 @@ } else { // We are the toolbar default - for (fo=flag.first();fo; fo=flag.next() ) - fo->updateButton(); + if (toolbar) + { + // Update state of actions in toolbar + for (fo=flag.first();fo; fo=flag.next() ) + fo->updateAction(); + } } }