Changeset b8a3ad1 for src


Ignore:
Timestamp:
01/22/10 07:18:25 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
8b71fb3
Parents:
d336730
Message:

implemented NOW tab

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    rd336730 rb8a3ad1  
    2626    setupUi(this);
    2727
    28     // TODO: conference ID should be assigned based on actual data in the DB
    29     // for testing only
    30     AppSettings::setConfId(1);
    31 
    3228    // connect Menu actions
    3329    connect(actionImportSchedule, SIGNAL(triggered()), SLOT(importSchedule()));
     
    8076        searchTreeView->setItemDelegate(new Delegate(searchTreeView));
    8177
     78    // NOW View
     79        nowTreeView->setHeaderHidden(true);
     80        nowTreeView->setRootIsDecorated(false);
     81        nowTreeView->setIndentation(0);
     82        nowTreeView->setAnimated(true);
     83        nowTreeView->setModel(new EventModel());
     84        nowTreeView->setItemDelegate(new Delegate(nowTreeView));
     85
    8286    // event details have changed
    8387    connect(dayTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     
    8589    connect(trackTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
    8690    connect(searchTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     91    connect(nowTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
    8792
    8893    // event clicked
     
    9196    connect(trackTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    9297    connect(searchTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
     98    connect(nowTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    9399    // request for map to be displayed
    94100    connect(dayTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     
    96102    connect(trackTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    97103    connect(searchTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     104    connect(nowTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    98105    // request for warning to be displayed
    99106    connect(dayTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     
    101108    connect(trackTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    102109    connect(searchTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     110    connect(nowTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    103111    // event search button clicked
    104112    connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked()));
     
    215223}
    216224
     225void MainWindow::updateNowView()
     226{
     227    EventModel *model = static_cast<EventModel*>(nowTreeView->model());
     228    model->loadNowEvents(AppSettings::confId());
     229    nowTreeView->reset();
     230    nowTreeView->setAllExpanded(true);
     231}
     232
    217233void MainWindow::itemClicked(const QModelIndex &aIndex)
    218234{
     
    275291    static_cast<EventModel*>(trackTreeView->model())->updateModel(aEventId);
    276292    static_cast<EventModel*>(searchTreeView->model())->updateModel(aEventId);
     293    static_cast<EventModel*>(nowTreeView->model())->updateModel(aEventId);
    277294}
    278295
     
    281298    Q_UNUSED(aIndex);
    282299
     300    // TODO: only if it changed to favourities tab
    283301    updateFavouritesView(favouriteDayNavigator->getCurrentDate());
    284 }
    285 
     302    // TODO: only if it changed to now tab
     303    updateNowView();
     304}
     305
  • src/gui/mainwindow.h

    rd336730 rb8a3ad1  
    2323    void updateFavouritesView(const QDate &aDate);
    2424    void updateSearchView(const QDate &aDate);
     25    void updateNowView();
    2526    void itemClicked(const QModelIndex &aIndex);
    2627    void displayMap(const QModelIndex &aIndex);
  • src/gui/mainwindow.ui

    rd336730 rb8a3ad1  
    66    <x>0</x>
    77    <y>0</y>
    8     <width>609</width>
    9     <height>431</height>
     8    <width>654</width>
     9    <height>444</height>
    1010   </rect>
    1111  </property>
     
    322322       </layout>
    323323      </widget>
     324      <widget class="QWidget" name="tab" >
     325       <attribute name="title" >
     326        <string>Now</string>
     327       </attribute>
     328       <layout class="QGridLayout" name="gridLayout_7" >
     329        <item row="0" column="0" >
     330         <widget class="TreeView" name="nowTreeView" />
     331        </item>
     332       </layout>
     333      </widget>
    324334     </widget>
    325335    </item>
     
    331341     <x>0</x>
    332342     <y>0</y>
    333      <width>609</width>
     343     <width>654</width>
    334344     <height>22</height>
    335345    </rect>
  • src/mvc/event.cpp

    rd336730 rb8a3ad1  
    3636    query.bindValue(":start", convertToDb(date, QVariant::DateTime));
    3737    query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
     38
     39    return load(query);
     40}
     41
     42QList<Event> Event::nowEvents(int conferenceId, QString orderBy)
     43{
     44    //uint curTime_t =  QDateTime(QDate::currentDate(),QTime::currentTime(),Qt::UTC).toTime_t();
     45    uint curTime_t = 1265457610; // for testing
     46
     47    QSqlQuery query;
     48    query.prepare(selectQuery() + QString("WHERE xid_conference = :conf AND start <= :now1 AND ( start + duration ) > :now2 ORDER BY %1").arg(orderBy));
     49    query.bindValue(":conf", conferenceId);
     50    query.bindValue(":now1", convertToDb(curTime_t, QVariant::DateTime));
     51    query.bindValue(":now2", convertToDb(curTime_t, QVariant::DateTime));
    3852
    3953    return load(query);
  • src/mvc/event.h

    rd336730 rb8a3ad1  
    2525    static QList<Event> getFavByDate(const QDate & date, int conferenceId); // get Favourities by Date
    2626    static QList<Event> getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy);
     27    static QList<Event> nowEvents(int conferenceId, QString orderBy); // get events scheduled NOW
    2728public:
    2829    int id() const { return value("id").toInt(); }
  • src/mvc/eventmodel.cpp

    rd336730 rb8a3ad1  
    221221}
    222222
     223void EventModel::loadNowEvents(int aConferenceId)
     224{
     225    clearModel();
     226    // check for existence of the conference in the DB
     227    if(Conference::getAll().count())
     228    {
     229        qDebug() << "Loading Conference Data: [" << Conference::getById(aConferenceId).title() << "] scheduled NOW";
     230        mEvents = Event::nowEvents(aConferenceId, "start");
     231    }
     232    createTimeGroups();
     233}
     234
    223235void EventModel::updateModel(int aEventId)
    224236{
  • src/mvc/eventmodel.h

    rd336730 rb8a3ad1  
    2121    void loadEventsByTrack(const QDate &aDate, int aConferenceId); // loads Events grouped by Track from the DB
    2222    int loadSearchResultEvents(const QDate &aDate, int aConferenceId);
     23    void loadNowEvents(int aConferenceId); // loads Now events from the DB
    2324
    2425private:
  • src/mvc/treeview.cpp

    rd336730 rb8a3ad1  
    133133}
    134134
     135void TreeView::setAllExpanded(bool aExpanded)
     136{
     137    for(int i=0; i<model()->rowCount(QModelIndex()); i++)
     138    {
     139        setExpanded(model()->index(i,0,QModelIndex()),aExpanded);
     140    }
     141}
     142
  • src/mvc/treeview.h

    rd336730 rb8a3ad1  
    1313    void mouseReleaseEvent(QMouseEvent *aEvent);
    1414    bool testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint);
     15public slots:
     16    void setAllExpanded(bool aExpanded); // (aExpanded==true) => expanded; (aExpanded==false) => collapsed
    1517private slots:
    1618    void handleItemClicked(const QModelIndex &index);
Note: See TracChangeset for help on using the changeset viewer.