Reloading a conference works now.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 25 Sep 2012 20:50:11 +0000 (20:50 +0000)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 25 Sep 2012 20:50:11 +0000 (20:50 +0000)
src/gui/conferenceeditor.cpp
src/gui/conferenceeditor.h
src/gui/mainwindow.cpp
src/mvc/conferencemodel.cpp
src/mvc/conferencemodel.h
src/sql/schedulexmlparser.cpp
src/sql/schedulexmlparser.h
src/sql/sqlengine.cpp

index 5de436bba7740235427a3d08bb7ee134446f0e7d..bfc736ab3fbd16315f7e3e5e97e313e40213585a 100644 (file)
@@ -178,8 +178,7 @@ void ConferenceEditor::showParsingProgress(int progress)
     QApplication::processEvents();
 }
 
-void ConferenceEditor::importFinished(const QString& title)
-{
+void ConferenceEditor::importFinished(int conferenceId) {
     addBtn->show();
     // removeItem should be shown later, but it takes some time,
     // and not looks good
@@ -190,14 +189,10 @@ void ConferenceEditor::importFinished(const QString& title)
 
     QApplication::processEvents();
 
-    int num = model->rowCount();
-    for (int i = 0; i < num; i++) {
-        QModelIndex item = model->index(i, 0);
-        if (model->data(item) == title) {
-            emit wantCurrent(item, QItemSelectionModel::SelectCurrent);
-            return;
-        }
-    }
-    itemSelected(QModelIndex(), QModelIndex());
+    QModelIndex item = model->indexFromId(conferenceId);
+    if (item.isValid())
+        emit wantCurrent(item, QItemSelectionModel::SelectCurrent);
+    else
+        itemSelected(QModelIndex(), QModelIndex());
 }
 
index 33454c1df3d1348e303904ca78d7e0c5adefc76a..9b602b42c2ba2a1c1f7f7912161f2158888fb098 100644 (file)
@@ -55,7 +55,7 @@ signals:
     void wantCurrent(const QModelIndex&, QItemSelectionModel::SelectionFlags);
 public slots:
     void importStarted();
-    void importFinished(const QString& title);
+    void importFinished(int conferenceId);
     void conferenceRemoved();
     void showParsingProgress(int);
 private slots:
index 9a17036083fac6466f6916c964bd1a13b7ab4845..a0b7cec9c3b72addbd5e07c34d0409d4687ac0b7 100644 (file)
@@ -132,7 +132,7 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent): QMainWindow(aParent) {
     connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), SLOT(networkQueryFinished(QNetworkReply*)));
 
     connect(mXmlParser, SIGNAL(parsingScheduleBegin()), conferenceModel, SLOT(newConferenceBegin()));
-    connect(mXmlParser, SIGNAL(parsingScheduleEnd(const QString&)), conferenceModel, SLOT(newConferenceEnd(const QString&)));
+    connect(mXmlParser, SIGNAL(parsingScheduleEnd(int)), conferenceModel, SLOT(newConferenceEnd(int)));
 }
 
 void MainWindow::on_aboutAction_triggered()
@@ -340,7 +340,7 @@ void MainWindow::on_conferencesAction_triggered()
 
     connect(mXmlParser, SIGNAL(parsingScheduleBegin()), &dialog, SLOT(importStarted()));
     connect(mXmlParser, SIGNAL(progressStatus(int)), &dialog, SLOT(showParsingProgress(int)));
-    connect(mXmlParser, SIGNAL(parsingScheduleEnd(const QString&)), &dialog, SLOT(importFinished(const QString&)));
+    connect(mXmlParser, SIGNAL(parsingScheduleEnd(int)), &dialog, SLOT(importFinished(int)));
 
     connect(this, SIGNAL(conferenceRemoved()), &dialog, SLOT(conferenceRemoved()));
 
index 16d76a567bbdb6f13ed398afc88212a07ae31e2d..94f6f4b101a6e766cb1a1923e53ff20ce4a2a22b 100644 (file)
@@ -77,9 +77,8 @@ void ConferenceModel::newConferenceBegin()
 {
 }
 
-void ConferenceModel::newConferenceEnd(const QString& title)
-{
-    Q_UNUSED(title);
+void ConferenceModel::newConferenceEnd(int conferenceId) {
+    Q_UNUSED(conferenceId);
     reinit();
 }
 
index cd1c4fdd55227140e5be503e70d2ccb81123ea70..6737ce6acda992afa9e13467688492542a9cc67a 100644 (file)
@@ -46,7 +46,7 @@ public:
     QModelIndex indexFromId(int id) const;
 public slots:
     void newConferenceBegin();
-    void newConferenceEnd(const QString& title);
+    void newConferenceEnd(int conferenceId);
     void conferenceRemoved();
 private:
     // reinitialize list from database
index e4a40f62a6f1a3fbca251ed08cc1b8a3666b2cbd..4256290ce4b614a81a93e50e067fbe9c4242d03d 100644 (file)
@@ -54,7 +54,7 @@ void ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url, i
         {
             emit(parsingScheduleBegin());
             QHash<QString,QString> conference;
-            conference["id"] = conferenceId; // conference ID is assigned automatically if 0
+            conference["id"] = QVariant(conferenceId).toString(); // conference ID is assigned automatically if 0
             conference["title"] = conferenceElement.firstChildElement("title").text();
             conference["subtitle"] = conferenceElement.firstChildElement("subtitle").text();
             conference["venue"] = conferenceElement.firstChildElement("venue").text();
@@ -153,7 +153,7 @@ void ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url, i
     } // schedule element
     sqlEngine->commitTransaction();
     if (!conference_title.isNull()) {
-        emit parsingScheduleEnd(conference_title);
+        emit parsingScheduleEnd(conferenceId);
     } else {
         error_message("Could not parse schedule");
     }
index c23c43e0f9d890d289e47b19aef40f74ac15176f..b219ec2fcb48fe7c71bbc4f8e17a1dd1d1ad07d2 100644 (file)
@@ -37,7 +37,7 @@ class ScheduleXmlParser : public QObject
     signals:
         void progressStatus(int aStatus);
         void parsingScheduleBegin();
-        void parsingScheduleEnd(const QString& title);
+        void parsingScheduleEnd(int conferenceId);
 };
 
 #endif /* SCHEDULEXMLPARSER_H_ */
index 878cfb851a73c66701af73d278c7865c26dabd54..f9e58c4c8a931cee5cfe901c888e8a7e5ca8789b 100644 (file)
@@ -162,7 +162,7 @@ void SqlEngine::addConferenceToDB(QHash<QString,QString> &aConference, int confe
         query.bindValue(":id", conferenceId);
         query.exec();
         emitSqlQueryError(query);
-        aConference["id"] = conferenceId;
+        aConference["id"] = QVariant(conferenceId).toString();
     }
 }