summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/EventViewer')
-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();
}