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/QtMUCSearchWindow.cpp
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/QtMUCSearchWindow.cpp')
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
index 8bef7e4..114ec1d 100644
--- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
@@ -6,13 +6,14 @@
#include <Swift/QtUI/MUCSearch/QtMUCSearchWindow.h>
+#include <memory>
+#include <vector>
+
#include <QMovie>
#include <QPushButton>
#include <QScrollBar>
#include <QTimer>
-#include <qdebug.h>
-
#include <Swift/Controllers/UIEvents/AddMUCBookmarkUIEvent.h>
#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h>
@@ -38,6 +39,8 @@ QtMUCSearchWindow::QtMUCSearchWindow() {
ui_.results_->setRootIsDecorated(true);
ui_.results_->setAnimated(true);
ui_.results_->setAlternatingRowColors(true);
+ ui_.results_->setSortingEnabled(true);
+ ui_.results_->sortByColumn(0, Qt::AscendingOrder);
connect(ui_.searchButton, SIGNAL(clicked()), this, SLOT(handleSearch()));
connect(ui_.service_, SIGNAL(activated(const QString&)), this, SLOT(handleSearch(const QString&)));
connect(ui_.results_->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT(handleSelectionChanged (const QItemSelection&, const QItemSelection&)));
@@ -86,7 +89,7 @@ void QtMUCSearchWindow::updateThrobberPosition() {
void QtMUCSearchWindow::addSavedServices(const std::list<JID>& services) {
ui_.service_->clear();
- foreach (const JID& jid, services) {
+ for (const auto& jid : services) {
ui_.service_->addItem(P2QSTRING(jid.toString()));
}
if (!services.empty()) {
@@ -127,14 +130,18 @@ void QtMUCSearchWindow::clearList() {
void QtMUCSearchWindow::addService(const MUCService& service) {
updateThrobberPosition();
- MUCSearchServiceItem* serviceItem = new MUCSearchServiceItem(P2QSTRING(service.getJID().toString()));
+ auto serviceItem = std::make_shared<MUCSearchServiceItem>(P2QSTRING(service.getJID().toString()));
if (service.getRooms().size() > 0) {
- foreach (MUCService::MUCRoom room, service.getRooms()) {
- new MUCSearchRoomItem(P2QSTRING(room.getNode()), serviceItem);
+ std::vector<std::shared_ptr<MUCSearchItem>> rooms;
+ for (auto&& room : service.getRooms()) {
+ if (!room.getNode().empty()) {
+ rooms.push_back(std::make_shared<MUCSearchRoomItem>(P2QSTRING(room.getNode())));
+ }
}
+ serviceItem->addRooms(rooms);
}
else {
- new MUCSearchEmptyItem(serviceItem);
+ serviceItem->addRoom(std::make_shared<MUCSearchEmptyItem>());
}
model_->addService(serviceItem);
ui_.results_->expandAll();