30 #include <QApplication>
32 #include "../WMainWindow.h"
33 #include "../WQtGui.h"
34 #include "../events/WEventTypes.h"
35 #include "../events/WModuleConnectorEvent.h"
36 #include "../events/WModuleDeleteEvent.h"
37 #include "../events/WPropertyChangedEvent.h"
38 #include "WQtControlPanel.h"
39 #include "WQtTreeItem.h"
40 #include "WTreeItemTypes.h"
41 #include "core/common/WLogger.h"
42 #include "core/common/WProgress.h"
43 #include "core/common/WProgressCombiner.h"
44 #include "core/kernel/WKernel.h"
45 #include "core/kernel/WModuleInputConnector.h"
46 #include "core/kernel/WModuleOutputConnector.h"
50 m_deleteInProgress( false ),
51 m_needPostDeleteEvent( true ),
55 m_name = module->getName();
57 if( module->getProperties()->getProperty(
"active" )->toPropBool()->get() )
59 this->setCheckState( 0, Qt::Checked );
63 this->setCheckState( 0, Qt::Unchecked );
66 this->setFlags( Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
70 std::shared_ptr< WPropertyBase > p = module->getProperties()->findProperty(
"Name" );
92 for( WModule::OutputConnectorList::const_iterator iter = outs.begin(); iter != outs.end(); ++iter )
105 ( *iter ).disconnect();
122 std::string tooltip =
"";
123 tooltip +=
"<b>Module: </b>" + module->getName() +
"<br/>";
124 if( module->isCrashed()() )
126 tooltip +=
"<b>State: </b>crashed<br/>";
127 tooltip +=
"<b>Crash-Message: </b>" + module->getCrashMessage() +
"<br/>";
131 tooltip +=
"<b>State: </b>normal<br/>";
133 tooltip +=
"<b>Connectors: </b>";
136 std::string conList =
"";
139 conList +=
"<table><tr><th>Name</th><th>Description</th><th>Type (I/O)</th><th>Connected</th></tr>";
141 for( WModule::InputConnectorList::const_iterator it = consIn.begin(); it != consIn.end(); ++it )
144 conList +=
"<tr><td><b>" + ( *it )->getName() +
" </b></td><td>" + ( *it )->getDescription() +
" </td>";
145 conList +=
"<td><center>In</center></td>";
146 conList += ( *it )->isConnected() ?
"<td><center>Yes</center></td>" :
"<td><center>No</center></td>";
149 for( WModule::OutputConnectorList::const_iterator it = consOut.begin(); it != consOut.end(); ++it )
152 conList +=
"<tr><td><b>" + ( *it )->getName() +
" </b></td><td>" + ( *it )->getDescription() +
" </td>";
153 conList +=
"<td><center>Out</center></td>";
154 conList += ( *it )->isConnected() ?
"<td></center>Yes</center></td>" :
"<td><center>No</center></td>";
157 conList +=
"</table>";
159 tooltip += conCount ?
"Yes" + conList +
"<br/><br/>" :
"None<br/>";
160 tooltip +=
"<b>Module Description: </b><br/>" + module->getMetaInformation()->getDescription();
178 std::shared_ptr< WProgressCombiner> p =
m_module->getRootProgressCombiner();
183 std::string connInfo =
"";
190 std::string progress =
"Waiting";
193 progress =
"Problem occurred";
194 setText( 0, (
m_name +
" (problem occurred)" + connInfo ).c_str() );
197 QFont curFont = font( 0 );
198 curFont.setStrikeOut(
true );
199 setFont( 0, curFont );
203 setDisabled(
false );
205 else if( p->isPending() )
207 progress =
"Busy " + p->getCombinedNames();
209 std::ostringstream progressText;
212 std::string name = p->getName();
215 name =
" [" + name +
"]";
218 if( p->isDetermined() )
220 progressText.setf( std::ios::fixed );
221 progressText.precision( 0 );
222 progressText << p->getProgress() <<
"%" << name;
226 progressText <<
"Pending" << name;
229 setText( 0, (
m_name +
" - " + progressText.str() + connInfo ).c_str() );
233 setIcon( 0, QIcon() );
234 setText( 0, (
m_name + connInfo ).c_str() );
240 setForeground( 0, QBrush( QColor::fromRgb( 255, 0, 0 ) ) );
253 if(
m_module->getProperties()->getProperty(
"active" )->toPropBool()->get() )
255 setCheckState( 0, Qt::Checked );
259 setCheckState( 0, Qt::Unchecked );
303 if( checkState( 0 ) == Qt::Checked )
305 m_module->getProperties()->getProperty(
"active" )->toPropBool()->set(
true );
309 m_module->getProperties()->getProperty(
"active" )->toPropBool()->set(
false );
Event signalling a module connector changed its data.
Event signalling a module item should be deleted.
std::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
std::vector< std::shared_ptr< WModuleOutputConnector > > OutputConnectorList
The type for the list of output connectors.
std::vector< std::shared_ptr< WModuleInputConnector > > InputConnectorList
The type for the list of input connectors.
static WMainWindow * getMainWindow()
Returns the current main window instance or NULL if not existent.
std::vector< boost::signals2::connection > m_outputUpdateConnections
The output connector update connections.
std::shared_ptr< WModule > m_module
The module represented by this tree item.
std::string m_name
Name of the tree item.
WModule::SPtr getModule()
Get for the module pointer.
void setHandledOutput(std::string out)
Sets the name of the output represented by this item.
virtual ~WQtTreeItem()
Destructor.
std::string getHandledOutput() const
The name of the output represented by this item.
std::string getHandledInput() const
The name of the input represented by this item.
std::string getName()
Returns the name used for this tree item.
void nameChanged()
Called when the name property changes.
void slotDataChanged(std::shared_ptr< WModuleConnector > connector)
Called on output-connector update.
bool m_deleteInProgress
True if the treeitem and the module gets deleted currently.
virtual void updateState()
Updates the state of the tree item basing on the module's state.
static std::string createTooltip(WModule::SPtr module)
Create tooltip for a given module.
std::shared_ptr< QTimer > m_updateTimer
Updates this item in regular intervals.
virtual void gotRemoved()
Gets called by the GUI whenever the module was removed from the root container and should now be dele...
void update()
Gets called by m_updateTimer in some interval to update the item state, basing on the state of m_modu...
WQtTreeItem(QTreeWidgetItem *parent, WTreeItemType type, std::shared_ptr< WModule > module)
Constructor creates an empty item.
void setHandledInput(std::string in)
Sets the name of the input represented by this item.
std::string m_handledOutput
The output name handled by this item.
bool m_needPostDeleteEvent
True if no delete event has been posted yet.
std::string m_handledInput
The name of the input connector represented by this item.
virtual void handleCheckStateChange()
Handle changes in check state.
WPropString m_nameProp
The property containing the name of the module.