Commit 62dd914f authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[FIX #471] avoid flickering by updating instead of replacing the compatibles toolbar

parent b6e755f9
......@@ -566,6 +566,11 @@ void WMainWindow::setCompatiblesToolbar( WQtCombinerToolbar* toolbar )
addToolBar( toQtToolBarArea( getCompatiblesToolbarPos() ), m_currentCompatiblesToolbar );
}
WQtCombinerToolbar* WMainWindow::getCompatiblesToolbar()
{
return m_currentCompatiblesToolbar;
}
WQtControlPanel* WMainWindow::getControlPanel()
{
return m_controlPanel;
......
......@@ -162,6 +162,13 @@ public:
*/
void setCompatiblesToolbar( WQtCombinerToolbar* toolbar = NULL );
/**
* This method returns the a pointer to the current compatibles toolbar.
*
* \return a pointer to the current compatibles toolbar.
*/
WQtCombinerToolbar* getCompatiblesToolbar();
protected:
/**
......
......@@ -39,7 +39,8 @@
#include "WQtCombinerToolbar.h"
WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, WCombinerTypes::WCompatiblesList compatibles )
: QToolBar( "Compatible Modules", parent )
: QToolBar( "Compatible Modules", parent ),
m_parent( parent )
{
// setup toolbar
setAllowedAreas( Qt::AllToolBarAreas );
......@@ -80,3 +81,9 @@ WQtCombinerToolbar::~WQtCombinerToolbar()
{
}
void WQtCombinerToolbar::updateButtons( WCombinerTypes::WCompatiblesList compatibles )
{
clear();
// create the list of actions possible
addActions( WQtCombinerActionList( this, m_parent->getIconManager(), compatibles ) );
}
......@@ -51,9 +51,17 @@ public:
*/
virtual ~WQtCombinerToolbar();
/**
* Update the toolbar to represent the compatibles given as parameter.
*
* \param compatibles The compatibles to produce the buttons for.
*/
void updateButtons( WCombinerTypes::WCompatiblesList compatibles );
protected:
private:
WMainWindow* m_parent;
};
#endif // WQTCOMBINERTOOLBAR_H
......@@ -622,8 +622,6 @@ void WQtControlPanel::selectTreeItem()
boost::shared_ptr< WProperties > props;
boost::shared_ptr< WProperties > infoProps;
WQtCombinerToolbar* newToolbar = NULL;
if ( m_moduleTreeWidget->selectedItems().size() != 0 )
{
// disable delete action for tree items that have children.
......@@ -642,7 +640,7 @@ void WQtControlPanel::selectTreeItem()
case MODULEHEADER:
// deletion of headers and subjects is not allowed
m_deleteModuleAction->setEnabled( false );
newToolbar = createCompatibleButtons( module ); // module is NULL at this point
createCompatibleButtons( module ); // module is NULL at this point
break;
case DATASET:
module = ( static_cast< WQtDatasetTreeItem* >( m_moduleTreeWidget->selectedItems().at( 0 ) ) )->getModule();
......@@ -654,7 +652,7 @@ void WQtControlPanel::selectTreeItem()
props = module->getProperties();
infoProps = module->getInformationProperties();
newToolbar = createCompatibleButtons( module );
createCompatibleButtons( module );
{
boost::shared_ptr< WMData > dataModule = boost::shared_dynamic_cast< WMData >( module );
......@@ -693,7 +691,7 @@ void WQtControlPanel::selectTreeItem()
}
props = module->getProperties();
infoProps = module->getInformationProperties();
newToolbar = createCompatibleButtons( module );
createCompatibleButtons( module );
}
break;
case ROIHEADER:
......@@ -705,9 +703,6 @@ void WQtControlPanel::selectTreeItem()
}
}
// set the new toolbar
// NOTE: setCompatiblesToolbar removes the toolbar if NULL is specified.
m_mainWindow->setCompatiblesToolbar( newToolbar );
buildPropTab( props, infoProps );
}
......@@ -861,7 +856,7 @@ void WQtControlPanel::buildPropTab( boost::shared_ptr< WProperties > props, boos
}
}
WQtCombinerToolbar* WQtControlPanel::createCompatibleButtons( boost::shared_ptr< WModule >module )
void WQtControlPanel::createCompatibleButtons( boost::shared_ptr< WModule > module )
{
// every module may have compatibles: create ribbon menu entry
// NOTE: if module is NULL, getCompatiblePrototypes returns the list of modules without input connector (nav slices and so on)
......@@ -894,7 +889,14 @@ WQtCombinerToolbar* WQtControlPanel::createCompatibleButtons( boost::shared_ptr<
delete( m_disconnectAction->menu() ); // ensure that combiners get free'd
m_disconnectAction->setMenu( m );
return new WQtCombinerToolbar( m_mainWindow, comps );
if( m_mainWindow->getCompatiblesToolbar() != 0 )
{
m_mainWindow->getCompatiblesToolbar()->updateButtons( comps );
}
else
{
m_mainWindow->setCompatiblesToolbar( new WQtCombinerToolbar( m_mainWindow, comps ) );
}
}
void WQtControlPanel::changeTreeItem()
......
......@@ -190,9 +190,8 @@ protected:
*
* \param module pointer to the currently selected module
*
* \return the new toolbar instance
*/
WQtCombinerToolbar* createCompatibleButtons( boost::shared_ptr< WModule >module );
void createCompatibleButtons( boost::shared_ptr< WModule > module );
/**
* Reference to the main window of the application.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment