Implemented "now" action and removed the "now" button from the day navigator.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Mon, 17 Oct 2011 21:37:48 +0000 (21:37 +0000)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Mon, 17 Oct 2011 21:37:48 +0000 (21:37 +0000)
src/create_tables.sql
src/gui/daynavigatorwidget.cpp
src/gui/daynavigatorwidget.h
src/gui/daynavigatorwidget.ui
src/gui/dayviewtabcontainer.cpp
src/gui/dayviewtabcontainer.h
src/gui/mainwindow.cpp
src/mvc/event.h

index a04b8d2..122c1cf 100644 (file)
@@ -32,7 +32,7 @@ CREATE TABLE PERSON ( id INTEGER NOT NULL
 CREATE TABLE EVENT ( xid_conference INTEGER  NOT NULL
     , id INTEGER NOT NULL
     , start INTEGER NOT NULL
-    , duration INTEGER NOT NULL
+    , duration INTEGER NOT NULL -- duration of the event in seconds
     , xid_track INTEGER NOT NULL REFERENCES TRACK(id)
     , type VARCHAR
     , language VARCHAR
index e251f6f..c48f354 100644 (file)
@@ -28,7 +28,6 @@ DayNavigatorWidget::DayNavigatorWidget(QWidget *aParent): QWidget(aParent) {
 
     connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked()));
     connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked()));
-    connect(todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked()));
 
     configureNavigation();
 }
@@ -106,11 +105,6 @@ void DayNavigatorWidget::nextDayButtonClicked() {
 }
 
 
-void DayNavigatorWidget::todayButtonClicked() {
-    setCurDate(QDate::currentDate());
-}
-
-
 void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent)
 {
     Q_UNUSED(aEvent);
index d342e19..e16017c 100644 (file)
@@ -40,7 +40,6 @@ class DayNavigatorWidget : public QWidget, private Ui::DayNavigatorWidget {
         void paintEvent(QPaintEvent *);
         void configureNavigation();
     private slots:
-        void todayButtonClicked();
         void prevDayButtonClicked();
         void nextDayButtonClicked();
     signals:
index 255790a..650d533 100644 (file)
        </property>
       </widget>
      </item>
-     <item>
-      <widget class="QToolButton" name="todayButton">
-       <property name="text">
-        <string>...</string>
-       </property>
-       <property name="icon">
-        <iconset resource="../icons.qrc">
-         <normaloff>:/icons/today.png</normaloff>:/icons/today.png</iconset>
-       </property>
-       <property name="autoRaise">
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
     </layout>
    </item>
   </layout>
  </widget>
- <resources>
-  <include location="../icons.qrc"/>
- </resources>
+ <resources/>
  <connections/>
  <slots>
   <slot>prevDayButtonClicked()</slot>
index 35ce2d8..9230327 100644 (file)
 
 #include "dayviewtabcontainer.h"
 
-DayViewTabContainer::DayViewTabContainer(QWidget *aParent) : TabContainer( aParent )
-{
+DayViewTabContainer::DayViewTabContainer(QWidget *aParent): TabContainer(aParent) {
 }
 
-DayViewTabContainer::~DayViewTabContainer()
-{
+
+void DayViewTabContainer::expandTimeGroup(QTime time, int conferenceId) {
+    EventModel* eventModel = static_cast<EventModel*>(treeView->model());
+
+    // iterate over the time groups
+    for (int g = 0; g != eventModel->rowCount(); ++g) {
+        QModelIndex groupIdx = eventModel->index(g, 0);
+        // iterate over the events in the group
+        for (int e = 0; e != eventModel->rowCount(groupIdx); ++e) {
+            QModelIndex eventIdx = eventModel->index(e, 0, groupIdx);
+            int eventId = eventIdx.data().toInt();
+            Event event = Event::getById(eventId, conferenceId);
+            if (time < event.start().time().addSecs(event.duration())) { // if time < end
+                // expand this group
+                treeView->expand(groupIdx);
+                treeView->scrollTo(eventIdx, QAbstractItemView::PositionAtTop);
+                return;
+            }
+        }
+    }
 }
 
-void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId )
-{
+
+void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) {
     static_cast<EventModel*>(treeView->model())->loadEvents( aDate, aConferenceId );
 }
index e049ff6..f0ab645 100644 (file)
@@ -27,7 +27,11 @@ class DayViewTabContainer: public TabContainer {
     Q_OBJECT
 public:
     DayViewTabContainer(QWidget *aParent);
-    virtual ~DayViewTabContainer();
+    virtual ~DayViewTabContainer() {}
+
+public slots:
+    void expandTimeGroup(QTime time, int conferenceId);
+
 protected:
     virtual void loadEvents(const QDate &aDate, const int aConferenceId );
 };
index 8373041..b9969a9 100644 (file)
@@ -149,7 +149,10 @@ void MainWindow::on_reloadAction_triggered() {
 
 
 void MainWindow::on_nowAction_triggered() {
-
+    int confId = Conference::activeConference();
+    if (confId== -1) return;
+    dayNavigator->setCurDate(QDate::currentDate());
+    dayTabContainer->expandTimeGroup(QTime::currentTime(), confId);
 }
 
 
index 08c86f0..ad83521 100644 (file)
@@ -53,6 +53,7 @@ public:
     int id() const { return value("id").toInt(); }
     int conferenceId() const { return value("xid_conference").toInt(); }
     QDateTime start() const { return value("start").toDateTime(); }
+    /// duration of the event in seconds
     int duration() const { return value("duration").toInt(); }
     int trackId() const { return value("xid_track").toInt(); }
     QString type() const { return value("type").toString(); }