source: src/gui/importschedulewidget.cpp @ 8b0bf22

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

modified 'about' dialog

  • changed "Qt FOSDEM" -> "FOSDEM Schedule"
  • Property mode set to 100644
File size: 1.8 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    cancel->hide();
23    online->hide();
24    importAction->hide();
25}
26
27ImportScheduleWidget::~ImportScheduleWidget()
28{
29    if(mXmlParser)
30    {
31        delete mXmlParser;
32        mXmlParser = NULL;
33    }
34}
35
36void ImportScheduleWidget::parsingSchedule(const QString &aTitle)
37{
38    importScheduleLabel->setText("Importing: " + aTitle);
39}
40
41void ImportScheduleWidget::showParsingProgress(int progress)
42{
43    progressBar->setValue(progress);
44}
45
46void ImportScheduleWidget::browseSchedule()
47{
48    QString scheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)"));
49    if(QFile::exists(scheduleFileName))
50    {
51        QFile file(scheduleFileName);
52        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
53        {
54            qDebug() << "can't open " << file.fileName();
55            return;
56        }
57
58        QByteArray data = file.readAll();
59        browse->hide();
60        progressBar->show();
61        int confId = mXmlParser->parseData(data);
62
63        progressBar->hide();
64        browse->show();
65        importScheduleLabel->setText("Import schedule: ");
66
67        emit(scheduleImported(confId));
68    }
69    else
70    {
71        progressBar->hide();
72    }
73}
74
Note: See TracBrowser for help on using the repository browser.