Changeset 05afe5f in confclerk_git


Ignore:
Timestamp:
01/26/10 20:17:47 (13 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
3a8dc71
Parents:
61ff1b8
Message:

implemented 'tab container' widget, which groups daynavigator with treeview

  • moved functionality from mainwindow to tabcontainer
  • TODO: 'search' tab not done yet
Location:
src
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/app/app.pro

    r61ff1b8 r05afe5f  
    77# module dependencies
    88LIBS += -L$$DESTDIR -lgui -lmvc -lsql
    9 INCLUDEPATH += ../gui
     9INCLUDEPATH += ../gui ../sql
    1010DEPENDPATH += . ../gui
    1111TARGETDEPS += $$DESTDIR/libmvc.a $$DESTDIR/libgui.a $$DESTDIR/libsql.a
  • src/app/main.cpp

    r61ff1b8 r05afe5f  
    55#include <alarmdialog.h>
    66#endif /* MAEMO */
     7
     8#include <sqlengine.h>
    79
    810int main(int argc, char *argv[])
     
    1315    QApplication a(argc, argv);
    1416    QApplication::setWindowIcon(QIcon(":/icons/fosdem.png"));
     17
     18    SqlEngine::initialize(); // creates DB connection
    1519
    1620    QWidget *window;
  • src/gui/gui.pro

    r61ff1b8 r05afe5f  
    2929         about.ui \
    3030         eventdialog.ui \
     31         tabcontainer.ui \
    3132         mapwindow.ui
    3233
     
    3637           eventdialog.h \
    3738           tabwidget.h \
     39           tabcontainer.h \
    3840           mapwindow.h
    3941
     
    4345           eventdialog.cpp \
    4446           tabwidget.cpp \
     47           tabcontainer.cpp \
    4548           mapwindow.cpp
    4649
  • src/gui/mainwindow.cpp

    r61ff1b8 r05afe5f  
    33
    44#include <QTreeView>
    5 #include <QDirModel>
     5#include <QFile>
    66
    77#include <sqlengine.h>
     
    1515#include <QDialog>
    1616#include <QMessageBox>
    17 #include <QTimer>
    1817#include "ui_about.h"
    19 #include "eventdialog.h"
     18#include <eventdialog.h>
    2019#include "daynavigatorwidget.h"
    2120#include "importschedulewidget.h"
    2221#include "mapwindow.h"
    2322
     23#include <tabcontainer.h>
     24
    2425MainWindow::MainWindow(int aEventId, QWidget *aParent)
    2526    : QMainWindow(aParent)
     
    3031    // opens DB connection (needed for EventModel)
    3132    mSqlEngine = new SqlEngine(this);
    32     mSqlEngine->initialize();
     33    //mSqlEngine->initialize();
    3334    importScheduleWidget->setSqlEngine(mSqlEngine);
    3435
     
    4950    }
    5051
     52    dayTabContainer->setType(TabContainer::EContainerTypeDay);
     53    favsTabContainer->setType(TabContainer::EContainerTypeFavs);
     54    tracksTabContainer->setType(TabContainer::EContainerTypeTracks);
     55    nowTabContainer->setType(TabContainer::EContainerTypeNow);
     56    roomsTabContainer->setType(TabContainer::EContainerTypeRooms);
     57
    5158    connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
    5259
    53     connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
    54     connect(trackDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTracksView(const QDate &)));
    55     connect(favouriteDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateFavouritesView(const QDate &)));
    5660    connect(searchDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateSearchView(const QDate &)));
    57     connect(roomDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateRoomView(const QDate &)));
    58 
    59     // DAY EVENTS View
    60     dayTreeView->setHeaderHidden(true);
    61     dayTreeView->setRootIsDecorated(false);
    62     dayTreeView->setIndentation(0);
    63     dayTreeView->setAnimated(true);
    64     dayTreeView->setModel(new EventModel());
    65     dayTreeView->setItemDelegate(new Delegate(dayTreeView));
    66 
    67     // FAVOURITIES View
    68     favTreeView->setHeaderHidden(true);
    69     favTreeView->setRootIsDecorated(false);
    70     favTreeView->setIndentation(0);
    71     favTreeView->setAnimated(true);
    72     favTreeView->setModel(new EventModel());
    73     favTreeView->setItemDelegate(new Delegate(favTreeView));
    74 
    75     // TRACKS View
    76     trackTreeView->setHeaderHidden(true);
    77     trackTreeView->setRootIsDecorated(false);
    78     trackTreeView->setIndentation(0);
    79     trackTreeView->setAnimated(true);
    80     trackTreeView->setModel(new EventModel());
    81     trackTreeView->setItemDelegate(new Delegate(trackTreeView));
    8261
    8362    // SEARCH EVENTS View
     
    8968        searchTreeView->setItemDelegate(new Delegate(searchTreeView));
    9069
    91     // NOW View
    92         nowTreeView->setHeaderHidden(true);
    93         nowTreeView->setRootIsDecorated(false);
    94         nowTreeView->setIndentation(0);
    95         nowTreeView->setAnimated(true);
    96         nowTreeView->setModel(new EventModel());
    97         nowTreeView->setItemDelegate(new Delegate(nowTreeView));
    98 
    99         // NOW View refresh timer
    100     QTimer *timer = new QTimer( this );
    101     connect( timer, SIGNAL(timeout()), SLOT(timerUpdateNowView()) );
    102     timer->start( 30000); // 30 seconds timer
    103 
    104     // ROOMS View
    105     roomTreeView->setHeaderHidden(true);
    106     roomTreeView->setRootIsDecorated(false);
    107     roomTreeView->setIndentation(0);
    108     roomTreeView->setAnimated(true);
    109     roomTreeView->setModel(new EventModel());
    110     roomTreeView->setItemDelegate(new Delegate(roomTreeView));
    111 
    11270    // event details have changed
    113     connect(dayTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
    114     connect(favTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
    115     connect(trackTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     71    connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     72    connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     73    connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     74    connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     75    connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
     76
    11677    connect(searchTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
    117     connect(nowTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
    118     connect(roomTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
    11978
    12079    // event clicked
    121     connect(dayTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    122     connect(favTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    123     connect(trackTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    12480    connect(searchTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    125     connect(nowTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    126     connect(roomTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    127     // request for map to be displayed
    128     connect(dayTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    129     connect(favTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    130     connect(trackTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    131     connect(searchTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    132     connect(nowTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    133     connect(roomTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    134     // request for warning to be displayed
    135     connect(dayTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    136     connect(favTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    137     connect(trackTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    138     connect(searchTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    139     connect(nowTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    140     connect(roomTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     81
    14182    // event search button clicked
    14283    connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked()));
    14384    connect(searchAgainButton, SIGNAL(clicked()), SLOT(searchAgainClicked()));
     85
    14486    // event conference map button clicked
    14587    connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
    14688    //
    147     connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(tabHasChanged(int)));
    14889    connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
    14990
    150     if(!Conference::getAll().count()) // no conference(s) in the DB
    151     {
    152         dayNavigator->hide(); // hide DayNavigatorWidget
    153         trackDayNavigator->hide();
    154         roomDayNavigator->hide();
    155     }
    156     else
     91    if(Conference::getAll().count()) // no conference(s) in the DB
    15792    {
    15893        QDate aStartDate = Conference::getById(AppSettings::confId()).start();
    15994        QDate aEndDate = Conference::getById(AppSettings::confId()).end();
    160         dayNavigator->setDates(aStartDate, aEndDate);
    161         trackDayNavigator->setDates(aStartDate, aEndDate);
    162         favouriteDayNavigator->setDates(aStartDate, aEndDate);
    16395        searchDayNavigator->setDates(aStartDate, aEndDate);
    164         roomDayNavigator->setDates(aStartDate, aEndDate);
     96        //
     97        dayTabContainer->setDates(aStartDate, aEndDate);
     98        tracksTabContainer->setDates(aStartDate, aEndDate);
     99        roomsTabContainer->setDates(aStartDate, aEndDate);
     100        favsTabContainer->setDates(aStartDate, aEndDate);
    165101        //
    166102        conferenceTitle->setText(Conference::getById(AppSettings::confId()).title());
     
    215151
    216152        // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
    217         QDate aStartDate = Conference::getById(AppSettings::confId()).start();
    218         QDate aEndDate = Conference::getById(AppSettings::confId()).end();
    219         dayNavigator->setDates(aStartDate, aEndDate);
    220         trackDayNavigator->setDates(aStartDate, aEndDate);
    221         roomDayNavigator->setDates(aStartDate, aEndDate);
     153        QDate startDate = Conference::getById(AppSettings::confId()).start();
     154        QDate endDate = Conference::getById(AppSettings::confId()).end();
     155        dayTabContainer->setDates(startDate, endDate);
     156        tracksTabContainer->setDates(startDate, endDate);
     157        roomsTabContainer->setDates(startDate, endDate);
     158        favsTabContainer->setDates(startDate, endDate);
    222159    }
    223160}
     
    229166    ui.setupUi(&dialog);
    230167    dialog.exec();
    231 }
    232 
    233 void MainWindow::updateDayView(const QDate &aDate)
    234 {
    235     static_cast<EventModel*>(dayTreeView->model())->loadEvents(aDate,AppSettings::confId());
    236     dayTreeView->reset();
    237     dayNavigator->show();
    238 }
    239 
    240 void MainWindow::updateTracksView(const QDate &aDate)
    241 {
    242     static_cast<EventModel*>(trackTreeView->model())->loadEventsByTrack(aDate, AppSettings::confId());
    243     trackTreeView->reset();
    244     trackDayNavigator->show();
    245 }
    246 
    247 void MainWindow::updateFavouritesView(const QDate &aDate)
    248 {
    249     static_cast<EventModel*>(favTreeView->model())->loadFavEvents(aDate,AppSettings::confId());
    250     favTreeView->reset();
    251     favouriteDayNavigator->show();
    252168}
    253169
     
    269185        searchHead->show();
    270186    }
    271 }
    272 
    273 void MainWindow::updateNowView()
    274 {
    275     EventModel *model = static_cast<EventModel*>(nowTreeView->model());
    276     model->loadNowEvents(AppSettings::confId());
    277     nowTreeView->reset();
    278     nowTreeView->setAllExpanded(true);
    279 }
    280 
    281 void MainWindow::updateRoomView(const QDate &aDate)
    282 {
    283     static_cast<EventModel*>(roomTreeView->model())->loadEventsByRoom(aDate, AppSettings::confId());
    284     roomTreeView->reset();
    285     roomDayNavigator->show();
    286 }
    287 
    288 void MainWindow::itemClicked(const QModelIndex &aIndex)
    289 {
    290     // have to handle only events, not time-groups
    291     if(!aIndex.parent().isValid()) // time-group
    292         return;
    293 
    294     EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
    295     dialog.exec();
    296 }
    297 
    298 void MainWindow::displayMap(const QModelIndex &aIndex)
    299 {
    300     Event *event = static_cast<Event*>(aIndex.internalPointer());
    301 
    302     // room names are stored in lower-case format
    303     // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png"
    304     QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room().toLower().remove("."));
    305     if(!QFile::exists(mapPath))
    306         mapPath = QString(":/maps/rooms/not-available.png");
    307 
    308     QString roomName;
    309     if(mapPath.contains("not-available", Qt::CaseInsensitive))
    310         roomName = QString("Map is not available: %1").arg(event->room());
    311     else
    312         roomName = event->room();
    313 
    314     QPixmap map(mapPath);
    315     MapWindow window(map,roomName,this);
    316     window.exec();
    317187}
    318188
     
    348218    searchVerticalWidget->hide();
    349219    searchTreeView->hide();
    350 
    351220}
    352221
    353222void MainWindow::conferenceMapClicked()
    354223{
    355 
    356224    QString mapPath = QString(":/maps/campus.png");
    357225    if(!QFile::exists(mapPath))
     
    365233}
    366234
    367 void MainWindow::displayWarning(const QModelIndex &aIndex)
    368 {
    369     Q_UNUSED(aIndex);
    370 
    371     QMessageBox::warning(
    372     this,
    373     tr("Time Conflict Warning"),
    374     tr("This event happens at the same time than another one of your favourites.") );
    375 }
    376 
    377235void MainWindow::eventHasChanged(int aEventId)
    378236{
    379     static_cast<EventModel*>(dayTreeView->model())->updateModel(aEventId);
    380 
    381     // we need to reload favourites, because some favourite could be deleted
    382     //static_cast<EventModel*>(favTreeView->model())->updateModel(aEventId);
    383     QDate aStartDate = Conference::getById(AppSettings::confId()).start();
    384     QDate aEndDate = Conference::getById(AppSettings::confId()).end();
    385     favouriteDayNavigator->setDates(aStartDate, aEndDate);
    386     updateFavouritesView( Conference::getById(AppSettings::confId()).start() );
    387 
    388     static_cast<EventModel*>(trackTreeView->model())->updateModel(aEventId);
     237    dayTabContainer->updateTreeViewModel(aEventId);
     238    favsTabContainer->updateTreeViewModel(aEventId);
     239    tracksTabContainer->updateTreeViewModel(aEventId);
     240    nowTabContainer->updateTreeViewModel(aEventId);
     241    roomsTabContainer->updateTreeViewModel(aEventId);
     242
    389243    static_cast<EventModel*>(searchTreeView->model())->updateModel(aEventId);
    390     static_cast<EventModel*>(nowTreeView->model())->updateModel(aEventId);
    391     static_cast<EventModel*>(roomTreeView->model())->updateModel(aEventId);
    392 }
    393 
    394 void MainWindow::tabHasChanged(int aIndex)
    395 {
    396     Q_UNUSED(aIndex);
    397 
    398     // TODO: only if it changed to favourities tab
    399     updateFavouritesView(favouriteDayNavigator->getCurrentDate());
    400     // TODO: only if it changed to now tab
    401     updateNowView();
    402 }
    403 
    404 void MainWindow::timerUpdateNowView()
    405 {
    406         QWidget * pCurrentWidget = tabWidget->widget(tabWidget->currentIndex());
    407 
    408         if( pCurrentWidget != NULL )
    409         {
    410                 if( pCurrentWidget == tab )
    411                     updateNowView();
    412         }
    413 }
     244}
     245
  • src/gui/mainwindow.h

    r61ff1b8 r05afe5f  
    1919    void scheduleImported(int aConfId);
    2020    void aboutApp();
    21     void updateDayView(const QDate &aDate);
    22     void updateTracksView(const QDate &aDate);
    23     void updateFavouritesView(const QDate &aDate);
    2421    void updateSearchView(const QDate &aDate);
    25     void updateNowView();
    26     void updateRoomView(const QDate &aDate);
    27     void itemClicked(const QModelIndex &aIndex);
    28     void displayMap(const QModelIndex &aIndex);
    29     void displayWarning(const QModelIndex &aIndex);
    3022    void searchClicked();
    3123        void searchAgainClicked();
    3224    void conferenceMapClicked();
    33     void tabHasChanged(int aIndex);
    3425    void eventHasChanged(int aEventId);
    35     void timerUpdateNowView();
    3626private:
    3727    SqlEngine *mSqlEngine;
  • src/gui/mainwindow.ui

    r61ff1b8 r05afe5f  
    66    <x>0</x>
    77    <y>0</y>
    8     <width>935</width>
    9     <height>514</height>
     8    <width>903</width>
     9    <height>498</height>
    1010   </rect>
    1111  </property>
     
    3232       <layout class="QGridLayout" name="gridLayout_2" >
    3333        <item row="0" column="0" >
    34          <layout class="QVBoxLayout" name="verticalLayout" >
    35           <item>
    36            <layout class="QHBoxLayout" name="horizontalLayout_2" >
    37             <item>
    38              <widget class="DayNavigatorWidget" native="1" name="dayNavigator" >
    39               <property name="sizePolicy" >
    40                <sizepolicy vsizetype="Expanding" hsizetype="Minimum" >
    41                 <horstretch>0</horstretch>
    42                 <verstretch>0</verstretch>
    43                </sizepolicy>
    44               </property>
    45              </widget>
    46             </item>
    47             <item>
    48              <widget class="TreeView" name="dayTreeView" >
    49               <property name="maximumSize" >
    50                <size>
    51                 <width>16777215</width>
    52                 <height>16777215</height>
    53                </size>
    54               </property>
    55              </widget>
    56             </item>
    57            </layout>
    58           </item>
    59          </layout>
     34         <widget class="TabContainer" native="1" name="dayTabContainer" />
    6035        </item>
    6136       </layout>
     
    6641       </attribute>
    6742       <layout class="QGridLayout" name="gridLayout_3" >
    68         <item row="1" column="0" >
    69          <layout class="QHBoxLayout" name="horizontalLayout_4" >
    70           <item>
    71            <widget class="DayNavigatorWidget" native="1" name="favouriteDayNavigator" />
    72           </item>
    73           <item>
    74            <widget class="TreeView" name="favTreeView" />
    75           </item>
    76          </layout>
     43        <item row="0" column="0" >
     44         <widget class="TabContainer" native="1" name="favsTabContainer" />
    7745        </item>
    7846       </layout>
     
    8452       <layout class="QGridLayout" name="gridLayout_4" >
    8553        <item row="0" column="0" >
    86          <layout class="QHBoxLayout" name="horizontalLayout_3" >
    87           <item>
    88            <widget class="DayNavigatorWidget" native="1" name="trackDayNavigator" />
    89           </item>
    90           <item>
    91            <widget class="TreeView" name="trackTreeView" >
    92             <property name="maximumSize" >
    93              <size>
    94               <width>16777215</width>
    95               <height>16777215</height>
    96              </size>
    97             </property>
    98            </widget>
    99           </item>
    100          </layout>
     54         <widget class="TabContainer" native="1" name="tracksTabContainer" />
    10155        </item>
    10256       </layout>
     
    339293       <layout class="QGridLayout" name="gridLayout_8" >
    340294        <item row="0" column="0" >
    341          <layout class="QHBoxLayout" name="horizontalLayout_5" >
    342           <property name="sizeConstraint" >
    343            <enum>QLayout::SetDefaultConstraint</enum>
    344           </property>
    345           <item>
    346            <widget class="DayNavigatorWidget" native="1" name="roomDayNavigator" />
    347           </item>
    348           <item>
    349            <widget class="TreeView" name="roomTreeView" >
    350             <property name="maximumSize" >
    351              <size>
    352               <width>16777215</width>
    353               <height>16777215</height>
    354              </size>
    355             </property>
    356            </widget>
    357           </item>
    358          </layout>
     295         <widget class="TabContainer" native="1" name="roomsTabContainer" />
    359296        </item>
    360297       </layout>
     
    520457       </layout>
    521458      </widget>
    522       <widget class="QWidget" name="tab" >
     459      <widget class="QWidget" name="nowTab" >
    523460       <attribute name="title" >
    524461        <string>Now</string>
     
    526463       <layout class="QGridLayout" name="gridLayout_7" >
    527464        <item row="0" column="0" >
    528          <widget class="TreeView" name="nowTreeView" />
     465         <widget class="TabContainer" native="1" name="nowTabContainer" />
    529466        </item>
    530467       </layout>
     
    560497   <container>1</container>
    561498  </customwidget>
     499  <customwidget>
     500   <class>TabContainer</class>
     501   <extends>QWidget</extends>
     502   <header>tabcontainer.h</header>
     503   <container>1</container>
     504  </customwidget>
    562505 </customwidgets>
    563506 <resources>
  • src/sql/sqlengine.h

    r61ff1b8 r05afe5f  
    1313        SqlEngine(QObject *aParent = NULL);
    1414        ~SqlEngine();
    15         void initialize();
     15        static void initialize();
    1616        void addConferenceToDB(QHash<QString,QString> &aConference);
    1717        void addEventToDB(QHash<QString,QString> &aEvent);
     
    2323        int searchEvent(int conferenceId, const QHash<QString,QString> &columns, const QString &keyword);
    2424    private:
    25         QString login(const QString &aDatabaseType, const QString &aDatabaseName);
    26         bool createTables(QSqlDatabase &aDatabase);
     25        static QString login(const QString &aDatabaseType, const QString &aDatabaseName);
     26        static bool createTables(QSqlDatabase &aDatabase);
    2727        bool execQuery(QSqlDatabase &aDatabase, const QString &aQuery);
    2828};
Note: See TracChangeset for help on using the changeset viewer.