summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/MUCSearch/MUCSearchServiceItem.h')
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchServiceItem.h47
1 files changed, 27 insertions, 20 deletions
diff --git a/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h b/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h
index 306e85a..9f5e000 100644
--- a/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h
+++ b/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h
@@ -1,32 +1,39 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <QList>
+#include <memory>
+
+#include <boost/optional.hpp>
+
#include <QString>
+#include <QVector>
-#include "Swift/QtUI/MUCSearch/MUCSearchRoomItem.h"
+#include <Swift/QtUI/MUCSearch/MUCSearchRoomItem.h>
namespace Swift {
- class MUCSearchServiceItem : public MUCSearchItem {
- public:
- MUCSearchServiceItem(const QString& jidString) : jidString_(jidString) {}
- void addRoom(MUCSearchItem* room) {rooms_.push_back(room);}
- int rowCount() {return rooms_.count();}
- MUCSearchItem* getItem(int i) {return rooms_[i];}
- QVariant data(int role) {
- switch (role) {
- case Qt::DisplayRole: return QVariant(jidString_);
- default: return QVariant();
- }
- }
- QString getHost() const {return jidString_;}
- private:
- QList<MUCSearchItem*> rooms_;
- QString jidString_;
- };
+ class MUCSearchServiceItem : public MUCSearchItem, public std::enable_shared_from_this<MUCSearchServiceItem> {
+ public:
+ MUCSearchServiceItem(const QString& jidString);
+
+ void addRoom(std::shared_ptr<MUCSearchItem> room);
+ void addRooms(const std::vector<std::shared_ptr<MUCSearchItem>>& rooms);
+ int rowCount();
+ MUCSearchItem* getItem(int i);
+ QVariant data(int role);
+ QString getHost() const;
+ void setSorting(Qt::SortOrder sortOrder);
+
+ private:
+ void sort();
+
+ private:
+ QVector<std::shared_ptr<MUCSearchItem>> rooms_;
+ QString jidString_;
+ boost::optional<Qt::SortOrder> sortOrder_;
+ };
}