Changeset 990afd5
- Timestamp:
- 01/20/10 15:50:12 (13 years ago)
- Branches:
- master, qt5
- Children:
- f2ef735
- Parents:
- b1a201a
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gui/mainwindow.cpp
rb1a201a r990afd5 71 71 actTreeView->setItemDelegate(new Delegate(actTreeView)); 72 72 73 // DAY EVENTS View 74 searchTreeView->setHeaderHidden(true); 75 searchTreeView->setRootIsDecorated(false); 76 searchTreeView->setIndentation(0); 77 searchTreeView->setAnimated(true); 78 searchTreeView->setModel(new EventModel()); 79 searchTreeView->setItemDelegate(new Delegate(searchTreeView)); 80 searchTreeView->setVisible(false); 81 searchDayNavigator->setVisible(false); 73 82 // event clicked 74 83 connect(dayTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); 75 84 connect(favTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); 76 85 connect(actTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); 86 connect(searchTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &))); 77 87 // request for map to be displayed 78 88 connect(dayTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); 79 89 connect(favTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); 80 90 connect(actTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); 81 91 connect(searchTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); 92 // event search button clicked 93 connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked())); 82 94 83 95 // TESTING: load some 'fav' data … … 241 253 window.exec(); 242 254 } 255 256 void MainWindow::searchClicked() 257 { 258 QList<QString> columns; 259 260 if( searchTitle->isChecked() ) 261 columns.append( "title" ); 262 if( searchAbstract->isChecked() ) 263 columns.append( "abstract" ); 264 265 if( mSqlEngine->searchEvent( confId, columns, searchEdit->text() ) > 0 ){ 266 searchTreeView->setVisible(true); 267 searchDayNavigator->setVisible(true); 268 } 269 } 270 -
src/gui/mainwindow.h
rb1a201a r990afd5 25 25 void itemClicked(const QModelIndex &aIndex); 26 26 void displayMap(const QModelIndex &aIndex); 27 void searchClicked(); 27 28 private: 28 29 SqlEngine *mSqlEngine; -
src/gui/mainwindow.ui
rb1a201a r990afd5 91 91 </layout> 92 92 </widget> 93 <widget class="QWidget" name="searchTab" 94 <attribute name="title" 93 <widget class="QWidget" name="searchTab"> 94 <attribute name="title"> 95 95 <string>Search</string> 96 96 </attribute> 97 </widget> 98 <widget class="QWidget" name="mapTab" > 99 <attribute name="title" > 97 <layout class="QVBoxLayout" name="verticalLayout_3"> 98 <item> 99 <layout class="QFormLayout" name="formLayout"> 100 <property name="fieldGrowthPolicy"> 101 <enum>QFormLayout::AllNonFixedFieldsGrow</enum> 102 </property> 103 <item row="0" column="0"> 104 <widget class="QCheckBox" name="searchTitle"> 105 <property name="text"> 106 <string>Title</string> 107 </property> 108 </widget> 109 </item> 110 <item row="0" column="1"> 111 <layout class="QHBoxLayout" name="horizontalLayout"> 112 <item> 113 <widget class="QLineEdit" name="searchEdit"> 114 <property name="enabled"> 115 <bool>true</bool> 116 </property> 117 <property name="toolTip"> 118 <string>type a keyword to search</string> 119 </property> 120 </widget> 121 </item> 122 <item> 123 <widget class="QPushButton" name="searchButton"> 124 <property name="text"> 125 <string>Search</string> 126 </property> 127 <property name="checkable"> 128 <bool>false</bool> 129 </property> 130 <property name="autoDefault"> 131 <bool>false</bool> 132 </property> 133 <property name="default"> 134 <bool>true</bool> 135 </property> 136 <property name="flat"> 137 <bool>false</bool> 138 </property> 139 </widget> 140 </item> 141 </layout> 142 </item> 143 <item row="1" column="0"> 144 <widget class="QCheckBox" name="searchAbstract"> 145 <property name="text"> 146 <string>Abstract</string> 147 </property> 148 </widget> 149 </item> 150 </layout> 151 </item> 152 <item> 153 <widget class="DayNavigatorWidget" name="searchDayNavigator" native="true"> 154 <property name="maximumSize"> 155 <size> 156 <width>16777215</width> 157 <height>16777215</height> 158 </size> 159 </property> 160 </widget> 161 </item> 162 <item> 163 <widget class="TreeView" name="searchTreeView"> 164 <property name="maximumSize"> 165 <size> 166 <width>16777215</width> 167 <height>16777215</height> 168 </size> 169 </property> 170 </widget> 171 </item> 172 </layout> 173 </widget> 174 <widget class="QWidget" name="mapTab"> 175 <attribute name="title"> 100 176 <string>Map</string> 101 177 </attribute> -
src/sql/sqlengine.cpp
rb1a201a r990afd5 290 290 } 291 291 292 int SqlEngine::searchEvent(int aConferenceId, const QList<QString> &aColumns, const QString &aKeyword) 293 { 294 QSqlDatabase db = QSqlDatabase::database(); 295 296 if ( !db.isValid() || !db.isOpen()) 297 return -1; 298 299 QString query = QString( 300 "DROP TABLE IF EXISTS SEARCH_EVENT;" 301 "CREATE TEMP TABLE SEARCH_EVENT ( xid_conference INTEGER NOT NULL, id INTEGER NOT NULL );" 302 "INSERT INTO SEARCH_EVENT ( xid_conference, id) " 303 "SELECT xid_conference, id FROM EVENT AS e INNER JOIN VIRTUAL_EVENT AS ve USING (xid_conference, id) " 304 "WHERE xid_conference = %1 AND (").arg( aConferenceId ); 305 306 int i = 0; 307 foreach (QString str, aColumns){ 308 query += QString("%1 LIKE '\%%2\%' OR ").arg( aColumns.at(i++), aKeyword ); 309 } 310 query.chop( QString(" OR ").length() ); 311 query += QString(");"); 312 313 qDebug() << "\nSQL: " << query; 314 315 db.exec(); 316 317 if( db.lastError().isValid() && db.lastError().number() != 0 ){ 318 qDebug() << "SQL ERR: " << db.lastError().number() << ", " << db.lastError().text(); 319 return 0; 320 } 321 else{ 322 qDebug() << "SQL OK.\n"; 323 return 1; 324 } 325 326 } -
src/sql/sqlengine.h
rb1a201a r990afd5 19 19 void addLinkToDB(QHash<QString,QString> &aLink); 20 20 void addRoomToDB(QHash<QString,QString> &aRoom); 21 22 // search Events for .... 23 int searchEvent(int conferenceId, const QList<QString> &columns, const QString &keyword); 21 24 private: 22 25 QString login(const QString &aDatabaseType, const QString &aDatabaseName);
Note: See TracChangeset
for help on using the changeset viewer.