Avoid a function call for most status updates
[linguistica.git] / gui / Status.h
blob3793a1cfdde5d8470b7624ed7ebb51289ba84fbf
1 // Linguistica’s interface to Qt’s status and progress bars.
2 // Copyright © 2010 The University of Chicago
3 #ifndef LXA_GUI_STATUS_H
4 #define LXA_GUI_STATUS_H
6 namespace linguistica { namespace ui {
7 struct status_user_agent;
9 namespace qt {
10 struct status_interface;
12 } }
14 #include "ui/Status.h"
15 class QLabel;
16 class QProgressBar;
18 class linguistica::ui::qt::status_interface
19 : public linguistica::ui::status_user_agent {
20 struct label : public status_user_agent::string_type {
21 QLabel& w;
22 explicit label(QLabel& bar) : w(bar) { }
23 private:
24 // XXX. lxa processing blocks repaint events.
25 void update();
26 public:
27 void clear();
28 label& operator=(const QString& str);
29 // caller is responsible for freeing the label.
32 struct progressbar : public status_user_agent::progress_type {
33 QProgressBar& w;
34 explicit progressbar(QProgressBar& bar) : w(bar) { }
35 private:
36 // XXX. lxa processing blocks repaint events.
37 void update();
38 progressbar& assign(int n);
39 public:
40 void clear();
41 void set_denominator(int denom);
42 // caller is responsible for progress bar.
45 label l;
46 progressbar m;
47 label r;
48 public:
49 status_interface(QLabel& left, QLabel& right, QProgressBar& middle)
50 : status_user_agent(l, r, m), l(left), m(middle), r(right) { }
53 #endif // LXA_GUI_STATUS_H