From f299a08d712ae3228b7dc131eaa2ed930351e7d8 Mon Sep 17 00:00:00 2001 From: kirilma Date: Thu, 22 Apr 2010 15:34:03 +0000 Subject: [PATCH] remove obsoleted code also fix some types --- src/gui/importschedulewidget.cpp | 216 ------------------------------- src/gui/importschedulewidget.h | 56 -------- src/gui/importschedulewidget.ui | 119 ----------------- src/gui/mainwindow.cpp | 132 ++----------------- src/gui/mainwindow.h | 2 - src/sql/schedulexmlparser.cpp | 12 +- src/sql/schedulexmlparser.h | 2 +- 7 files changed, 18 insertions(+), 521 deletions(-) delete mode 100644 src/gui/importschedulewidget.cpp delete mode 100644 src/gui/importschedulewidget.h delete mode 100644 src/gui/importschedulewidget.ui diff --git a/src/gui/importschedulewidget.cpp b/src/gui/importschedulewidget.cpp deleted file mode 100644 index de8efbc..0000000 --- a/src/gui/importschedulewidget.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2010 Ixonos Plc. - * - * This file is part of fosdem-schedule. - * - * fosdem-schedule 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 - * 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 . - */ -#include "importschedulewidget.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// TODO: this is temporary -#include - -#include "conference.h" -#include "errormessage.h" - -// const QString SCHEDULE_URL = "http://fosdem.org/2010/schedule/xml"; - -const QString PROXY_USERNAME; -const QString PROXY_PASSWD; - -ImportScheduleWidget::ImportScheduleWidget(QWidget *aParent) - : QWidget(aParent) -{ - setupUi(this); - - mXmlParser = new ScheduleXmlParser(this); - connect(mXmlParser, SIGNAL(progressStatus(int)), SLOT(showParsingProgress(int))); - connect(mXmlParser, SIGNAL(parsingSchedule(const QString &)), SLOT(parsingSchedule(const QString &))); - - connect(browse, SIGNAL(clicked()), SLOT(browseSchedule())); - progressBar->hide(); - - 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()); -} - -ImportScheduleWidget::~ImportScheduleWidget() -{ - if(mXmlParser) - { - delete mXmlParser; - mXmlParser = NULL; - } - if(mNetworkAccessManager) - { - delete mNetworkAccessManager; - mNetworkAccessManager = NULL; - } -} - -void ImportScheduleWidget::parsingSchedule(const QString &aTitle) -{ - importScheduleLabel->setText("Importing: " + aTitle); -} - -void ImportScheduleWidget::showParsingProgress(int progress) -{ - progressBar->setValue(progress); -} - -void ImportScheduleWidget::browseSchedule() -{ - QString scheduleFileName = QFileDialog::getOpenFileName(this, tr("Select Conference Schedule"), QDir::homePath(), tr("Schedule Files (*.xml)")); - if(QFile::exists(scheduleFileName)) - { - QFile file(scheduleFileName); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - { - qDebug() << "can't open " << file.fileName(); - return; - } - - importData(file.readAll(), QString()); - - } - else - { - progressBar->hide(); - } -} - -void ImportScheduleWidget::networkQueryFinished(QNetworkReply *aReply) -{ - if ( aReply->error() != QNetworkReply::NoError ) - { - error_message(QString("Error occured during download: ") + aReply->errorString()); - } - else - { - importData(aReply->readAll(), aReply->url().toEncoded()); - } -} - -void ImportScheduleWidget::downloadSchedule() -{ - - // TODO: make a nicer GUI - // basically, you have to do the following things: - // 1. store schedule URL for each conteferce - // 2. allow refreshing of the current conference schedule with "1 button click" - // 3. allow changing of the URL for a conference; - // run refresh together with it is ok and even justified by usability, - // but it must not loose this change if refresh not available. - // So it cannot be done as "do like #4 and rely on REPLACE". - // 4. allow getting the new conference by URL - - // 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 the schedule URL", QLineEdit::Normal, "", &ok); - if (ok) { - importFromNetwork(url); - } - -} - -void ImportScheduleWidget::on_delete() -{ - int active_id = Conference::activeConference(); - Conference active_conference = Conference::getById(active_id); - - QMessageBox::StandardButton answer = - QMessageBox::question(0 - , "Deletion confirmation" - , QString("Really delete the %1 conference").arg(active_conference.title()) - , QMessageBox::Yes | QMessageBox::No - , QMessageBox::No); - - if (answer == QMessageBox::Yes) { - QString title = active_conference.title(); - Conference::deleteConference(active_id); - emit(scheduleDeleted(title)); - } -} - -void ImportScheduleWidget::importFromNetwork(const QString& url) -{ - QNetworkRequest request; - request.setUrl(QUrl(url)); - - mNetworkAccessManager->setProxy(QNetworkProxy::applicationProxy()); - mNetworkAccessManager->get(request); -} - -void ImportScheduleWidget::importData(const QByteArray &aData, const QString& url) -{ - browse->hide(); - online->hide(); - progressBar->show(); - // proxySettings->hide(); - - int confId = mXmlParser->parseData(aData, url); - - progressBar->hide(); - browse->show(); - online->show(); - // proxySettings->show(); - importScheduleLabel->setText("Schedule:"); - - if (confId > 0) { - emit(scheduleImported(confId)); - } -} - diff --git a/src/gui/importschedulewidget.h b/src/gui/importschedulewidget.h deleted file mode 100644 index 3e00d76..0000000 --- a/src/gui/importschedulewidget.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2010 Ixonos Plc. - * - * This file is part of fosdem-schedule. - * - * fosdem-schedule 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 - * 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 . - */ -#ifndef IMPORTSCHEDULEWIDGET_H -#define IMPORTSCHEDULEWIDGET_H - -#include -#include "ui_importschedulewidget.h" - -class ScheduleXmlParser; -class QNetworkAccessManager; -class QNetworkReply; - -class ImportScheduleWidget : public QWidget, Ui::ImportScheduleWidget -{ - Q_OBJECT - public: - ImportScheduleWidget(QWidget *aParent = NULL); - ~ImportScheduleWidget(); - private slots: - void browseSchedule(); - void parsingSchedule(const QString &aTitle); - void showParsingProgress(int progress); - void networkQueryFinished(QNetworkReply *aReply); - void downloadSchedule(); - void on_changeUrl(); - void on_delete(); - void on_newFromUrl(); - signals: - void scheduleImported(int confId); - void scheduleDeleted(const QString& title); - private: - void importFromNetwork(const QString& url); - void importData(const QByteArray &aData, const QString& url); - private: - ScheduleXmlParser *mXmlParser; - QNetworkAccessManager *mNetworkAccessManager; -}; - -#endif /* IMPORTSCHEDULEWIDGET_H */ - diff --git a/src/gui/importschedulewidget.ui b/src/gui/importschedulewidget.ui deleted file mode 100644 index 91542ae..0000000 --- a/src/gui/importschedulewidget.ui +++ /dev/null @@ -1,119 +0,0 @@ - - - ImportScheduleWidget - - - - 0 - 0 - 710 - 79 - - - - - 0 - 0 - - - - Import schedule - - - - - - - - - 0 - 0 - - - - Schedule: - - - - - - - Change Url - - - - - - - true - - - - 10 - 0 - - - - Reresh - - - - - - - From Url - - - - - - - - 0 - 0 - - - - From File - - - - - - - Delete - - - - - - - Cancel - - - - - - - - 0 - 10 - - - - 0 - - - false - - - - - - - - - - - - diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 08ba45b..5f38fcc 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -81,14 +81,6 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) PROXY_PASSWD); QNetworkProxy::setApplicationProxy(proxy); - #if 0 - // list of conferences must be maintained by ConferenceEditor - // here must be one of the signals from the closing ConferenceEditor (or model): - // selectedConf(conference), noConf() - connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int))); - connect(importScheduleWidget, SIGNAL(scheduleDeleted(const QString&)), SLOT(scheduleDeleted(const QString&))); - #endif - // event details have changed connect(dayTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); connect(favsTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); @@ -97,12 +89,6 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) connect(nowTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); connect(searchTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); - // event conference map button clicked - #if 0 - // TODO: think about it when return to maps - connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked())); - #endif - connect(aboutAction, SIGNAL(triggered()), SLOT(aboutApp())); connect(settingsAction, SIGNAL(triggered()), SLOT(setup())); connect(conferencesAction, SIGNAL(triggered()), SLOT(showConferences())); @@ -115,38 +101,10 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) clearTabs(); } + // TODO: open conferences at startup? #if 0 - // TODO: remove GUI - // initialisation of model and pick active conference from there and call conferenceChanged() - // selectConference->setDuplicatesEnabled(false); - int confCount = Conference::getAll().count(); - if(confCount) - { - initTabs(); - // fillAndShowConferenceHeader(); - setWindowTitle(Conference::getById(confId).title()); - - QList confs = Conference::getAll(); - QListIterator i(confs); - while(i.hasNext()) - { - Conference conf = i.next(); - // TODO: remove GUI - // selectConference->addItem(conf.title(),conf.id()); - } - // TODO: remove GUI - // int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title()); - // selectConference->setCurrentIndex(idx); - // connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int))); - // conferenceChanged(idx); - } - else - { - // TODO: remove GUI - // conferenceHeader->hide(); - // selectConferenceWidget->hide(); - // // go to the 'conferenceTab', so the user can import the schedule - // tabWidget->setCurrentIndex(6); // 6 - conference tab + if(!confCount) + tabWidget->setCurrentIndex(6); // 6 - conference tab } #endif @@ -169,58 +127,6 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) connect(mXmlParser, SIGNAL(parsingScheduleEnd(const QString&)), conferenceModel, SLOT(newConferenceEnd(const QString&))); } -void MainWindow::scheduleImported(int aConfId) -{ - Q_UNUSED(aConfId); - - // TODO: this all goes to ConferenceEditor and model of conferences - #if 0 - - Conference conf = Conference::getById(aConfId); - if( selectConference->findText(conf.title()) < 0 ) // item doesn't exist - { - disconnect(selectConference, SIGNAL(currentIndexChanged(int)), this, SLOT(conferenceChanged(int))); - selectConference->addItem(conf.title(),conf.id()); - connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int))); - } - int confCount = Conference::getAll().count(); - if(confCount) - { - int idx = selectConference->findText(conf.title()); - selectConference->setCurrentIndex(idx); - - selectConferenceWidget->show(); - - conferenceChanged(idx); - } - #endif -} - -void MainWindow::scheduleDeleted(const QString& title) -{ - Q_UNUSED(title); - // TODO: this all goes to ConferenceEditor and model of conferences - #if 0 - int idx = selectConference->findText(title); - - if (idx == -1) { - // should not happen - qWarning() << __PRETTY_FUNCTION__ << "removed non-existent item:" << title; - // this happens when you remove the only conference (the list is not ptoperly inited in this case) - // now make sure that conferencet - if (selectConference->count() > 0) { - selectConference->setCurrentIndex(0); - conferenceChanged(0); - } else { - conferenceChanged(-1); - } - } else { - // will it signal "changed"? - selectConference->removeItem(idx); - } - #endif -} - void MainWindow::aboutApp() { QDialog dialog(this); @@ -269,7 +175,9 @@ void MainWindow::useConference(int id) // dont run initTabs() here // it takes much CPU, making travelling between conferences in ConferenceEditor longer // and is not seen in maemo WM anyway - // instead run it explicitly where needed + // instead run it explicitly + // 1. at startup + // 2. when ConferenceEditor finished // dont forget to protect the calls by try-catch! // just in case, clear conference selection instead @@ -348,8 +256,6 @@ void MainWindow::showConferences() { ConferenceEditor dialog(conferenceModel, this); - // TODO: connect signals about progress of network and parsing - connect(&dialog, SIGNAL(haveConferenceUrl(const QString&)), SLOT(importFromNetwork(const QString&))); connect(&dialog, SIGNAL(haveConferenceFile(const QString&)), SLOT(importFromFile(const QString&))); connect(&dialog, SIGNAL(removeConferenceRequested(int)), SLOT(removeConference(int))); @@ -365,6 +271,9 @@ void MainWindow::showConferences() connect(this, SIGNAL(conferenceRemoved()), &dialog, SLOT(conferenceRemoved())); + // TODO: propagate press of showMapButton here + // connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked())); + dialog.exec(); // optimization, see useConference() code @@ -390,28 +299,7 @@ void MainWindow::networkQueryFinished(QNetworkReply *aReply) void MainWindow::importData(const QByteArray &aData, const QString& url) { - // TODO: remove GUI - // instead send signals to the child dialog - #if 0 - browse->hide(); - online->hide(); - progressBar->show(); - // proxySettings->hide(); - #endif - - int confId = mXmlParser->parseData(aData, url); - - #if 0 - progressBar->hide(); - browse->show(); - online->show(); - // proxySettings->show(); - importScheduleLabel->setText("Schedule:"); - - #endif - if (confId > 0) { - emit(scheduleImported(confId)); - } + mXmlParser->parseData(aData, url); } void MainWindow::importFromNetwork(const QString& url) diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index c01f6bf..1d1c4a8 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -40,8 +40,6 @@ public: signals: void conferenceRemoved(); private slots: - void scheduleImported(int aConfId); - void scheduleDeleted(const QString& title); void aboutApp(); void conferenceMapClicked(); void eventHasChanged(int aEventId, bool aReloadModel); diff --git a/src/sql/schedulexmlparser.cpp b/src/sql/schedulexmlparser.cpp index ba06515..68bf711 100644 --- a/src/sql/schedulexmlparser.cpp +++ b/src/sql/schedulexmlparser.cpp @@ -31,13 +31,13 @@ ScheduleXmlParser::ScheduleXmlParser(QObject *aParent) { } -int ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url) +void ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url) { QDomDocument document; QString xml_error; if (!document.setContent (aData, false, &xml_error)) { error_message("Could not parse schedule: " + xml_error); - return -1; + return; } QDomElement scheduleElement = document.firstChildElement("schedule"); @@ -155,8 +155,10 @@ int ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url) } // parsing day elements } // schedule element SqlEngine::commitTransaction(); - emit parsingScheduleEnd(conference_title); - - return confId; + if (!conference_title.isNull()) { + emit parsingScheduleEnd(conference_title); + } else { + error_message("Could not parse schedule"); + } } diff --git a/src/sql/schedulexmlparser.h b/src/sql/schedulexmlparser.h index a2ad828..cb61966 100644 --- a/src/sql/schedulexmlparser.h +++ b/src/sql/schedulexmlparser.h @@ -28,7 +28,7 @@ class ScheduleXmlParser : public QObject ScheduleXmlParser (QObject *aParent = NULL); public slots: - int parseData(const QByteArray &aData, const QString& url); // returns 'confId' of parsed conference schedule + void parseData(const QByteArray &aData, const QString& url); signals: void progressStatus(int aStatus); -- 2.39.5