source: src/gui/mainwindow.cpp @ 21d7cc0

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

fixed 'copy-paste' error

  • Property mode set to 100644
File size: 4.2 KB
Line 
1#include "mainwindow.h"
2
3#include <QTreeView>
4#include <QFile>
5
6#include <sqlengine.h>
7
8#include <track.h>
9#include <eventmodel.h>
10#include <delegate.h>
11
12#include <conference.h>
13
14#include <QDialog>
15#include <QMessageBox>
16#include "ui_about.h"
17#include <eventdialog.h>
18#include "daynavigatorwidget.h"
19#include "importschedulewidget.h"
20#include "mapwindow.h"
21
22#include <tabcontainer.h>
23
24MainWindow::MainWindow(int aEventId, QWidget *aParent)
25    : QMainWindow(aParent)
26{
27    setupUi(this);
28
29    int confId = Conference::activeConference();
30
31    QList<Conference> confs = Conference::getAll();
32    if(confs.count())
33    {
34        setWindowTitle(confs[0].title());
35    }
36
37    connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
38
39    // event details have changed
40    connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
41    connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
42    connect(tracksTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
43    connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
44    connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
45    connect(searchTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
46
47
48    // event conference map button clicked
49    connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
50
51    connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
52
53    if(Conference::getAll().count()) // no conference(s) in the DB
54    {
55        QDate startDate = Conference::getById(confId).start();
56        QDate endDate = Conference::getById(confId).end();
57        //
58        dayTabContainer->setDates(startDate, endDate);
59        tracksTabContainer->setDates(startDate, endDate);
60        roomsTabContainer->setDates(startDate, endDate);
61        favsTabContainer->setDates(startDate, endDate);
62        searchTabContainer->setDates(startDate, endDate);
63        //
64        conferenceTitle->setText(Conference::getById(confId).title());
65        conferenceSubtitle->setText(Conference::getById(confId).subtitle());
66        conferenceWhere->setText(Conference::getById(confId).city() + ", " + Conference::getById(confId).venue());
67        conferenceWhen->setText(
68                Conference::getById(confId).start().toString("dd-MM-yyyy")
69                + ", " +
70                Conference::getById(confId).end().toString("dd-MM-yyyy"));
71    }
72
73    // open dialog for given Event ID
74    // this is used in case Alarm Dialog request application to start
75    if(aEventId)
76    {
77        try
78        {
79            EventDialog dialog(aEventId,this);
80            dialog.exec();
81        }
82        catch(OrmNoObjectException&) {} // just start application
83        catch(...) {} // just start application
84    }
85}
86
87void MainWindow::scheduleImported(int aConfId)
88{
89    Q_UNUSED(aConfId);
90
91    QList<Conference> confs = Conference::getAll();
92    if(confs.count())
93    {
94        // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
95        QDate startDate = Conference::getById(Conference::activeConference()).start();
96        QDate endDate = Conference::getById(Conference::activeConference()).end();
97        dayTabContainer->setDates(startDate, endDate);
98        tracksTabContainer->setDates(startDate, endDate);
99        roomsTabContainer->setDates(startDate, endDate);
100        favsTabContainer->setDates(startDate, endDate);
101    }
102}
103
104void MainWindow::aboutApp()
105{
106    QDialog dialog(this);
107    Ui::AboutDialog ui;
108    ui.setupUi(&dialog);
109    dialog.exec();
110}
111
112void MainWindow::conferenceMapClicked()
113{
114    QString mapPath = QString(":/maps/campus.png");
115    if(!QFile::exists(mapPath))
116        mapPath = QString(":/maps/rooms/not-available.png");
117
118    QString roomName;
119
120    QPixmap map(mapPath);
121    MapWindow window(map,roomName,this);
122    window.exec();
123}
124
125void MainWindow::eventHasChanged(int aEventId)
126{
127    dayTabContainer->updateTreeViewModel(aEventId);
128    favsTabContainer->updateTreeViewModel(aEventId);
129    tracksTabContainer->updateTreeViewModel(aEventId);
130    nowTabContainer->updateTreeViewModel(aEventId);
131    roomsTabContainer->updateTreeViewModel(aEventId);
132    searchTabContainer->updateTreeViewModel(aEventId);
133}
134
Note: See TracBrowser for help on using the repository browser.