Commit cd5ee932 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added functionality to mark a module deprecated in a user-oriented...

[ADD] - added functionality to mark a module deprecated in a user-oriented way. This will notify the user about this. A dialog box is not the best option here but works for now.
parent b5cc3395
......@@ -221,6 +221,11 @@ void WModule::activate()
{
}
std::string WModule::deprecated() const
{
return "";
}
void WModule::initialize()
{
// doing it twice is not allowed
......@@ -595,3 +600,13 @@ boost::filesystem::path WModule::getLocalPath() const
return m_localPath;
}
bool WModule::isDeprecated() const
{
return !deprecated().empty();
}
std::string WModule::getDeprecationMessage() const
{
return deprecated();
}
......@@ -341,6 +341,19 @@ public:
*/
boost::filesystem::path getLocalPath() const;
/**
* Checks whether the module was marked as deprecated.
*
* \return true if deprecated
*/
bool isDeprecated() const;
/**
* Queries the deprecation message of a module if specified. If not specified, an empty string is returned. Check \ref isDeprecated first.
*
* \return deprecation message
*/
std::string getDeprecationMessage() const;
protected:
/**
......@@ -386,6 +399,16 @@ protected:
*/
virtual void requirements();
/**
* This function allows module programmers to mark their modules deprecated in a user-friendly way. If you implement this function, you need
* to specify an text which should mention an alternative module.
*
* \note do not add sentences like "this module is deprecated" or similar, since the GUI the user is using already shows this message. The
* message should say WHY it is deprecated and what alternative module is available.
* \return deprecation message
*/
virtual std::string deprecated() const;
/**
* Manages connector initialization. Gets called by module container.
*
......
......@@ -91,6 +91,12 @@ void WMSubtractDataSetScalar::properties()
{
}
std::string WMSubtractDataSetScalar::deprecated() const
{
// NOTE: do not add sentences like "this module is deprecated" or similar, since the GUI the user is using already shows this message.
return "This module is not as capable as the module \"Scalar Operator\".";
}
void WMSubtractDataSetScalar::moduleMain()
{
m_moduleState.setResetable( true, true );
......
......@@ -98,6 +98,13 @@ protected:
*/
virtual void properties();
/**
* Deprecation marker.
*
* \return the message why it is deprecated.
*/
virtual std::string deprecated() const;
private:
/**
......
......@@ -34,6 +34,7 @@
#include <QtGui/QScrollArea>
#include <QtGui/QShortcut>
#include <QtGui/QSplitter>
#include <QtGui/QMessageBox>
#include "core/common/WLogger.h"
#include "core/common/WPredicateHelper.h"
......@@ -253,6 +254,16 @@ bool WQtControlPanel::event( QEvent* event )
WLogger::getLogger()->addLogMessage( "Inserting module " + e1->getModule()->getName() + " to control panel.",
"ControlPanel", LL_DEBUG );
// show deprecation message?
if( e1->getModule()->isDeprecated() )
{
std::string d = e1->getModule()->getDeprecationMessage();
std::string m = "The module \"" + e1->getModule()->getName() + "\" is marked deprecated. You should avoid using it."
"<br><br>"
"Message: " + d;
QMessageBox::warning( this, "Deprecation Warning", QString::fromStdString( m ) );
}
// finally add the module
// TODO(schurade): is this differentiation between data and "normal" modules really needed?
if( boost::shared_dynamic_cast< WDataModule >( e1->getModule() ).get() )
......
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