Adjust whitespace in if statements.
[toast/confclerk.git] / src / gui / searchtabcontainer.cpp
index 0f4aac8475cad9e61651c997608c503377fabd39..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);
@@ -54,23 +53,26 @@ int SearchTabContainer::searchResultCount(const QDate& date) const {
 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();
 
@@ -78,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))