flagrowobj.cpp
changeset 366 e95081c21da2
parent 311 6a7db028088e
child 406 1c8ff1928b97
     1.1 --- a/flagrowobj.cpp	Tue Sep 05 09:47:13 2006 +0000
     1.2 +++ b/flagrowobj.cpp	Tue Sep 05 09:47:14 2006 +0000
     1.3 @@ -1,5 +1,7 @@
     1.4  #include "flagrowobj.h"
     1.5  
     1.6 +#include <QToolBar>
     1.7 +
     1.8  /////////////////////////////////////////////////////////////////
     1.9  // FlagRowObj
    1.10  /////////////////////////////////////////////////////////////////
    1.11 @@ -9,7 +11,7 @@
    1.12      init ();
    1.13  }
    1.14  
    1.15 -FlagRowObj::FlagRowObj(QCanvas* c):MapObj(c) 
    1.16 +FlagRowObj::FlagRowObj(Q3Canvas* c):MapObj(c) 
    1.17  {
    1.18  //    cout << "Const FlagRowObj\n";
    1.19      init ();
    1.20 @@ -232,15 +234,16 @@
    1.21  	}	
    1.22  }
    1.23  
    1.24 +void FlagRowObj::setToolBar(QToolBar *tb)
    1.25 +{
    1.26 +	toolbar=tb;
    1.27 +}
    1.28 +
    1.29  void FlagRowObj::setEnabled (bool b)
    1.30  {
    1.31 -	// If we have no parent, we are the default FlagRowObj
    1.32 -	// and have QToolbarButtons
    1.33 -	if (!parentRow)
    1.34 +	if (toolbar)
    1.35  	{
    1.36 -		FlagObj *fo;
    1.37 -		for (fo=flag.first();fo; fo=flag.next() )
    1.38 -			fo->setEnabled (b);
    1.39 +		toolbar->setEnabled (b);
    1.40  	}
    1.41  }
    1.42  
    1.43 @@ -286,44 +289,13 @@
    1.44  	name=n;
    1.45  }
    1.46  
    1.47 -void FlagRowObj::makeToolbar (QMainWindow *w, const QString &n)
    1.48 -{
    1.49 -	//Only make toolbar for the parentrow, not each row in branches
    1.50 -	if (!parentRow)
    1.51 -	{
    1.52 -		// create bar and buttons
    1.53 -		QToolBar* tb = new QToolBar( w);
    1.54 -		tb->setLabel (n);
    1.55 -		QAction *a;
    1.56 -		FlagObj *fo;
    1.57 -		for (fo=flag.first();fo; fo=flag.next() )
    1.58 -		{
    1.59 -			a=new QAction (
    1.60 -				fo->getToolTip(),
    1.61 -				fo->getPixmap(),
    1.62 -				fo->getName(),
    1.63 -				0,
    1.64 -				w,
    1.65 -				fo->getName()
    1.66 -			);
    1.67 -			a->setToggleAction(true);
    1.68 -			// FIXME should not be enabled by default, later in updateToolbar
    1.69 -			a->setEnabled(true);
    1.70 -			a->addTo (tb);
    1.71 -			fo->setButton (a);
    1.72 -			connect(a, SIGNAL( activated() ), 
    1.73 -					w, SLOT( standardFlagChanged() ) );
    1.74 -		}
    1.75 -	} else
    1.76 -		qWarning ("FlagRowObj::makeToolbar must not be called for ordinary rows");
    1.77 -}
    1.78 -
    1.79  void  FlagRowObj::updateToolbar()
    1.80  {
    1.81  	FlagObj *fo;
    1.82  	if (parentRow)
    1.83  	{
    1.84  		// We are just a branch, not the toolbar default
    1.85 +		// but state has to be copied from ourselves to parentrow!
    1.86  		parentRow->deactivateAll();
    1.87  		// In parentRow activate all existing (==active) flags
    1.88  		for (fo=flag.first();fo; fo=flag.next() ) 
    1.89 @@ -332,8 +304,12 @@
    1.90  	} else
    1.91  	{
    1.92  		// We are the toolbar default
    1.93 -		for (fo=flag.first();fo; fo=flag.next() ) 
    1.94 -			fo->updateButton();
    1.95 +		if (toolbar)
    1.96 +		{
    1.97 +			// Update state of actions in toolbar
    1.98 +			for (fo=flag.first();fo; fo=flag.next() ) 
    1.99 +				fo->updateAction();
   1.100 +		}	
   1.101  	}
   1.102  }
   1.103