mirror of https://github.com/KDE/kasts.git
Finish basic ErrorListPage implementation
This commit is contained in:
parent
3653aa4687
commit
7d21f5fbe7
14
src/error.h
14
src/error.h
|
@ -9,6 +9,7 @@
|
|||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include "datamanager.h"
|
||||
|
||||
class Error : public QObject
|
||||
{
|
||||
|
@ -19,6 +20,7 @@ class Error : public QObject
|
|||
Q_PROPERTY(int code MEMBER code CONSTANT)
|
||||
Q_PROPERTY(QString string MEMBER string CONSTANT)
|
||||
Q_PROPERTY(QDateTime date MEMBER date CONSTANT)
|
||||
Q_PROPERTY(QString title READ title CONSTANT)
|
||||
|
||||
public:
|
||||
Error(const QString url, const QString id, const int code, const QString string, const QDateTime date): QObject(nullptr)
|
||||
|
@ -35,4 +37,16 @@ public:
|
|||
int code;
|
||||
QString string;
|
||||
QDateTime date;
|
||||
|
||||
QString title () {
|
||||
QString title;
|
||||
if (!id.isEmpty()) {
|
||||
if (DataManager::instance().getEntry(id))
|
||||
title = DataManager::instance().getEntry(id)->title();
|
||||
} else if (!url.isEmpty()) {
|
||||
if (DataManager::instance().getFeed(url))
|
||||
title = DataManager::instance().getFeed(url)->name();
|
||||
}
|
||||
return title;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "fetcher.h"
|
||||
#include "database.h"
|
||||
#include "datamanager.h"
|
||||
|
||||
|
||||
ErrorLogModel::ErrorLogModel()
|
||||
|
@ -21,7 +22,10 @@ ErrorLogModel::ErrorLogModel()
|
|||
query.prepare(QStringLiteral("SELECT * FROM Errors ORDER BY date DESC;"));
|
||||
Database::instance().execute(query);
|
||||
while (query.next()) {
|
||||
Error* error = new Error(query.value(QStringLiteral("url")).toString(), query.value(QStringLiteral("id")).toString(), query.value(QStringLiteral("code")).toInt(), query.value(QStringLiteral("string")).toString(), QDateTime::fromSecsSinceEpoch(query.value(QStringLiteral("date")).toInt()));
|
||||
QString id = query.value(QStringLiteral("id")).toString();
|
||||
QString url = query.value(QStringLiteral("url")).toString();
|
||||
|
||||
Error* error = new Error(url, id, query.value(QStringLiteral("code")).toInt(), query.value(QStringLiteral("string")).toString(), QDateTime::fromSecsSinceEpoch(query.value(QStringLiteral("date")).toInt()));
|
||||
m_errors += error;
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +53,8 @@ int ErrorLogModel::rowCount(const QModelIndex &parent) const
|
|||
void ErrorLogModel::monitorErrorMessages(const QString &url, const QString& id, const int errorCode, const QString& errorString)
|
||||
{
|
||||
qDebug() << "Error happened:" << url << id << errorCode << errorString;
|
||||
QString title;
|
||||
|
||||
Error* error = new Error(url, id, errorCode, errorString, QDateTime::currentDateTime());
|
||||
beginInsertRows(QModelIndex(), 0, 0);
|
||||
m_errors.prepend(error);
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.kde.alligator 1.0
|
|||
|
||||
Kirigami.ScrollablePage {
|
||||
|
||||
padding: 0
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
visible: errorList.count === 0
|
||||
|
||||
|
@ -27,12 +29,41 @@ Kirigami.ScrollablePage {
|
|||
Component {
|
||||
id: errorListDelegate
|
||||
Kirigami.SwipeListItem {
|
||||
contentItem: Kirigami.BasicListItem {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
text: error.id ? DataManager.getEntry(error.id).title : DataManager.getFeed(error.url).title
|
||||
icon: "data-error"
|
||||
subtitle: error.string
|
||||
contentItem: RowLayout {
|
||||
Kirigami.Icon {
|
||||
source: "data-error"
|
||||
property int size: Kirigami.Units.iconSizes.medium
|
||||
Layout.minimumHeight: size
|
||||
Layout.maximumHeight: size
|
||||
Layout.minimumWidth: size
|
||||
Layout.maximumWidth: size
|
||||
}
|
||||
ColumnLayout {
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Controls.Label {
|
||||
text: ( (error.id) ? i18n("Media download") : i18n("Feed update error") ) + " · " + error.date.toLocaleDateString(Qt.locale(), Locale.NarrowFormat) + " · " + error.date.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat)
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
font: Kirigami.Theme.smallFont
|
||||
opacity: 0.7
|
||||
}
|
||||
Controls.Label {
|
||||
text: error.title
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
font.weight: Font.Normal
|
||||
opacity: 1
|
||||
}
|
||||
Controls.Label {
|
||||
text: i18n("Error code: ") + error.code + " · " + error.string
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
font: Kirigami.Theme.smallFont
|
||||
opacity: 0.7
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue