summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-08-25 14:00:10 (GMT)
committerTobias Markmann <tm@ayena.de>2016-08-25 14:12:34 (GMT)
commit5a4e7d9518e91cf39b96f14b3b310fe5b9a27594 (patch)
treede15882d3bb6f7b5e8230deada40ccc705a25c9c /Swift/QtUI/MUCSearch/MUCSearchModel.h
parent5a19f3167b640966c582e52abe4b55ef20bd79b2 (diff)
downloadswift-5a4e7d9518e91cf39b96f14b3b310fe5b9a27594.zip
swift-5a4e7d9518e91cf39b96f14b3b310fe5b9a27594.tar.bz2
Alphabetically sort MUC search result
This also changes the classes around MUCSearchModel to C++11 smart pointer based memory management. Test-Information: Verified that dtors of MUCSearch*Items are called when old search results are replaced by new search results. This was not the case previously. All unit tests and manual testing with an ASAN enabled build succeeded. Change-Id: I84d62f3b86138728401b98d3774f47c72fdf9a4c
Diffstat (limited to 'Swift/QtUI/MUCSearch/MUCSearchModel.h')
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchModel.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/Swift/QtUI/MUCSearch/MUCSearchModel.h b/Swift/QtUI/MUCSearch/MUCSearchModel.h
index 2922ca6..f36d147 100644
--- a/Swift/QtUI/MUCSearch/MUCSearchModel.h
+++ b/Swift/QtUI/MUCSearch/MUCSearchModel.h
@@ -8,8 +8,10 @@
#include <memory>
+#include <boost/optional.hpp>
+
#include <QAbstractItemModel>
-#include <QList>
+#include <QVector>
#include <Swift/QtUI/MUCSearch/MUCSearchServiceItem.h>
@@ -19,17 +21,17 @@ namespace Swift {
public:
MUCSearchModel();
void clear();
- void addService(MUCSearchServiceItem* service);
+ void addService(std::shared_ptr<MUCSearchServiceItem> service);
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& index) const;
int rowCount(const QModelIndex& parent = QModelIndex()) const;
-// ChatListItem* getItemForIndex(const QModelIndex& index) const;
+ virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
private:
-// ChatListGroupItem* mucBookmarks_;
-// ChatListGroupItem* root_;
- QList<MUCSearchServiceItem*> services_;
+ QVector<std::shared_ptr<MUCSearchServiceItem>> services_;
+ boost::optional<Qt::SortOrder> sortOrder_;
};
}