summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtFormResultItemModel.cpp87
-rw-r--r--Swift/QtUI/QtFormResultItemModel.h36
-rw-r--r--Swift/QtUI/SConscript1
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchFieldsPage.cpp23
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchFieldsPage.h9
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchFieldsPage.ui39
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchResultsPage.ui6
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.cpp102
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.h4
9 files changed, 259 insertions, 48 deletions
diff --git a/Swift/QtUI/QtFormResultItemModel.cpp b/Swift/QtUI/QtFormResultItemModel.cpp
new file mode 100644
index 0000000..5461f05
--- /dev/null
+++ b/Swift/QtUI/QtFormResultItemModel.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2012 Tobias Markmann
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include "QtFormResultItemModel.h"
+
+#include <boost/algorithm/string/join.hpp>
+
+#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swiften/Base/foreach.h>
+
+namespace Swift {
+
+QtFormResultItemModel::QtFormResultItemModel(QObject *parent) : QAbstractTableModel(parent) {
+
+}
+
+QtFormResultItemModel::QtFormResultItemModel(QObject* parent, Form::ref formResult) : QAbstractTableModel(parent), formResult_(formResult) {
+
+}
+
+void QtFormResultItemModel::setForm(Form::ref formResult) {
+ emit layoutAboutToBeChanged();
+ formResult_ = formResult;
+ emit layoutChanged();
+}
+
+const Form::ref QtFormResultItemModel::getForm() const {
+ return formResult_;
+}
+
+QVariant QtFormResultItemModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const {
+ if (!formResult_) return QVariant();
+ if (role != Qt::DisplayRole) return QVariant();
+ if (static_cast<size_t>(section) >= formResult_->getReportedFields().size()) return QVariant();
+ return QVariant(QString::fromStdString(formResult_->getReportedFields().at(section)->getLabel()));
+}
+
+int QtFormResultItemModel::rowCount(const QModelIndex &/*parent*/) const {
+ if (!formResult_) return 0;
+ return formResult_->getItems().size();
+}
+
+int QtFormResultItemModel::columnCount(const QModelIndex &/*parent*/) const {
+ if (!formResult_) return 0;
+ return formResult_->getReportedFields().size();
+}
+
+QVariant QtFormResultItemModel::data(const QModelIndex &index, int role) const {
+ if (!formResult_) return QVariant();
+ if (role != Qt::DisplayRole || !index.isValid()) {
+ return QVariant();
+ }
+
+ if (static_cast<size_t>(index.row()) >= formResult_->getItems().size()) return QVariant();
+ if (static_cast<size_t>(index.column()) >= formResult_->getReportedFields().size()) return QVariant();
+
+ Form::FormItem item = formResult_->getItems().at(index.row());
+
+ return QVariant(P2QSTRING(getFieldValue(item, index.column())));
+}
+
+const std::string QtFormResultItemModel::getFieldValue(const Form::FormItem& item, const int column) const {
+ // determine field name
+ std::string name = formResult_->getReportedFields().at(column)->getName();
+
+ foreach(FormField::ref field, item) {
+ if (field->getName() == name) {
+ std::string delimiter = "";
+ if (boost::dynamic_pointer_cast<TextMultiFormField>(field)) {
+ delimiter = "\n";
+ } else if (boost::dynamic_pointer_cast<JIDMultiFormField>(field)) {
+ delimiter = ", ";
+ } else if (boost::dynamic_pointer_cast<ListMultiFormField>(field)) {
+ delimiter = ", ";
+ }
+
+ return boost::algorithm::join(field->getRawValues(), delimiter);
+ }
+ }
+
+ return "";
+}
+
+}
diff --git a/Swift/QtUI/QtFormResultItemModel.h b/Swift/QtUI/QtFormResultItemModel.h
new file mode 100644
index 0000000..f383f74
--- /dev/null
+++ b/Swift/QtUI/QtFormResultItemModel.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012 Tobias Markmann
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <QAbstractTableModel>
+
+#include <Swiften/Elements/Form.h>
+
+namespace Swift {
+
+class QtFormResultItemModel : public QAbstractTableModel {
+ Q_OBJECT
+ public:
+ QtFormResultItemModel(QObject* parent);
+ QtFormResultItemModel(QObject* parent, Form::ref formResult);
+
+ void setForm(Form::ref formResult);
+ const Form::ref getForm() const;
+
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+
+ private:
+ const std::string getFieldValue(const Form::FormItem& item, const int column) const;
+
+ private:
+ Form::ref formResult_;
+};
+
+}
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 95ec49a..2283001 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -93,18 +93,19 @@ sources = [
"QtAddBookmarkWindow.cpp",
"QtEditBookmarkWindow.cpp",
"QtContactEditWindow.cpp",
"QtContactEditWidget.cpp",
"ChatSnippet.cpp",
"MessageSnippet.cpp",
"SystemMessageSnippet.cpp",
"QtElidingLabel.cpp",
"QtFormWidget.cpp",
+ "QtFormResultItemModel.cpp",
"QtLineEdit.cpp",
"QtJoinMUCWindow.cpp",
"Roster/RosterModel.cpp",
"Roster/QtTreeWidget.cpp",
# "Roster/QtTreeWidgetItem.cpp",
"Roster/RosterDelegate.cpp",
"Roster/GroupItemDelegate.cpp",
"Roster/DelegateCommons.cpp",
"Roster/QtRosterWidget.cpp",
diff --git a/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.cpp b/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.cpp
index 3ef048b..13858a7 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.cpp
@@ -2,22 +2,41 @@
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Swift/QtUI/UserSearch/QtUserSearchFieldsPage.h"
namespace Swift {
-QtUserSearchFieldsPage::QtUserSearchFieldsPage() {
+QtUserSearchFieldsPage::QtUserSearchFieldsPage() : formWidget_(0) {
setupUi(this);
}
bool QtUserSearchFieldsPage::isComplete() const {
- return nickInput_->isEnabled() || firstInput_->isEnabled() || lastInput_->isEnabled() || emailInput_->isEnabled();
+ if (formWidget_) {
+ return formWidget_->isEnabled();
+ } else {
+ return nickInput_->isEnabled() || firstInput_->isEnabled() || lastInput_->isEnabled() || emailInput_->isEnabled();
+ }
+}
+
+QtFormWidget* QtUserSearchFieldsPage::getFormWidget() {
+ return formWidget_;
+}
+
+void QtUserSearchFieldsPage::setFormWidget(QtFormWidget *widget) {
+ if (formWidget_) {
+ delete formWidget_;
+ formWidget_ = NULL;
+ }
+ if (widget) {
+ formContainer_->layout()->addWidget(widget);
+ }
+ formWidget_ = widget;
}
void QtUserSearchFieldsPage::emitCompletenessCheck() {
emit completeChanged();
}
}
diff --git a/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.h b/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.h
index 12c28b5..066205b 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.h
+++ b/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.h
@@ -2,21 +2,30 @@
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <QWizardPage>
+#include <Swift/QtUI/QtFormWidget.h>
+
#include <Swift/QtUI/UserSearch/ui_QtUserSearchFieldsPage.h>
namespace Swift {
class QtUserSearchFieldsPage : public QWizardPage, public Ui::QtUserSearchFieldsPage {
Q_OBJECT
public:
QtUserSearchFieldsPage();
virtual bool isComplete() const;
+
+ QtFormWidget* getFormWidget();
+ void setFormWidget(QtFormWidget *widget);
+
public slots:
void emitCompletenessCheck();
+
+ private:
+ QtFormWidget *formWidget_;
};
}
diff --git a/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.ui b/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.ui
index fa6e376..f972516 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.ui
+++ b/Swift/QtUI/UserSearch/QtUserSearchFieldsPage.ui
@@ -5,19 +5,19 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
- <string></string>
+ <string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="instructionsLabel_">
<property name="text">
<string/>
</property>
</widget>
</item>
@@ -55,41 +55,50 @@
<widget class="QLabel" name="emailInputLabel_">
<property name="text">
<string>E-Mail:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="emailInput_"/>
</item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="fetchingThrobber_">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
<item row="6" column="1">
+ <widget class="QLabel" name="fetchingLabel_">
+ <property name="text">
+ <string>Fetching search fields</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QWidget" name="formContainer_" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ </layout>
+ </widget>
+ </item>
+ <item row="7" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
- <item row="5" column="0">
- <widget class="QLabel" name="fetchingThrobber_">
- <property name="text">
- <string></string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QLabel" name="fetchingLabel_">
- <property name="text">
- <string>Fetching search fields</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
diff --git a/Swift/QtUI/UserSearch/QtUserSearchResultsPage.ui b/Swift/QtUI/UserSearch/QtUserSearchResultsPage.ui
index f312fde..ceb15e1 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchResultsPage.ui
+++ b/Swift/QtUI/UserSearch/QtUserSearchResultsPage.ui
@@ -5,22 +5,22 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
- <string></string>
+ <string/>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
+ <layout class="QGridLayout" name="layout">
+ <item row="0" column="0">
<widget class="QTreeView" name="results_">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index 0559683..933612c 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -1,65 +1,65 @@
/*
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Swift/QtUI/UserSearch/QtUserSearchWindow.h"
+#include <QItemDelegate>
#include <QModelIndex>
#include <QWizardPage>
#include <QMovie>
#include <boost/smart_ptr/make_shared.hpp>
+#include <Swiften/Base/foreach.h>
#include "Swift/Controllers/UIEvents/UIEventStream.h"
#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h"
#include "Swift/Controllers/UIEvents/AddContactUIEvent.h"
#include "Swift/QtUI/UserSearch/UserSearchModel.h"
#include "Swift/QtUI/UserSearch/UserSearchDelegate.h"
#include "Swift/QtUI/QtSwiftUtil.h"
+#include "Swift/QtUI/QtFormResultItemModel.h"
#include "QtUserSearchFirstPage.h"
#include "QtUserSearchFieldsPage.h"
#include "QtUserSearchResultsPage.h"
#include "QtUserSearchDetailsPage.h"
namespace Swift {
-QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type, const std::set<std::string>& groups) : eventStream_(eventStream), type_(type) {
+QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type, const std::set<std::string>& groups) : eventStream_(eventStream), type_(type), model_(NULL) {
setupUi(this);
#ifndef Q_WS_MAC
setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
QString title(type == UserSearchWindow::AddContact ? tr("Add Contact") : tr("Chat to User"));
setWindowTitle(title);
- model_ = new UserSearchModel();
delegate_ = new UserSearchDelegate();
firstPage_ = new QtUserSearchFirstPage(type, title);
connect(firstPage_->byJID_, SIGNAL(toggled(bool)), this, SLOT(handleFirstPageRadioChange()));
connect(firstPage_->byLocalSearch_, SIGNAL(toggled(bool)), this, SLOT(handleFirstPageRadioChange()));
connect(firstPage_->byRemoteSearch_, SIGNAL(toggled(bool)), this, SLOT(handleFirstPageRadioChange()));
#if QT_VERSION >= 0x040700
firstPage_->jid_->setPlaceholderText(tr("alice@wonderland.lit"));
#endif
firstPage_->service_->setEnabled(false);
setPage(1, firstPage_);
fieldsPage_ = new QtUserSearchFieldsPage();
fieldsPage_->fetchingThrobber_->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), this));
fieldsPage_->fetchingThrobber_->movie()->stop();
setPage(2, fieldsPage_);
resultsPage_ = new QtUserSearchResultsPage();
- resultsPage_->results_->setModel(model_);
- resultsPage_->results_->setItemDelegate(delegate_);
- resultsPage_->results_->setHeaderHidden(true);
+
#ifdef SWIFT_PLATFORM_MACOSX
resultsPage_->results_->setAlternatingRowColors(true);
#endif
if (type == AddContact) {
connect(resultsPage_, SIGNAL(onUserTriggersContinue()), this, SLOT(next()));
}
else {
connect(resultsPage_, SIGNAL(onUserTriggersContinue()), this, SLOT(accept()));
}
@@ -68,19 +68,19 @@ QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWin
detailsPage_ = new QtUserSearchDetailsPage(groups);
setPage(4, detailsPage_);
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(handleCurrentChanged(int)));
connect(this, SIGNAL(accepted()), this, SLOT(handleAccepted()));
clear();
}
QtUserSearchWindow::~QtUserSearchWindow() {
-
+ delete model_;
}
void QtUserSearchWindow::handleCurrentChanged(int page) {
if (page == 2 && lastPage_ == 1) {
setError("");
/* next won't be called if JID is selected */
JID server = getServerToSearch();
clearForm();
onFormRequested(server);
@@ -95,21 +95,40 @@ void QtUserSearchWindow::handleCurrentChanged(int page) {
}
JID QtUserSearchWindow::getServerToSearch() {
return firstPage_->byRemoteSearch_->isChecked() ? JID(Q2PSTRING(firstPage_->service_->currentText())) : myServer_;
}
void QtUserSearchWindow::handleAccepted() {
JID jid;
if (!firstPage_->byJID_->isChecked()) {
- UserSearchResult* userItem = static_cast<UserSearchResult*>(resultsPage_->results_->currentIndex().internalPointer());
- if (userItem) { /* Remember to leave this if we change to dynamic cast */
- jid = userItem->getJID();
+ if (dynamic_cast<UserSearchModel*>(model_)) {
+ UserSearchResult* userItem = static_cast<UserSearchResult*>(resultsPage_->results_->currentIndex().internalPointer());
+ if (userItem) { /* Remember to leave this if we change to dynamic cast */
+ jid = userItem->getJID();
+ }
+ } else {
+ int row = resultsPage_->results_->currentIndex().row();
+
+ Form::FormItem item = dynamic_cast<QtFormResultItemModel*>(model_)->getForm()->getItems().at(row);
+ JID fallbackJid;
+ foreach(FormField::ref field, item) {
+ if (boost::dynamic_pointer_cast<JIDSingleFormField>(field)) {
+ jid = JID(field->getRawValues().at(0));
+ break;
+ }
+ if (field->getName() == "jid") {
+ fallbackJid = field->getRawValues().at(0);
+ }
+ }
+ if (!jid.isValid()) {
+ jid = fallbackJid;
+ }
}
}
else {
jid = JID(Q2PSTRING(firstPage_->jid_->text()));
}
if (type_ == AddContact) {
eventStream_->send(boost::make_shared<AddContactUIEvent>(jid, detailsPage_->getName(), detailsPage_->getSelectedGroups()));
}
@@ -146,29 +165,33 @@ void QtUserSearchWindow::handleFirstPageRadioChange() {
else {
firstPage_->jid_->setEnabled(false);
firstPage_->service_->setEnabled(false);
restart();
}
}
void QtUserSearchWindow::handleSearch() {
boost::shared_ptr<SearchPayload> search(new SearchPayload());
- if (fieldsPage_->nickInput_->isEnabled()) {
- search->setNick(Q2PSTRING(fieldsPage_->nickInput_->text()));
- }
- if (fieldsPage_->firstInput_->isEnabled()) {
- search->setFirst(Q2PSTRING(fieldsPage_->firstInput_->text()));
- }
- if (fieldsPage_->lastInput_->isEnabled()) {
- search->setLast(Q2PSTRING(fieldsPage_->lastInput_->text()));
- }
- if (fieldsPage_->emailInput_->isEnabled()) {
- search->setEMail(Q2PSTRING(fieldsPage_->emailInput_->text()));
+ if (fieldsPage_->getFormWidget()) {
+ search->setForm(fieldsPage_->getFormWidget()->getCompletedForm());
+ } else {
+ if (fieldsPage_->nickInput_->isEnabled()) {
+ search->setNick(Q2PSTRING(fieldsPage_->nickInput_->text()));
+ }
+ if (fieldsPage_->firstInput_->isEnabled()) {
+ search->setFirst(Q2PSTRING(fieldsPage_->firstInput_->text()));
+ }
+ if (fieldsPage_->lastInput_->isEnabled()) {
+ search->setLast(Q2PSTRING(fieldsPage_->lastInput_->text()));
+ }
+ if (fieldsPage_->emailInput_->isEnabled()) {
+ search->setEMail(Q2PSTRING(fieldsPage_->emailInput_->text()));
+ }
}
onSearchRequested(search, getServerToSearch());
}
void QtUserSearchWindow::show() {
clear();
QWidget::show();
}
@@ -178,30 +201,53 @@ void QtUserSearchWindow::addSavedServices(const std::vector<JID>& services) {
firstPage_->service_->addItem(P2QSTRING(jid.toString()));
}
firstPage_->service_->clearEditText();
}
void QtUserSearchWindow::setSearchFields(boost::shared_ptr<SearchPayload> fields) {
fieldsPage_->fetchingThrobber_->hide();
fieldsPage_->fetchingThrobber_->movie()->stop();
fieldsPage_->fetchingLabel_->hide();
+
fieldsPage_->instructionsLabel_->setText(fields->getInstructions() ? P2QSTRING(fields->getInstructions().get()) : "Enter search terms");
- bool enabled[8] = {fields->getNick(), fields->getNick(), fields->getFirst(), fields->getFirst(), fields->getLast(), fields->getLast(), fields->getEMail(), fields->getEMail()};
- QWidget* legacySearchWidgets[8] = {fieldsPage_->nickInputLabel_, fieldsPage_->nickInput_, fieldsPage_->firstInputLabel_, fieldsPage_->firstInput_, fieldsPage_->lastInputLabel_, fieldsPage_->lastInput_, fieldsPage_->emailInputLabel_, fieldsPage_->emailInput_};
- for (int i = 0; i < 8; i++) {
- legacySearchWidgets[i]->setVisible(enabled[i]);
- legacySearchWidgets[i]->setEnabled(enabled[i]);
+ if (fields->getForm()) {
+ fieldsPage_->setFormWidget(new QtFormWidget(fields->getForm(), fieldsPage_));
+ } else {
+ fieldsPage_->setFormWidget(NULL);
+ bool enabled[8] = {fields->getNick(), fields->getNick(), fields->getFirst(), fields->getFirst(), fields->getLast(), fields->getLast(), fields->getEMail(), fields->getEMail()};
+ QWidget* legacySearchWidgets[8] = {fieldsPage_->nickInputLabel_, fieldsPage_->nickInput_, fieldsPage_->firstInputLabel_, fieldsPage_->firstInput_, fieldsPage_->lastInputLabel_, fieldsPage_->lastInput_, fieldsPage_->emailInputLabel_, fieldsPage_->emailInput_};
+ for (int i = 0; i < 8; i++) {
+ legacySearchWidgets[i]->setVisible(enabled[i]);
+ legacySearchWidgets[i]->setEnabled(enabled[i]);
+ }
}
fieldsPage_->emitCompletenessCheck();
}
void QtUserSearchWindow::setResults(const std::vector<UserSearchResult>& results) {
- model_->setResults(results);
+ UserSearchModel *newModel = new UserSearchModel();
+ newModel->setResults(results);
+ resultsPage_->results_->setModel(newModel);
+ resultsPage_->results_->setItemDelegate(delegate_);
+ resultsPage_->results_->setHeaderHidden(true);
+ delete model_;
+ model_ = newModel;
+}
+
+void QtUserSearchWindow::setResultsForm(Form::ref results) {
+ QtFormResultItemModel *newModel = new QtFormResultItemModel(this);
+ newModel->setForm(results);
+ resultsPage_->results_->setModel(newModel);
+ resultsPage_->results_->setItemDelegate(new QItemDelegate());
+ resultsPage_->results_->setHeaderHidden(false);
+ resultsPage_->results_->header()->setResizeMode(QHeaderView::ResizeToContents);
+ delete model_;
+ model_ = newModel;
}
void QtUserSearchWindow::setSelectedService(const JID& jid) {
myServer_ = jid;
}
void QtUserSearchWindow::clearForm() {
fieldsPage_->fetchingThrobber_->show();
fieldsPage_->fetchingThrobber_->movie()->start();
@@ -222,19 +268,21 @@ void QtUserSearchWindow::clear() {
if (type_ == AddContact) {
howText = QString(tr("How would you like to find the user to add?"));
}
else {
howText = QString(tr("How would you like to find the user to chat to?"));
}
firstPage_->howLabel_->setText(howText);
firstPage_->byJID_->setChecked(true);
clearForm();
- model_->clear();
+ resultsPage_->results_->setModel(NULL);
+ delete model_;
+ model_ = NULL;
handleFirstPageRadioChange();
restart();
lastPage_ = 1;
}
void QtUserSearchWindow::setError(const QString& error) {
if (error.isEmpty()) {
firstPage_->errorLabel_->hide();
}
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.h b/Swift/QtUI/UserSearch/QtUserSearchWindow.h
index bb40cd3..4cfe93f 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.h
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.h
@@ -15,30 +15,32 @@
namespace Swift {
class UserSearchModel;
class UserSearchDelegate;
class UserSearchResult;
class UIEventStream;
class QtUserSearchFirstPage;
class QtUserSearchFieldsPage;
class QtUserSearchResultsPage;
class QtUserSearchDetailsPage;
+ class QtFormResultItemModel;
class QtUserSearchWindow : public QWizard, public UserSearchWindow, private Ui::QtUserSearchWizard {
Q_OBJECT
public:
QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type, const std::set<std::string>& groups);
virtual ~QtUserSearchWindow();
virtual void addSavedServices(const std::vector<JID>& services);
virtual void clear();
virtual void show();
virtual void setResults(const std::vector<UserSearchResult>& results);
+ virtual void setResultsForm(Form::ref results);
virtual void setSelectedService(const JID& jid);
virtual void setServerSupportsSearch(bool error);
virtual void setSearchError(bool error);
virtual void setSearchFields(boost::shared_ptr<SearchPayload> fields) ;
protected:
virtual int nextId() const;
private slots:
void handleFirstPageRadioChange();
virtual void handleCurrentChanged(int);
@@ -46,19 +48,19 @@ namespace Swift {
private:
void clearForm();
void setError(const QString& error);
JID getServerToSearch();
void handleSearch();
private:
UIEventStream* eventStream_;
UserSearchWindow::Type type_;
- UserSearchModel* model_;
+ QAbstractItemModel* model_;
UserSearchDelegate* delegate_;
QtUserSearchFirstPage* firstPage_;
QtUserSearchFieldsPage* fieldsPage_;
QtUserSearchResultsPage* resultsPage_;
QtUserSearchDetailsPage* detailsPage_;
JID myServer_;
int lastPage_;
};
}