]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/gui/importschedulewidget.cpp
store URL's for conferences
[toast/confclerk.git] / src / gui / importschedulewidget.cpp
index a63d93ff061934608ff4f4d22d4ef1b5df1dba0d..e6f3e02c1b491898110f1d3f5cee5aa8055e790b 100644 (file)
 #include <QDebug>
 #include <appsettings.h>
 
-const QString SCHEDULE_URL = "http://fosdem.org/2010/schedule/xml";
+// TODO: this is temporary
+#include <QInputDialog>
+
+#include "conference.h"
+
+// const QString SCHEDULE_URL = "http://fosdem.org/2010/schedule/xml";
 
 const QString PROXY_USERNAME;
 const QString PROXY_PASSWD;
@@ -90,7 +95,7 @@ void ImportScheduleWidget::browseSchedule()
             return;
         }
 
-        importData(file.readAll());
+        importData(file.readAll(), QString());
 
     }
     else
@@ -107,27 +112,50 @@ void ImportScheduleWidget::networkQueryFinished(QNetworkReply *aReply)
     }
     else
     {
-        importData(aReply->readAll());
+        importData(aReply->readAll(), aReply->url().toEncoded());
     }
 }
 
 void ImportScheduleWidget::downloadSchedule()
 {
     QNetworkRequest request;
-    request.setUrl(QUrl(SCHEDULE_URL));
+
+    // TODO: make a nicer GUI
+    // basically, you have to do the following things:
+    // 1. store schedule URL for each conteferce
+    // 2. allow refreshing of the current conference schedule with "1 button click"
+    // 3. allow changing of the URL for a conference;
+    //     run refresh together with it is ok and even justified by usability,
+    //     but it must not loose this change if refresh not available.
+    //     So it cannot be done as "do like #4 and rely on REPLACE".
+    // 4. allow getting the new conference by URL
+
+    QString url_default;
+    try {
+        url_default = Conference::getById(Conference::activeConference()).getUrl();
+    } catch (OrmException& e) {
+        qWarning() << "failed to get default URL:" << e.text();
+    }
+
+    bool ok = false;
+    QString url = QInputDialog::getText(this, "URL request", "Put proper schedule URL or let it try with it", QLineEdit::Normal, url_default, &ok);
+    if (!ok) { // cancel pressed
+        return;
+    }
+    request.setUrl(QUrl(url));
 
     mNetworkAccessManager->setProxy(QNetworkProxy::applicationProxy());
     mNetworkAccessManager->get(request);
 }
 
-void ImportScheduleWidget::importData(const QByteArray &aData)
+void ImportScheduleWidget::importData(const QByteArray &aData, const QString& url)
 {
     browse->hide();
     online->hide();
     progressBar->show();
     // proxySettings->hide();
 
-    int confId = mXmlParser->parseData(aData);
+    int confId = mXmlParser->parseData(aData, url);
 
     progressBar->hide();
     browse->show();