From: kirilma Date: Thu, 15 Apr 2010 12:06:07 +0000 (+0000) Subject: add buttons for refreshm new url and delete and partly implement corresponding actions X-Git-Tag: 0.5.0~96 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/f5b68a40860a2e3c38ca34a407eef382e742f21f add buttons for refreshm new url and delete and partly implement corresponding actions also changed Online -> Refresh delete action is not implemented yet --- diff --git a/src/gui/importschedulewidget.cpp b/src/gui/importschedulewidget.cpp index e6f3e02..5583028 100644 --- a/src/gui/importschedulewidget.cpp +++ b/src/gui/importschedulewidget.cpp @@ -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()); diff --git a/src/gui/importschedulewidget.h b/src/gui/importschedulewidget.h index f067921..236e1fd 100644 --- a/src/gui/importschedulewidget.h +++ b/src/gui/importschedulewidget.h @@ -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; diff --git a/src/gui/importschedulewidget.ui b/src/gui/importschedulewidget.ui index 7f50431..e0212ed 100644 --- a/src/gui/importschedulewidget.ui +++ b/src/gui/importschedulewidget.ui @@ -6,7 +6,7 @@ 0 0 - 699 + 710 79 @@ -35,10 +35,33 @@ + + + + Change Url + + + + + true + + + + 10 + 0 + + - Online + Reresh + + + + + + + From Url @@ -51,7 +74,14 @@ - Browse + From File + + + + + + + Delete diff --git a/src/mvc/conference.h b/src/mvc/conference.h index 26ea87b..c16ac74 100644 --- a/src/mvc/conference.h +++ b/src/mvc/conference.h @@ -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 */