Skip to content

Commit

Permalink
Move previous value getting logic to separated method.
Browse files Browse the repository at this point in the history
Might be useful when we need to get previous value, without setting it.

Refs #7441
  • Loading branch information
arturbekasov committed Jul 22, 2013
1 parent 1ca1df0 commit f9e44b2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Code/Mantid/MantidQt/API/inc/MantidQtAPI/AlgorithmDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ protected slots:
void parse();
/// Test if the given name's widget has been explicity asked to be enabled
bool requestedToKeepEnabled(const QString& propName) const;
/// Get the property value from either the previous input store or from Python argument
/// @param propName :: Name of the property
/// @return Previous value. If there is no value, empty string is returned
QString getPreviousValue(const QString& propName);
/// Set a value based on any old input that we have
void setPreviousValue(QWidget *widget, const QString & property);

Expand Down
41 changes: 24 additions & 17 deletions Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,24 @@ QString AlgorithmDialog::getValue(QWidget *widget)
}
}

QString AlgorithmDialog::getPreviousValue(const QString& propName)
{
QString value;

if (!isForScript())
{
value = m_propertyValueMap.value(propName);
if (value.isEmpty())
value = AlgorithmInputHistory::Instance().previousInput(m_algName, propName);
}
else if(getAlgorithmProperty(propName) != NULL)
{
value = m_propertyValueMap.value(propName);
}

return value;
}

//------------------------------------------------------------------------------------------------
/** Set a value for a widget.
*
Expand All @@ -885,25 +903,14 @@ QString AlgorithmDialog::getValue(QWidget *widget)
* @param widget :: A pointer to the widget
* @param propName :: The property name
*/
void AlgorithmDialog::setPreviousValue(QWidget *widget, const QString & propName)
void AlgorithmDialog::setPreviousValue(QWidget* widget, const QString& propName)
{
// Get the value from either the previous input store or from Python argument
QString value("");
Mantid::Kernel::Property *property = getAlgorithmProperty(propName);
QString value = getPreviousValue(propName);

if( !isForScript() )
{
value = m_propertyValueMap.value(propName);
if( value.isEmpty() )
{
value = AlgorithmInputHistory::Instance().previousInput(m_algName, propName);
}
}
else
{
if( !property ) return;
value = m_propertyValueMap.value(propName);
}
if(value.isEmpty())
return;

Mantid::Kernel::Property *property = getAlgorithmProperty(propName);

// Do the right thing for the widget type
if( QComboBox *opts = qobject_cast<QComboBox*>(widget) )
Expand Down

0 comments on commit f9e44b2

Please sign in to comment.