Changeset 969a840


Ignore:
Timestamp:
01/13/10 21:51:06 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
6a624f7
Parents:
69393c0
Message:

implemented day navigator widget

  • to switch between conference days
Location:
src
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/gui/gui.pro

    r69393c0 r969a840  
    1616# (which means they need to be added to the test module as well,
    1717# but I am sure you can live with that for the time being).
     18
    1819FORMS += mainwindow.ui \
     20         daynavigatorwidget.ui \
    1921         about.ui
    20 SOURCES += mainwindow.cpp
    21 HEADERS += mainwindow.h
    2222
     23HEADERS += mainwindow.h \
     24           daynavigatorwidget.h
     25
     26SOURCES += mainwindow.cpp \
     27           daynavigatorwidget.cpp
     28
  • src/gui/mainwindow.cpp

    r69393c0 r969a840  
    1010#include <delegate.h>
    1111
     12#include <conference.h>
     13
    1214#include <QDialog>
    1315#include "ui_about.h"
     16#include "daynavigatorwidget.h"
    1417
    1518MainWindow::MainWindow(QWidget *parent)
     
    3235    statusBar()->showMessage(tr("Ready"));
    3336
     37    connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
     38
    3439    treeView->setHeaderHidden(true);
    3540    treeView->setRootIsDecorated(false);
     
    3843    treeView->setModel(new EventModel());
    3944    treeView->setItemDelegate(new Delegate(treeView));
     45
     46    if(!Conference::getAll().count()) // no conference(s) in the DB
     47        dayNavigator->hide(); // hide DayNavigatorWidget
     48    else
     49    {
     50        int confId = 1;
     51        dayNavigator->setDates(Conference::getById(confId).start(),Conference::getById(confId).end());
     52    }
    4053}
    4154
     
    6578    QByteArray data = file.readAll();
    6679    mXmlParser->parseData(data,mSqlEngine);
    67     static_cast<EventModel*>(treeView->model())->loadEvents();
    68     treeView->reset();
     80
     81    if(Conference::getAll().count())
     82    {
     83        int confId = 1;
     84        // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
     85        dayNavigator->setDates(Conference::getById(confId).start(),Conference::getById(confId).end());
     86    }
    6987}
    7088
     
    83101}
    84102
     103void MainWindow::updateDayView(const QDate &aDate)
     104{
     105    int confId = 1;
     106    static_cast<EventModel*>(treeView->model())->loadEvents(aDate,confId);
     107    treeView->reset();
     108    dayNavigator->show();
     109}
     110
  • src/gui/mainwindow.h

    r69393c0 r969a840  
    1919    void showParsingProgress(int aStatus);
    2020    void aboutApp();
     21    void updateDayView(const QDate &aDate);
    2122private:
    2223    SqlEngine *mSqlEngine;
  • src/gui/mainwindow.ui

    r69393c0 r969a840  
    2828         <layout class="QVBoxLayout" name="verticalLayout" >
    2929          <item>
    30            <layout class="QHBoxLayout" name="horizontalLayout_2" >
    31             <item>
    32              <widget class="QToolButton" name="buttonPrevDay" >
    33               <property name="text" >
    34                <string>&lt;|</string>
    35               </property>
    36               <property name="autoRaise" >
    37                <bool>true</bool>
    38               </property>
    39               <property name="arrowType" >
    40                <enum>Qt::LeftArrow</enum>
    41               </property>
    42              </widget>
    43             </item>
    44             <item>
    45              <spacer name="horizontalSpacer" >
    46               <property name="orientation" >
    47                <enum>Qt::Horizontal</enum>
    48               </property>
    49               <property name="sizeHint" stdset="0" >
    50                <size>
    51                 <width>40</width>
    52                 <height>20</height>
    53                </size>
    54               </property>
    55              </spacer>
    56             </item>
    57             <item>
    58              <widget class="QLabel" name="label" >
    59               <property name="text" >
    60                <string>Selected Date Goes Here</string>
    61               </property>
    62              </widget>
    63             </item>
    64             <item>
    65              <spacer name="horizontalSpacer_2" >
    66               <property name="orientation" >
    67                <enum>Qt::Horizontal</enum>
    68               </property>
    69               <property name="sizeHint" stdset="0" >
    70                <size>
    71                 <width>40</width>
    72                 <height>20</height>
    73                </size>
    74               </property>
    75              </spacer>
    76             </item>
    77             <item>
    78              <widget class="QToolButton" name="buttonNextDay" >
    79               <property name="text" >
    80                <string>|></string>
    81               </property>
    82               <property name="autoRaise" >
    83                <bool>true</bool>
    84               </property>
    85               <property name="arrowType" >
    86                <enum>Qt::RightArrow</enum>
    87               </property>
    88              </widget>
    89             </item>
    90            </layout>
     30           <widget class="DayNavigatorWidget" native="1" name="dayNavigator" />
    9131          </item>
    9232          <item>
     
    161101   <header>../model/treeview.h</header>
    162102  </customwidget>
     103  <customwidget>
     104   <class>DayNavigatorWidget</class>
     105   <extends>QWidget</extends>
     106   <header>daynavigatorwidget.h</header>
     107   <container>1</container>
     108  </customwidget>
    163109 </customwidgets>
    164110 <resources/>
  • src/model/conference.h

    r69393c0 r969a840  
    2424    QString venue() const { return value("venue").toString(); }
    2525    QString city() const { return value("city").toString(); }
    26     QDate start() const { return value("start").toDate(); }
    27     QDate end() const { return value("end").toDate(); }
     26    // TODO: there is some problem with converting "Time_t" to QDateTime: had to manually add 1 day
     27    // NEEDS TO BE FIXED
     28    QDate start() const { return value("start").toDateTime().addDays(1).date(); }
     29    QDate end() const { return value("end").toDateTime().addDays(1).date(); }
     30    //
    2831    int days() const { return value("days").toInt(); }
    2932    int dayChange() const { return value("day_change").toInt(); } // in seconds from 00:00
  • src/model/eventmodel.cpp

    r69393c0 r969a840  
    44EventModel::EventModel()
    55{
    6 
    7     loadEvents();
     6    mEvents.clear();
    87}
    98
     
    119118}
    120119
    121 void EventModel::loadEvents()
     120void EventModel::loadEvents(const QDate &aDate, int aConferenceId)
    122121{
    123122    mEvents.clear();
    124123
    125     mConfId = 1; // current conference selected: we have only one DB so far
    126     // check for existence of conference in the DB
     124    // check for existence of the conference in the DB
    127125    if(Conference::getAll().count())
    128126    {
    129         mCurrentDate = Conference::getById(mConfId).start();
    130         qDebug() << "Loading Conference Data: [" << Conference::getById(mConfId).title() << "] " << mCurrentDate;
    131         mEvents = Event::getByDate(QDate(mCurrentDate.year(), mCurrentDate.month(), mCurrentDate.day()), mConfId);
     127        qDebug() << "Loading Conference Data: [" << Conference::getById(aConferenceId).title() << "] " << aDate;
     128        mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
    132129    }
    133     mEvents = Event::getByDate(QDate(mCurrentDate.year(), mCurrentDate.month(), mCurrentDate.day()), mConfId);
    134130    createTimeGroups();
    135131}
  • src/model/eventmodel.h

    r69393c0 r969a840  
    1515    int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
    1616    int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
    17     void loadEvents(); // loads Events from the DB
     17    void loadEvents(const QDate &aDate, int aConferenceId); // loads Events from the DB
    1818
    1919private:
     
    4040    QList<Group> mGroups;
    4141    QHash<int, int> mParents;
    42     QDate mCurrentDate;
    43     int mConfId;
    4442};
    4543
Note: See TracChangeset for help on using the changeset viewer.