Commit f9937d71 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

Merge branch 'master'

parents d6493d8a 0f9a49d4
......@@ -33,6 +33,7 @@
#include <QtCore/QDir>
#include <QCheckBox>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QGridLayout>
......@@ -115,8 +116,74 @@ WQtModuleConfig::WQtModuleConfig( QWidget* parent, Qt::WindowFlags f ):
m_asBlackList = new QCheckBox( "Use as black-list", this );
m_asBlackList->setToolTip( "Activate this option if you want all modules to be active in OpenWalnut that are not explicitly deactivated here." );
connect( m_asBlackList, SIGNAL( stateChanged( int ) ), this, SLOT( showBlacklistPresetOptions() ) );
layoutAllowedModules->addWidget( m_asBlackList );
QHBoxLayout* blacklistPresetRow = new QHBoxLayout();
layoutAllowedModules->addLayout( blacklistPresetRow );
m_usePreset = new QCheckBox( "Use a preset module list", this );
m_usePreset->setToolTip( "Activate this option if you want to use a preset of preselected "
"modules which may be specific for different research areas. "
"To activate this checkbox, you must use the list in black-list mode." );
m_usePreset->setDisabled( true );
if( m_asBlackList->checkState() )
{
m_usePreset->setDisabled( false );
}
connect( m_usePreset, SIGNAL( stateChanged( int ) ), this, SLOT( resetAllModuleCheckboxes() ) );
blacklistPresetRow->addWidget( m_usePreset );
// Set presets here
QString presetSIVERT = "Anisotropic Filter,Calculate GFA,Calculate Tensors,Cluster Display,ClusterDisplayVoxels,"
"Data Type Conversion,Diffusion Tensor Scalars,EEG View,Effective Connectivity Cluster,Fiber Data Creator,"
"Fiber translator,Functional MRI Viewer,Hierarchical Clustering Display,Image Space LIC,Image Space Tensor LIC,"
"Merge Components To Vector,Mori Det. Tracking,Partition To Mesh,Picking in DVR Evaluation,"
"Probabilistic Tract Rendering with multi transparent iso surfaces.,"
"Read Amira Mesh,Read Dipoles,Read Raw Data,Read Simple Text Line Data,Read Spherical Harmonics,Read VCL,"
"Read VIM,Scalar Data Creator,Spline Surface,Superquadric Glyphs,Surface Parameter Animator,"
"Template,Template Colormapping,Template Containers,Template Data Loader,Template Render Pipelines,"
"Template Shaders,Template UI,Vector Align,Vector Data Creator,Vector Normalize,Vector Operator,"
"Vector Plot,Vector Scaling,WebGL Support,Write Amira Mesh,Write Dendrogram,";
WQtGui::getSettings().setValue( "qtgui/modules/preset/ ", QString::fromStdString( "" ) );
WQtGui::getSettings().setValue( "qtgui/modules/preset/SIVERT", presetSIVERT );
// combobox for black-list presets
m_selectPresetBlacklist = new QComboBox( this );
m_selectPresetBlacklist->setToolTip( "Select a black-list preset or create a new one by selecting modules in the list below "
"and type in a name here. The selected preset is only active when you've checked the "
"black-list and the use-preset checkbox!" );
m_selectPresetBlacklist->setFixedSize( 120, 26 );
m_selectPresetBlacklist->setEditable( true );
m_selectPresetBlacklist->setInsertPolicy( QComboBox::InsertAtBottom );
// read preset names from settings
QSettings* settings = &WQtGui::getSettings();
settings->beginGroup( "qtgui/modules/preset/" );
QStringList childKeys = settings->childKeys();
m_selectPresetBlacklist->addItems( childKeys );
settings->endGroup();
int selectedPresetIndex = m_selectPresetBlacklist->findText( WQtGui::getSettings().value( "qtgui/modules/selectedPreset", "" ).toString() );
// -1 means selectedPresetIndex not found
if( selectedPresetIndex != -1 )
{
m_selectPresetBlacklist->setCurrentIndex( selectedPresetIndex );
}
else
{
m_selectPresetBlacklist->setCurrentIndex( 0 );
}
m_selectPresetBlacklist->setDisabled( true );
if( m_asBlackList->checkState() )
{
m_selectPresetBlacklist->setDisabled( false );
}
connect( m_selectPresetBlacklist, SIGNAL( editTextChanged( QString ) ), this, SLOT( comboboxItemChanged( QString ) ) );
blacklistPresetRow->addWidget( m_selectPresetBlacklist );
QSpacerItem* horizSpacer = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed );
blacklistPresetRow->addSpacerItem( horizSpacer );
// create the module list
m_list = new QListWidget();
layoutAllowedModules->addWidget( m_list );
......@@ -236,11 +303,24 @@ void WQtModuleConfig::loadListsFromSettings( bool defaultModulePaths )
bool asBlackList = WQtGui::getSettings().value( "qtgui/modules/asBlackList", false ).toBool();
m_asBlackList->setCheckState( asBlackList ? Qt::Checked : Qt::Unchecked );
bool usePreset = WQtGui::getSettings().value( "qtgui/modules/usePreset", false ).toBool();
m_usePreset->setCheckState( usePreset ? Qt::Checked : Qt::Unchecked );
std::string allowedModules = "";
// read settings
std::string allowedModules = WQtGui::getSettings().value( "qtgui/modules/allowedList", "" ).toString().toStdString();
if( usePreset )
{
allowedModules = WQtGui::getSettings().value( "qtgui/modules/preset/" + m_selectPresetBlacklist->currentText(), "" ).toString().toStdString();
}
else
{
allowedModules = WQtGui::getSettings().value( "qtgui/modules/allowedList", "" ).toString().toStdString();
}
m_allowedModules = string_utils::tokenize( allowedModules, "," );
// set dialog according to the settings
// set dialog according to the settings
for( AllowedModuleList::const_iterator iter = m_allowedModules.begin(); iter != m_allowedModules.end(); ++iter )
{
if( m_moduleItemMap.count( *iter ) )
......@@ -285,6 +365,15 @@ void WQtModuleConfig::saveListToSettings()
WQtGui::getSettings().setValue( "qtgui/modules/IgnoreAllowedList", ( m_showThemAll->checkState() == Qt::Checked ) );
WQtGui::getSettings().setValue( "qtgui/modules/asBlackList", ( m_asBlackList->checkState() == Qt::Checked ) );
WQtGui::getSettings().setValue( "qtgui/modules/usePreset", m_usePreset->checkState() );
WQtGui::getSettings().setValue( "qtgui/modules/selectedPreset", m_selectPresetBlacklist->currentText() );
// -1 means, that the preset name is not in the list of presets
if( m_selectPresetBlacklist->findText( m_selectPresetBlacklist->currentText() ) == -1 )
{
WQtGui::getSettings().setValue( "qtgui/modules/preset/" + m_selectPresetBlacklist->currentText(), QString::fromStdString( allowedAsString ) );
}
// also write the path list
QList< QVariant > paths;
for( int i = 0; i < m_pathList->count(); ++i )
......@@ -352,16 +441,12 @@ void WQtModuleConfig::reset()
{
m_pathList->clear();
// reset all checkboxes
for( std::vector< WModule::ConstSPtr >::const_iterator iter = m_moduleList.begin(); iter != m_moduleList.end(); ++iter )
{
// we later need to find the checkbox for one module easily:
m_moduleItemMap[ ( *iter )->getName() ]->setCheckState( Qt::Unchecked );
}
resetAllModuleCheckboxes();
loadListsFromSettings( true );
m_showThemAll->setCheckState( Qt::Unchecked );
m_asBlackList->setCheckState( Qt::Unchecked );
m_usePreset->setCheckState( Qt::Unchecked );
m_list->setDisabled( false );
}
......@@ -390,3 +475,54 @@ void WQtModuleConfig::pathListSelectionChanged()
m_removePathButton->setEnabled( false );
}
}
void WQtModuleConfig::resetAllModuleCheckboxes()
{
for( std::vector< WModule::ConstSPtr >::const_iterator iter = m_moduleList.begin(); iter != m_moduleList.end(); ++iter )
{
// we later need to find the checkbox for one module easily:
m_moduleItemMap[ ( *iter )->getName() ]->setCheckState( Qt::Unchecked );
}
}
void WQtModuleConfig::comboboxItemChanged( QString selectedPreset )
{
std::string allowedModules = "";
// read settings
if( m_usePreset->isChecked() )
{
allowedModules = WQtGui::getSettings().value( "qtgui/modules/preset/" + selectedPreset, "" ).toString().toStdString();
}
else
{
allowedModules = WQtGui::getSettings().value( "qtgui/modules/allowedList", "" ).toString().toStdString();
}
m_allowedModules = string_utils::tokenize( allowedModules, "," );
resetAllModuleCheckboxes();
// set dialog according to the settings
for( AllowedModuleList::const_iterator iter = m_allowedModules.begin(); iter != m_allowedModules.end(); ++iter )
{
if( m_moduleItemMap.count( *iter ) )
{
m_moduleItemMap[ *iter ]->setCheckState( Qt::Checked );
}
}
}
void WQtModuleConfig::showBlacklistPresetOptions()
{
if( m_asBlackList->checkState() == Qt::Checked )
{
m_usePreset->setDisabled( false );
m_selectPresetBlacklist->setDisabled( false );
}
else
{
m_usePreset->setDisabled( true );
m_selectPresetBlacklist->setDisabled( true );
}
}
......@@ -33,6 +33,7 @@
#include <QDialog>
#include <QListWidget>
#include <QCheckBox>
#include <QComboBox>
#include "core/kernel/WModule.h"
......@@ -127,6 +128,23 @@ private slots:
*/
virtual void pathListSelectionChanged();
/**
* Call this to refresh the selected modules when a preset is selected
*
* \param selectedPreset the preset which is selected inside of the combobox
*/
void comboboxItemChanged( QString selectedPreset );
/**
* Call this to show the blacklist preset options
*/
void showBlacklistPresetOptions();
/**
* Call this to reset all checkboxes in the list of modules
*/
void resetAllModuleCheckboxes();
protected:
private:
/**
......@@ -186,6 +204,16 @@ private:
*/
QCheckBox* m_asBlackList;
/**
* Check if you want to use a preset module list
*/
QCheckBox* m_usePreset;
/**
* Combobox to select a black list
*/
QComboBox* m_selectPresetBlacklist;
/**
* Button responsible for removing the currently selected path in m_pathList.
*/
......
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