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 a04b8d2af150c347976e67245dd1bb8511b54389..122c1cf9240720d865145c2648bc023cf3adefac 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 e251f6f6a4f225ce4af5ee7c058e7766e11eaf38..c48f354fa349408a1e6dd2d8ca3df8ae52067c8f 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 d342e19b9fd643666794beca31ef40213b18e7a2..e16017c9b8961d8a6f2d3a4e40e6f47ebf0e7c49 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 255790a96bc3f036cd85b0ef54dd52eda9f59f14..650d53353d938538f85fe69123bc4e491bff9af0 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 35ce2d81ff96cd60a3fb52ae89866f3d88f1bc08..9230327cbb554bcebca05a17e8188a0791dbf544 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 e049ff6f622078b8e92e8843263f077374c1309b..f0ab645bd7f271d71c8cd517a1f3c7c65944d5ec 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 8373041ab864874e2f9484408613b923e2df6d9c..b9969a9d5a1eefb5409a6790381136d956784e83 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 08c86f0bd939dda10acd290c0652befdc4d0cde9..ad835216ef6d193678bf2c2c567443b517d63bdb 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(); }