Changeset ac2b0b2 in confclerk_git for src/gui/searchtabcontainer.cpp


Ignore:
Timestamp:
12/12/11 20:59:00 (11 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
71c3eb6
Parents:
018d4d6
Message:

The search result is now synced with the daynavigator.
When the search result is not on the current date, the date is changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gui/searchtabcontainer.cpp

    r018d4d6 rac2b0b2  
    4040
    4141
     42int SearchTabContainer::searchResultCount(const QDate& date) const {
     43    int confId = Conference::activeConference();
     44    if (confId == -1) return 0;
     45    return Event::getSearchResultByDate(date, confId, "start, duration").count();
     46}
     47
     48
    4249void SearchTabContainer::showSearchDialog() {
    4350    header->show();
     
    6572    int confId = Conference::activeConference();
    6673    if (confId == -1) return;
     74    Conference conf = Conference::getById(confId);
    6775
    6876    SqlEngine::searchEvent( confId, columns, keyword );
    6977
    70     QDate startDate = Conference::getById(confId).start();
    71     QDate endDate = Conference::getById(confId).end();
     78    int nrofFounds = 0;
     79    for (QDate d = conf.start(); d <= conf.end(); d = d.addDays(1))
     80        nrofFounds += Event::getSearchResultByDate(d, confId, "start, duration").count();
    7281
    73     int nrofFounds = 0;
    74     QDate firstDateWithFounds = endDate;
    75     QDate lastDateWithFounds = startDate;
    76     for(QDate d=startDate; d<=endDate; d=d.addDays(1))
    77     {
    78         try{
    79             int count = Event::getSearchResultByDate(d, confId, "start, duration").count();
    80             if(count && (firstDateWithFounds==endDate))
    81                 firstDateWithFounds=d;
    82             if(count)
    83                 lastDateWithFounds=d;
    84             nrofFounds+=count;
    85         }
    86         catch( OrmException &e  ){
    87             qDebug() << "Event::getSearchResultByDate failed: " << e.text();
    88         }
    89         catch(...){
    90             qDebug() << "Event::getSearchResultByDate failed";
    91         }
    92     }
    93 
    94     if(!nrofFounds)
    95     {
    96         // TODO: display some message
     82    if (!nrofFounds) {
    9783        treeView->hide();
    9884        header->show();
     
    10288                QString("No events containing '%1' found!").arg(keyword),
    10389                QMessageBox::Ok);
    104     }
    105     else
    106     {
     90    } else {
    10791        treeView->show();
    10892        header->hide();
    10993
    110         updateTreeView( firstDateWithFounds );
     94        emit searchResultChanged();
    11195    }
    11296}
Note: See TracChangeset for help on using the changeset viewer.