summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-01-21 22:16:28 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-21 22:16:28 (GMT)
commitd0442b239d93a0cb9a04b112d5df5c34d557da6a (patch)
treeb1f87e5536531b206242d71dfc2946508b3dbc85 /Swift/QtUI
parent04f983d68e996708adcc7a68b852b0e953a28786 (diff)
downloadswift-contrib-d0442b239d93a0cb9a04b112d5df5c34d557da6a.zip
swift-contrib-d0442b239d93a0cb9a04b112d5df5c34d557da6a.tar.bz2
Disable 'ok' button when no MUC is selected in MUC search.
Resolves: #749
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp13
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.h1
2 files changed, 14 insertions, 0 deletions
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<MUCSearchRoomItem*>(static_cast<MUCSearchItem*>(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_;