diff options
Diffstat (limited to 'Swift/QtUI/ChatList')
-rw-r--r-- | Swift/QtUI/ChatList/ChatListGroupItem.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/ChatListModel.cpp | 6 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/ChatListModel.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/QtChatListWindow.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/QtChatListWindow.h | 1 |
5 files changed, 13 insertions, 0 deletions
diff --git a/Swift/QtUI/ChatList/ChatListGroupItem.h b/Swift/QtUI/ChatList/ChatListGroupItem.h index 389410a..cc4d4af 100644 --- a/Swift/QtUI/ChatList/ChatListGroupItem.h +++ b/Swift/QtUI/ChatList/ChatListGroupItem.h @@ -20,6 +20,7 @@ namespace Swift { ChatListItem* item(int i) {return items_[i];}; int row(ChatListItem* item) {return items_.indexOf(item);}; QVariant data(int role) const {return (role == Qt::DisplayRole) ? name_ : QVariant();}; + void clear() {items_.clear();}; private: static bool pointerItemLessThan(const ChatListItem* first, const ChatListItem* second) { QString myName = first->data(Qt::DisplayRole).toString().toLower(); diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp index 50a6ad3..39b6a3c 100644 --- a/Swift/QtUI/ChatList/ChatListModel.cpp +++ b/Swift/QtUI/ChatList/ChatListModel.cpp @@ -16,6 +16,12 @@ ChatListModel::ChatListModel() { root_->addItem(mucBookmarks_); } +void ChatListModel::clear() { + emit layoutAboutToBeChanged(); + mucBookmarks_->clear(); + emit layoutChanged(); +} + void ChatListModel::addMUCBookmark(const Swift::MUCBookmark& bookmark) { emit layoutAboutToBeChanged(); mucBookmarks_->addItem(new ChatListMUCItem(bookmark, mucBookmarks_)); diff --git a/Swift/QtUI/ChatList/ChatListModel.h b/Swift/QtUI/ChatList/ChatListModel.h index 05fa60b..adde148 100644 --- a/Swift/QtUI/ChatList/ChatListModel.h +++ b/Swift/QtUI/ChatList/ChatListModel.h @@ -28,6 +28,7 @@ namespace Swift { QModelIndex parent(const QModelIndex& index) const; int rowCount(const QModelIndex& parent = QModelIndex()) const; ChatListItem* getItemForIndex(const QModelIndex& index) const; + void clear(); private: ChatListGroupItem* mucBookmarks_; ChatListGroupItem* root_; diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp index 887d9a4..48ccf7f 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.cpp +++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp @@ -79,6 +79,10 @@ void QtChatListWindow::handleItemActivated(const QModelIndex& index) { } } +void QtChatListWindow::clear() { + model_->clear(); +} + void QtChatListWindow::addMUCBookmark(const MUCBookmark& bookmark) { model_->addMUCBookmark(bookmark); } diff --git a/Swift/QtUI/ChatList/QtChatListWindow.h b/Swift/QtUI/ChatList/QtChatListWindow.h index 2c13300..b389474 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.h +++ b/Swift/QtUI/ChatList/QtChatListWindow.h @@ -24,6 +24,7 @@ namespace Swift { void addMUCBookmark(const MUCBookmark& bookmark); void removeMUCBookmark(const MUCBookmark& bookmark); void setBookmarksEnabled(bool enabled); + void clear(); private slots: void handleItemActivated(const QModelIndex&); void handleAddBookmark(); |