source: src/gui/mainwindow.cpp @ 69393c0

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

implemented 'conference' record for accessing info about the conference

  • events are loaded from the first day of the conference
  • Property mode set to 100644
File size: 2.0 KB
Line 
1#include "mainwindow.h"
2
3#include <QTreeView>
4#include <QDirModel>
5
6#include <sqlengine.h>
7#include <schedulexmlparser.h>
8
9#include <eventmodel.h>
10#include <delegate.h>
11
12#include <QDialog>
13#include "ui_about.h"
14
15MainWindow::MainWindow(QWidget *parent)
16    : QMainWindow(parent)
17{
18    setupUi(this);
19
20    // connect Menu actions
21    connect(actionImportSchedule, SIGNAL(triggered()), SLOT(importSchedule()));
22    connect(actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
23    connect(actionAboutApplication, SIGNAL(triggered()), SLOT(aboutApp()));
24
25    // create "SQLITE" DB instance/connection
26    // opens DB connection (needed for EventModel)
27    mSqlEngine = new SqlEngine(this);
28    mSqlEngine->initialize();
29
30    mXmlParser = new ScheduleXmlParser(this);
31    connect(mXmlParser, SIGNAL(progressStatus(int)), this, SLOT(showParsingProgress(int)));
32    statusBar()->showMessage(tr("Ready"));
33
34    treeView->setHeaderHidden(true);
35    treeView->setRootIsDecorated(false);
36    treeView->setIndentation(0);
37    treeView->setAnimated(true);
38    treeView->setModel(new EventModel());
39    treeView->setItemDelegate(new Delegate(treeView));
40}
41
42MainWindow::~MainWindow()
43{
44    if(mSqlEngine)
45    {
46        delete mSqlEngine;
47        mSqlEngine = NULL;
48    }
49    if(mXmlParser)
50    {
51        delete mXmlParser;
52        mXmlParser = NULL;
53    }
54}
55
56void MainWindow::importSchedule()
57{
58    QFile file("../schedule.en.xml");
59    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
60    {
61        qDebug() << "can't open " << file.fileName();
62        return;
63    }
64
65    QByteArray data = file.readAll();
66    mXmlParser->parseData(data,mSqlEngine);
67    static_cast<EventModel*>(treeView->model())->loadEvents();
68    treeView->reset();
69}
70
71void MainWindow::showParsingProgress(int aStatus)
72{
73    QString msg = QString("Parsing completed: %1\%").arg(aStatus);
74    statusBar()->showMessage(msg,1000);
75}
76
77void MainWindow::aboutApp()
78{
79    QDialog dialog(this);
80    Ui::AboutDialog ui;
81    ui.setupUi(&dialog);
82    dialog.exec();
83}
84
Note: See TracBrowser for help on using the repository browser.