Commit 7ed31245 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD #152] added progress text instead of the busy-word. Data modules again...

[ADD #152] added progress text instead of the busy-word. Data modules again show their filenames if no busy indication is active
parent 634076cd
......@@ -81,23 +81,29 @@ void WProgressCombiner::update()
rlock.unlock();
}
std::string WProgressCombiner::getCombinedNames() const
std::string WProgressCombiner::getCombinedNames( bool excludeFinished ) const
{
// read lock combiner
boost::shared_lock< boost::shared_mutex > rlock = boost::shared_lock< boost::shared_mutex >( m_updateLock );
std::stringstream ss;
ss << "[";
bool addComma = false; // when true, a "," is appended before printing the next name. This is needed as we do not know if an element is the
// last one if excludeFinished == true.
for( std::set< boost::shared_ptr< WProgress > >::const_iterator i = m_children.begin(); i != m_children.end(); ++i )
{
// enforce child to update
ss << ( *i )->getName();
if( boost::next( i ) != m_children.end() )
if( !( !( *i )->isPending() && excludeFinished ) )
{
ss << ", ";
if( addComma )
{
ss << ", ";
}
// enforce child to update
ss << ( *i )->getName();
// in next step, add a comma
addComma = true;
}
}
ss << "]";
// Done. Free lock.
rlock.unlock();
......
......@@ -103,9 +103,11 @@ public:
/**
* Generates a string combined out of every child progress name.
*
* \param excludeFinished if true, the combined name list only contains unfinished progress'
*
* \return One describing string for all child progress names.
*/
std::string getCombinedNames() const;
std::string getCombinedNames( bool excludeFinished = false ) const;
protected:
/**
......
......@@ -73,6 +73,27 @@ namespace string_utils
return ss.str();
}
/**
* Convert a given value to a string. The input value must provide a operator<< or be a standard scalar type. This method additionally allows
* setting width and precision flags of the used std::stringstream.
*
* \tparam T the source type. You do not need to specify this directly as it can be deducted from the given parameter
* \param value the value to cast to string
* \param precision the precision
* \param width the width
*
* \return the string.
*/
template< typename T >
inline std::string toString( const T& value, const size_t width, const size_t precision )
{
std::stringstream ss;
ss.width( width );
ss.precision( precision );
ss << value;
return ss.str();
}
/**
* Convert a given string to a value of a certain type. The target type must provide a operator>> to work or be a standard scalar type.
*
......
......@@ -32,6 +32,8 @@
#include <QtGui/QTextCharFormat>
#include <QtGui/QTextCursor>
#include "core/common/WStringUtils.h"
#include "WQtNetworkArrow.h"
#include "WQtNetworkItem.h"
#include "WQtNetworkItemActivator.h"
......@@ -152,7 +154,10 @@ int WQtNetworkItem::type() const
void WQtNetworkItem::updater()
{
// it is very important to avoid unnecessary changes to pen/brush and similar stuff to avoid permanent updates of the graphics item.
bool needUpdate = false;
// handle progress indication
boost::shared_ptr< WProgressCombiner> p = m_module->getRootProgressCombiner();
// update the progress combiners internal state
......@@ -160,13 +165,24 @@ void WQtNetworkItem::updater()
if( p->isPending() )
{
m_busyIndicatorShow = true;
m_busyIsDetermined = p->isDetermined();
// update subtext
m_subtitleFull = "Busy"; // TODO(ebaum): use progress text here
m_subtitleFull = p->getCombinedNames( true );
// we add the percent-counter to the front because the fitLook method shortens the subtext string if it is too long. This might clip out
// the percentage if the p->getCombinedNames string is quite long.
if(m_busyIsDetermined ) // <- of course only add if we have a known percentage
{
// NOTE: Percentage of a WProgressCombiner always multiplicatively combines all percentages of the children
m_subtitleFull = string_utils::toString( static_cast< uint16_t >( p->getProgress() ) ) + "% - " + m_subtitleFull;
}
// this method ensures the text is shortened and correctly placed in the iem
fitLook();
// update indicator
m_busyIndicatorShow = true;
m_busyIsDetermined = p->isDetermined();
if( m_busyIsDetermined )
{
m_busyPercent = p->getProgress() / 100.0;
......@@ -186,7 +202,15 @@ void WQtNetworkItem::updater()
// if busy indication was active -> update to remove it again
needUpdate |= m_busyIndicatorShow;
m_busyIndicatorShow = false;
m_subtitleFull = "Idle";
WDataModule::SPtr dataModule = boost::shared_dynamic_cast< WDataModule >( m_module );
if( dataModule )
{
m_subtitleFull = dataModule->getFilename().filename().string();
}
else
{
m_subtitleFull = "Idle";
}
fitLook();
}
......
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