X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/blobdiff_plain/ca2084237a7f3fbc0437bc379b492b9e816197f5..080dc7d603d45ba0662aa731418993ddd45b5fe8:/src/gui/conferenceeditor.cpp diff --git a/src/gui/conferenceeditor.cpp b/src/gui/conferenceeditor.cpp index bfb73ea..d93deee 100644 --- a/src/gui/conferenceeditor.cpp +++ b/src/gui/conferenceeditor.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Ixonos Plc. - * Copyright (C) 2011-2012 Philipp Spitzer, gregor herrmann, Stefan Stahl + * Copyright (C) 2011-2024 Philipp Spitzer, gregor herrmann, Stefan Stahl * * This file is part of ConfClerk. * @@ -50,6 +50,8 @@ ConferenceEditor::ConferenceEditor(ConferenceModel* model, QWidget* parent) connect(changeUrl, SIGNAL(clicked()), SLOT(changeUrlClicked())); connect(refreshBtn, SIGNAL(clicked()), SLOT(refreshClicked())); 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 @@ -89,11 +91,22 @@ void ConferenceEditor::itemSelected(const QModelIndex& current, const QModelInde conferenceTitle->setText(conf.title()); conferenceSubtitle->setText(conf.subtitle()); - conferenceWhere->setText(conf.city() + (!conf.venue().isEmpty() ? ", " + 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("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(); } @@ -103,8 +116,8 @@ void ConferenceEditor::addClicked() { 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; } } @@ -143,7 +156,7 @@ void ConferenceEditor::changeUrlClicked() void ConferenceEditor::refreshClicked() { - if (selected_id < 0) return; + if (selected_id <= 0) return; const Conference& selectedConf = Conference::getById(selected_id); QString url = selectedConf.url(); @@ -157,7 +170,15 @@ void ConferenceEditor::refreshClicked() } // fetch importStarted(); // just to show the progress bar - emit haveConferenceUrl(url); + 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() @@ -178,8 +199,7 @@ void ConferenceEditor::showParsingProgress(int progress) QApplication::processEvents(); } -void ConferenceEditor::importFinished(const QString& title) -{ +void ConferenceEditor::importFinished(int conferenceId) { addBtn->show(); // removeItem should be shown later, but it takes some time, // and not looks good @@ -190,14 +210,10 @@ void ConferenceEditor::importFinished(const QString& title) 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()); }