Changeset f6300c7


Ignore:
Timestamp:
01/18/10 16:25:57 (12 years ago)
Author:
korrco <korrco@…>
Branches:
master, qt5
Children:
28d9e28
Parents:
b6cd05c
Message:

activities tab implemented - not finished yet

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/gui/daynavigatorwidget.cpp

    rb6cd05c rf6300c7  
    8383}
    8484
     85QDate DayNavigatorWidget::getCurrentDate()
     86{
     87    return mCurDate;
     88}
     89
  • src/gui/daynavigatorwidget.h

    rb6cd05c rf6300c7  
    66#include <QDate>
    77
    8 class DayNavigatorWidget : public QWidget, Ui::DayNavigatorWidget
     8class DayNavigatorWidget : public QWidget, private Ui::DayNavigatorWidget
    99{
    1010    Q_OBJECT
     
    1313        ~DayNavigatorWidget() {}
    1414        void setDates(const QDate &aStartDate, const QDate &aEndDate);
     15        QDate getCurrentDate();
    1516    private slots:
    1617        void prevDayButtonClicked();
  • src/gui/daynavigatorwidget.ui

    rb6cd05c rf6300c7  
    77    <y>0</y>
    88    <width>360</width>
    9     <height>50</height>
     9    <height>52</height>
    1010   </rect>
    1111  </property>
  • src/gui/mainwindow.cpp

    rb6cd05c rf6300c7  
    3636
    3737    connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
    38 
     38    connect(activityDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateActivitiesDayView(const QDate &)));
     39    connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(updateView(int)));
    3940
    4041    // DAY EVENTS View
     
    105106        int confId = 1;
    106107        // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
    107         dayNavigator->setDates(Conference::getById(confId).start(),Conference::getById(confId).end());
     108        dayNavigator->setDates(Conference::getById(confId).start(), Conference::getById(confId).end());
    108109    }
    109110}
     
    145146    updateDayView(Conference::getById(confId).start());
    146147}
     148
     149void MainWindow::updateActivitiesDayView(const QDate &aDate)
     150{
     151    int confId = 1;
     152    static_cast<EventModel*>(activityDayTreeView->model())->loadEventsByActivities(aDate,confId);
     153    activityDayTreeView->reset();
     154    activityDayNavigator->show();
     155}
     156
     157void MainWindow::updateView(int tabIndex)
     158{
     159    //TODO korinpa: skraslit ! aj pre ine taby
     160    qDebug() << "updateView index: " << tabIndex;
     161    if (tabIndex == 2)
     162    {
     163        QDate date = activityDayNavigator->getCurrentDate();
     164        updateActivitiesDayView(date);
     165    }
     166}
     167
  • src/gui/mainwindow.h

    rb6cd05c rf6300c7  
    2222    void updateFavView();
    2323    void updateFavViewComplete();
     24    void updateActivitiesDayView(const QDate &aDate);
     25    void updateView(int tabIndex);
    2426private:
    2527    SqlEngine *mSqlEngine;
  • src/gui/mainwindow.ui

    rb6cd05c rf6300c7  
    5858        <string>Activities</string>
    5959       </attribute>
     60       <widget class="QWidget" name="verticalLayoutWidget" >
     61        <property name="geometry" >
     62         <rect>
     63          <x>0</x>
     64          <y>0</y>
     65          <width>501</width>
     66          <height>231</height>
     67         </rect>
     68        </property>
     69        <layout class="QVBoxLayout" name="activitiesVerticalLayout" >
     70         <item>
     71          <widget class="DayNavigatorWidget" native="1" name="activityDayNavigator" />
     72         </item>
     73         <item>
     74          <widget class="TreeView" name="activityDayTreeView" >
     75           <property name="maximumSize" >
     76            <size>
     77             <width>16777215</width>
     78             <height>16777215</height>
     79            </size>
     80           </property>
     81          </widget>
     82         </item>
     83        </layout>
     84       </widget>
    6085      </widget>
    6186      <widget class="QWidget" name="searchTab" >
     
    79104     <y>0</y>
    80105     <width>534</width>
    81      <height>26</height>
     106     <height>40</height>
    82107    </rect>
    83108   </property>
  • src/mvc/eventmodel.cpp

    rb6cd05c rf6300c7  
    4343}
    4444
     45void EventModel::createActivityGroups() {
     46    mGroups.clear();
     47    mParents.clear();
     48    if (mEvents.empty())
     49    {
     50        return;
     51    }
     52    int activityId = mEvents.first().activityId();
     53    //TODO korinpa: get activity name
     54    mGroups << EventModel::Group(QString("activity %1").arg(activityId), 0);
     55    int nextActivityId = activityId;
     56
     57    for (int i=0; i<mEvents.count(); i++)
     58    {
     59        activityId = mEvents.at(i).activityId();
     60        if (nextActivityId != activityId)
     61        {
     62            mGroups.last().mChildCount = i - mGroups.last().mFirstEventIndex;
     63            mGroups << EventModel::Group(QString("activity %1").arg(activityId), 0);
     64            int nextActivityId = activityId;
     65        }
     66        // add parent-child relation
     67        mParents[mEvents.at(i).id()] = mGroups.count() - 1;
     68    }
     69    mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
     70}
     71
    4572QVariant EventModel::data(const QModelIndex& index, int role) const
    4673{
     
    118145}
    119146
    120 void EventModel::loadEvents(const QDate &aDate, int aConferenceId)
    121 {
    122     for(int i=0; i<mGroups.count(); i++)
    123     {
    124         QModelIndex idx = index(i,0);
     147void EventModel::clearModel()
     148{
     149/*
     150    for(int i = 0;i < mGroups.count();i++){
     151        QModelIndex idx = index(i, 0);
    125152        Group group = mGroups[i];
    126         beginRemoveRows(idx,0,group.mChildCount-1);
    127         removeRows(0,group.mChildCount,idx);
     153        beginRemoveRows(idx, 0, group.mChildCount - 1);
     154        bool ok = removeRows(0, group.mChildCount, idx);
    128155        endRemoveRows();
    129156        //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
    130157    }
    131 
     158*/
     159    mGroups.clear();
    132160    mEvents.clear();
    133 
     161}
     162
     163void EventModel::loadEvents(const QDate &aDate, int aConferenceId)
     164{
     165    clearModel();
    134166    // check for existence of the conference in the DB
    135167    if(Conference::getAll().count())
     
    143175void EventModel::loadFavEvents(const QDate &aDate, int aConferenceId)
    144176{
    145     for(int i=0; i<mGroups.count(); i++)
    146     {
    147         QModelIndex idx = index(i,0);
    148         Group group = mGroups[i];
    149         beginRemoveRows(idx,0,group.mChildCount-1);
    150         removeRows(0,group.mChildCount,idx);
    151         endRemoveRows();
    152         //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
    153     }
    154 
    155     mEvents.clear();
    156 
     177    clearModel();
    157178    // check for existence of the conference in the DB
    158179    if(Conference::getAll().count())
     
    164185}
    165186
     187void EventModel::loadEventsByActivities(const QDate &aDate, int aConferenceId)
     188{
     189    clearModel();
     190    if(Conference::getAll().count())
     191        {
     192            qDebug() << "Loading Conference Data (by Activities): [" << Conference::getById(aConferenceId).title() << "] " << aDate;
     193            mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
     194        }
     195    createActivityGroups();
     196}
     197
    166198void EventModel::emitDataChangedSignal(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight)
    167199{
  • src/mvc/eventmodel.h

    rb6cd05c rf6300c7  
    1717    void loadEvents(const QDate &aDate, int aConferenceId); // loads Events from the DB
    1818    void loadFavEvents(const QDate &aDate, int aConferenceId); // loads Favourite events from the DB
    19    
     19    void loadEventsByActivities(const QDate &aDate, int aConferenceId); // loads Events grouped by Activities from the DB
    2020    // a method to force 'EventModel' emit signal 'dataChanged()'
    2121    // a 'view', eg. 'TreeView' listens for this signal and redraws changed items(indexes)
     
    4040private:
    4141    void createTimeGroups();
     42    void createActivityGroups();
     43    void clearModel();
    4244
    4345private:
Note: See TracChangeset for help on using the changeset viewer.