libpappsomspp
Library for mass spectrometry
pappso::UiMonitorTextPercent Class Reference

#include <uimonitortextpercent.h>

Inheritance diagram for pappso::UiMonitorTextPercent:
pappso::UiMonitorText pappso::UiMonitorInterface

Public Member Functions

 UiMonitorTextPercent (QTextStream &output_stream)
 
virtual ~UiMonitorTextPercent ()
 
virtual void count () override
 count steps report when a step is computed in an algorithm More...
 
virtual void setTotalSteps (std::size_t total_number_of_steps)
 use it if the number of steps is known in an algorithm the total number of steps is usefull to report to the user a progress message in percents or with a progress bar More...
 
- Public Member Functions inherited from pappso::UiMonitorText
 UiMonitorText (QTextStream &output_stream)
 
 ~UiMonitorText ()
 
virtual bool shouldIstop () override
 should the procces be stopped ? If true, then cancel process Use this function at strategic point of your process in order to interrupt it cleanly Implementation must take care of thread resistance if implemented More...
 
virtual void setTitle (const QString &title) override
 current kind of process running More...
 
virtual void setStatus (const QString &status) override
 current status of the process More...
 
virtual void appendText (const QString &text) override
 append a text to a long report More...
 

Protected Attributes

int m_unit
 
- Protected Attributes inherited from pappso::UiMonitorText
QTextStream & m_outputStream
 
std::size_t m_count = 0
 
- Protected Attributes inherited from pappso::UiMonitorInterface
std::size_t m_totalSteps = 0
 

Detailed Description

Todo:
write docs

Definition at line 43 of file uimonitortextpercent.h.

Constructor & Destructor Documentation

◆ UiMonitorTextPercent()

UiMonitorTextPercent::UiMonitorTextPercent ( QTextStream &  output_stream)

Default constructor

Definition at line 35 of file uimonitortextpercent.cpp.

36  : UiMonitorText(output_stream)
37 {
38  m_unit = -1;
39  m_totalSteps = 1;
40 }
UiMonitorText(QTextStream &output_stream)

References pappso::UiMonitorInterface::m_totalSteps, and m_unit.

◆ ~UiMonitorTextPercent()

UiMonitorTextPercent::~UiMonitorTextPercent ( )
virtual

Destructor

Definition at line 42 of file uimonitortextpercent.cpp.

43 {
44 }

Member Function Documentation

◆ count()

void pappso::UiMonitorTextPercent::count ( )
overridevirtual

count steps report when a step is computed in an algorithm

Reimplemented from pappso::UiMonitorText.

Definition at line 65 of file uimonitortextpercent.cpp.

66 {
67  m_count++;
68  if(m_count <= m_totalSteps)
69  {
70  int unit = (int)(((float)m_count / (float)m_totalSteps) * 10);
71  // qDebug() << unit;
72  if(unit > m_unit)
73  {
74  m_outputStream << (unit * 10) << "% ";
75  m_outputStream.flush();
76  m_unit = unit;
77  }
78  }
79 }
QTextStream & m_outputStream
Definition: uimonitortext.h:80

◆ setTotalSteps()

void pappso::UiMonitorTextPercent::setTotalSteps ( std::size_t  total_number_of_steps)
virtual

use it if the number of steps is known in an algorithm the total number of steps is usefull to report to the user a progress message in percents or with a progress bar

Parameters
total_number_of_stepsthe total number of steps

Reimplemented from pappso::UiMonitorText.

Definition at line 48 of file uimonitortextpercent.cpp.

49 {
50  if(m_count > 0)
51  {
52 
53  m_outputStream << Qt::endl;
54  m_outputStream.flush();
55  }
56  UiMonitorText::setTotalSteps(total_number_of_steps);
57  m_unit = -1;
58  if(m_totalSteps == 0)
59  {
60  m_totalSteps = -1;
61  }
62 }
virtual void setTotalSteps(std::size_t total_number_of_steps)
use it if the number of steps is known in an algorithm the total number of steps is usefull to report...

References pappso::UiMonitorText::setTotalSteps().

Member Data Documentation

◆ m_unit

int pappso::UiMonitorTextPercent::m_unit
protected

Definition at line 67 of file uimonitortextpercent.h.

Referenced by UiMonitorTextPercent().


The documentation for this class was generated from the following files: