source: src/gui/mainwindow.cpp @ 872aeaa

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

some performance optimizations

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