source: src/gui/importscheduledialog.cpp @ a957cfa

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

forgotten Import Schedule Dialog files

  • Property mode set to 100644
File size: 1.6 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)), this, SLOT(showParsingProgress(int)));
19    connect(import, SIGNAL(clicked()), SLOT(importSchedule()));
20    connect(search, SIGNAL(clicked()), SLOT(searchSchedule()));
21    progressBar->hide();
22    import->setEnabled(false);
23}
24
25ImportScheduleDialog::~ImportScheduleDialog()
26{
27    if(mXmlParser)
28    {
29        delete mXmlParser;
30        mXmlParser = NULL;
31    }
32}
33
34void ImportScheduleDialog::showParsingProgress(int progress)
35{
36    progressBar->setValue(progress);
37}
38
39void ImportScheduleDialog::searchSchedule()
40{
41    mScheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)"));
42    fileName->setText(mScheduleFileName);
43    if(QFile::exists(mScheduleFileName))
44        import->setEnabled(true);
45    else
46    {
47        import->setEnabled(false);
48        progressBar->hide();
49    }
50}
51
52void ImportScheduleDialog::importSchedule()
53{
54    QFile file(mScheduleFileName);
55    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
56    {
57        qDebug() << "can't open " << file.fileName();
58        return;
59    }
60
61    QByteArray data = file.readAll();
62    if(mSqlEngine)
63    {
64        progressBar->show();
65        mXmlParser->parseData(data,mSqlEngine);
66    }
67}
68
Note: See TracBrowser for help on using the repository browser.