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 49 50 51 52 53 54 55 56
|
#include "EventDisplayer.h"
#include <Wt/WText>
using namespace Wt;
EventDisplayer::EventDisplayer(WContainerWidget *parent):
WContainerWidget(parent),
text_(new WText("Events will be shown here.", this)),
map_(new WSignalMapper<std::string>(this)),
mapWString_(new WSignalMapper<std::string, WString>(this))
{
setStyleClass("events");
map_->mapped().connect(SLOT(this, EventDisplayer::showSignal));
mapWString_->mapped().connect(SLOT(this, EventDisplayer::showWStringSignal));
}
void EventDisplayer::mapConnect(Wt::SignalBase &signal, const std::string& data)
{
map_->mapConnect(signal, data);
}
void EventDisplayer::mapConnectWString(Signal<WString> &signal,
const std::string& data)
{
mapWString_->mapConnect1(signal, data);
}
void EventDisplayer::showSignal(const std::string& str)
{
showEvent("Last activated signal: " + str);
}
void EventDisplayer::showWStringSignal(const std::string& str,
const WString& wstr)
{
showEvent("Last activated signal: " + str + wstr);
}
void EventDisplayer::setStatus(const WString &msg)
{
showEvent("Last status message: " + msg);
}
void EventDisplayer::showEvent(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);
}
}
|