From: kirilma Date: Fri, 16 Apr 2010 12:14:19 +0000 (+0000) Subject: use visible notifications of errors X-Git-Tag: 0.5.0~92 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/3329d3936b567d40a56de5ca3347d0416cf098f4 use visible notifications of errors also early detect parsing errors --- diff --git a/src/app/app.pro b/src/app/app.pro index 935836a..c6e6be4 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -3,6 +3,9 @@ TEMPLATE = app TARGET = fosdem-schedule DESTDIR = ../bin QT += sql xml network dbus +CONFIG(maemo5) { + QT += maemo5 +} # module dependencies LIBS += -L$$DESTDIR -lgui -lmvc -lsql diff --git a/src/app/application.cpp b/src/app/application.cpp index 353d8c7..29a0148 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -17,6 +17,7 @@ * fosdem-schedule. If not, see . */ #include "application.h" +#include "errormessage.h" #include @@ -28,10 +29,10 @@ bool Application::notify(QObject* receiver, QEvent* event) try { return QApplication::notify(receiver, event); } catch (OrmException& e) { - qWarning() << "UNCAUGHT EXCEPTION: OrmException, text= " << e.text(); + error_message("UNCAUGHT OrmException: " + e.text()); return false; } catch (...) { - qWarning() << "UNCAUGHT EXCEPTION: unknown"; + error_message("UNCAUGHT EXCEPTION: unknown"); return false; } } diff --git a/src/gui/errormessage.cpp b/src/gui/errormessage.cpp new file mode 100644 index 0000000..b5498c5 --- /dev/null +++ b/src/gui/errormessage.cpp @@ -0,0 +1,41 @@ +/* + * 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 "errormessage.h" + +#include + +#include +#ifdef QT_MAEMO5_LIB +#include +#else +#include +#endif + +void error_message(const QString& message) +{ + QTextStream(stderr) << "ERROR: " << message << "\n"; +#ifdef QT_MAEMO5_LIB + // by default the message is white on yellow, which is unusable + // but some html here works + // remove it as soon as they fix the colors + QMaemo5InformationBox::information(0, "" + message + ""); +#else + QMessageBox::warning(0, "Error", message); +#endif +} diff --git a/src/gui/errormessage.h b/src/gui/errormessage.h new file mode 100644 index 0000000..467a3bd --- /dev/null +++ b/src/gui/errormessage.h @@ -0,0 +1,26 @@ +/* + * 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 ERRORMESSAGE_H +#define ERRORMESSAGE_H + +#include + +void error_message(const QString& message); + +#endif diff --git a/src/gui/gui.pro b/src/gui/gui.pro index c7dd18b..20aed51 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -81,6 +81,12 @@ SOURCES += roomstabcontainer.cpp \ mapwindow.cpp \ settingsdialog.cpp +HEADERS += errormessage.h +SOURCES += errormessage.cpp +CONFIG(maemo5) { + QT += maemo5 +} + #maemo { # FORMS += alarmdialog.ui # HEADERS += alarmdialog.h diff --git a/src/gui/importschedulewidget.cpp b/src/gui/importschedulewidget.cpp index 2eb47ac..de8efbc 100644 --- a/src/gui/importschedulewidget.cpp +++ b/src/gui/importschedulewidget.cpp @@ -34,6 +34,7 @@ #include #include "conference.h" +#include "errormessage.h" // const QString SCHEDULE_URL = "http://fosdem.org/2010/schedule/xml"; @@ -113,7 +114,7 @@ void ImportScheduleWidget::networkQueryFinished(QNetworkReply *aReply) { if ( aReply->error() != QNetworkReply::NoError ) { - qDebug() << "Error occured during download: " << aReply->errorString(); + error_message(QString("Error occured during download: ") + aReply->errorString()); } else { @@ -208,6 +209,8 @@ void ImportScheduleWidget::importData(const QByteArray &aData, const QString& ur // proxySettings->show(); importScheduleLabel->setText("Schedule:"); - emit(scheduleImported(confId)); + if (confId > 0) { + emit(scheduleImported(confId)); + } } diff --git a/src/sql/schedulexmlparser.cpp b/src/sql/schedulexmlparser.cpp index fb869ae..4da3b5d 100644 --- a/src/sql/schedulexmlparser.cpp +++ b/src/sql/schedulexmlparser.cpp @@ -22,6 +22,7 @@ #include "schedulexmlparser.h" #include "sqlengine.h" +#include "../gui/errormessage.h" #include @@ -33,7 +34,11 @@ ScheduleXmlParser::ScheduleXmlParser(QObject *aParent) int ScheduleXmlParser::parseData(const QByteArray &aData, const QString& url) { QDomDocument document; - document.setContent (aData, false); + QString xml_error; + if (!document.setContent (aData, false, &xml_error)) { + error_message("Could not parse schedule: " + xml_error); + return -1; + } QDomElement scheduleElement = document.firstChildElement("schedule");