Ignore:
Timestamp:
01/26/10 15:11:04 (13 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
a226ba2
Parents:
e4c5a03
Message:

reimplemented 'import schedule'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gui/importschedulewidget.cpp

    re4c5a03 rb86d4aa  
    1717    mXmlParser = new ScheduleXmlParser(this);
    1818    connect(mXmlParser, SIGNAL(progressStatus(int)), SLOT(showParsingProgress(int)));
    19     connect(mXmlParser, SIGNAL(parsingSchedule(const QString &)), SLOT(setWindowTitle(const QString &)));
     19    connect(mXmlParser, SIGNAL(parsingSchedule(const QString &)), SLOT(parsingSchedule(const QString &)));
    2020
    21     connect(import, SIGNAL(clicked()), SLOT(importSchedule()));
    22     connect(search, SIGNAL(clicked()), SLOT(searchSchedule()));
     21    connect(browse, SIGNAL(clicked()), SLOT(browseSchedule()));
    2322    progressBar->hide();
    24     import->setEnabled(false);
    2523}
    2624
     
    4139}
    4240
     41void ImportScheduleWidget::parsingSchedule(const QString &aTitle)
     42{
     43    importScheduleLabel->setText("Importing: " + aTitle);
     44}
     45
    4346void ImportScheduleWidget::showParsingProgress(int progress)
    4447{
     
    4649}
    4750
    48 void ImportScheduleWidget::searchSchedule()
     51void ImportScheduleWidget::browseSchedule()
    4952{
    5053    Q_ASSERT(mSqlEngine != NULL);
    5154
    52     mScheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)"));
    53     if(QFile::exists(mScheduleFileName))
    54         import->setEnabled(true);
     55    QString scheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)"));
     56    if(QFile::exists(scheduleFileName))
     57    {
     58        QFile file(scheduleFileName);
     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        browse->hide();
     67        progressBar->show();
     68        int confId = mXmlParser->parseData(data,mSqlEngine);
     69
     70        progressBar->hide();
     71        browse->show();
     72        importScheduleLabel->setText("Import schedule: ");
     73
     74        emit(scheduleImported(confId));
     75    }
    5576    else
    5677    {
    57         import->setEnabled(false);
    5878        progressBar->hide();
    5979    }
    6080}
    6181
    62 void ImportScheduleWidget::importSchedule()
    63 {
    64     if(!mSqlEngine)
    65     {
    66         qDebug() << "ImportScheduleWidget::importSchedule(): sqlEngine not set";
    67         return;
    68     }
    69 
    70     QFile file(mScheduleFileName);
    71     if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    72     {
    73         qDebug() << "can't open " << file.fileName();
    74         return;
    75     }
    76 
    77     QByteArray data = file.readAll();
    78     progressBar->show();
    79     int confId = mXmlParser->parseData(data,mSqlEngine);
    80 
    81     // hide stuff
    82     import->setEnabled(false);
    83     progressBar->hide();
    84 
    85     emit(scheduleImported(confId));
    86 }
    87 
Note: See TracChangeset for help on using the changeset viewer.