Changeset 11d7ec5


Ignore:
Timestamp:
10/17/11 23:37:48 (11 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
9196cb0
Parents:
066b41f
Message:

Implemented "now" action and removed the "now" button from the day navigator.

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/create_tables.sql

    r066b41f r11d7ec5  
    3333    , id INTEGER NOT NULL
    3434    , start INTEGER NOT NULL
    35     , duration INTEGER NOT NULL
     35    , duration INTEGER NOT NULL -- duration of the event in seconds
    3636    , xid_track INTEGER NOT NULL REFERENCES TRACK(id)
    3737    , type VARCHAR
  • src/gui/daynavigatorwidget.cpp

    r066b41f r11d7ec5  
    2929    connect(prevDayButton, SIGNAL(clicked()), SLOT(prevDayButtonClicked()));
    3030    connect(nextDayButton, SIGNAL(clicked()), SLOT(nextDayButtonClicked()));
    31     connect(todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked()));
    3231
    3332    configureNavigation();
     
    107106
    108107
    109 void DayNavigatorWidget::todayButtonClicked() {
    110     setCurDate(QDate::currentDate());
    111 }
    112 
    113 
    114108void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent)
    115109{
  • src/gui/daynavigatorwidget.h

    r066b41f r11d7ec5  
    4141        void configureNavigation();
    4242    private slots:
    43         void todayButtonClicked();
    4443        void prevDayButtonClicked();
    4544        void nextDayButtonClicked();
  • src/gui/daynavigatorwidget.ui

    r066b41f r11d7ec5  
    6565      </widget>
    6666     </item>
    67      <item>
    68       <widget class="QToolButton" name="todayButton">
    69        <property name="text">
    70         <string>...</string>
    71        </property>
    72        <property name="icon">
    73         <iconset resource="../icons.qrc">
    74          <normaloff>:/icons/today.png</normaloff>:/icons/today.png</iconset>
    75        </property>
    76        <property name="autoRaise">
    77         <bool>true</bool>
    78        </property>
    79       </widget>
    80      </item>
    8167    </layout>
    8268   </item>
    8369  </layout>
    8470 </widget>
    85  <resources>
    86   <include location="../icons.qrc"/>
    87  </resources>
     71 <resources/>
    8872 <connections/>
    8973 <slots>
  • src/gui/dayviewtabcontainer.cpp

    r066b41f r11d7ec5  
    2121#include "dayviewtabcontainer.h"
    2222
    23 DayViewTabContainer::DayViewTabContainer(QWidget *aParent) : TabContainer( aParent )
    24 {
     23DayViewTabContainer::DayViewTabContainer(QWidget *aParent): TabContainer(aParent) {
    2524}
    2625
    27 DayViewTabContainer::~DayViewTabContainer()
    28 {
     26
     27void DayViewTabContainer::expandTimeGroup(QTime time, int conferenceId) {
     28    EventModel* eventModel = static_cast<EventModel*>(treeView->model());
     29
     30    // iterate over the time groups
     31    for (int g = 0; g != eventModel->rowCount(); ++g) {
     32        QModelIndex groupIdx = eventModel->index(g, 0);
     33        // iterate over the events in the group
     34        for (int e = 0; e != eventModel->rowCount(groupIdx); ++e) {
     35            QModelIndex eventIdx = eventModel->index(e, 0, groupIdx);
     36            int eventId = eventIdx.data().toInt();
     37            Event event = Event::getById(eventId, conferenceId);
     38            if (time < event.start().time().addSecs(event.duration())) { // if time < end
     39                // expand this group
     40                treeView->expand(groupIdx);
     41                treeView->scrollTo(eventIdx, QAbstractItemView::PositionAtTop);
     42                return;
     43            }
     44        }
     45    }
    2946}
    3047
    31 void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId )
    32 {
     48
     49void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) {
    3350    static_cast<EventModel*>(treeView->model())->loadEvents( aDate, aConferenceId );
    3451}
  • src/gui/dayviewtabcontainer.h

    r066b41f r11d7ec5  
    2828public:
    2929    DayViewTabContainer(QWidget *aParent);
    30     virtual ~DayViewTabContainer();
     30    virtual ~DayViewTabContainer() {}
     31
     32public slots:
     33    void expandTimeGroup(QTime time, int conferenceId);
     34
    3135protected:
    3236    virtual void loadEvents(const QDate &aDate, const int aConferenceId );
  • src/gui/mainwindow.cpp

    r066b41f r11d7ec5  
    150150
    151151void MainWindow::on_nowAction_triggered() {
    152 
     152    int confId = Conference::activeConference();
     153    if (confId== -1) return;
     154    dayNavigator->setCurDate(QDate::currentDate());
     155    dayTabContainer->expandTimeGroup(QTime::currentTime(), confId);
    153156}
    154157
  • src/mvc/event.h

    r066b41f r11d7ec5  
    5454    int conferenceId() const { return value("xid_conference").toInt(); }
    5555    QDateTime start() const { return value("start").toDateTime(); }
     56    /// duration of the event in seconds
    5657    int duration() const { return value("duration").toInt(); }
    5758    int trackId() const { return value("xid_track").toInt(); }
Note: See TracChangeset for help on using the changeset viewer.