/*
* Copyright (C) 2010 Ixonos Plc.
+ * Copyright (C) 2011-2017 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 "mapwindow.h"
+#include "errormessage.h"
#include <QInputDialog>
#include <QItemSelectionModel>
connect(removeBtn, SIGNAL(clicked()), SLOT(removeClicked()));
connect(changeUrl, SIGNAL(clicked()), SLOT(changeUrlClicked()));
connect(refreshBtn, SIGNAL(clicked()), SLOT(refreshClicked()));
- connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked()));
+ connect(buttonBox, SIGNAL(rejected()), SLOT(close()));
+ connect(conferenceDtsHours, SIGNAL(valueChanged(int)), SLOT(dtsChanged()));
+ connect(conferenceDtsMinutes, SIGNAL(valueChanged(int)), SLOT(dtsChanged()));
// it's OK to emit selection signals here
// because they are not yet connected to anybody
conferenceTitle->setText(conf.title());
conferenceSubtitle->setText(conf.subtitle());
- conferenceWhere->setText(conf.city() + ", " + conf.venue());
+ QString where = conf.city();
+ if (!conf.city().isEmpty() && !conf.venue().isEmpty()) where += ", ";
+ where += conf.venue();
+ conferenceWhere->setText(where);
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"));
+ if (conf.hasUtcOffset()) {
+ conferenceUtcOffset->setText(QString::number(conf.utcOffset()) + " min");
+ } else {
+ conferenceUtcOffset->setText("N/A");
+ }
+ int dts = conf.displayTimeShift();
+ conferenceDtsHours->setValue(dts / 60);
+ conferenceDtsMinutes->setValue(abs(dts) % 60);
conferenceInfo->setCurrentIndex(0);
removeBtn->show();
}
{
UrlInputDialog url_input(this);
switch (url_input.exec()) {
- case UrlInputDialog::HaveUrl: emit haveConferenceUrl(url_input.url()); break;
- case UrlInputDialog::HaveFile: emit haveConferenceFile(url_input.url()); break;
+ case UrlInputDialog::HaveUrl: emit haveConferenceUrl(url_input.url(), 0); break;
+ case UrlInputDialog::HaveFile: emit haveConferenceFile(url_input.url(), 0); break;
case UrlInputDialog::Cancel: return;
}
}
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);
void ConferenceEditor::refreshClicked()
{
- if (selected_id < 0) {
- return;
- }
- const Conference& selected = Conference::getById(selected_id);
-
- QString url = selected.url();
+ if (selected_id <= 0) return;
+ const Conference& selectedConf = Conference::getById(selected_id);
+ QString url = selectedConf.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);
- }
+ 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, selected_id);
+}
+
+void ConferenceEditor::dtsChanged() {
+ if (selected_id < 0) return;
+ Conference& conference = model->conferenceFromIndex(model->indexFromId(selected_id));
+ int minutes = conferenceDtsMinutes->value();
+ if (conferenceDtsHours->value() < 0) minutes *= -1;
+ conference.setDisplayTimeShift(conferenceDtsHours->value() * 60 + minutes);
}
void ConferenceEditor::importStarted()
QApplication::processEvents();
}
-void ConferenceEditor::importFinished(const QString& title)
-{
- qDebug() << __PRETTY_FUNCTION__ << title;
+void ConferenceEditor::importFinished(int conferenceId) {
addBtn->show();
// removeItem should be shown later, but it takes some time,
// and not looks good
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());
}
-void ConferenceEditor::conferenceMapClicked()
-{
- QString mapPath = QString(":/maps/campus.png");
- if(!QFile::exists(mapPath))
- mapPath = QString(":/maps/rooms/not-available.png");
-
- QString roomName;
-
- QPixmap map(mapPath);
- MapWindow window(map,roomName,this);
- window.exec();
-}