Commit 5a870215 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD #171] module items in the network editor now have proper tooltips, including crash messages.

parent 03e8b94f
......@@ -39,6 +39,7 @@
WThreadedRunner::WThreadedRunner():
m_shutdownFlag( new WConditionOneShot(), false ),
m_isCrashed( new WConditionOneShot(), false ),
m_crashMessage( "" ),
m_threadName( "" )
{
// initialize members
......@@ -68,6 +69,7 @@ void WThreadedRunner::handleDeadlyException( const WException& e, std::string se
// notify waiting threads
m_isCrashed( true );
m_crashMessage = e.what();
}
void WThreadedRunner::run()
......@@ -167,6 +169,11 @@ std::string WThreadedRunner::getThreadName() const
return m_threadName;
}
const std::string& WThreadedRunner::getCrashMessage() const
{
return m_crashMessage;
}
void WThreadedRunner::setThisThreadName( std::string name )
{
#ifdef __linux__
......
......@@ -103,6 +103,13 @@ public:
*/
const WBoolFlag& isCrashed() const;
/**
* Get the message of the exception finally causing the crash.
*
* \return the message
*/
const std::string& getCrashMessage() const;
/**
* Set the name of the thread. This can be handy for debugging as it gets set on Linux as the pthread name. You MUST set this before starting
* the thread.
......@@ -197,6 +204,11 @@ protected:
*/
WBoolFlag m_isCrashed;
/**
* The crash message. Only filled if m_isCrashed is true.
*/
std::string m_crashMessage;
private:
/**
* Disallow copy construction.
......
......@@ -116,21 +116,26 @@ std::string WQtTreeItem::getName()
return m_name;
}
void WQtTreeItem::updateTooltip( std::string progress )
std::string WQtTreeItem::createTooltip( WModule::SPtr module )
{
// create the tooltip text
std::string tooltip = "";
if( m_module->isCrashed()() )
tooltip += "<b>Module: </b>" + module->getName() + "<br/>";
if( module->isCrashed()() )
{
tooltip += "<b>State: </b>crashed<br/>";
tooltip += "<b>Crash-Message: </b>" + module->getCrashMessage() + "<br/>";
}
else
{
tooltip += "<b>A problem occured. The module has been stopped. </b><br/><br/>";
tooltip += "<b>State: </b>normal<br/>";
}
tooltip += "<b>Module: </b>" + m_module->getName() + "<br/>";
tooltip += "<b>Progress: </b>" + progress + "<br/>";
tooltip += "<b>Connectors: </b>";
// also list the connectors
std::string conList = "";
WModule::InputConnectorList consIn = m_module->getInputConnectors();
WModule::OutputConnectorList consOut = m_module->getOutputConnectors();
WModule::InputConnectorList consIn = module->getInputConnectors();
WModule::OutputConnectorList consOut = module->getOutputConnectors();
conList += "<table><tr><th>Name</th><th>Description</th><th>Type (I/O)</th><th>Connected</th></tr>";
int conCount = 0;
for( WModule::InputConnectorList::const_iterator it = consIn.begin(); it != consIn.end(); ++it )
......@@ -152,9 +157,9 @@ void WQtTreeItem::updateTooltip( std::string progress )
conList += "</table>";
tooltip += conCount ? "Yes" + conList + "<br/><br/>" : "None<br/>";
tooltip += "<b>Module Description: </b><br/>" + m_module->getDescription();
tooltip += "<b>Module Description: </b><br/>" + module->getDescription();
setToolTip( 0, tooltip.c_str() );
return tooltip;
}
void WQtTreeItem::slotDataChanged( boost::shared_ptr<WModuleConnector> connector )
......@@ -255,7 +260,7 @@ void WQtTreeItem::updateState()
}
// update tooltip
updateTooltip( progress );
setToolTip( 0, WQtTreeItem::createTooltip( m_module ).c_str() );
}
void WQtTreeItem::gotRemoved()
......
......@@ -112,6 +112,14 @@ public:
*/
virtual void handleCheckStateChange();
/**
* Create tooltip for a given module. This can be used by all the widgets needing a tooltip for a module.
*
* \param module the module to create the tooltip for
*
* \return the tooltip.
*/
static std::string createTooltip( WModule::SPtr module );
public slots:
/**
......@@ -135,13 +143,6 @@ protected:
*/
std::string m_name;
/**
* Method updates the tooltip of the tree item.
*
* \param progress the current progress as string.
*/
void updateTooltip( std::string progress );
/**
* True if the treeitem and the module gets deleted currently.
*/
......
......@@ -34,6 +34,8 @@
#include "core/common/WStringUtils.h"
#include "../controlPanel/WQtTreeItem.h"
#include "WQtNetworkArrow.h"
#include "WQtNetworkItem.h"
#include "WQtNetworkItemActivator.h"
......@@ -235,6 +237,10 @@ void WQtNetworkItem::updater()
needUpdate = true;
}
// update tooltip
setToolTip( WQtTreeItem::createTooltip( m_module ).c_str() );
// if something has changed -> update
if( needUpdate )
{
update();
......
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