Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProgressDisplay.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
26 #include "ProgressDisplay.h"
27 
28 namespace AppBase
29 {
30 
31 void ProgressDisplay::setMessage(const std::string& message, const std::string& filename)
32 {
33  m_message = message;
34  m_filename = filename;
36 }
37 
39 {
40  setMessage("");
41 }
42 
44 {
45  return !m_canceled;
46 }
47 
48 bool ProgressDisplay::updateDisplay(const std::string& message)
49 {
50  setMessage(message);
51  return !m_canceled;
52 }
53 
55 {
56  if (m_progress < m_maximum)
57  {
58  ++m_progress;
59  };
61  return !m_canceled;
62 }
63 
64 void ProgressDisplay::setMaximum(int newMaximum)
65 {
66  m_maximum = newMaximum;
67  if (m_progress > m_maximum)
68  {
70  };
71 }
72 
74 {
75  return m_canceled;
76 }
77 
79 {
80  // TODO: check for Ctrl-C then cancelTask() ?
81  if (!m_message.empty())
82  {
83  // don't print empty messages
84  if (m_filename.empty())
85  {
86  m_stream << m_message << std::endl;
87  }
88  else
89  {
90  m_stream << m_message << " " << m_filename << std::endl;
91  }
92  m_stream.flush();
93  };
94 }
95 
96 }; //namespace
void setMaximum(int newMaximum)
sets the new maximum value of the progress value
virtual void updateProgressDisplay()=0
Template method, updates the display.
bool updateDisplay()
updates the display, return true, if update was successful, false if cancel was pressed ...
bool wasCancelled()
return true, if process should be canceled by user e.g.
void taskFinished()
call when a task has finished and the status message should be cleared
virtual void updateProgressDisplay()
update the display, print the message to stream
void setMessage(const std::string &message, const std::string &filename="")
sets the message to given string