diff options
Diffstat (limited to 'Swift/QtUI/ChatList/ChatListGroupItem.h')
-rw-r--r-- | Swift/QtUI/ChatList/ChatListGroupItem.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Swift/QtUI/ChatList/ChatListGroupItem.h b/Swift/QtUI/ChatList/ChatListGroupItem.h index 2fc99df..389410a 100644 --- a/Swift/QtUI/ChatList/ChatListGroupItem.h +++ b/Swift/QtUI/ChatList/ChatListGroupItem.h @@ -14,13 +14,19 @@ namespace Swift { class ChatListGroupItem : public ChatListItem { public: ChatListGroupItem(const QString& name, ChatListGroupItem* parent) : ChatListItem(parent), name_(name) {}; - void addItem(ChatListItem* item) {items_.push_back(item);}; + void addItem(ChatListItem* item) {items_.push_back(item); qStableSort(items_.begin(), items_.end(), pointerItemLessThan);}; void remove(int index) {items_.removeAt(index);}; int rowCount() {return items_.size();}; ChatListItem* item(int i) {return items_[i];}; int row(ChatListItem* item) {return items_.indexOf(item);}; - QVariant data(int role) {return (role == Qt::DisplayRole) ? name_ : QVariant();}; + QVariant data(int role) const {return (role == Qt::DisplayRole) ? name_ : QVariant();}; private: + static bool pointerItemLessThan(const ChatListItem* first, const ChatListItem* second) { + QString myName = first->data(Qt::DisplayRole).toString().toLower(); + QString theirName = second->data(Qt::DisplayRole).toString().toLower(); + return myName < theirName; + } + QString name_; QList<ChatListItem*> items_; }; |