Changeset 6f39595


Ignore:
Timestamp:
01/17/10 18:18:22 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
9f473ba
Parents:
c790268
Message:

started work on 'favourities'

  • created tavourities tree view in the MainWindow? 'Favourities' tab
  • listed some testing 'fav' events
  • TODO: list isn't updated dynamically, which means that the list isn't updated if the user adds/removes an event(s) to/from the 'favourities' list
Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    rc790268 r6f39595  
    3737    connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
    3838
    39     treeView->setHeaderHidden(true);
    40     treeView->setRootIsDecorated(false);
    41     treeView->setIndentation(0);
    42     treeView->setAnimated(true);
    43     treeView->setModel(new EventModel());
    44     treeView->setItemDelegate(new Delegate(treeView));
     39    // DAY EVENTS View
     40    dayTreeView->setHeaderHidden(true);
     41    dayTreeView->setRootIsDecorated(false);
     42    dayTreeView->setIndentation(0);
     43    dayTreeView->setAnimated(true);
     44    dayTreeView->setModel(new EventModel());
     45    dayTreeView->setItemDelegate(new Delegate(dayTreeView));
     46
     47    // FAVOURITIES View
     48    favTreeView->setHeaderHidden(true);
     49    favTreeView->setRootIsDecorated(false);
     50    favTreeView->setIndentation(0);
     51    favTreeView->setAnimated(true);
     52    favTreeView->setModel(new EventModel());
     53    favTreeView->setItemDelegate(new Delegate(favTreeView));
     54    // TESTING: load some 'fav' data
     55    if(Conference::getAll().count()) // no conference(s) in the DB
     56    {
     57        int confId = 1;
     58        static_cast<EventModel*>(favTreeView->model())->loadFavEvents(Conference::getById(confId).start(),confId);
     59        favTreeView->reset();
     60    }
    4561
    4662    if(!Conference::getAll().count()) // no conference(s) in the DB
     
    104120{
    105121    int confId = 1;
    106     static_cast<EventModel*>(treeView->model())->loadEvents(aDate,confId);
    107     treeView->reset();
     122    static_cast<EventModel*>(dayTreeView->model())->loadEvents(aDate,confId);
     123    dayTreeView->reset();
    108124    dayNavigator->show();
    109125}
  • src/gui/mainwindow.ui

    rc790268 r6f39595  
    1 <?xml version="1.0" encoding="UTF-8"?>
    2 <ui version="4.0">
     1<ui version="4.0" >
    32 <class>MainWindow</class>
    4  <widget class="QMainWindow" name="MainWindow">
    5   <property name="geometry">
     3 <widget class="QMainWindow" name="MainWindow" >
     4  <property name="geometry" >
    65   <rect>
    76    <x>0</x>
    87    <y>0</y>
    9     <width>856</width>
    10     <height>558</height>
     8    <width>534</width>
     9    <height>375</height>
    1110   </rect>
    1211  </property>
    13   <property name="windowTitle">
     12  <property name="windowTitle" >
    1413   <string>MainWindow</string>
    1514  </property>
    16   <widget class="QWidget" name="centralwidget">
    17    <layout class="QGridLayout" name="gridLayout">
    18     <item row="0" column="0">
    19      <widget class="QTabWidget" name="tabWidget">
    20       <property name="currentIndex">
    21        <number>0</number>
     15  <widget class="QWidget" name="centralwidget" >
     16   <layout class="QGridLayout" name="gridLayout" >
     17    <item row="0" column="0" >
     18     <widget class="QTabWidget" name="tabWidget" >
     19      <property name="currentIndex" >
     20       <number>1</number>
    2221      </property>
    23       <widget class="QWidget" name="dayViewTab">
    24        <attribute name="title">
     22      <widget class="QWidget" name="dayViewTab" >
     23       <attribute name="title" >
    2524        <string>Day View</string>
    2625       </attribute>
    27        <layout class="QGridLayout" name="gridLayout_2">
    28         <item row="0" column="0">
    29          <layout class="QVBoxLayout" name="verticalLayout">
     26       <layout class="QGridLayout" name="gridLayout_2" >
     27        <item row="0" column="0" >
     28         <layout class="QVBoxLayout" name="verticalLayout" >
    3029          <item>
    31            <widget class="DayNavigatorWidget" name="dayNavigator" native="true"/>
     30           <widget class="DayNavigatorWidget" native="1" name="dayNavigator" />
    3231          </item>
    3332          <item>
    34            <widget class="TreeView" name="treeView">
    35             <property name="maximumSize">
     33           <widget class="TreeView" name="dayTreeView" >
     34            <property name="maximumSize" >
    3635             <size>
    3736              <width>16777215</width>
     
    4544       </layout>
    4645      </widget>
    47       <widget class="QWidget" name="activitiesTab">
    48        <attribute name="title">
     46      <widget class="QWidget" name="favouritesTab" >
     47       <attribute name="title" >
     48        <string>Favourites</string>
     49       </attribute>
     50       <layout class="QGridLayout" name="gridLayout_3" >
     51        <item row="0" column="0" >
     52         <widget class="TreeView" name="favTreeView" />
     53        </item>
     54       </layout>
     55      </widget>
     56      <widget class="QWidget" name="activitiesTab" >
     57       <attribute name="title" >
    4958        <string>Activities</string>
    5059       </attribute>
    5160      </widget>
    52       <widget class="QWidget" name="favouritesTab">
    53        <attribute name="title">
    54         <string>Favourites</string>
    55        </attribute>
    56       </widget>
    57       <widget class="QWidget" name="searchTab">
    58        <attribute name="title">
     61      <widget class="QWidget" name="searchTab" >
     62       <attribute name="title" >
    5963        <string>Search</string>
    6064       </attribute>
    6165      </widget>
    62       <widget class="QWidget" name="mapTab">
    63        <attribute name="title">
     66      <widget class="QWidget" name="mapTab" >
     67       <attribute name="title" >
    6468        <string>Map</string>
    6569       </attribute>
     
    6973   </layout>
    7074  </widget>
    71   <widget class="QMenuBar" name="menubar">
    72    <property name="geometry">
     75  <widget class="QMenuBar" name="menubar" >
     76   <property name="geometry" >
    7377    <rect>
    7478     <x>0</x>
    7579     <y>0</y>
    76      <width>856</width>
    77      <height>24</height>
     80     <width>534</width>
     81     <height>22</height>
    7882    </rect>
    7983   </property>
    80    <widget class="QMenu" name="menuFile">
    81     <property name="title">
     84   <widget class="QMenu" name="menuFile" >
     85    <property name="title" >
    8286     <string>File</string>
    8387    </property>
    84     <addaction name="actionImportSchedule"/>
     88    <addaction name="actionImportSchedule" />
    8589   </widget>
    86    <widget class="QMenu" name="menuAbout">
    87     <property name="title">
     90   <widget class="QMenu" name="menuAbout" >
     91    <property name="title" >
    8892     <string>Help</string>
    8993    </property>
    90     <addaction name="actionAboutQt"/>
    91     <addaction name="actionAboutApplication"/>
     94    <addaction name="actionAboutQt" />
     95    <addaction name="actionAboutApplication" />
    9296   </widget>
    93    <addaction name="menuFile"/>
    94    <addaction name="menuAbout"/>
     97   <addaction name="menuFile" />
     98   <addaction name="menuAbout" />
    9599  </widget>
    96   <widget class="QStatusBar" name="statusbar"/>
    97   <action name="actionImportSchedule">
    98    <property name="text">
     100  <widget class="QStatusBar" name="statusbar" />
     101  <action name="actionImportSchedule" >
     102   <property name="text" >
    99103    <string>Import Schedule</string>
    100104   </property>
    101105  </action>
    102   <action name="actionAboutQt">
    103    <property name="text">
     106  <action name="actionAboutQt" >
     107   <property name="text" >
    104108    <string>About Qt</string>
    105109   </property>
    106110  </action>
    107   <action name="actionAboutApplication">
    108    <property name="text">
     111  <action name="actionAboutApplication" >
     112   <property name="text" >
    109113    <string>About application</string>
    110114   </property>
  • src/mvc/event.cpp

    rc790268 r6f39595  
    4848}
    4949
     50QList<Event> Event::getFavByDate(const QDate& date, int conferenceId)
     51{
     52    QSqlQuery query;
     53    query.prepare(selectQueryJoin2T("id") + "WHERE event.xid_conference = :conf AND event.start >= :start AND event.start < :end AND event.favourite = 1 ORDER BY event.start");
     54    query.bindValue(":conf", conferenceId);
     55    query.bindValue(":start", convertToDb(date, QVariant::DateTime));
     56    query.bindValue(":end", convertToDb(date.addDays(1), QVariant::DateTime));
     57
     58    return load(query);
     59}
     60
  • src/mvc/event.h

    rc790268 r6f39595  
    2828    static Event getById(int id, int conferenceId);
    2929    static QList<Event> getByDate(const QDate& date, int conferenceId);
     30    static QList<Event> getFavByDate(const QDate& date, int conferenceId); // get Favourities by Date
    3031
    3132public:
     
    5455    void setType(const QString& type) { setValue("type", type); }
    5556    void setLanguage(const QString& language) { setValue("language", language); }
    56     void setFavourite(bool favourite) { setValue("favourite", favourite); }
     57    void setFavourite(bool favourite) { setValue("favourite", (int)favourite); }
    5758    // Table 2 : virtual table for FTS (Full Text Search)
    5859    void setTag(const QString& tag) { setValue("tag", tag); }
  • src/mvc/eventmodel.cpp

    rc790268 r6f39595  
    131131}
    132132
     133void EventModel::loadFavEvents(const QDate &aDate, int aConferenceId)
     134{
     135    mEvents.clear();
     136
     137    // check for existence of the conference in the DB
     138    if(Conference::getAll().count())
     139    {
     140        qDebug() << "Loading FAV Conference Data: [" << Conference::getById(aConferenceId).title() << "] " << aDate;
     141        mEvents = Event::getFavByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
     142    }
     143    createTimeGroups();
     144}
     145
  • src/mvc/eventmodel.h

    rc790268 r6f39595  
    1616    int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
    1717    void loadEvents(const QDate &aDate, int aConferenceId); // loads Events from the DB
     18    void loadFavEvents(const QDate &aDate, int aConferenceId); // loads Favourite events from the DB
    1819
    1920private:
Note: See TracChangeset for help on using the changeset viewer.