source: src/gui/importschedulewidget.cpp @ c9fa699

qt5
Last change on this file since c9fa699 was 3a8dc71, checked in by pavelpa <pavelpa@…>, 13 years ago

SqlEngine? made STATIC

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#include "importschedulewidget.h"
2
3#include <schedulexmlparser.h>
4
5#include <QDir>
6#include <QFile>
7#include <QFileDialog>
8#include <QDebug>
9
10ImportScheduleWidget::ImportScheduleWidget(QWidget *aParent)
11    : QWidget(aParent)
12{
13    setupUi(this);
14
15    mXmlParser = new ScheduleXmlParser(this);
16    connect(mXmlParser, SIGNAL(progressStatus(int)), SLOT(showParsingProgress(int)));
17    connect(mXmlParser, SIGNAL(parsingSchedule(const QString &)), SLOT(parsingSchedule(const QString &)));
18
19    connect(browse, SIGNAL(clicked()), SLOT(browseSchedule()));
20    progressBar->hide();
21}
22
23ImportScheduleWidget::~ImportScheduleWidget()
24{
25    if(mXmlParser)
26    {
27        delete mXmlParser;
28        mXmlParser = NULL;
29    }
30}
31
32void ImportScheduleWidget::parsingSchedule(const QString &aTitle)
33{
34    importScheduleLabel->setText("Importing: " + aTitle);
35}
36
37void ImportScheduleWidget::showParsingProgress(int progress)
38{
39    progressBar->setValue(progress);
40}
41
42void ImportScheduleWidget::browseSchedule()
43{
44    QString scheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)"));
45    if(QFile::exists(scheduleFileName))
46    {
47        QFile file(scheduleFileName);
48        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
49        {
50            qDebug() << "can't open " << file.fileName();
51            return;
52        }
53
54        QByteArray data = file.readAll();
55        browse->hide();
56        progressBar->show();
57        int confId = mXmlParser->parseData(data);
58
59        progressBar->hide();
60        browse->show();
61        importScheduleLabel->setText("Import schedule: ");
62
63        emit(scheduleImported(confId));
64    }
65    else
66    {
67        progressBar->hide();
68    }
69}
70
Note: See TracBrowser for help on using the repository browser.