remove obsoleted code
authorkirilma <kirilma@localhost>
Thu, 22 Apr 2010 15:34:03 +0000 (15:34 +0000)
committerkirilma <kirilma@localhost>
Thu, 22 Apr 2010 15:34:03 +0000 (15:34 +0000)
also fix some types

src/gui/importschedulewidget.cpp [deleted file]
src/gui/importschedulewidget.h [deleted file]
src/gui/importschedulewidget.ui [deleted file]
src/gui/mainwindow.cpp
src/gui/mainwindow.h
src/sql/schedulexmlparser.cpp
src/sql/schedulexmlparser.h

diff --git a/src/gui/importschedulewidget.cpp b/src/gui/importschedulewidget.cpp
deleted file mode 100644 (file)
index de8efbc..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-#include "importschedulewidget.h"
-
-#include <schedulexmlparser.h>
-
-#include <QDir>
-#include <QFile>
-#include <QFileDialog>
-#include <QNetworkProxy>
-#include <QNetworkAccessManager>
-#include <QNetworkReply>
-#include <QMessageBox>
-#include <QDebug>
-#include <appsettings.h>
-
-// TODO: this is temporary
-#include <QInputDialog>
-
-#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 (file)
index 3e00d76..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-#ifndef IMPORTSCHEDULEWIDGET_H
-#define IMPORTSCHEDULEWIDGET_H
-
-#include <QWidget>
-#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 (file)
index 91542ae..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ImportScheduleWidget</class>
- <widget class="QWidget" name="ImportScheduleWidget">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>710</width>
-    <height>79</height>
-   </rect>
-  </property>
-  <property name="sizePolicy">
-   <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
-    <horstretch>0</horstretch>
-    <verstretch>0</verstretch>
-   </sizepolicy>
-  </property>
-  <property name="windowTitle">
-   <string>Import schedule</string>
-  </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0">
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
-      <widget class="QLabel" name="importScheduleLabel">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text">
-        <string>Schedule:</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="changeUrl">
-       <property name="text">
-        <string>Change Url</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="online">
-       <property name="enabled">
-        <bool>true</bool>
-       </property>
-       <property name="minimumSize">
-        <size>
-         <width>10</width>
-         <height>0</height>
-        </size>
-       </property>
-       <property name="text">
-        <string>Reresh</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="newConfFromUrl">
-       <property name="text">
-        <string>From Url</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="browse">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text">
-        <string>From File</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="delConf">
-       <property name="text">
-        <string>Delete</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="cancel">
-       <property name="text">
-        <string>Cancel</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QProgressBar" name="progressBar">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-         <horstretch>0</horstretch>
-         <verstretch>10</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="value">
-        <number>0</number>
-       </property>
-       <property name="textVisible">
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <resources>
-  <include location="../icons.qrc"/>
- </resources>
- <connections/>
-</ui>
index 08ba45b..5f38fcc 100644 (file)
@@ -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<Conference> confs = Conference::getAll();
-        QListIterator<Conference> 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)
index c01f6bf..1d1c4a8 100644 (file)
@@ -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);
index ba06515..68bf711 100644 (file)
@@ -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");
+    }
 }
 
index a2ad828..cb61966 100644 (file)
@@ -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);