summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-08 12:14:01 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-13 12:29:20 (GMT)
commit705bd7256fa4812045677743fc1e939ccfd66d05 (patch)
tree84502c2c6bd6bda1bc38e7fce59cc451e05b21c4 /Swift/QtUI
parent61078c4e4fd553bf952bae5c9d44da6cb96a3a70 (diff)
downloadswift-contrib-705bd7256fa4812045677743fc1e939ccfd66d05.zip
swift-contrib-705bd7256fa4812045677743fc1e939ccfd66d05.tar.bz2
List MUCs available on services.
Resolves: #276
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchDelegate.cpp86
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchDelegate.h28
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchItem.h17
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchModel.cpp77
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchModel.h35
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchRoomItem.cpp26
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchRoomItem.h23
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchServiceItem.h32
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp112
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.h39
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui185
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindowFactory.h22
-rw-r--r--Swift/QtUI/QtMainWindow.cpp2
-rw-r--r--Swift/QtUI/QtSwift.cpp5
-rw-r--r--Swift/QtUI/QtSwift.h2
-rw-r--r--Swift/QtUI/SConscript5
16 files changed, 695 insertions, 1 deletions
diff --git a/Swift/QtUI/MUCSearch/MUCSearchDelegate.cpp b/Swift/QtUI/MUCSearch/MUCSearchDelegate.cpp
new file mode 100644
index 0000000..be92efe
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchDelegate.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <QPen>
+#include <QPainter>
+
+#include "Swift/QtUI/MUCSearch/MUCSearchDelegate.h"
+#include "Swift/QtUI/Roster/GroupItemDelegate.h"
+#include "Swift/QtUI/MUCSearch/MUCSearchItem.h"
+#include "Swift/QtUI/MUCSearch/MUCSearchRoomItem.h"
+#include "Swift/QtUI/MUCSearch/MUCSearchServiceItem.h"
+
+namespace Swift {
+
+MUCSearchDelegate::MUCSearchDelegate() {
+
+}
+
+MUCSearchDelegate::~MUCSearchDelegate() {
+
+}
+
+// QSize MUCSearchDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const {
+// // MUCSearchItem* item = static_cast<MUCSearchItem*>(index.internalPointer());
+// // if (item && dynamic_cast<MUCSearchMUCItem*>(item)) {
+// // return mucSizeHint(option, index);
+// // } else if (item && dynamic_cast<MUCSearchGroupItem*>(item)) {
+// // return groupDelegate_->sizeHint(option, index);
+// // }
+// return QStyledItemDelegate::sizeHint(option, index);
+// }
+
+// QSize MUCSearchDelegate::mucSizeHint(const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/ ) const {
+// QFontMetrics nameMetrics(common_.nameFont);
+// QFontMetrics statusMetrics(common_.detailFont);
+// int sizeByText = 2 * common_.verticalMargin + nameMetrics.height() + statusMetrics.height();
+// return QSize(150, sizeByText);
+// }
+
+// void MUCSearchDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
+// MUCSearchItem* item = static_cast<MUCSearchItem*>(index.internalPointer());
+// if (item && dynamic_cast<MUCSearchMUCItem*>(item)) {
+// paintMUC(painter, option, dynamic_cast<MUCSearchMUCItem*>(item));
+// } else if (item && dynamic_cast<MUCSearchGroupItem*>(item)) {
+// MUCSearchGroupItem* group = dynamic_cast<MUCSearchGroupItem*>(item);
+// groupDelegate_->paint(painter, option, group->data(Qt::DisplayRole).toString(), group->rowCount(), option.state & QStyle::State_Open);
+// } else {
+// QStyledItemDelegate::paint(painter, option, index);
+// }
+// }
+
+// void MUCSearchDelegate::paintMUC(QPainter* painter, const QStyleOptionViewItem& option, MUCSearchMUCItem* item) const {
+// painter->save();
+// QRect fullRegion(option.rect);
+// if ( option.state & QStyle::State_Selected ) {
+// painter->fillRect(fullRegion, option.palette.highlight());
+// painter->setPen(option.palette.highlightedText().color());
+// } else {
+// QColor nameColor = item->data(Qt::TextColorRole).value<QColor>();
+// painter->setPen(QPen(nameColor));
+// }
+
+// QFontMetrics nameMetrics(common_.nameFont);
+// painter->setFont(common_.nameFont);
+// int extraFontWidth = nameMetrics.width("H");
+// int leftOffset = common_.horizontalMargin * 2 + extraFontWidth / 2;
+// QRect textRegion(fullRegion.adjusted(leftOffset, 0, 0, 0));
+
+// int nameHeight = nameMetrics.height() + common_.verticalMargin;
+// QRect nameRegion(textRegion.adjusted(0, common_.verticalMargin, 0, 0));
+
+// painter->drawText(nameRegion, Qt::AlignTop, item->data(Qt::DisplayRole).toString());
+
+// painter->setFont(common_.detailFont);
+// painter->setPen(QPen(QColor(160,160,160)));
+
+// QRect detailRegion(textRegion.adjusted(0, nameHeight, 0, 0));
+// painter->drawText(detailRegion, Qt::AlignTop, item->data(DetailTextRole).toString());
+
+// painter->restore();
+// }
+
+}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchDelegate.h b/Swift/QtUI/MUCSearch/MUCSearchDelegate.h
new file mode 100644
index 0000000..2662bb9
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchDelegate.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <QStyledItemDelegate>
+
+#include "Swift/QtUI/Roster/DelegateCommons.h"
+
+namespace Swift {
+ class MUCSearchDelegate : public QStyledItemDelegate {
+ public:
+ MUCSearchDelegate();
+ ~MUCSearchDelegate();
+ /* QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; */
+ /* void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; */
+ private:
+// void paintMUC(QPainter* painter, const QStyleOptionViewItem& option, MUCSearchMUCItem* item) const;
+// QSize mucSizeHint(const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/ ) const;
+
+ DelegateCommons common_;
+ };
+
+}
+
diff --git a/Swift/QtUI/MUCSearch/MUCSearchItem.h b/Swift/QtUI/MUCSearch/MUCSearchItem.h
new file mode 100644
index 0000000..7bac25d
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchItem.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <QVariant>
+
+namespace Swift {
+ class MUCSearchItem {
+ public:
+ virtual ~MUCSearchItem() {}
+ virtual QVariant data(int role) = 0;
+ };
+}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchModel.cpp b/Swift/QtUI/MUCSearch/MUCSearchModel.cpp
new file mode 100644
index 0000000..eb7fe20
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchModel.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swift/QtUI/MUCSearch/MUCSearchModel.h"
+
+namespace Swift {
+
+MUCSearchModel::MUCSearchModel() {
+}
+
+void MUCSearchModel::clear() {
+ emit layoutAboutToBeChanged();
+ services_.clear();
+ emit layoutChanged();
+}
+
+void MUCSearchModel::addService(MUCSearchServiceItem* service) {
+ emit layoutAboutToBeChanged();
+ services_.push_back(service);
+ emit layoutChanged();
+}
+
+int MUCSearchModel::columnCount(const QModelIndex& /*parent*/) const {
+ return 1;
+}
+
+QVariant MUCSearchModel::data(const QModelIndex& index, int role) const {
+ return index.isValid() ? static_cast<MUCSearchItem*>(index.internalPointer())->data(role) : QVariant();
+}
+
+QModelIndex MUCSearchModel::index(int row, int column, const QModelIndex & parent) const {
+ if (!hasIndex(row, column, parent)) {
+ return QModelIndex();
+ }
+
+ if (parent.isValid()) {
+ MUCSearchServiceItem* parentItem = static_cast<MUCSearchServiceItem*>(parent.internalPointer());
+ return row < parentItem->rowCount() ? createIndex(row, column, parentItem->getItem(row)) : QModelIndex();
+
+ } else {
+ return row < services_.size() ? createIndex(row, column, services_[row]) : QModelIndex();
+ }
+
+
+}
+
+QModelIndex MUCSearchModel::parent(const QModelIndex& index) const {
+ if (!index.isValid()) {
+ return QModelIndex();
+ }
+ MUCSearchItem* item = static_cast<MUCSearchItem*>(index.internalPointer());
+ if (!item) {
+ return QModelIndex();
+ }
+ if (dynamic_cast<MUCSearchServiceItem*>(item)) {
+ return QModelIndex();
+ }
+ MUCSearchServiceItem* parent = dynamic_cast<MUCSearchRoomItem*>(item)->getParent();
+ int row = services_.indexOf(parent);
+ return parent ? createIndex(row, 1, parent) : QModelIndex();
+}
+
+int MUCSearchModel::rowCount(const QModelIndex& parentIndex) const {
+ if (!parentIndex.isValid()) {
+ return services_.size();
+ }
+ if (dynamic_cast<MUCSearchServiceItem*>(static_cast<MUCSearchItem*>(parentIndex.internalPointer()))) {
+ return services_[parentIndex.row()]->rowCount();
+ } else {
+ return 0;
+ }
+}
+
+}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchModel.h b/Swift/QtUI/MUCSearch/MUCSearchModel.h
new file mode 100644
index 0000000..0c02c72
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchModel.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+
+#include <QAbstractItemModel>
+#include <QList>
+
+#include "Swift/QtUI/MUCSearch/MUCSearchServiceItem.h"
+
+namespace Swift {
+ class MUCSearchModel : public QAbstractItemModel {
+ Q_OBJECT
+ public:
+ MUCSearchModel();
+ void clear();
+ void addService(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;
+ private:
+// ChatListGroupItem* mucBookmarks_;
+// ChatListGroupItem* root_;
+ QList<MUCSearchServiceItem*> services_;
+ };
+
+}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchRoomItem.cpp b/Swift/QtUI/MUCSearch/MUCSearchRoomItem.cpp
new file mode 100644
index 0000000..a53a577
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchRoomItem.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swift/QtUI/MUCSearch/MUCSearchRoomItem.h"
+
+#include "Swift/QtUI/MUCSearch/MUCSearchServiceItem.h"
+
+namespace Swift {
+MUCSearchRoomItem::MUCSearchRoomItem(const QString& node, MUCSearchServiceItem* parent) : parent_(parent), node_(node) {
+ parent_->addRoom(this);
+}
+
+MUCSearchServiceItem* MUCSearchRoomItem::getParent() {
+ return parent_;
+}
+QVariant MUCSearchRoomItem::data(int role) {
+ switch (role) {
+ case Qt::DisplayRole: return QVariant(node_);
+ default: return QVariant();
+ }
+}
+
+}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchRoomItem.h b/Swift/QtUI/MUCSearch/MUCSearchRoomItem.h
new file mode 100644
index 0000000..920aaae
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchRoomItem.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swift/QtUI/MUCSearch/MUCSearchItem.h"
+
+namespace Swift {
+ class MUCSearchServiceItem;
+ class MUCSearchRoomItem : public MUCSearchItem {
+ public:
+ MUCSearchRoomItem(const QString& node, MUCSearchServiceItem* parent);
+ MUCSearchServiceItem* getParent();
+ QVariant data(int role);
+ QString getNode() {return node_;}
+ private:
+ MUCSearchServiceItem* parent_;
+ QString node_;
+ };
+}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h b/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h
new file mode 100644
index 0000000..860792f
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <QList>
+#include <QString>
+
+#include "Swift/QtUI/MUCSearch/MUCSearchRoomItem.h"
+
+namespace Swift {
+ class MUCSearchServiceItem : public MUCSearchItem {
+ public:
+ MUCSearchServiceItem(const QString& jidString) : jidString_(jidString) {}
+ void addRoom(MUCSearchRoomItem* room) {rooms_.push_back(room);}
+ int rowCount() {return rooms_.count();}
+ MUCSearchRoomItem* getItem(int i) {return rooms_[i];}
+ QVariant data(int role) {
+ switch (role) {
+ case Qt::DisplayRole: return QVariant(jidString_);
+ default: return QVariant();
+ }
+ }
+ QString getHost() {return jidString_;}
+ private:
+ QList<MUCSearchRoomItem*> rooms_;
+ QString jidString_;
+ };
+}
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
new file mode 100644
index 0000000..78e4fa5
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swift/QtUI/MUCSearch/QtMUCSearchWindow.h"
+
+#include <qdebug.h>
+
+#include "Swift/Controllers/UIEvents/UIEventStream.h"
+#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
+#include "Swift/QtUI/MUCSearch/MUCSearchModel.h"
+#include "Swift/QtUI/MUCSearch/MUCSearchDelegate.h"
+#include "Swift/QtUI/QtSwiftUtil.h"
+
+namespace Swift {
+
+QtMUCSearchWindow::QtMUCSearchWindow(UIEventStream* eventStream) {
+ eventStream_ = eventStream;
+ setupUi(this);
+ showEmptyRooms_->hide();
+ filterLabel_->hide();
+ filter_->hide();
+ model_ = new MUCSearchModel();
+ delegate_ = new MUCSearchDelegate();
+ results_->setModel(model_);
+ results_->setItemDelegate(delegate_);
+ results_->setHeaderHidden(true);
+#ifdef SWIFT_PLATFORM_MACOSX
+ results_->setAlternatingRowColors(true);
+#endif
+ connect(searchButton_, SIGNAL(clicked()), this, SLOT(handleSearch()));
+ connect(joinButton_, SIGNAL(clicked()), this, SLOT(handleJoin()));
+ connect(results_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(handleSelected(const QModelIndex&)));
+ connect(results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleActivated(const QModelIndex&)));
+}
+
+QtMUCSearchWindow::~QtMUCSearchWindow() {
+
+}
+
+void QtMUCSearchWindow::handleActivated(const QModelIndex& index) {
+ if (!index.isValid()) {
+ return;
+ }
+ MUCSearchRoomItem* roomItem = dynamic_cast<MUCSearchRoomItem*>(static_cast<MUCSearchItem*>(index.internalPointer()));
+ if (roomItem) {
+ handleSelected(index);
+ handleJoin();
+ }
+}
+
+void QtMUCSearchWindow::handleSelected(const QModelIndex& current) {
+ if (!current.isValid()) {
+ return;
+ }
+ MUCSearchRoomItem* roomItem = dynamic_cast<MUCSearchRoomItem*>(static_cast<MUCSearchItem*>(current.internalPointer()));
+ if (roomItem) {
+ room_->setText(roomItem->getNode() + "@" + roomItem->getParent()->getHost());
+ }
+
+}
+
+void QtMUCSearchWindow::handleSearch() {
+ if (service_->text().isEmpty()) {
+ return;
+ }
+ onAddService(JID(Q2PSTRING(service_->text())));
+}
+
+void QtMUCSearchWindow::handleJoin() {
+ if (room_->text().isEmpty()) {
+ handleSelected(results_->currentIndex());
+ }
+ if (room_->text().isEmpty()) {
+ return;
+ }
+ boost::optional<String> maybeNick;
+ if (!nickName_->text().isEmpty()) {
+ maybeNick = Q2PSTRING(nickName_->text());
+ }
+ eventStream_->send(boost::shared_ptr<UIEvent>(new JoinMUCUIEvent(JID(Q2PSTRING(room_->text())), maybeNick)));
+ hide();
+}
+
+void QtMUCSearchWindow::setNick(const String& nick) {
+ nickName_->setText(P2QSTRING(nick));
+}
+
+void QtMUCSearchWindow::setMUC(const String& nick) {
+ room_->setText(P2QSTRING(nick));
+}
+
+void QtMUCSearchWindow::show() {
+ QWidget::show();
+ QWidget::activateWindow();
+}
+
+void QtMUCSearchWindow::clearList() {
+ model_->clear();
+}
+
+void QtMUCSearchWindow::addService(const MUCService& service) {
+ MUCSearchServiceItem* serviceItem = new MUCSearchServiceItem(P2QSTRING(service.getJID().toString()));
+ foreach (MUCService::MUCRoom room, service.getRooms()) {
+ new MUCSearchRoomItem(P2QSTRING(room.getNode()), serviceItem);
+ }
+ model_->addService(serviceItem);
+}
+
+}
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h
new file mode 100644
index 0000000..7b556b0
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swift/QtUI/MUCSearch/ui_QtMUCSearchWindow.h"
+
+#include "Swift/Controllers/UIInterfaces/MUCSearchWindow.h"
+
+namespace Swift {
+ class MUCSearchModel;
+ class MUCSearchDelegate;
+ class UIEventStream;
+ class QtMUCSearchWindow : public QWidget, public MUCSearchWindow, private Ui::QtMUCSearchWindow {
+ Q_OBJECT
+ public:
+ QtMUCSearchWindow(UIEventStream* eventStream);
+ virtual ~QtMUCSearchWindow();
+
+ virtual void setNick(const String& nick);
+ virtual void setMUC(const String& nick);
+ virtual void clearList();
+ virtual void addService(const MUCService& service);
+
+ virtual void show();
+ private slots:
+ void handleSearch();
+ void handleJoin();
+ void handleSelected(const QModelIndex& current);
+ void handleActivated(const QModelIndex& index);
+ private:
+ MUCSearchModel* model_;
+ MUCSearchDelegate* delegate_;
+ UIEventStream* eventStream_;
+ };
+}
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui
new file mode 100644
index 0000000..d3d327e
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QtMUCSearchWindow</class>
+ <widget class="QWidget" name="QtMUCSearchWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>502</width>
+ <height>526</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Find Room</string>
+ </property>
+ <widget class="QTreeView" name="results_">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>30</y>
+ <width>256</width>
+ <height>441</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>251</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Available Rooms</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="service_">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>140</y>
+ <width>211</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_2">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>120</y>
+ <width>201</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Search another service:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="filterLabel_">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>260</y>
+ <width>211</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Only show rooms matching:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="filter_">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>280</y>
+ <width>211</width>
+ <height>26</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_4">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>410</y>
+ <width>211</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Join Room Directly:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_5">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>10</y>
+ <width>211</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Your nickname:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="nickName_">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>30</y>
+ <width>211</width>
+ <height>26</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="room_">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>430</y>
+ <width>201</width>
+ <height>26</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="joinButton_">
+ <property name="geometry">
+ <rect>
+ <x>210</x>
+ <y>480</y>
+ <width>92</width>
+ <height>28</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Join Room</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="showEmptyRooms_">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>310</y>
+ <width>201</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Show Empty Rooms</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="searchButton_">
+ <property name="geometry">
+ <rect>
+ <x>410</x>
+ <y>170</y>
+ <width>80</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Search</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindowFactory.h b/Swift/QtUI/MUCSearch/QtMUCSearchWindowFactory.h
new file mode 100644
index 0000000..9bcb53f
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindowFactory.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swift/Controllers/UIInterfaces/MUCSearchWindowFactory.h"
+#include "Swift/QtUI/MUCSearch/QtMUCSearchWindow.h"
+
+namespace Swift {
+ class UIEventStream;
+ class QtMUCSearchWindowFactory : public MUCSearchWindowFactory {
+ public:
+ virtual ~QtMUCSearchWindowFactory() {};
+
+ MUCSearchWindow* createMUCSearchWindow(UIEventStream* eventStream) {
+ return new QtMUCSearchWindow(eventStream);
+ };
+ };
+}
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index fcfb693..7d987c6 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -25,6 +25,7 @@
#include "QtTabWidget.h"
#include "Roster/QtTreeWidget.h"
#include "Swift/Controllers/UIEvents/AddContactUIEvent.h"
+#include "Swift/Controllers/UIEvents/RequestMUCSearchUIEvent.h"
#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
namespace Swift {
@@ -138,6 +139,7 @@ void QtMainWindow::handleJoinMUCAction() {
QtJoinMUCDialog* joinMUC = new QtJoinMUCDialog("jabber@conference.jabber.org", "SwiftUser", this);
connect(joinMUC, SIGNAL(onJoinCommand(const JID&, const QString&)), SLOT(handleJoinMUCDialogComplete(const JID&, const QString&)));
joinMUC->show();
+ uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestMUCSearchUIEvent()));
}
void QtMainWindow::handleJoinMUCDialogComplete(const JID& muc, const QString& nick) {
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 534697b..3b286b4 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -16,6 +16,7 @@
#include "QtXMLConsoleWidgetFactory.h"
#include "ChatList/QtChatListWindowFactory.h"
#include "EventViewer/QtEventWindowFactory.h"
+#include "MUCSearch/QtMUCSearchWindowFactory.h"
#include <boost/bind.hpp>
#include <QSplitter>
@@ -71,11 +72,12 @@ QtSwift::QtSwift(po::variables_map options) : autoUpdater_(NULL) {
eventWindowFactory_ = new QtEventWindowFactory(rosterWindowFactory_);
xmlConsoleWidgetFactory_ = new QtXMLConsoleWidgetFactory(tabs_);
chatListWindowFactory_ = new QtChatListWindowFactory(rosterWindowFactory_);
+ mucSearchWindowFactory_ = new QtMUCSearchWindowFactory();
soundPlayer_ = new QtSoundPlayer();
if (splitter_) {
splitter_->show();
}
- mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, eventWindowFactory_, settings_, application_, systemTray_, soundPlayer_, xmlConsoleWidgetFactory_, chatListWindowFactory_, options.count("latency-debug") > 0);
+ mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, eventWindowFactory_, settings_, application_, systemTray_, soundPlayer_, xmlConsoleWidgetFactory_, chatListWindowFactory_, mucSearchWindowFactory_, options.count("latency-debug") > 0);
PlatformAutoUpdaterFactory autoUpdaterFactory;
if (autoUpdaterFactory.isSupported()) {
@@ -89,6 +91,7 @@ QtSwift::~QtSwift() {
delete chatWindowFactory_;
delete rosterWindowFactory_;
delete loginWindowFactory_;
+ delete mucSearchWindowFactory_;
delete mainController_;
delete settings_;
delete application_;
diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h
index d0141b2..37dd4ce 100644
--- a/Swift/QtUI/QtSwift.h
+++ b/Swift/QtUI/QtSwift.h
@@ -33,6 +33,7 @@ namespace Swift {
class QtSoundPlayer;
class QtEventWindowFactory;
class QtChatListWindowFactory;
+ class QtMUCSearchWindowFactory;
class QtSwift : public QObject {
Q_OBJECT
@@ -56,6 +57,7 @@ namespace Swift {
QtEventWindowFactory* eventWindowFactory_;
Application* application_;
AutoUpdater* autoUpdater_;
+ QtMUCSearchWindowFactory* mucSearchWindowFactory_;
};
}
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 4311623..4ccb301 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -95,6 +95,10 @@ sources = [
"ChatList/ChatListModel.cpp",
"ChatList/ChatListDelegate.cpp",
"ChatList/ChatListMUCItem.cpp",
+ "MUCSearch/QtMUCSearchWindow.cpp",
+ "MUCSearch/MUCSearchModel.cpp",
+ "MUCSearch/MUCSearchRoomItem.cpp",
+ "MUCSearch/MUCSearchDelegate.cpp",
"ContextMenus/QtRosterContextMenu.cpp",
"ContextMenus/QtContextMenu.cpp",
"QtSubscriptionRequestWindow.cpp",
@@ -116,6 +120,7 @@ else :
swiftProgram = myenv.Program("swift", sources)
myenv.Uic4("QtJoinMUCDialog.ui")
+myenv.Uic4("MUCSearch/QtMUCSearchWindow.ui")
myenv.Uic4("QtAddContactDialog.ui")
myenv.Uic4("QtBookmarkDetailWindow.ui")
myenv.Qrc("DefaultTheme.qrc")