Changeset c7b58d4 in confclerk_git
- Timestamp:
- 01/25/10 14:05:23 (13 years ago)
- Branches:
- master, qt5
- Children:
- 1deea3b
- Parents:
- 7620de0
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gui/mainwindow.cpp
r7620de0 rc7b58d4 247 247 void MainWindow::updateSearchView(const QDate &aDate) 248 248 { 249 /* 249 qDebug() << "MainWindow::updateSearchView(), aDate: " << aDate.toString() ; 250 250 searchTreeView->reset(); 251 251 int eventsCount = static_cast<EventModel*>(searchTreeView->model())->loadSearchResultEvents(aDate,AppSettings::confId()); 252 if( eventsCount ){ 252 if( eventsCount || 253 searchDayNavigator->getCurrentDate() != Conference::getById(AppSettings::confId()).start() ){ 253 254 searchVerticalWidget->show(); 254 255 searchAgainButton->show(); … … 261 262 searchHead->show(); 262 263 } 263 */264 264 } 265 265 … … 312 312 void MainWindow::searchClicked() 313 313 { 314 Q List<QString> columns;314 QHash<QString,QString> columns; 315 315 316 316 if( searchTitle->isChecked() ) 317 columns. append( "title");317 columns.insertMulti("EVENT", "title"); 318 318 if( searchAbstract->isChecked() ) 319 columns.append( "abstract" ); 320 321 mSqlEngine->searchEvent( AppSettings::confId(), columns, searchEdit->text() ); 319 columns.insertMulti("EVENT", "abstract"); 320 if( searchTag->isChecked() ) 321 columns.insertMulti("EVENT", "tag"); 322 if( searchSpeaker->isChecked() ) 323 columns["PERSON"] = "name"; 324 if( searchRoom->isChecked() ) 325 columns["ROOM"] = "name"; 326 327 QString keyword = searchEdit->text().replace( QString("%"), QString("\\%") ); 328 qDebug() << "\nKeyword to search: " << keyword; 329 mSqlEngine->searchEvent( AppSettings::confId(), columns, keyword ); 330 322 331 updateSearchView( Conference::getById(AppSettings::confId()).start() ); 323 332 } -
src/gui/mainwindow.ui
r7620de0 rc7b58d4 119 119 </layout> 120 120 </widget> 121 <widget class="QWidget" name="searchTab" 122 <attribute name="title" 121 <widget class="QWidget" name="searchTab"> 122 <attribute name="title"> 123 123 <string>Search</string> 124 124 </attribute> 125 <layout class="Q VBoxLayout" name="verticalLayout_3">125 <layout class="QHBoxLayout" name="horizontalLayout_1"> 126 126 <item> 127 <layout class="QFormLayout" name="searchHeadLayout" > 128 <property name="fieldGrowthPolicy" > 129 <enum>QFormLayout::AllNonFixedFieldsGrow</enum> 130 </property> 131 <item row="0" column="0" > 132 <widget class="QCheckBox" name="searchTitle" > 133 <property name="text" > 134 <string>Title</string> 135 </property> 136 </widget> 137 </item> 138 <item row="0" column="1" > 139 <layout class="QHBoxLayout" name="horizontalLayout" > 140 <item> 141 <widget class="QLineEdit" name="searchEdit" > 142 <property name="enabled" > 143 <bool>true</bool> 144 </property> 145 <property name="toolTip" > 146 <string>type a keyword to search</string> 147 </property> 148 </widget> 149 </item> 150 <item> 151 <widget class="QPushButton" name="searchButton" > 152 <property name="text" > 153 <string>Search</string> 154 </property> 155 <property name="checkable" > 156 <bool>false</bool> 157 </property> 158 <property name="autoDefault" > 159 <bool>false</bool> 160 </property> 161 <property name="default" > 162 <bool>true</bool> 163 </property> 164 <property name="flat" > 165 <bool>false</bool> 166 </property> 167 </widget> 168 </item> 169 </layout> 170 </item> 171 <item row="1" column="0" > 172 <widget class="QCheckBox" name="searchAbstract" > 173 <property name="text" > 174 <string>Abstract</string> 175 </property> 176 </widget> 177 </item> 178 </layout> 127 <widget class="QWidget" name="searchVerticalWidget" native="true"> 128 <layout class="QVBoxLayout" name="searchDayNavigatorVerticalLayout"> 129 <item> 130 <widget class="QToolButton" name="searchAgainButton"> 131 <property name="text"> 132 <string>Search again</string> 133 </property> 134 <property name="toolButtonStyle"> 135 <enum>Qt::ToolButtonTextOnly</enum> 136 </property> 137 </widget> 138 </item> 139 <item> 140 <widget class="DayNavigatorWidget" name="searchDayNavigator" native="true"> 141 <property name="maximumSize"> 142 <size> 143 <width>16777215</width> 144 <height>16777215</height> 145 </size> 146 </property> 147 </widget> 148 </item> 149 </layout> 150 </widget> 179 151 </item> 180 152 <item> 181 <layout class="QHBoxLayout" name="searchDayNavigatorHorizontalLayout" > 182 <item> 183 <spacer name="horizontalSpacer_2" > 184 <property name="orientation" > 185 <enum>Qt::Horizontal</enum> 186 </property> 187 <property name="sizeHint" stdset="0" > 188 <size> 189 <width>40</width> 190 <height>20</height> 191 </size> 192 </property> 193 </spacer> 194 </item> 195 <item> 196 <widget class="DayNavigatorWidget" native="1" name="searchDayNavigator" > 197 <property name="maximumSize" > 153 <layout class="QVBoxLayout" name="verticalLayout_3"> 154 <item> 155 <widget class="QWidget" name="searchHead" native="true"> 156 <layout class="QFormLayout" name="searchHeadLayout"> 157 <property name="fieldGrowthPolicy"> 158 <enum>QFormLayout::AllNonFixedFieldsGrow</enum> 159 </property> 160 <item row="0" column="0"> 161 <widget class="QCheckBox" name="searchTitle"> 162 <property name="text"> 163 <string>Title</string> 164 </property> 165 </widget> 166 </item> 167 <item row="1" column="0"> 168 <widget class="QCheckBox" name="searchAbstract"> 169 <property name="text"> 170 <string>Abstract</string> 171 </property> 172 </widget> 173 </item> 174 <item row="2" column="0"> 175 <widget class="QCheckBox" name="searchSpeaker"> 176 <property name="text"> 177 <string>Speaker</string> 178 </property> 179 </widget> 180 </item> 181 <item row="0" column="1"> 182 <widget class="QCheckBox" name="searchTag"> 183 <property name="text"> 184 <string>Tag</string> 185 </property> 186 </widget> 187 </item> 188 <item row="1" column="1"> 189 <widget class="QCheckBox" name="searchRoom"> 190 <property name="text"> 191 <string>Room</string> 192 </property> 193 </widget> 194 </item> 195 <item row="2" column="1"> 196 <layout class="QHBoxLayout" name="horizontalLayout"> 197 <item> 198 <widget class="QLineEdit" name="searchEdit"> 199 <property name="enabled"> 200 <bool>true</bool> 201 </property> 202 <property name="toolTip"> 203 <string>type a keyword to search</string> 204 </property> 205 </widget> 206 </item> 207 <item> 208 <widget class="QPushButton" name="searchButton"> 209 <property name="text"> 210 <string>Search</string> 211 </property> 212 <property name="checkable"> 213 <bool>false</bool> 214 </property> 215 <property name="autoDefault"> 216 <bool>true</bool> 217 </property> 218 <property name="default"> 219 <bool>true</bool> 220 </property> 221 <property name="flat"> 222 <bool>false</bool> 223 </property> 224 </widget> 225 </item> 226 </layout> 227 </item> 228 </layout> 229 </widget> 230 </item> 231 <item> 232 <widget class="TreeView" name="searchTreeView"> 233 <property name="maximumSize"> 198 234 <size> 199 235 <width>16777215</width> … … 203 239 </widget> 204 240 </item> 205 <item> 206 <spacer name="horizontalSpacer" > 207 <property name="orientation" > 208 <enum>Qt::Horizontal</enum> 209 </property> 210 <property name="sizeHint" stdset="0" > 211 <size> 212 <width>40</width> 213 <height>20</height> 214 </size> 215 </property> 216 </spacer> 217 </item> 218 </layout> 219 </item> 220 <item> 221 <widget class="TreeView" name="searchTreeView" > 222 <property name="maximumSize" > 223 <size> 224 <width>16777215</width> 225 <height>16777215</height> 226 </size> 227 </property> 228 </widget> 241 </layout> 229 242 </item> 230 243 </layout> -
src/sql/sqlengine.cpp
r7620de0 rc7b58d4 307 307 } 308 308 309 int SqlEngine::searchEvent(int aConferenceId, const Q List<QString> &aColumns, const QString &aKeyword)309 int SqlEngine::searchEvent(int aConferenceId, const QHash<QString,QString> &aColumns, const QString &aKeyword) 310 310 { 311 311 QSqlDatabase db = QSqlDatabase::database(); … … 321 321 // INSERT 322 322 QString query = QString("INSERT INTO SEARCH_EVENT ( xid_conference, id) " 323 "SELECT xid_conference, id FROM EVENT " 324 "WHERE xid_conference = %1 AND (").arg( aConferenceId ); 325 int i = 0; 326 foreach (QString str, aColumns){ 327 query += QString("%1 LIKE '\%%2\%' OR ").arg( aColumns.at(i++), aKeyword ); 323 "SELECT EVENT.xid_conference, EVENT.id FROM EVENT "); 324 if( aColumns.contains("ROOM") ){ 325 query += "INNER JOIN EVENT_ROOM ON (EVENT.xid_conference = EVENT_ROOM.xid_conference AND EVENT.id = EVENT_ROOM.xid_event ) "; 326 query += "INNER JOIN ROOM ON ( EVENT_ROOM.xid_room = ROOM.id ) "; 327 } 328 if( aColumns.contains("PERSON") ){ 329 query += "INNER JOIN EVENT_PERSON ON (EVENT.xid_conference = EVENT_PERSON.xid_conference AND EVENT.id = EVENT_PERSON.xid_event ) "; 330 query += "INNER JOIN PERSON ON ( EVENT_PERSON.xid_person = PERSON.id ) "; 331 } 332 query += QString("WHERE EVENT.xid_conference = %1 AND (").arg( aConferenceId ); 333 334 foreach (QString table, aColumns.uniqueKeys()){ 335 foreach (QString column, aColumns.values(table)){ 336 query += QString("%1.%2 LIKE '\%%3\%' OR ").arg( table, column, aKeyword ); 337 } 328 338 } 329 339 query.chop( QString(" OR ").length() ); -
src/sql/sqlengine.h
r7620de0 rc7b58d4 21 21 22 22 // search Events for .... 23 int searchEvent(int conferenceId, const Q List<QString> &columns, const QString &keyword);23 int searchEvent(int conferenceId, const QHash<QString,QString> &columns, const QString &keyword); 24 24 private: 25 25 QString login(const QString &aDatabaseType, const QString &aDatabaseName);
Note: See TracChangeset
for help on using the changeset viewer.