Commit 25aec535 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - modules now have a Name property which is used for display in tree widget

Added several new config settings to customize the gui
parent a7978ee2
......@@ -42,6 +42,9 @@ compatiblesToolBarPos = 0 # position of the compatibles toolbar (overrides toolB
# Dataset Browser
# combineTreeAndRoiAndTextureSorter = yes # should the module tree, ROI tree and the Texture Sorter be combined in ONE Tab widget?
# dsbWidth = 400 # the width of the dataset browser
# dsbInvisibleByDefault = yes # hide the dataset browser on startup. Can be shown using F9.
# dsbFloatingByDefault = yes # should the dataset browser be undocked on startup?
####################################################################
# Other GUI settings
......
......@@ -48,6 +48,9 @@ compatiblesToolBarPos = 0 # position of the compatibles toolbar (overrides toolB
# Dataset Browser
# combineTreeAndRoiAndTextureSorter = yes # should the module tree, ROI tree and the Texture Sorter be combined in ONE Tab widget?
# dsbWidth = 400 # the width of the dataset browser
# dsbInvisibleByDefault = yes # hide the dataset browser on startup. Can be shown using F9.
# dsbFloatingByDefault = yes # should the dataset browser be undocked on startup?
####################################################################
# Other GUI settings
......
......@@ -26,6 +26,7 @@
#define WGEGROUPNODE_H
#include <queue>
#include <utility>
#include <boost/thread.hpp>
......
......@@ -88,6 +88,7 @@ void WMainWindow::setupGUI()
{
setObjectName( QString::fromUtf8( "MainWindow" ) );
}
// TODO(all): what is this?
resize( 946, 632 );
setWindowIcon( m_iconManager.getIcon( "logo" ) );
setWindowTitle( QApplication::translate( "MainWindow", "OpenWalnut (development version)", 0, QApplication::UnicodeUTF8 ) );
......@@ -98,6 +99,28 @@ void WMainWindow::setupGUI()
addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
m_datasetBrowser->addSubject( "Default Subject" );
// set the size of the dsb according to config file
int dsbWidth = 250;
if ( WPreferences::getPreference( "qt4gui.dsbWidth", &dsbWidth ) )
{
m_datasetBrowser->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
m_datasetBrowser->setMinimumWidth( dsbWidth );
}
// hide the DSB by default?
bool dsbInvisibleByDefault = false;
if ( WPreferences::getPreference( "qt4gui.dsbInvisibleByDefault", &dsbInvisibleByDefault ) )
{
m_datasetBrowser->setVisible( !dsbInvisibleByDefault );
}
// undock the DSB by default?
bool dsbFloatingByDefault = false;
if ( WPreferences::getPreference( "qt4gui.dsbFloatingByDefault", &dsbFloatingByDefault ) )
{
m_datasetBrowser->setFloating( dsbFloatingByDefault );
}
// NOTE: Please be aware that not every menu needs a shortcut key. If you add a shortcut, you should use one of the
// QKeySequence::StandardKey defaults and avoid ambiguities like Ctrl-C for the configure dialog is not the best choice as Ctrl-C, for the
// most users is the Copy shortcut.
......
......@@ -279,6 +279,13 @@ void WQtConfigWidget::registerComponents()
ctbpos->setMax( 3 );
m_defaultProperties->addProperty( "qt4gui.hideMenuBar", "Hide the menu bar.", false, m_propCondition );
WPropInt dsbWidth = m_defaultProperties->addProperty( "qt4gui.dsbWidth", "The width of the dataset browser.", 250, m_propCondition );
dsbWidth->setMin( 0 );
dsbWidth->setMax( 1000 );
m_defaultProperties->addProperty( "qt4gui.dsbInvisibleByDefault", "Hide the dataset browser on startup?", false, m_propCondition );
m_defaultProperties->addProperty( "qt4gui.dsbFloatingByDefault", "Undock the dataset browser on startup?", false, m_propCondition );
WPropGroup moduleWhiteList = m_defaultProperties->addPropertyGroup( "modules.whiteListGroup", "moduleWhiteList" );
m_skipPropertyWrite.push_back( "modules.whiteListGroup" );
WPropString whiteList = moduleWhiteList->addProperty( "modules.whiteList", "Modules that are whitelisted",
......
......@@ -24,64 +24,16 @@
#include <string>
#include <QtGui/QApplication>
#include "WTreeItemTypes.h"
#include "../events/WEventTypes.h"
#include "../events/WPropertyChangedEvent.h"
#include "WQtDatasetTreeItem.h"
namespace
{
std::string getNameFromPath( std::string path )
{
std::string name;
// remove the path up to the file name
if ( path != "" )
{
name = string_utils::tokenize( path, "/" ).back();
}
else
{
name = "";
}
return name;
}
}
WQtDatasetTreeItem::WQtDatasetTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module )
: WQtTreeItem( parent, DATASET, module )
{
// the update mechanism of WQtTreeItem sets the item text by using m_name. So we need to set the name only in m_name
m_name = "unnamed";
// replace the name by the filename
boost::shared_ptr< WPropertyBase > p = module->getInformationProperties()->findProperty( "Name" );
// always ensure that findProperty really found something
if ( p )
{
m_nameProp = p->toPropString();
}
// was it a string prop?
if ( m_nameProp )
{
m_nameProp->getUpdateCondition()->subscribeSignal( boost::bind( &WQtDatasetTreeItem::nameChanged, this ) );
m_name = getNameFromPath( m_nameProp->get() );
}
}
WQtDatasetTreeItem::~WQtDatasetTreeItem()
{
}
void WQtDatasetTreeItem::nameChanged()
{
// luckily, the update mechanism of WQtTreeItem regularily sets the name using m_name. So we do not even need to post some kind of event.
m_name = getNameFromPath( m_nameProp->get() );
}
......@@ -31,35 +31,28 @@
#include "WQtTreeItem.h"
/**
* tree widget item to represent a dataset in the dataset browser tree widget
* Tree widget item to represent a dataset in the dataset browser tree widget. This class is currently empty as all the functionality has been
* generalized and moved to WQtTreeItem. This class should be removed.
*/
class WQtDatasetTreeItem : public WQtTreeItem
{
public:
/**
* standard constructor
* Constructor
*
* \param parent The parent widget that manages this widget.
* \param module The module that will be represented by the item.
*/
WQtDatasetTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module );
/**
* destructor
* Destructor
*/
virtual ~WQtDatasetTreeItem();
protected:
/**
* The property containing the name of the module.
*/
WPropString m_nameProp;
/**
* Called when the name property changes.
*/
void nameChanged();
private:
};
......
......@@ -33,15 +33,18 @@
#include "../../../kernel/WModule.h"
/**
* TODO(schurade): Document this!
* Tree widget item to represent a module in the dataset browser tree widget. This class is currently empty as all the functionality has been
* generalized and moved to WQtTreeItem. This class should be removed.
*/
class WQtModuleTreeItem: public WQtTreeItem
{
public:
/**
* TODO(schurade): Document this!
* \param parent The widget managing this widget
* \param module The represented module
* Constructor
*
* \param parent The parent widget that manages this widget.
* \param module The module that will be represented by the item.
*/
WQtModuleTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module );
......
......@@ -36,6 +36,9 @@
#include "../../../kernel/WModuleOutputConnector.h"
#include "../events/WModuleDeleteEvent.h"
#include "../events/WEventTypes.h"
#include "../events/WPropertyChangedEvent.h"
#include "../WQt4Gui.h"
#include "../WMainWindow.h"
......@@ -61,6 +64,23 @@ WQtTreeItem::WQtTreeItem( QTreeWidgetItem * parent, WTreeItemType type, boost::s
this->setFlags( Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
// grab the runtime name property
// replace the name by the filename
boost::shared_ptr< WPropertyBase > p = module->getProperties()->findProperty( "Name" );
// always ensure that findProperty really found something
if ( p )
{
m_nameProp = p->toPropString();
}
// was it a string prop?
if ( m_nameProp )
{
m_name = m_nameProp->get( true );
m_nameProp->getUpdateCondition()->subscribeSignal( boost::bind( &WQtTreeItem::nameChanged, this ) );
}
m_updateTimer = boost::shared_ptr< QTimer >( new QTimer() );
connect( m_updateTimer.get(), SIGNAL( timeout() ), this, SLOT( update() ) );
m_updateTimer->start( 50 );
......@@ -195,3 +215,9 @@ void WQtTreeItem::gotRemoved()
m_deleteInProgress = true;
}
void WQtTreeItem::nameChanged()
{
// luckily, the update mechanism of WQtTreeItem regularly sets the name using m_name. So we do not even need to post some kind of event.
m_name = m_nameProp->get( true );
}
......@@ -117,12 +117,22 @@ protected:
*/
bool m_needPostDeleteEvent;
/**
* The property containing the name of the module.
*/
WPropString m_nameProp;
private:
/**
* The module represented by this tree item.
*/
boost::shared_ptr< WModule > m_module;
/**
* Called when the name property changes.
*/
void nameChanged();
};
#endif // WQTTREEITEM_H
......@@ -70,6 +70,10 @@ WModule::WModule():
m_infoProperties = boost::shared_ptr< WProperties >( new WProperties( "Informational Properties", "Module's information properties" ) );
m_infoProperties->setPurpose( PV_PURPOSE_INFORMATION );
m_runtimeName = m_properties->addProperty( "Name", "The name of the module defined by the user. This is, by default, the module name but "
"can be changed by the user to provide some kind of simple identification upon many modules.",
std::string( "" ), false );
m_active = m_properties->addProperty( "active", "Determines whether the module should be activated.", true, true );
m_active->getCondition()->subscribeSignal( boost::bind( &WModule::activate, this ) );
......@@ -159,9 +163,14 @@ void WModule::initialize()
throw WModuleConnectorInitFailed( "Could not initialize connectors for Module " + getName() + ". Reason: already initialized." );
}
// set the module name as default runtime name
m_runtimeName->set( getName() );
// initialize connectors and properties
connectors();
properties();
// now, the module is initialized but not necessarily usable (if not associated with a container)
m_initialized( true );
m_isUsable( m_initialized() && m_isAssociated() );
}
......
......@@ -493,6 +493,11 @@ protected:
*/
WPropBool m_active;
/**
* This property holds a user specified name for the current module instance.
*/
WPropString m_runtimeName;
private:
/**
......
......@@ -121,7 +121,7 @@ void WMData::properties()
{
// properties
m_dataName = m_infoProperties->addProperty( "Name", "The name of the dataset.", std::string( "" ) );
m_dataName = m_infoProperties->addProperty( "Filename", "The filename of the dataset.", std::string( "" ) );
// use this callback for the other properties
WPropertyBase::PropertyChangeNotifierType propertyCallback = boost::bind( &WMData::propertyChanged, this, _1 );
......@@ -221,6 +221,12 @@ void WMData::moduleMain()
debugLog() << "Loading data from \"" << fileName << "\".";
m_dataName->set( fileName );
// remove the path up to the file name and set it as a convenient name for this module instance
if ( fileName != "" )
{
m_runtimeName->set( string_utils::tokenize( fileName, "/" ).back() );
}
// load it now
std::string suffix = getSuffix( fileName );
......
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