source: src/gui/mainwindow.cpp @ 6bc425e

qt5
Last change on this file since 6bc425e 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
Line 
1#include "mainwindow.h"
2#include <appsettings.h>
3
4#include <QTreeView>
5#include <QFile>
6
7#include <sqlengine.h>
8
9#include <track.h>
10#include <eventmodel.h>
11#include <delegate.h>
12
13#include <conference.h>
14
15#include <QDialog>
16#include <QMessageBox>
17#include "ui_about.h"
18#include <eventdialog.h>
19#include "daynavigatorwidget.h"
20#include "importschedulewidget.h"
21#include "mapwindow.h"
22
23#include <tabcontainer.h>
24
25MainWindow::MainWindow(int aEventId, QWidget *aParent)
26    : QMainWindow(aParent)
27{
28    setupUi(this);
29
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());
42
43        setWindowTitle(confs[0].title());
44    }
45
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);
51    searchTabContainer->setType(TabContainer::EContainerTypeSearch);
52
53    connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));
54
55    // event details have changed
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)));
61    connect(searchTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int)));
62
63
64    // event conference map button clicked
65    connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
66
67    connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
68
69    if(Conference::getAll().count()) // no conference(s) in the DB
70    {
71        QDate startDate = Conference::getById(AppSettings::confId()).start();
72        QDate endDate = Conference::getById(AppSettings::confId()).end();
73        //
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);
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"));
87    }
88
89    // open dialog for given Event ID
90    // this is used in case Alarm Dialog request application to start
91    if(aEventId)
92    {
93        try
94        {
95            EventDialog dialog(aEventId,this);
96            dialog.exec();
97        }
98        catch(OrmNoObjectException&) {} // just start application
99        catch(...) {} // just start application
100    }
101}
102
103void MainWindow::scheduleImported(int aConfId)
104{
105    Q_UNUSED(aConfId);
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
113    {
114        if(AppSettings::confId() == 0)
115            AppSettings::setConfId(confs[0].id());
116
117        // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
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);
124    }
125}
126
127void MainWindow::aboutApp()
128{
129    QDialog dialog(this);
130    Ui::AboutDialog ui;
131    ui.setupUi(&dialog);
132    dialog.exec();
133}
134
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
148void MainWindow::eventHasChanged(int aEventId)
149{
150    dayTabContainer->updateTreeViewModel(aEventId);
151    favsTabContainer->updateTreeViewModel(aEventId);
152    tracksTabContainer->updateTreeViewModel(aEventId);
153    nowTabContainer->updateTreeViewModel(aEventId);
154    roomsTabContainer->updateTreeViewModel(aEventId);
155    searchTabContainer->updateTreeViewModel(aEventId);
156}
157
Note: See TracBrowser for help on using the repository browser.