When the search toolbox button is clicked when the search dialog is already open...
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Mon, 12 Dec 2011 22:53:04 +0000 (22:53 +0000)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Mon, 12 Dec 2011 22:53:04 +0000 (22:53 +0000)
src/gui/mainwindow.cpp
src/gui/searchtabcontainer.cpp
src/gui/searchtabcontainer.h

index ce40dfa..830923a 100644 (file)
@@ -161,8 +161,12 @@ void MainWindow::on_nowAction_triggered() {
 
 
 void MainWindow::on_searchAction_triggered() {
-    searchTabContainer->showSearchDialog();
-    tabWidget->setCurrentWidget(searchTab);
+    if (tabWidget->currentWidget() == searchTab)
+        searchTabContainer->showSearchDialog(!searchTabContainer->searchDialogIsVisible());
+    else {
+        tabWidget->setCurrentWidget(searchTab);
+        searchTabContainer->showSearchDialog();
+    }
 }
 
 
index 3abc8e5..0f4aac8 100644 (file)
@@ -39,6 +39,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,9 +51,9 @@ 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);
 }
 
 
index 80ecd4c..3475632 100644 (file)
@@ -31,6 +31,7 @@ class SearchTabContainer: public TabContainer {
 public:
     SearchTabContainer(QWidget *aParent);
     virtual ~SearchTabContainer() {}
+    bool searchDialogIsVisible() const;
     int searchResultCount(const QDate& date) const; ///< returns the number of events found on that specific date
 
 protected:
@@ -40,7 +41,7 @@ signals:
     void searchResultChanged();
 
 public slots:
-    void showSearchDialog();
+    void showSearchDialog(bool show=true);
 
 private slots:
     void searchButtonClicked();