Adjust whitespace in if statements.
[toast/confclerk.git] / src / gui / searchtabcontainer.cpp
index 3abc8e5b194dc907ddb9d5375af82dd0cd16a7b2..3c3d7bdd326c42cef91b777c04023ec61864a5b0 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
+ * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
  *
  * This file is part of ConfClerk.
  *
@@ -22,8 +22,7 @@
 #include "searchhead.h"
 #include <QMessageBox>
 
-SearchTabContainer::SearchTabContainer(QWidget *aParent) : TabContainer( aParent )
-{
+SearchTabContainer::SearchTabContainer(QWidget *aParent): TabContainer(aParent), sqlEngine(0) {
     header = new SearchHead(this);
     header->setObjectName(QString::fromUtf8("header"));
     QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
@@ -39,6 +38,11 @@ SearchTabContainer::SearchTabContainer(QWidget *aParent) : TabContainer( aParent
 }
 
 
+bool SearchTabContainer::searchDialogIsVisible() const {
+    return header->isVisible();
+}
+
+
 int SearchTabContainer::searchResultCount(const QDate& date) const {
     int confId = Conference::activeConference();
     if (confId == -1) return 0;
@@ -46,26 +50,29 @@ int SearchTabContainer::searchResultCount(const QDate& date) const {
 }
 
 
-void SearchTabContainer::showSearchDialog() {
-    header->show();
-    treeView->hide();
+void SearchTabContainer::showSearchDialog(bool show) {
+    header->setVisible(show);
+    treeView->setVisible(!show);
+    if (show) header->searchEdit->setFocus(Qt::OtherFocusReason);
 }
 
 
 void SearchTabContainer::searchButtonClicked() {
-    QHash<QString,QString> columns;
+    if (!sqlEngine) return;
+
+    QMultiHash<QString,QString> columns;
 
     SearchHead *searchHeader = static_cast<SearchHead*>(header);
-    if( searchHeader->searchTitle->isChecked() )
-        columns.insertMulti("EVENT", "title");
-    if( searchHeader->searchAbstract->isChecked() )
-        columns.insertMulti("EVENT", "abstract");
-    if( searchHeader->searchTag->isChecked() )
-        columns.insertMulti("EVENT", "tag");
-    if( searchHeader->searchSpeaker->isChecked() )
-        columns["PERSON"] = "name";
-    if( searchHeader->searchRoom->isChecked() )
-        columns["ROOM"] = "name";
+    if (searchHeader->searchTitle->isChecked())
+        columns.insert("EVENT", "title");
+    if (searchHeader->searchAbstract->isChecked())
+        columns.insert("EVENT", "abstract");
+    if (searchHeader->searchTag->isChecked())
+        columns.insert("EVENT", "tag");
+    if (searchHeader->searchSpeaker->isChecked())
+        columns.insert("PERSON", "name");
+    if (searchHeader->searchRoom->isChecked())
+        columns.insert("ROOM", "name");
 
     QString keyword = searchHeader->searchEdit->text();
 
@@ -73,7 +80,7 @@ void SearchTabContainer::searchButtonClicked() {
     if (confId == -1) return;
     Conference conf = Conference::getById(confId);
 
-    SqlEngine::searchEvent( confId, columns, keyword );
+    sqlEngine->searchEvent( confId, columns, keyword );
 
     int nrofFounds = 0;
     for (QDate d = conf.start(); d <= conf.end(); d = d.addDays(1))