room view added - need to test it
authorkorrco <korrco@localhost>
Mon, 25 Jan 2010 12:52:01 +0000 (12:52 +0000)
committerkorrco <korrco@localhost>
Mon, 25 Jan 2010 12:52:01 +0000 (12:52 +0000)
12 files changed:
src/gui/mainwindow.cpp
src/gui/mainwindow.h
src/gui/mainwindow.ui
src/mvc/event.cpp
src/mvc/event.h
src/mvc/eventmodel.cpp
src/mvc/eventmodel.h
src/mvc/mvc.pro
src/mvc/room.cpp [new file with mode: 0644]
src/mvc/room.h [new file with mode: 0644]
src/mvc/track.cpp
src/mvc/track.h

index 43ae8b2..47bb535 100644 (file)
@@ -53,6 +53,7 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent)
     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 &)));
+    connect(roomDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateRoomView(const QDate &)));
 
     // DAY EVENTS View
     dayTreeView->setHeaderHidden(true);
@@ -94,12 +95,21 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent)
        nowTreeView->setModel(new EventModel());
        nowTreeView->setItemDelegate(new Delegate(nowTreeView));
 
+    // ROOMS View
+    roomTreeView->setHeaderHidden(true);
+    roomTreeView->setRootIsDecorated(false);
+    roomTreeView->setIndentation(0);
+    roomTreeView->setAnimated(true);
+    roomTreeView->setModel(new EventModel());
+    roomTreeView->setItemDelegate(new Delegate(roomTreeView));
+
     // event details have changed
     connect(dayTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     connect(favTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     connect(trackTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     connect(searchTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     connect(nowTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
+    connect(roomTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
 
     // event clicked
     connect(dayTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
@@ -107,18 +117,21 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent)
     connect(trackTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
     connect(searchTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
     connect(nowTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
+    connect(roomTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
     // request for map to be displayed
     connect(dayTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     connect(favTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     connect(trackTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     connect(searchTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     connect(nowTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
+    connect(roomTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     // request for warning to be displayed
     connect(dayTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     connect(favTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     connect(trackTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     connect(searchTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     connect(nowTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
+    connect(roomTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     // event search button clicked
     connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked()));
     connect(searchAgainButton, SIGNAL(clicked()), SLOT(searchAgainClicked()));
@@ -131,6 +144,7 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent)
     {
         dayNavigator->hide(); // hide DayNavigatorWidget
         trackDayNavigator->hide();
+        roomDayNavigator->hide();
     }
     else
     {
@@ -140,6 +154,7 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent)
         trackDayNavigator->setDates(aStartDate, aEndDate);
         favouriteDayNavigator->setDates(aStartDate, aEndDate);
         searchDayNavigator->setDates(aStartDate, aEndDate);
+        roomDayNavigator->setDates(aStartDate, aEndDate);
         //
         conferenceTitle->setText(Conference::getById(AppSettings::confId()).title());
         conferenceSubtitle->setText(Conference::getById(AppSettings::confId()).subtitle());
@@ -231,6 +246,7 @@ void MainWindow::updateFavouritesView(const QDate &aDate)
 
 void MainWindow::updateSearchView(const QDate &aDate)
 {
+/*
     searchTreeView->reset();
     int eventsCount = static_cast<EventModel*>(searchTreeView->model())->loadSearchResultEvents(aDate,AppSettings::confId());
     if( eventsCount ){
@@ -244,6 +260,7 @@ void MainWindow::updateSearchView(const QDate &aDate)
         searchVerticalWidget->hide();
         searchHead->show();
     }
+*/
 }
 
 void MainWindow::updateNowView()
@@ -254,6 +271,13 @@ void MainWindow::updateNowView()
     nowTreeView->setAllExpanded(true);
 }
 
+void MainWindow::updateRoomView(const QDate &aDate)
+{
+    static_cast<EventModel*>(roomTreeView->model())->loadEventsByRoom(aDate, AppSettings::confId());
+    roomTreeView->reset();
+    roomDayNavigator->show();
+}
+
 void MainWindow::itemClicked(const QModelIndex &aIndex)
 {
     // have to handle only events, not time-groups
index 8e311c2..f79c2f3 100644 (file)
@@ -23,6 +23,7 @@ private slots:
     void updateFavouritesView(const QDate &aDate);
     void updateSearchView(const QDate &aDate);
     void updateNowView();
+    void updateRoomView(const QDate &aDate);
     void itemClicked(const QModelIndex &aIndex);
     void displayMap(const QModelIndex &aIndex);
     void displayWarning(const QModelIndex &aIndex);
index 9abb7e4..d5c48ce 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>654</width>
-    <height>444</height>
+    <width>935</width>
+    <height>530</height>
    </rect>
   </property>
   <property name="minimumSize" >
         </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="QHBoxLayout" name="horizontalLayout_1">
+       <layout class="QVBoxLayout" name="verticalLayout_3" >
         <item>
-         <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>
+         <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="QVBoxLayout" name="verticalLayout_3">
+         <layout class="QHBoxLayout" name="searchDayNavigatorHorizontalLayout" >
           <item>
-           <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="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>true</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>
+           <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" native="1" name="searchDayNavigator" >
+            <property name="maximumSize" >
+             <size>
+              <width>16777215</width>
+              <height>16777215</height>
+             </size>
+            </property>
            </widget>
           </item>
           <item>
-           <widget class="TreeView" name="searchTreeView">
-            <property name="maximumSize">
+           <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" >
+       <attribute name="title" >
+        <string>Rooms</string>
+       </attribute>
+       <layout class="QGridLayout" name="gridLayout_8" >
+        <item row="0" column="0" >
+         <layout class="QHBoxLayout" name="horizontalLayout_5" >
+          <property name="sizeConstraint" >
+           <enum>QLayout::SetDefaultConstraint</enum>
+          </property>
+          <item>
+           <widget class="DayNavigatorWidget" native="1" name="roomDayNavigator" />
+          </item>
+          <item>
+           <widget class="TreeView" name="roomTreeView" >
+            <property name="maximumSize" >
              <size>
               <width>16777215</width>
               <height>16777215</height>
         </item>
        </layout>
       </widget>
-     <widget class="QWidget" name="conferenceTab" >
-      <attribute name="title" >
+      <widget class="QWidget" name="conferenceTab" >
+       <attribute name="title" >
         <string>Conference</string>
        </attribute>
        <layout class="QGridLayout" name="gridLayout_5" >
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>654</width>
+     <width>935</width>
      <height>26</height>
     </rect>
    </property>
index 2685fb4..1af20d5 100644 (file)
@@ -1,4 +1,5 @@
 #include "event.h"
+#include "room.h"
 
 QString const Event::sTableName = QString("event");
 
@@ -39,6 +40,20 @@ QList<Event> Event::getByDate(const QDate& date, int conferenceId, QString order
     return load(query);
 }
 
+QList<Event> Event::getByDateAndRoom(const QDate& date, int conferenceId)
+{
+    QSqlQuery query;
+    QString aliasEvent("E");
+    QString aliasEventRoom("R");
+    query.prepare(QString("SELECT %1 FROM %2 %3, %4 %5 WHERE %3.xid_conference = :conf AND %3.start >= :start AND %3.start < :end AND %3.id = R.xid_event ORDER BY %5.xid_room, %3.start").arg(
+                    columnsForSelect(aliasEvent), Event::sTableName, aliasEvent, "EVENT_ROOM", aliasEventRoom));
+    query.bindValue(":conf", conferenceId);
+    query.bindValue(":start", convertToDb(date, QVariant::DateTime));
+    query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
+
+    return load(query);
+}
+
 QList<Event> Event::nowEvents(int conferenceId, QString orderBy)
 {
     //uint curTime_t =  QDateTime(QDate::currentDate(),QTime::currentTime(),Qt::UTC).toTime_t();
@@ -64,15 +79,6 @@ QList<Event> Event::getFavByDate(const QDate& date, int conferenceId)
     return load(query);
 }
 
-QList<Event> Event::getByTrack(int trackId)
-{
-    QSqlQuery query;
-    query.prepare(selectQuery() + QString("WHERE xid_track = :trackId ORDER BY start"));
-    query.bindValue(":trackId", trackId);
-
-    return load(query);
-}
-
 QString Event::room() const
 {
     QSqlQuery query;
@@ -88,6 +94,19 @@ QString Event::room() const
         return QString("not-available");
 }
 
+int Event::roomId() const
+{
+    QSqlQuery query;
+    query.prepare("SELECT xid_room FROM event_room WHERE xid_event = :id");
+    query.bindValue(":id", id());
+    if (!query.isActive())
+        if (!query.exec())
+            throw OrmSqlException(query.lastError().text());
+    if (!query.next())
+        throw OrmNoObjectException();
+    return query.record().value("xid_room").toInt();
+}
+
 QStringList Event::persons() const
 {
     QSqlQuery query;
index 8eaedc1..6c82a2b 100644 (file)
@@ -26,6 +26,7 @@ public:
     static QList<Event> getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy);
     static QList<Event> nowEvents(int conferenceId, QString orderBy); // get events scheduled NOW
     static QList<Event> getByTrack(int id);
+    static QList<Event> getByDateAndRoom(const QDate& date, int conferenceId);
 public:
     int id() const { return value("id").toInt(); }
     int conferenceId() const { return value("xid_conference").toInt(); }
@@ -44,6 +45,7 @@ public:
     QString description() const { return value("description").toString(); }
     // records from other tables associated with 'id'
     QString room() const;
+    int roomId() const;
     QStringList persons() const;
 
     void setId(int id) { setValue("id", id); }
index 4fb24b7..03b2ba4 100644 (file)
@@ -2,6 +2,7 @@
 #include <appsettings.h>
 #include <conference.h>
 #include <track.h>
+#include <room.h>
 
 const QString EventModel::COMMA_SEPARATOR = ", ";
 
@@ -73,26 +74,35 @@ void EventModel::createTrackGroups() {
     mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
 }
 
-void EventModel::createTrackGroupsNew() {
+void EventModel::createRoomGroups()
+{
     mGroups.clear();
     mParents.clear();
     if (mEvents.empty())
     {
         return;
     }
-    QList<Track> trackList = Track::getAll();
-    QList<Track>::iterator track = trackList.begin();
-    while (track != trackList.end())
+    int roomId = mEvents.first().roomId();
+
+    mGroups << EventModel::Group(Room::retrieveRoomName(roomId), 0);
+    int nextRoomId = roomId;
+
+    QList<Event>::iterator event = mEvents.begin();
+    int i = 0;
+    while (event != mEvents.end())
     {
-        QList<Event> eventList = Event::getByTrack(track->id());
-        QList<Event>::iterator event = eventList.begin();
-        while (event != eventList.end())
+        roomId = event->roomId();
+        if (nextRoomId != roomId)
         {
-            //TODO korinpa: pokracuj
-            event++;
+            mGroups.last().mChildCount = i - mGroups.last().mFirstEventIndex;
+            mGroups << EventModel::Group(Room::retrieveRoomName(roomId), i);
+            nextRoomId = roomId;
         }
-        track++;
+        mParents[event->id()] = mGroups.count() - 1;
+        event++;
+        i++;
     }
+    mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
 }
 
 QVariant EventModel::data(const QModelIndex& index, int role) const
@@ -234,7 +244,7 @@ int EventModel::loadSearchResultEvents(const QDate &aDate, int aConferenceId)
 void EventModel::loadEventsByTrack(const QDate &aDate, int aConferenceId)
 {
     clearModel();
-    if(Conference::getAll().count())
+    if (Conference::getAll().count())
     {
         qDebug() << "Loading Conference Data (by Track): [" << Conference::getById(aConferenceId).title() << "] " << aDate;
         mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "xid_track, start");
@@ -242,6 +252,17 @@ void EventModel::loadEventsByTrack(const QDate &aDate, int aConferenceId)
     createTrackGroups();
 }
 
+void EventModel::loadEventsByRoom(const QDate &aDate, int aConferenceId)
+{
+    clearModel();
+    if (Conference::getAll().count())
+    {
+        qDebug() << "Loading Conference Data (by Room): [" << Conference::getById(aConferenceId).title() << "] " << aDate;
+        mEvents = Event::getByDateAndRoom(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
+    }
+    createRoomGroups();
+}
+
 void EventModel::loadNowEvents(int aConferenceId)
 {
     clearModel();
index 44ad43c..67d1820 100644 (file)
@@ -18,9 +18,10 @@ public:
     int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
     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 loadEventsByTrack(const QDate &aDate, int aConferenceId); // loads Events sorted by Track id and Event start from the DB
     int loadSearchResultEvents(const QDate &aDate, int aConferenceId);
     void loadNowEvents(int aConferenceId); // loads Now events from the DB
+    void loadEventsByRoom(const QDate &aDate, int aConferenceId);
 
 private:
     struct Group
@@ -43,6 +44,7 @@ private:
     void createTrackGroups();
     void createTrackGroupsNew();
     void clearModel();
+    void createRoomGroups();
 
 public slots:
     void updateModel(int aEventId);
index 69f875b..03cea46 100644 (file)
@@ -25,10 +25,12 @@ HEADERS += event.h \
     track.h \
     delegate.h \
     eventmodel.h \
-    treeview.h
+    treeview.h \
+    room.h
 SOURCES += event.cpp \
     conference.cpp \
     track.cpp \
     delegate.cpp \
     eventmodel.cpp \
-    treeview.cpp
+    treeview.cpp \
+    room.cpp
diff --git a/src/mvc/room.cpp b/src/mvc/room.cpp
new file mode 100644 (file)
index 0000000..429a0c7
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * room.cpp
+ *
+ *  Created on: Dec 27, 2009
+ *      Author: user
+ */
+
+#include "room.h""
+
+QString const Room::sTableName = QString("room");
+int const Room::sTableColCount = 3;
+const QString Room::NAME = "name";
+
+QSqlRecord const Room::sColumns = Room::toRecord(QList<QSqlField>()
+    << QSqlField("id", QVariant::Int)
+    << QSqlField(NAME, QVariant::String)
+    << QSqlField("picture", QVariant::String));
+
+Room Room::retrieveByName(QString name)
+{
+    QSqlQuery query;
+    query.prepare(
+            selectQuery()
+            + QString("WHERE %1.name = :name").arg(sTableName));
+    query.bindValue(":name", name);
+    return loadOne(query);
+}
+
+QList<Room> Room::getAll()
+{
+    QSqlQuery query;
+    query.prepare(selectQuery());
+    return load(query);
+}
+
+Room Room::retrieve(int id)
+{
+    QSqlQuery query;
+    query.prepare(selectQuery()
+            + QString("WHERE %1.id = :id").arg(sTableName));
+    query.bindValue(":id", id);
+    return loadOne(query);
+}
+
+QString Room::retrieveRoomName(int id)
+{
+    Room room = retrieve(id);
+    return room.name();
+}
+
diff --git a/src/mvc/room.h b/src/mvc/room.h
new file mode 100644 (file)
index 0000000..037a3f2
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * room.h
+ *
+ *  Created on: Dec 27, 2009
+ *      Author: Pavol Korinek
+ */
+
+#ifndef ROOM_H_
+#define ROOM_H_
+
+#include <ormrecord.h>
+
+class Room : public OrmRecord<Room>
+{
+public:
+    static const QSqlRecord sColumns;
+    static QString const sTableName;
+    static const int sTableColCount;
+    static const QString NAME;
+public:
+    int id() const { return value("id").toInt(); }
+    void setId(int id) { setValue("id", id); }
+    QString name() const { return value("name").toString(); }
+    void setName(const QString & type) { setValue("name", type); }
+    int insert();
+public:
+    static QList<Room> getAll();
+    static Room retrieve(int id);
+    static QString retrieveRoomName(int id);
+    static Room retrieveByName(QString name);
+};
+
+#endif /* ROOM_H_ */
index d0d8c12..25df934 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include "track.h"
-#include <QSqlTableModel>
 
 QString const Track::sTableName = QString("track");
 int const Track::sTableColCount = 2;
@@ -16,8 +15,6 @@ QSqlRecord const Track::sColumns = Track::toRecord(QList<QSqlField>()
     << QSqlField("id", QVariant::Int)
     << QSqlField(NAME, QVariant::String));
 
-//QMap<int, Track> Track::mIdToTrack;
-
 class TrackInsertException : OrmSqlException
 {
 public:
index 425af6c..be6c041 100644 (file)
@@ -14,18 +14,15 @@ class Track : public OrmRecord<Track>
 {
 public:
     static const QSqlRecord sColumns;
-    static const QSqlRecord sInsertColumns;
     static QString const sTableName;
     static const int sTableColCount;
     static const QString NAME;
 public:
-    static QMap<int, Track> mIdToTrack;
-public:
-    int insert();
     int id() const { return value("id").toInt(); }
     void setId(int id) { setValue("id", id); }
     QString name() const { return value("name").toString(); }
     void setName(const QString & type) { setValue("name", type); }
+    int insert();
 public:
     static QList<Track> getAll();
     static Track retrieve(int id);