summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-03-19 17:49:50 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-03-19 17:49:50 (GMT)
commitcd1801ca176553c2c1727745228cdd2f076b62a5 (patch)
tree4804f34a5a2fbba70e7487022ddf198a5af95db4 /Swift/QtUI
parent580d3d49ea3df7bb1c00cb1052203d17ccaa9a8e (diff)
downloadswift-cd1801ca176553c2c1727745228cdd2f076b62a5.zip
swift-cd1801ca176553c2c1727745228cdd2f076b62a5.tar.bz2
Don't show messages forever in the EventViewer.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/EventViewer/EventModel.cpp18
-rw-r--r--Swift/QtUI/EventViewer/main.cpp5
2 files changed, 14 insertions, 9 deletions
diff --git a/Swift/QtUI/EventViewer/EventModel.cpp b/Swift/QtUI/EventViewer/EventModel.cpp
index ffe2110..f75fe74 100644
--- a/Swift/QtUI/EventViewer/EventModel.cpp
+++ b/Swift/QtUI/EventViewer/EventModel.cpp
@@ -41,11 +41,22 @@ void EventModel::addEvent(boost::shared_ptr<Event> event, bool active) {
} else {
inactiveEvents_.push_front(new QtEvent(event, active));
emit dataChanged(createIndex(activeEvents_.size() -1, 0), createIndex(activeEvents_.size(), 0));
+ if (inactiveEvents_.size() > 50) {
+ removeEvent(inactiveEvents_[20]->getEvent());
+ }
}
emit layoutChanged();
}
void EventModel::removeEvent(boost::shared_ptr<Event> event) {
+ for (int i = inactiveEvents_.size() - 1; i >= 0; i--) {
+ if (event == inactiveEvents_[i]->getEvent()) {
+ inactiveEvents_.removeAt(i);
+ emit dataChanged(createIndex(activeEvents_.size() + i - 1, 0), createIndex(activeEvents_.size() + i - 1, 0));
+ return;
+ }
+ }
+
for (int i = 0; i < activeEvents_.size(); i++) {
if (event == activeEvents_[i]->getEvent()) {
activeEvents_.removeAt(i);
@@ -53,13 +64,6 @@ void EventModel::removeEvent(boost::shared_ptr<Event> event) {
return;
}
}
- for (int i = 0; i < inactiveEvents_.size(); i++) {
- if (event == inactiveEvents_[i]->getEvent()) {
- inactiveEvents_.removeAt(i);
- emit dataChanged(createIndex(activeEvents_.size() + i - 1, 0), createIndex(activeEvents_.size() + i - 1, 0));
- return;
- }
- }
}
diff --git a/Swift/QtUI/EventViewer/main.cpp b/Swift/QtUI/EventViewer/main.cpp
index 647010d..1e8163b 100644
--- a/Swift/QtUI/EventViewer/main.cpp
+++ b/Swift/QtUI/EventViewer/main.cpp
@@ -14,7 +14,8 @@ int main(int argc, char *argv[])
message1->setBody("Oooh, shiny");
boost::shared_ptr<Swift::MessageEvent> event1(new Swift::MessageEvent(message1));
viewer->addEvent(boost::dynamic_pointer_cast<Swift::Event>(event1), true);
- viewer->addEvent(boost::dynamic_pointer_cast<Swift::Event>(event1), false);
- viewer->addEvent(boost::dynamic_pointer_cast<Swift::Event>(event1), false);
+ for (int i = 0; i < 100; i++) {
+ viewer->addEvent(boost::dynamic_pointer_cast<Swift::Event>(event1), false);
+ }
return app.exec();
}