Changeset ac2b0b2 in confclerk_git for src/gui/mainwindow.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/mainwindow.cpp

    r018d4d6 rac2b0b2  
    9898    connect(dayNavigator, SIGNAL(dateChanged(QDate)), searchTabContainer, SLOT(redisplayDate(QDate)));
    9999
     100    // search result has changed
     101    connect(searchTabContainer, SIGNAL(searchResultChanged()), SLOT(onSearchResultChanged()));
     102
     103
    100104    useConference(Conference::activeConference());
    101105    // optimization, see useConference() code
     
    170174    roomsTabContainer->redisplayEvent(aEventId);
    171175    searchTabContainer->redisplayEvent(aEventId);
     176}
     177
     178
     179void MainWindow::onSearchResultChanged() {
     180    // Are results found on the current date?
     181    QDate date = dayNavigator->curDate();
     182    int count = searchTabContainer->searchResultCount(date);
     183    if (count > 0) {searchTabContainer->redisplayDate(date); return;}
     184
     185    // Are results found in the future?
     186    for (date = date.addDays(1); date <= dayNavigator->endDate(); date = date.addDays(1)) {
     187        int count = searchTabContainer->searchResultCount(date);
     188        if (count > 0) {dayNavigator->setCurDate(date); return;}
     189    }
     190
     191    // Are results found in the past?
     192    for (date = dayNavigator->startDate(); date < dayNavigator->curDate(); date = date.addDays(1)) {
     193        int count = searchTabContainer->searchResultCount(date);
     194        if (count > 0) {dayNavigator->setCurDate(date); return;}
     195    }
     196    // No results were found
     197    searchTabContainer->redisplayDate(dayNavigator->curDate());
    172198}
    173199
Note: See TracChangeset for help on using the changeset viewer.