source: src/gui/mainwindow.cpp @ 001c8cf

qt5
Last change on this file since 001c8cf was 001c8cf, checked in by pavelpa <pavelpa@…>, 12 years ago

'search' tab functionality moved to 'tabcontainer'

  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[e5bc908]1#include "mainwindow.h"
[30e2bdf]2#include <appsettings.h>
[e5bc908]3
[d0d0a66]4#include <QTreeView>
[05afe5f]5#include <QFile>
[d0d0a66]6
[72f6fe4]7#include <sqlengine.h>
8
[4693fa6]9#include <track.h>
[d0d0a66]10#include <eventmodel.h>
[66327a0]11#include <delegate.h>
[d0d0a66]12
[969a840]13#include <conference.h>
14
[c2d66b2]15#include <QDialog>
[3f3e22d]16#include <QMessageBox>
[c2d66b2]17#include "ui_about.h"
[05afe5f]18#include <eventdialog.h>
[969a840]19#include "daynavigatorwidget.h"
[c15be10]20#include "importschedulewidget.h"
[59c6cfe]21#include "mapwindow.h"
[72f6fe4]22
[05afe5f]23#include <tabcontainer.h>
24
[d4a8bbf]25MainWindow::MainWindow(int aEventId, QWidget *aParent)
26    : QMainWindow(aParent)
[e5bc908]27{
[9bbb44e]28    setupUi(this);
[72f6fe4]29
[b128673]30    // Sanity check for existence of any Conference in the DB
31    // it AppSettings::confId() is 0, but there are any Conference(s) in the DB
32    // set the confId in the AppSettings for the ID of the first conference in the DB
33    QList<Conference> confs = Conference::getAll();
34    if(!confs.count()) // no conference(s) in the DB
35    {
36        AppSettings::setConfId(0); // no conference in the DB
37    }
38    else
39    {
40        if(AppSettings::confId() == 0)
41            AppSettings::setConfId(confs[0].id());
[b86d4aa]42
43        setWindowTitle(confs[0].title());
[b128673]44    }
45
[05afe5f]46    dayTabContainer->setType(TabContainer::EContainerTypeDay);
47    favsTabContainer->setType(TabContainer::EContainerTypeFavs);
48    tracksTabContainer->setType(TabContainer::EContainerTypeTracks);
49    nowTabContainer->setType(TabContainer::EContainerTypeNow);
50    roomsTabContainer->setType(TabContainer::EContainerTypeRooms);
[001c8cf]51    searchTabContainer->setType(TabContainer::EContainerTypeSearch);
[05afe5f]52
[c15be10]53    connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
54
[c718a77]55    // event details have changed
[05afe5f]56    connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
57    connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
58    connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
59    connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
60    connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
[001c8cf]61    connect(searchTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
[05afe5f]62
63
[e7340e1]64    // event conference map button clicked
65    connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
[001c8cf]66
[85340ae]67    connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
[969a840]68
[05afe5f]69    if(Conference::getAll().count()) // no conference(s) in the DB
[969a840]70    {
[001c8cf]71        QDate startDate = Conference::getById(AppSettings::confId()).start();
72        QDate endDate = Conference::getById(AppSettings::confId()).end();
[05afe5f]73        //
[001c8cf]74        dayTabContainer->setDates(startDate, endDate);
75        tracksTabContainer->setDates(startDate, endDate);
76        roomsTabContainer->setDates(startDate, endDate);
77        favsTabContainer->setDates(startDate, endDate);
78        searchTabContainer->setDates(startDate, endDate);
[30e2bdf]79        //
80        conferenceTitle->setText(Conference::getById(AppSettings::confId()).title());
81        conferenceSubtitle->setText(Conference::getById(AppSettings::confId()).subtitle());
82        conferenceWhere->setText(Conference::getById(AppSettings::confId()).city() + ", " + Conference::getById(AppSettings::confId()).venue());
83        conferenceWhen->setText(
84                Conference::getById(AppSettings::confId()).start().toString("dd-MM-yyyy")
85                + ", " +
86                Conference::getById(AppSettings::confId()).end().toString("dd-MM-yyyy"));
[969a840]87    }
[c5324ca]88
[d4a8bbf]89    // open dialog for given Event ID
90    // this is used in case Alarm Dialog request application to start
91    if(aEventId)
92    {
[95596f6]93        try
94        {
95            EventDialog dialog(aEventId,this);
96            dialog.exec();
97        }
[806b992]98        catch(OrmNoObjectException&) {} // just start application
[95596f6]99        catch(...) {} // just start application
[d4a8bbf]100    }
[e5bc908]101}
[66327a0]102
[c15be10]103void MainWindow::scheduleImported(int aConfId)
[72f6fe4]104{
[c15be10]105    Q_UNUSED(aConfId);
[49c5ad3]106
107    QList<Conference> confs = Conference::getAll();
108    if(!confs.count()) // no conference(s) in the DB
109    {
110        AppSettings::setConfId(0); // no conference in the DB
111    }
112    else
[969a840]113    {
[49c5ad3]114        if(AppSettings::confId() == 0)
115            AppSettings::setConfId(confs[0].id());
116
[969a840]117        // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
[05afe5f]118        QDate startDate = Conference::getById(AppSettings::confId()).start();
119        QDate endDate = Conference::getById(AppSettings::confId()).end();
120        dayTabContainer->setDates(startDate, endDate);
121        tracksTabContainer->setDates(startDate, endDate);
122        roomsTabContainer->setDates(startDate, endDate);
123        favsTabContainer->setDates(startDate, endDate);
[969a840]124    }
[72f6fe4]125}
126
[c2d66b2]127void MainWindow::aboutApp()
128{
129    QDialog dialog(this);
130    Ui::AboutDialog ui;
131    ui.setupUi(&dialog);
132    dialog.exec();
133}
134
[e7340e1]135void MainWindow::conferenceMapClicked()
136{
137    QString mapPath = QString(":/maps/campus.png");
138    if(!QFile::exists(mapPath))
139        mapPath = QString(":/maps/rooms/not-available.png");
140
141    QString roomName;
142
143    QPixmap map(mapPath);
144    MapWindow window(map,roomName,this);
145    window.exec();
146}
147
[c718a77]148void MainWindow::eventHasChanged(int aEventId)
149{
[05afe5f]150    dayTabContainer->updateTreeViewModel(aEventId);
151    favsTabContainer->updateTreeViewModel(aEventId);
152    tracksTabContainer->updateTreeViewModel(aEventId);
153    nowTabContainer->updateTreeViewModel(aEventId);
154    roomsTabContainer->updateTreeViewModel(aEventId);
[001c8cf]155    searchTabContainer->updateTreeViewModel(aEventId);
[c718a77]156}
157
Note: See TracBrowser for help on using the repository browser.