diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-12-31 18:34:28 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-12-31 18:34:28 (GMT) |
commit | 3fdf13823a391c7db83e05685e78db19e4110e59 (patch) | |
tree | ba08b60b31f70ab0f2cf761ed71e704bc8db1b53 /Swift | |
parent | 04ba92366c3618b6c3b4cd9e3c8e81572e62c54a (diff) | |
download | swift-3fdf13823a391c7db83e05685e78db19e4110e59.zip swift-3fdf13823a391c7db83e05685e78db19e4110e59.tar.bz2 |
Disable user search wizard pages unless they're ready.
Resolves: #731
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.cpp | 51 | ||||
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.h | 24 |
2 files changed, 57 insertions, 18 deletions
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index acc6a46..7e3c98d 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -20,16 +20,53 @@ namespace Swift { -bool QtUserSearchFirstPage::isComplete() { - return true; +QtUserSearchFirstPage::QtUserSearchFirstPage() { + setupUi(this); + connect(jid_, SIGNAL(textChanged(const QString&)), this, SLOT(emitCompletenessCheck())); + connect(service_, SIGNAL(textChanged(const QString&)), this, SLOT(emitCompletenessCheck())); +} + +QtUserSearchFieldsPage::QtUserSearchFieldsPage() { + setupUi(this); +} + +QtUserSearchResultsPage::QtUserSearchResultsPage() { + setupUi(this); + connect(results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); + connect(results_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); + connect(results_, SIGNAL(entered(const QModelIndex&)), this, SLOT(emitCompletenessCheck())); +} + +bool QtUserSearchFirstPage::isComplete() const { + bool complete = false; + if (byJID_->isChecked()) { + complete = JID(Q2PSTRING(jid_->text())).isValid(); + } else if (byLocalSearch_->isChecked()) { + complete = true; + } else if (byRemoteSearch_->isChecked()) { + complete = JID(Q2PSTRING(service_->currentText())).isValid(); + } + return complete; +} + +bool QtUserSearchFieldsPage::isComplete() const { + return nickInput_->isEnabled() || firstInput_->isEnabled() || lastInput_->isEnabled() || emailInput_->isEnabled(); +} + +bool QtUserSearchResultsPage::isComplete() const { + return results_->currentIndex().isValid(); +} + +void QtUserSearchFirstPage::emitCompletenessCheck() { + emit completeChanged(); } -bool QtUserSearchFieldsPage::isComplete() { - return true; +void QtUserSearchFieldsPage::emitCompletenessCheck() { + emit completeChanged(); } -bool QtUserSearchResultsPage::isComplete() { - return true; +void QtUserSearchResultsPage::emitCompletenessCheck() { + emit completeChanged(); } QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type) : type_(type) { @@ -199,6 +236,7 @@ void QtUserSearchWindow::setSearchFields(boost::shared_ptr<SearchPayload> fields legacySearchWidgets[i]->setVisible(enabled[i]); legacySearchWidgets[i]->setEnabled(enabled[i]); } + fieldsPage_->emitCompletenessCheck(); } // //void QtUserSearchWindow::handleActivated(const QModelIndex& index) { @@ -238,6 +276,7 @@ void QtUserSearchWindow::clearForm() { for (int i = 0; i < 8; i++) { legacySearchWidgets[i]->hide(); } + fieldsPage_->emitCompletenessCheck(); } void QtUserSearchWindow::clear() { diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.h b/Swift/QtUI/UserSearch/QtUserSearchWindow.h index 4672d32..cc6eefb 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.h +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.h @@ -25,28 +25,28 @@ namespace Swift { class QtUserSearchFirstPage : public QWizardPage, public Ui::QtUserSearchFirstPage { Q_OBJECT public: - QtUserSearchFirstPage() { - setupUi(this); - } - virtual bool isComplete(); + QtUserSearchFirstPage(); + virtual bool isComplete() const; + public slots: + void emitCompletenessCheck(); }; class QtUserSearchFieldsPage : public QWizardPage, public Ui::QtUserSearchFieldsPage { Q_OBJECT public: - QtUserSearchFieldsPage() { - setupUi(this); - } - virtual bool isComplete(); + QtUserSearchFieldsPage(); + virtual bool isComplete() const; + public slots: + void emitCompletenessCheck(); }; class QtUserSearchResultsPage : public QWizardPage, public Ui::QtUserSearchResultsPage { Q_OBJECT public: - QtUserSearchResultsPage() { - setupUi(this); - } - virtual bool isComplete(); + QtUserSearchResultsPage(); + virtual bool isComplete() const; + public slots: + void emitCompletenessCheck(); }; class QtUserSearchWindow : public QWizard, public UserSearchWindow, private Ui::QtUserSearchWizard { |