add buttons for refreshm new url and delete and partly implement corresponding actions
authorkirilma <kirilma@localhost>
Thu, 15 Apr 2010 12:06:07 +0000 (12:06 +0000)
committerkirilma <kirilma@localhost>
Thu, 15 Apr 2010 12:06:07 +0000 (12:06 +0000)
also changed Online -> Refresh
delete action is not implemented yet

src/gui/importschedulewidget.cpp
src/gui/importschedulewidget.h
src/gui/importschedulewidget.ui
src/mvc/conference.h

index e6f3e02..5583028 100644 (file)
@@ -54,6 +54,10 @@ ImportScheduleWidget::ImportScheduleWidget(QWidget *aParent)
     cancel->hide();
     connect(online, SIGNAL(clicked()), SLOT(downloadSchedule()));
 
+    connect(changeUrl, SIGNAL(clicked()), SLOT(on_changeUrl()));
+    connect(newConfFromUrl, SIGNAL(clicked()), SLOT(on_newFromUrl()));
+    connect(delConf, SIGNAL(clicked()), SLOT(on_delete()));
+
     mNetworkAccessManager = new QNetworkAccessManager(this);
     connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkQueryFinished(QNetworkReply*)));
     mNetworkAccessManager->setProxy(QNetworkProxy::applicationProxy());
@@ -118,7 +122,6 @@ void ImportScheduleWidget::networkQueryFinished(QNetworkReply *aReply)
 
 void ImportScheduleWidget::downloadSchedule()
 {
-    QNetworkRequest request;
 
     // TODO: make a nicer GUI
     // basically, you have to do the following things:
@@ -130,18 +133,45 @@ void ImportScheduleWidget::downloadSchedule()
     //     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();
+    // FIXME: it will throw
+    // GUI should not show this button if there is no active conf
+    importFromNetwork(Conference::getById(Conference::activeConference()).getUrl());
+}
+
+void ImportScheduleWidget::on_changeUrl()
+{
+    // FIXME: it will throw
+    // GUI should not show this button if there is no active conf
+    Conference active_conference = Conference::getById(Conference::activeConference());
+    bool ok = false;
+    QString new_url =
+        QInputDialog::getText(this, "URL request", "Enter the new URL for conference schedule"
+                                , QLineEdit::Normal
+                                , active_conference.getUrl()
+                                , &ok);
+    if (ok) {
+        active_conference.setUrl(new_url);
     }
+}
 
+void ImportScheduleWidget::on_newFromUrl()
+{
     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;
+    QString url = QInputDialog::getText(this, "URL request", "Put the schedule URL", QLineEdit::Normal, "", &ok);
+    if (ok) {
+        importFromNetwork(url);
     }
+
+}
+
+void ImportScheduleWidget::on_delete()
+{
+    // TODO: implement
+}
+
+void ImportScheduleWidget::importFromNetwork(const QString& url)
+{
+    QNetworkRequest request;
     request.setUrl(QUrl(url));
 
     mNetworkAccessManager->setProxy(QNetworkProxy::applicationProxy());
index f067921..236e1fd 100644 (file)
@@ -38,9 +38,13 @@ class ImportScheduleWidget : public QWidget, Ui::ImportScheduleWidget
         void showParsingProgress(int progress);
         void networkQueryFinished(QNetworkReply *aReply);
         void downloadSchedule();
+        void on_changeUrl();
+        void on_delete();
+        void on_newFromUrl();
     signals:
         void scheduleImported(int confId);
     private:
+        void importFromNetwork(const QString& url);
         void importData(const QByteArray &aData, const QString& url);
     private:
         ScheduleXmlParser *mXmlParser;
index 7f50431..e0212ed 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>699</width>
+    <width>710</width>
     <height>79</height>
    </rect>
   </property>
        </property>
       </widget>
      </item>
+     <item>
+      <widget class="QPushButton" name="changeUrl">
+       <property name="text">
+        <string>Change Url</string>
+       </property>
+      </widget>
+     </item>
      <item>
       <widget class="QPushButton" name="online">
+       <property name="enabled">
+        <bool>true</bool>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>10</width>
+         <height>0</height>
+        </size>
+       </property>
        <property name="text">
-        <string>Online</string>
+        <string>Reresh</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="newConfFromUrl">
+       <property name="text">
+        <string>From Url</string>
        </property>
       </widget>
      </item>
         </sizepolicy>
        </property>
        <property name="text">
-        <string>Browse</string>
+        <string>From File</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="delConf">
+       <property name="text">
+        <string>Delete</string>
        </property>
       </widget>
      </item>
index 26ea87b..c16ac74 100644 (file)
@@ -59,6 +59,7 @@ public:
         }
     }
 
+    #if 0
     void setId(int id) { setValue("id", id); }
     void setTitle(const QString& title) { setValue("title", title); }
     void setSubtitle(const QString& subtitle) { setValue("subtitle", subtitle); }
@@ -70,7 +71,12 @@ public:
     void setDayChange(int dayChange) { setValue("day_change", dayChange); }
     void setTimeslotDuration(int timeslotDuration) { setValue("timeslot_duration", timeslotDuration); }
     void setActive(bool active) { setValue("active", (int)((active))); }
-    void setUrl(const QString& url) { setValue("url", url.isNull() ? QVariant() : url); }
+    #endif
+    void setUrl(const QString& url)
+    {
+        setValue("url", url.isNull() ? QVariant() : url);
+        update("url");
+    }
 };
 
 #endif /* CONFERENCE_H */