File: EventDisplayer.C

package info (click to toggle)
witty 3.2.1-2%2Bdeb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 70,436 kB
  • sloc: cpp: 117,095; ansic: 77,999; xml: 7,564; sh: 1,037; perl: 208; makefile: 144; java: 86; sql: 14
file content (48 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "EventDisplayer.h"
#include <Wt/WText>

using namespace Wt;

EventDisplayer::EventDisplayer(WContainerWidget *parent):
  WContainerWidget(parent),
  eventCount_(0),
  text_(new WText("Events will be shown here.", this))
{
  setStyleClass("events");
}

void EventDisplayer::showSignal(Signal<WString>& signal,
				const std::string& data)
{
  signal.connect(boost::bind(&EventDisplayer::showWStringSignal,
			     this, data, _1));
}

void EventDisplayer::showSignalImpl(const std::string& str)
{
  showEventImpl("Last activated signal: " + str);
}

void EventDisplayer::showWStringSignal(const std::string& str,
				       const WString& wstr)
{
  showEventImpl("Last activated signal: " + str + wstr);
}

void EventDisplayer::setStatus(const WString &msg)
{
  showEventImpl("Last status message: " + msg);
}

void EventDisplayer::showEventImpl(const WString& str)
{
  if (str == lastEventStr_) {
    ++eventCount_;
    text_->setText(str + " (" + boost::lexical_cast<std::string>(eventCount_)
		   + " times)");
  } else {
    lastEventStr_ = str;
    eventCount_ = 1;
    text_->setText(str);
  }
}