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 <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include "datamanager.h"
|
||||||
|
|
||||||
class Error : public QObject
|
class Error : public QObject
|
||||||
{
|
{
|
||||||
@ -19,6 +20,7 @@ class Error : public QObject
|
|||||||
Q_PROPERTY(int code MEMBER code CONSTANT)
|
Q_PROPERTY(int code MEMBER code CONSTANT)
|
||||||
Q_PROPERTY(QString string MEMBER string CONSTANT)
|
Q_PROPERTY(QString string MEMBER string CONSTANT)
|
||||||
Q_PROPERTY(QDateTime date MEMBER date CONSTANT)
|
Q_PROPERTY(QDateTime date MEMBER date CONSTANT)
|
||||||
|
Q_PROPERTY(QString title READ title CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Error(const QString url, const QString id, const int code, const QString string, const QDateTime date): QObject(nullptr)
|
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;
|
int code;
|
||||||
QString string;
|
QString string;
|
||||||
QDateTime date;
|
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 "fetcher.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
#include "datamanager.h"
|
||||||
|
|
||||||
|
|
||||||
ErrorLogModel::ErrorLogModel()
|
ErrorLogModel::ErrorLogModel()
|
||||||
@ -21,7 +22,10 @@ ErrorLogModel::ErrorLogModel()
|
|||||||
query.prepare(QStringLiteral("SELECT * FROM Errors ORDER BY date DESC;"));
|
query.prepare(QStringLiteral("SELECT * FROM Errors ORDER BY date DESC;"));
|
||||||
Database::instance().execute(query);
|
Database::instance().execute(query);
|
||||||
while (query.next()) {
|
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;
|
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)
|
void ErrorLogModel::monitorErrorMessages(const QString &url, const QString& id, const int errorCode, const QString& errorString)
|
||||||
{
|
{
|
||||||
qDebug() << "Error happened:" << url << id << errorCode << errorString;
|
qDebug() << "Error happened:" << url << id << errorCode << errorString;
|
||||||
|
QString title;
|
||||||
|
|
||||||
Error* error = new Error(url, id, errorCode, errorString, QDateTime::currentDateTime());
|
Error* error = new Error(url, id, errorCode, errorString, QDateTime::currentDateTime());
|
||||||
beginInsertRows(QModelIndex(), 0, 0);
|
beginInsertRows(QModelIndex(), 0, 0);
|
||||||
m_errors.prepend(error);
|
m_errors.prepend(error);
|
||||||
|
@ -16,6 +16,8 @@ import org.kde.alligator 1.0
|
|||||||
|
|
||||||
Kirigami.ScrollablePage {
|
Kirigami.ScrollablePage {
|
||||||
|
|
||||||
|
padding: 0
|
||||||
|
|
||||||
Kirigami.PlaceholderMessage {
|
Kirigami.PlaceholderMessage {
|
||||||
visible: errorList.count === 0
|
visible: errorList.count === 0
|
||||||
|
|
||||||
@ -27,12 +29,41 @@ Kirigami.ScrollablePage {
|
|||||||
Component {
|
Component {
|
||||||
id: errorListDelegate
|
id: errorListDelegate
|
||||||
Kirigami.SwipeListItem {
|
Kirigami.SwipeListItem {
|
||||||
contentItem: Kirigami.BasicListItem {
|
contentItem: RowLayout {
|
||||||
anchors.top: parent.top
|
Kirigami.Icon {
|
||||||
anchors.bottom: parent.bottom
|
source: "data-error"
|
||||||
text: error.id ? DataManager.getEntry(error.id).title : DataManager.getFeed(error.url).title
|
property int size: Kirigami.Units.iconSizes.medium
|
||||||
icon: "data-error"
|
Layout.minimumHeight: size
|
||||||
subtitle: error.string
|
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…
x
Reference in New Issue
Block a user