connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
connect(trackDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTracksView(const QDate &)));
connect(favouriteDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateFavouritesView(const QDate &)));
+ connect(searchDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateSearchView(const QDate &)));
// DAY EVENTS View
dayTreeView->setHeaderHidden(true);
searchTreeView->setAnimated(true);
searchTreeView->setModel(new EventModel());
searchTreeView->setItemDelegate(new Delegate(searchTreeView));
- searchTreeView->setVisible(false);
- searchDayNavigator->setVisible(false);
+
// event clicked
connect(dayTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
connect(favTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)));
+ searchTreeView->hide();
+ searchDayNavigator->hide();
+
// open dialog for given Event ID
// this is used in case Alarm Dialog request application to start
if(aEventId)
updateTracksView(trackDayNavigator->getCurrentDate());
}
break;
+ case 3: //index 3 of tabWidget: searchTab
+ {
+ updateSearchView( searchDayNavigator->getCurrentDate() );
+ }
+ break;
default:
{
favouriteDayNavigator->show();
}
+void MainWindow::updateSearchView(const QDate &aDate)
+{
+ searchTreeView->reset();
+ int eventsCount = static_cast<EventModel*>(searchTreeView->model())->loadSearchResultEvents(aDate,confId);
+ if( eventsCount ){
+ searchDayNavigator->show();
+ searchTreeView->show();
+ }
+ else{
+ searchTreeView->hide();
+ searchDayNavigator->hide();
+ }
+}
+
void MainWindow::itemClicked(const QModelIndex &aIndex)
{
// have to handle only events, not time-groups
if( searchAbstract->isChecked() )
columns.append( "abstract" );
- searchTreeView->reset();
- if( mSqlEngine->searchEvent( confId, columns, searchEdit->text() ) > 0 ){
- static_cast<EventModel*>(searchTreeView->model())->loadSearchResultEvents(Conference::getById(confId).start(),confId);
- searchDayNavigator->show();
- searchTreeView->show();
- }
+ mSqlEngine->searchEvent( confId, columns, searchEdit->text() );
+ updateSearchView( Conference::getById(confId).start() );
}
void updateTab(const int n);
void updateTracksView(const QDate &aDate);
void updateFavouritesView(const QDate &aDate);
+ void updateSearchView(const QDate &aDate);
void itemClicked(const QModelIndex &aIndex);
void displayMap(const QModelIndex &aIndex);
void searchClicked();
<string>Search</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <layout class="QFormLayout" name="formLayout">
- <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>
- </item>
- <item>
- <widget class="DayNavigatorWidget" name="searchDayNavigator" native="true">
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>16777215</height>
- </size>
- </property>
- </widget>
- </item>
- <item>
- <widget class="TreeView" name="searchTreeView">
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>16777215</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
+ <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>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="searchDayNavigatorHorizontalLayout">
+ <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>
+ </item>
+ <item>
+ <widget class="DayNavigatorWidget" name="searchDayNavigator" native="true">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </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="mapTab" >
<attribute name="title" >
Event Event::getById(int id, int conferenceId)
{
-
QSqlQuery query;
query.prepare(selectQuery() + "WHERE id = :id AND xid_conference = :conf");
query.bindValue(":id", id);
createTimeGroups();
}
-void EventModel::loadSearchResultEvents(const QDate &aDate, int aConferenceId)
+int EventModel::loadSearchResultEvents(const QDate &aDate, int aConferenceId)
{
clearModel();
// check for existence of the conference in the DB
if(Conference::getAll().count())
{
qDebug() << "Loading search result Data: [" << Conference::getById(aConferenceId).title() << "] " << aDate;
- mEvents = Event::getSearchResultByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start");
+ try{
+ mEvents = Event::getSearchResultByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start");
+ }
+ catch( OrmException &e ){
+ qDebug() << "Event::getSearchResultByDate failed: " << e.text();
+ }
+ catch(...){
+ qDebug() << "Event::getSearchResultByDate failed";
+ }
+
}
+
createTimeGroups();
+
+ return mEvents.count();
}
void EventModel::loadEventsByTrack(const QDate &aDate, int aConferenceId)
void loadEvents(const QDate &aDate, int aConferenceId); // loads Events from the DB
void loadFavEvents(const QDate &aDate, int aConferenceId); // loads Favourite events from the DB
void loadEventsByTrack(const QDate &aDate, int aConferenceId); // loads Events grouped by Track from the DB
- void loadSearchResultEvents(const QDate &aDate, int aConferenceId);
+ int loadSearchResultEvents(const QDate &aDate, int aConferenceId);
// a method to force 'EventModel' emit signal 'dataChanged()'
// a 'view', eg. 'TreeView' listens for this signal and redraws changed items(indexes)
void emitDataChangedSignal(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);
class OrmException
{
+public:
+ OrmException(const QString& text) : mText(text) {};
+ virtual ~OrmException(){};
+ virtual const QString& text() const { return mText; }
+private:
+ QString mText;
};
class OrmNoObjectException : OrmException
{
+public:
+ OrmNoObjectException() : OrmException("No object exception"){};
+ ~OrmNoObjectException(){};
};
class OrmSqlException : OrmException
{
public:
- OrmSqlException(const QString& text) : mText(text) {}
- QString text() const { return mText; }
-
-private:
- QString mText;
+ OrmSqlException(const QString& text) : OrmException( QString("Sql error: ") + text ) {};
+ ~OrmSqlException(){};
};
template <typename T>
execQuery( db, "CREATE 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 AS e INNER JOIN VIRTUAL_EVENT AS ve USING (xid_conference, id) "
+ "SELECT xid_conference, id FROM EVENT "
"WHERE xid_conference = %1 AND (").arg( aConferenceId );
int i = 0;
foreach (QString str, aColumns){