- Timestamp:
- 12/12/11 20:59:00 (11 years ago)
- Branches:
- master, qt5
- Children:
- 71c3eb6
- Parents:
- 018d4d6
- Location:
- src/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gui/daynavigatorwidget.h
r018d4d6 rac2b0b2 35 35 void setDates(const QDate &aStartDate, const QDate &aEndDate); 36 36 void setCurDate(const QDate& curDate); 37 QDate startDate() const {return mStartDate;} 37 38 QDate curDate() const {return mCurDate;} 39 QDate endDate() const {return mEndDate;} 38 40 void unsetDates(); 39 41 protected: -
src/gui/mainwindow.cpp
r018d4d6 rac2b0b2 98 98 connect(dayNavigator, SIGNAL(dateChanged(QDate)), searchTabContainer, SLOT(redisplayDate(QDate))); 99 99 100 // search result has changed 101 connect(searchTabContainer, SIGNAL(searchResultChanged()), SLOT(onSearchResultChanged())); 102 103 100 104 useConference(Conference::activeConference()); 101 105 // optimization, see useConference() code … … 170 174 roomsTabContainer->redisplayEvent(aEventId); 171 175 searchTabContainer->redisplayEvent(aEventId); 176 } 177 178 179 void 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()); 172 198 } 173 199 -
src/gui/mainwindow.h
r018d4d6 rac2b0b2 50 50 51 51 void onEventChanged(int aEventId, bool favouriteChanged); 52 void onSearchResultChanged(); 52 53 // TODO: remove 53 54 void networkQueryFinished(QNetworkReply*); -
src/gui/searchtabcontainer.cpp
r018d4d6 rac2b0b2 40 40 41 41 42 int 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 42 49 void SearchTabContainer::showSearchDialog() { 43 50 header->show(); … … 65 72 int confId = Conference::activeConference(); 66 73 if (confId == -1) return; 74 Conference conf = Conference::getById(confId); 67 75 68 76 SqlEngine::searchEvent( confId, columns, keyword ); 69 77 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(); 72 81 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) { 97 83 treeView->hide(); 98 84 header->show(); … … 102 88 QString("No events containing '%1' found!").arg(keyword), 103 89 QMessageBox::Ok); 104 } 105 else 106 { 90 } else { 107 91 treeView->show(); 108 92 header->hide(); 109 93 110 updateTreeView( firstDateWithFounds);94 emit searchResultChanged(); 111 95 } 112 96 } -
src/gui/searchtabcontainer.h
r018d4d6 rac2b0b2 32 32 SearchTabContainer(QWidget *aParent); 33 33 virtual ~SearchTabContainer() {} 34 int searchResultCount(const QDate& date) const; ///< returns the number of events found on that specific date 35 34 36 protected: 35 37 virtual void loadEvents( const QDate &aDate, const int aConferenceId ); 38 39 signals: 40 void searchResultChanged(); 36 41 37 42 public slots:
Note: See TracChangeset
for help on using the changeset viewer.