]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/gui/conferenceeditor.cpp
Add .pro.user.* to svn:ignore and remove it in the release target.
[toast/confclerk.git] / src / gui / conferenceeditor.cpp
index 936f54127d85536e4240b3fae4b5b73d0b26b356..718999ce62e048b167ce06ce08184c78a52e5269 100644 (file)
@@ -1,25 +1,27 @@
 /*
  * Copyright (C) 2010 Ixonos Plc.
+ * Copyright (C) 2011-2012 Philipp Spitzer, gregor herrmann, Stefan Stahl
  *
- * This file is part of fosdem-schedule.
+ * This file is part of ConfClerk.
  *
- * fosdem-schedule is free software: you can redistribute it and/or modify it
+ * ConfClerk is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
  * Software Foundation, either version 2 of the License, or (at your option)
  * any later version.
  *
- * fosdem-schedule is distributed in the hope that it will be useful, but
+ * ConfClerk is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
  * You should have received a copy of the GNU General Public License along with
- * fosdem-schedule.  If not, see <http://www.gnu.org/licenses/>.
+ * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include "conferenceeditor.h"
 
 #include "conferencemodel.h"
 #include "urlinputdialog.h"
+#include "errormessage.h"
 
 #include <QInputDialog>
 #include <QItemSelectionModel>
@@ -47,6 +49,7 @@ ConferenceEditor::ConferenceEditor(ConferenceModel* model, QWidget* parent)
     connect(removeBtn, SIGNAL(clicked()), SLOT(removeClicked()));
     connect(changeUrl, SIGNAL(clicked()), SLOT(changeUrlClicked()));
     connect(refreshBtn, SIGNAL(clicked()), SLOT(refreshClicked()));
+    connect(buttonBox, SIGNAL(rejected()), SLOT(close()));
 
     // it's OK to emit selection signals here
     // because they are not yet connected to anybody
@@ -86,11 +89,11 @@ void ConferenceEditor::itemSelected(const QModelIndex& current, const QModelInde
 
         conferenceTitle->setText(conf.title());
         conferenceSubtitle->setText(conf.subtitle());
-        conferenceWhere->setText(conf.city() + ", " + conf.venue());
+        conferenceWhere->setText(conf.city() + (!conf.venue().isEmpty() ? ", " + conf.venue() : ""));
         conferenceWhen->setText(
-                conf.start().toString("dd-MM-yyyy")
-                + ", " +
-                conf.end().toString("dd-MM-yyyy"));
+                conf.start().toString("yyyy-MM-dd")
+                + " - " +
+                conf.end().toString("yyyy-MM-dd"));
         conferenceInfo->setCurrentIndex(0);
         removeBtn->show();
     }
@@ -127,13 +130,11 @@ void ConferenceEditor::removeClicked()
 
 void ConferenceEditor::changeUrlClicked()
 {
-    if (selected_id < 0) {
-        return;
-    }
-    const Conference& selected = Conference::getById(selected_id);
+    if (selected_id < 0) return;
+    const Conference& selectedConf = Conference::getById(selected_id);
 
     bool ok;
-    QString url = QInputDialog::getText(this, "URL Input", "Enter schedule URL", QLineEdit::Normal, selected.url(), &ok);
+    QString url = QInputDialog::getText(this, "URL Input", "Enter schedule URL", QLineEdit::Normal, selectedConf.url(), &ok);
 
     if (ok) {
         emit changeUrlRequested(selected_id, url);
@@ -142,27 +143,21 @@ void ConferenceEditor::changeUrlClicked()
 
 void ConferenceEditor::refreshClicked()
 {
-    if (selected_id < 0) {
-        return;
-    }
-    const Conference& selected = Conference::getById(selected_id);
+    if (selected_id < 0) return;
+    const Conference& selectedConf = Conference::getById(selected_id);
+    QString url = selectedConf.url();
 
-    QString url = selected.url();
-
-    if (!url.isEmpty()) {
-        emit haveConferenceUrl(url);
-    } else {
+    if (url.isEmpty()) {
         static const QString format("Schedule URL for %1 is not set. Enter the schedule URL:");
         bool ok;
-        QString url = QInputDialog::getText(this, "URL Input", format.arg(selected.title()), QLineEdit::Normal, QString(), &ok);
-
-        if (ok) {
-            // first save it, to remain if fetch fails
-            emit changeUrlRequested(selected_id, url);
-            // then fetch
-            emit haveConferenceUrl(url);
-        }
+        QString url = QInputDialog::getText(this, "URL Input", format.arg(selectedConf.title()), QLineEdit::Normal, QString(), &ok);
+        if (!ok) return;
+        // first save it, to remain if fetch fails
+        emit changeUrlRequested(selected_id, url);
     }
+    // fetch
+    importStarted(); // just to show the progress bar
+    emit haveConferenceUrl(url);
 }
 
 void ConferenceEditor::importStarted()
@@ -185,8 +180,11 @@ void ConferenceEditor::showParsingProgress(int progress)
 
 void ConferenceEditor::importFinished(const QString& title)
 {
-    qDebug() << __PRETTY_FUNCTION__ << title;
     addBtn->show();
+    // removeItem should be shown later, but it takes some time,
+    // and not looks good
+    // anyway it will be shown a bit later
+    removeBtn->show();
     buttons->layout()->addItem(buttonsSpacer);
     progressBar->hide();
 
@@ -202,3 +200,4 @@ void ConferenceEditor::importFinished(const QString& title)
     }
     itemSelected(QModelIndex(), QModelIndex());
 }
+