diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/ChatList/ChatListGroupItem.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Swift/QtUI/ChatList/ChatListGroupItem.h b/Swift/QtUI/ChatList/ChatListGroupItem.h index 17defea..3bb4b8e 100644 --- a/Swift/QtUI/ChatList/ChatListGroupItem.h +++ b/Swift/QtUI/ChatList/ChatListGroupItem.h @@ -1,3 +1,3 @@ /* - * Copyright (c) 2010-2011 Kevin Smith + * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. @@ -10,2 +10,4 @@ +#include <Swiften/Base/foreach.h> + #include "Swift/QtUI/ChatList/ChatListItem.h" @@ -16,2 +18,3 @@ namespace Swift { ChatListGroupItem(const QString& name, ChatListGroupItem* parent, bool sorted = true) : ChatListItem(parent), name_(name), sorted_(sorted) {} + virtual ~ChatListGroupItem() {clear();} void addItem(ChatListItem* item) {items_.push_back(item); if (sorted_) {qStableSort(items_.begin(), items_.end(), pointerItemLessThan);}} @@ -22,3 +25,10 @@ namespace Swift { QVariant data(int role) const {return (role == Qt::DisplayRole) ? name_ : QVariant();} - void clear() {items_.clear();} + void clear() { + foreach (ChatListItem* item, items_) { + delete item; + } + items_.clear(); + } + + private: |