]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/gui/searchtabcontainer.cpp
Removed commented out reference to removed files.
[toast/confclerk.git] / src / gui / searchtabcontainer.cpp
index 86c9fccf52616175b00c0addfc05cc86d7a46b1d..0f4aac8475cad9e61651c997608c503377fabd39 100644 (file)
@@ -39,9 +39,21 @@ SearchTabContainer::SearchTabContainer(QWidget *aParent) : TabContainer( aParent
 }
 
 
-void SearchTabContainer::showSearchDialog() {
-    header->show();
-    treeView->hide();
+bool SearchTabContainer::searchDialogIsVisible() const {
+    return header->isVisible();
+}
+
+
+int SearchTabContainer::searchResultCount(const QDate& date) const {
+    int confId = Conference::activeConference();
+    if (confId == -1) return 0;
+    return Event::getSearchResultByDate(date, confId, "start, duration").count();
+}
+
+
+void SearchTabContainer::showSearchDialog(bool show) {
+    header->setVisible(show);
+    treeView->setVisible(!show);
 }
 
 
@@ -64,36 +76,15 @@ void SearchTabContainer::searchButtonClicked() {
 
     int confId = Conference::activeConference();
     if (confId == -1) return;
+    Conference conf = Conference::getById(confId);
 
     SqlEngine::searchEvent( confId, columns, keyword );
 
-    QDate startDate = Conference::getById(confId).start();
-    QDate endDate = Conference::getById(confId).end();
-
     int nrofFounds = 0;
-    QDate firstDateWithFounds = endDate;
-    QDate lastDateWithFounds = startDate;
-    for(QDate d=startDate; d<=endDate; d=d.addDays(1))
-    {
-        try{
-            int count = Event::getSearchResultByDate(d, confId, "start, duration").count();
-            if(count && (firstDateWithFounds==endDate))
-                firstDateWithFounds=d;
-            if(count)
-                lastDateWithFounds=d;
-            nrofFounds+=count;
-        }
-        catch( OrmException &e  ){
-            qDebug() << "Event::getSearchResultByDate failed: " << e.text();
-        }
-        catch(...){
-            qDebug() << "Event::getSearchResultByDate failed";
-        }
-    }
+    for (QDate d = conf.start(); d <= conf.end(); d = d.addDays(1))
+        nrofFounds += Event::getSearchResultByDate(d, confId, "start, duration").count();
 
-    if(!nrofFounds)
-    {
-        // TODO: display some message
+    if (!nrofFounds) {
         treeView->hide();
         header->show();
         QMessageBox::information(
@@ -101,13 +92,11 @@ void SearchTabContainer::searchButtonClicked() {
                 QString("Keyword '%1' not found!").arg(keyword),
                 QString("No events containing '%1' found!").arg(keyword),
                 QMessageBox::Ok);
-    }
-    else
-    {
+    } else {
         treeView->show();
         header->hide();
 
-        updateTreeView( firstDateWithFounds );
+        emit searchResultChanged();
     }
 }