Skip to content

Commit

Permalink
Refs #6616. Add error description to the tooltip, when one is set
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Mar 12, 2014
1 parent 8da86b3 commit 7ee4e52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp
Expand Up @@ -5,6 +5,8 @@
#include <stdexcept>
#include <math.h>

const QString ParameterPropertyManager::ERROR_TOOLTIP(" (Error)");

ParameterPropertyManager::ParameterPropertyManager(QObject *parent)
: QtDoublePropertyManager(parent),
m_errors(), m_errorsEnabled(false)
Expand Down Expand Up @@ -61,7 +63,7 @@ void ParameterPropertyManager::setError(QtProperty* property, const double& erro
{
m_errors[property] = error;
emit propertyChanged(property);
// TODO: update tooltip
updateTooltip(property);
}

/**
Expand All @@ -82,7 +84,7 @@ void ParameterPropertyManager::clearError(QtProperty* property)
{
m_errors.remove(property);
emit propertyChanged(property);
// TODO: update tooltip
updateTooltip(property);
}

/**
Expand All @@ -96,7 +98,7 @@ void ParameterPropertyManager::setErrorsEnabled(bool enabled)
foreach(QtProperty* prop, m_errors.keys())
{
emit propertyChanged(prop);
// TODO: update tooltip
updateTooltip(prop);
}
}

Expand Down Expand Up @@ -133,6 +135,14 @@ QString ParameterPropertyManager::valueText(const QtProperty* property) const
*/
void ParameterPropertyManager::updateTooltip(QtProperty* property) const
{
property->setToolTip(QString::fromStdString(description(property)));
// TODO: append description for error if enabled and set
// Description only initially
QString tooltip = QString::fromStdString(description(property));

if ( areErrorsEnabled() && isErrorSet(property))
{
// If error is displayed - add description for it
tooltip += ERROR_TOOLTIP;
}

property->setToolTip(tooltip);
}
3 changes: 3 additions & 0 deletions Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.h
Expand Up @@ -70,6 +70,9 @@ private Q_SLOTS:
void updateTooltip(QtProperty* property) const;

private:
/// Text appended to parameter descr. tooltip if error is set
static const QString ERROR_TOOLTIP;

/// Parameter error values
QMap<QtProperty*, double> m_errors;

Expand Down

0 comments on commit 7ee4e52

Please sign in to comment.