reimplemented 'import schedule'
authorpavelpa <pavelpa@localhost>
Tue, 26 Jan 2010 14:11:04 +0000 (14:11 +0000)
committerpavelpa <pavelpa@localhost>
Tue, 26 Jan 2010 14:11:04 +0000 (14:11 +0000)
src/gui/importschedulewidget.cpp
src/gui/importschedulewidget.h
src/gui/importschedulewidget.ui
src/gui/mainwindow.cpp

index 20d48ac..c23ee88 100644 (file)
@@ -16,12 +16,10 @@ ImportScheduleWidget::ImportScheduleWidget(QWidget *aParent)
 
     mXmlParser = new ScheduleXmlParser(this);
     connect(mXmlParser, SIGNAL(progressStatus(int)), SLOT(showParsingProgress(int)));
-    connect(mXmlParser, SIGNAL(parsingSchedule(const QString &)), SLOT(setWindowTitle(const QString &)));
+    connect(mXmlParser, SIGNAL(parsingSchedule(const QString &)), SLOT(parsingSchedule(const QString &)));
 
-    connect(import, SIGNAL(clicked()), SLOT(importSchedule()));
-    connect(search, SIGNAL(clicked()), SLOT(searchSchedule()));
+    connect(browse, SIGNAL(clicked()), SLOT(browseSchedule()));
     progressBar->hide();
-    import->setEnabled(false);
 }
 
 ImportScheduleWidget::~ImportScheduleWidget()
@@ -40,48 +38,44 @@ void ImportScheduleWidget::setSqlEngine(SqlEngine *aSqlEngine)
     mSqlEngine = aSqlEngine;
 }
 
+void ImportScheduleWidget::parsingSchedule(const QString &aTitle)
+{
+    importScheduleLabel->setText("Importing: " + aTitle);
+}
+
 void ImportScheduleWidget::showParsingProgress(int progress)
 {
     progressBar->setValue(progress);
 }
 
-void ImportScheduleWidget::searchSchedule()
+void ImportScheduleWidget::browseSchedule()
 {
     Q_ASSERT(mSqlEngine != NULL);
 
-    mScheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)"));
-    if(QFile::exists(mScheduleFileName))
-        import->setEnabled(true);
-    else
+    QString scheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)"));
+    if(QFile::exists(scheduleFileName))
     {
-        import->setEnabled(false);
+        QFile file(scheduleFileName);
+        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+        {
+            qDebug() << "can't open " << file.fileName();
+            return;
+        }
+
+        QByteArray data = file.readAll();
+        browse->hide();
+        progressBar->show();
+        int confId = mXmlParser->parseData(data,mSqlEngine);
+
         progressBar->hide();
-    }
-}
+        browse->show();
+        importScheduleLabel->setText("Import schedule: ");
 
-void ImportScheduleWidget::importSchedule()
-{
-    if(!mSqlEngine)
-    {
-        qDebug() << "ImportScheduleWidget::importSchedule(): sqlEngine not set";
-        return;
+        emit(scheduleImported(confId));
     }
-
-    QFile file(mScheduleFileName);
-    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+    else
     {
-        qDebug() << "can't open " << file.fileName();
-        return;
+        progressBar->hide();
     }
-
-    QByteArray data = file.readAll();
-    progressBar->show();
-    int confId = mXmlParser->parseData(data,mSqlEngine);
-
-    // hide stuff
-    import->setEnabled(false);
-    progressBar->hide();
-
-    emit(scheduleImported(confId));
 }
 
index b9d8a1e..71a76fa 100644 (file)
@@ -15,15 +15,14 @@ class ImportScheduleWidget : public QWidget, Ui::ImportScheduleWidget
         ~ImportScheduleWidget();
         void setSqlEngine(SqlEngine *aSqlEngine);
     private slots:
-        void searchSchedule();
-        void importSchedule();
+        void browseSchedule();
+        void parsingSchedule(const QString &aTitle);
         void showParsingProgress(int progress);
     signals:
         void scheduleImported(int confId);
     private:
         ScheduleXmlParser *mXmlParser;
         SqlEngine *mSqlEngine; // uses it
-        QString mScheduleFileName;
 };
 
 #endif /* IMPORTSCHEDULEWIDGET_H */
index bf76875..e746ebf 100644 (file)
@@ -6,7 +6,7 @@
     <x>0</x>
     <y>0</y>
     <width>379</width>
-    <height>82</height>
+    <height>48</height>
    </rect>
   </property>
   <property name="sizePolicy" >
   </property>
   <layout class="QGridLayout" name="gridLayout" >
    <item row="0" column="0" >
-    <layout class="QVBoxLayout" name="verticalLayout" >
+    <layout class="QHBoxLayout" name="horizontalLayout_2" >
+     <item>
+      <widget class="QLabel" name="importScheduleLabel" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>Import schedule: </string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="browse" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>Browse</string>
+       </property>
+      </widget>
+     </item>
      <item>
       <widget class="QProgressBar" name="progressBar" >
        <property name="value" >
        </property>
       </widget>
      </item>
-     <item>
-      <layout class="QHBoxLayout" name="horizontalLayout_2" >
-       <item>
-        <widget class="QLabel" name="label" >
-         <property name="text" >
-          <string>Import schedule: </string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="search" >
-         <property name="text" >
-          <string>Search</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="horizontalSpacer_2" >
-         <property name="orientation" >
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeHint" stdset="0" >
-          <size>
-           <width>40</width>
-           <height>20</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <widget class="QPushButton" name="import" >
-         <property name="text" >
-          <string>Import</string>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
     </layout>
    </item>
   </layout>
index 118b823..d7d3fec 100644 (file)
@@ -44,6 +44,8 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent)
     {
         if(AppSettings::confId() == 0)
             AppSettings::setConfId(confs[0].id());
+
+        setWindowTitle(confs[0].title());
     }
 
     connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int)));