source: src/gui/importscheduledialog.cpp @ 9859cac

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

modifications to import-schedule dialog

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