void MainWindow::updateSearchView(const QDate &aDate)
{
-/*
+ qDebug() << "MainWindow::updateSearchView(), aDate: " << aDate.toString() ;
searchTreeView->reset();
int eventsCount = static_cast<EventModel*>(searchTreeView->model())->loadSearchResultEvents(aDate,AppSettings::confId());
- if( eventsCount ){
+ if( eventsCount ||
+ searchDayNavigator->getCurrentDate() != Conference::getById(AppSettings::confId()).start() ){
searchVerticalWidget->show();
searchAgainButton->show();
searchTreeView->show();
searchVerticalWidget->hide();
searchHead->show();
}
-*/
}
void MainWindow::updateNowView()
void MainWindow::searchClicked()
{
- QList<QString> columns;
+ QHash<QString,QString> columns;
if( searchTitle->isChecked() )
- columns.append( "title" );
+ columns.insertMulti("EVENT", "title");
if( searchAbstract->isChecked() )
- columns.append( "abstract" );
+ columns.insertMulti("EVENT", "abstract");
+ if( searchTag->isChecked() )
+ columns.insertMulti("EVENT", "tag");
+ if( searchSpeaker->isChecked() )
+ columns["PERSON"] = "name";
+ if( searchRoom->isChecked() )
+ columns["ROOM"] = "name";
+
+ QString keyword = searchEdit->text().replace( QString("%"), QString("\\%") );
+ qDebug() << "\nKeyword to search: " << keyword;
+ mSqlEngine->searchEvent( AppSettings::confId(), columns, keyword );
- mSqlEngine->searchEvent( AppSettings::confId(), columns, searchEdit->text() );
updateSearchView( Conference::getById(AppSettings::confId()).start() );
}
</item>
</layout>
</widget>
- <widget class="QWidget" name="searchTab" >
- <attribute name="title" >
+ <widget class="QWidget" name="searchTab">
+ <attribute name="title">
<string>Search</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_3" >
+ <layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
- <layout class="QFormLayout" name="searchHeadLayout" >
- <property name="fieldGrowthPolicy" >
- <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
- </property>
- <item row="0" column="0" >
- <widget class="QCheckBox" name="searchTitle" >
- <property name="text" >
- <string>Title</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <layout class="QHBoxLayout" name="horizontalLayout" >
- <item>
- <widget class="QLineEdit" name="searchEdit" >
- <property name="enabled" >
- <bool>true</bool>
- </property>
- <property name="toolTip" >
- <string>type a keyword to search</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="searchButton" >
- <property name="text" >
- <string>Search</string>
- </property>
- <property name="checkable" >
- <bool>false</bool>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- <property name="default" >
- <bool>true</bool>
- </property>
- <property name="flat" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" >
- <widget class="QCheckBox" name="searchAbstract" >
- <property name="text" >
- <string>Abstract</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QWidget" name="searchVerticalWidget" native="true">
+ <layout class="QVBoxLayout" name="searchDayNavigatorVerticalLayout">
+ <item>
+ <widget class="QToolButton" name="searchAgainButton">
+ <property name="text">
+ <string>Search again</string>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextOnly</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DayNavigatorWidget" name="searchDayNavigator" native="true">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
- <layout class="QHBoxLayout" name="searchDayNavigatorHorizontalLayout" >
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
- <spacer name="horizontalSpacer_2" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
+ <widget class="QWidget" name="searchHead" native="true">
+ <layout class="QFormLayout" name="searchHeadLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="searchTitle">
+ <property name="text">
+ <string>Title</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="searchAbstract">
+ <property name="text">
+ <string>Abstract</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="searchSpeaker">
+ <property name="text">
+ <string>Speaker</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="searchTag">
+ <property name="text">
+ <string>Tag</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="searchRoom">
+ <property name="text">
+ <string>Room</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="searchEdit">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip">
+ <string>type a keyword to search</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="searchButton">
+ <property name="text">
+ <string>Search</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
- <widget class="DayNavigatorWidget" native="1" name="searchDayNavigator" >
- <property name="maximumSize" >
+ <widget class="TreeView" name="searchTreeView">
+ <property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</item>
- <item>
- <widget class="TreeView" name="searchTreeView" >
- <property name="maximumSize" >
- <size>
- <width>16777215</width>
- <height>16777215</height>
- </size>
- </property>
- </widget>
- </item>
</layout>
</widget>
<widget class="QWidget" name="roomsTab" >
return result;
}
-int SqlEngine::searchEvent(int aConferenceId, const QList<QString> &aColumns, const QString &aKeyword)
+int SqlEngine::searchEvent(int aConferenceId, const QHash<QString,QString> &aColumns, const QString &aKeyword)
{
QSqlDatabase db = QSqlDatabase::database();
execQuery( db, "CREATE TEMP TABLE SEARCH_EVENT ( xid_conference INTEGER NOT NULL, id INTEGER NOT NULL );");
// INSERT
QString query = QString("INSERT INTO SEARCH_EVENT ( xid_conference, id) "
- "SELECT xid_conference, id FROM EVENT "
- "WHERE xid_conference = %1 AND (").arg( aConferenceId );
- int i = 0;
- foreach (QString str, aColumns){
- query += QString("%1 LIKE '\%%2\%' OR ").arg( aColumns.at(i++), aKeyword );
+ "SELECT EVENT.xid_conference, EVENT.id FROM EVENT ");
+ if( aColumns.contains("ROOM") ){
+ query += "INNER JOIN EVENT_ROOM ON (EVENT.xid_conference = EVENT_ROOM.xid_conference AND EVENT.id = EVENT_ROOM.xid_event ) ";
+ query += "INNER JOIN ROOM ON ( EVENT_ROOM.xid_room = ROOM.id ) ";
+ }
+ if( aColumns.contains("PERSON") ){
+ query += "INNER JOIN EVENT_PERSON ON (EVENT.xid_conference = EVENT_PERSON.xid_conference AND EVENT.id = EVENT_PERSON.xid_event ) ";
+ query += "INNER JOIN PERSON ON ( EVENT_PERSON.xid_person = PERSON.id ) ";
+ }
+ query += QString("WHERE EVENT.xid_conference = %1 AND (").arg( aConferenceId );
+
+ foreach (QString table, aColumns.uniqueKeys()){
+ foreach (QString column, aColumns.values(table)){
+ query += QString("%1.%2 LIKE '\%%3\%' OR ").arg( table, column, aKeyword );
+ }
}
query.chop( QString(" OR ").length() );
query += QString(");");