summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/EventViewer/EventModel.cpp')
-rw-r--r--Swift/QtUI/EventViewer/EventModel.cpp18
1 files changed, 11 insertions, 7 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;
- }
- }
}