From d0442b239d93a0cb9a04b112d5df5c34d557da6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Fri, 21 Jan 2011 23:16:28 +0100 Subject: Disable 'ok' button when no MUC is selected in MUC search. Resolves: #749 diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp index de8ceb6..52fbf8c 100644 --- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp +++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp @@ -38,9 +38,12 @@ QtMUCSearchWindow::QtMUCSearchWindow() { ui_.results_->setAnimated(true); ui_.results_->setAlternatingRowColors(true); 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&))); + connect(ui_.results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleActivated(const QModelIndex&))); connect(ui_.results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleActivated(const QModelIndex&))); // Not using a button box, because i can't seem to be able to make the ok button non-default (on mac) connect(ui_.okButton, SIGNAL(clicked()), this, SLOT(accept())); + ui_.okButton->setEnabled(false); connect(ui_.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); throbber_ = new QLabel("Searching", ui_.results_); @@ -164,4 +167,14 @@ void QtMUCSearchWindow::reject() { QDialog::reject(); } +void QtMUCSearchWindow::handleSelectionChanged(const QItemSelection& selection, const QItemSelection&) { + if (selection.indexes().size() > 0) { + ui_.okButton->setEnabled(dynamic_cast(static_cast(selection.indexes()[0].internalPointer()))); + } + else { + ui_.okButton->setEnabled(false); + } +} + + } diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h index cb4585d..c7661c2 100644 --- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h +++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h @@ -37,6 +37,7 @@ namespace Swift { void handleSearch(const QString&); void handleActivated(const QModelIndex& index); void updateThrobberPosition(); + void handleSelectionChanged (const QItemSelection&, const QItemSelection&); private: Ui::QtMUCSearchWindow ui_; -- cgit v0.10.2-6-g49f6