mirror of https://github.com/KDE/kasts.git
add all feeds view
This commit is contained in:
parent
a6f6969912
commit
7013a7278e
|
@ -34,6 +34,7 @@ Kirigami.ScrollablePage {
|
||||||
contextualActions: [
|
contextualActions: [
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "Details"
|
text: "Details"
|
||||||
|
visible: url != "all"
|
||||||
onTriggered: ;//pageStack.push("qrc:/qml/FeedDetailsPage.qml", {"modelData": atomModel})
|
onTriggered: ;//pageStack.push("qrc:/qml/FeedDetailsPage.qml", {"modelData": atomModel})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -61,11 +61,26 @@ Kirigami.ScrollablePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
|
id: feedList
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
model: FeedListModel {
|
model: FeedListModel {
|
||||||
id: feedListModel
|
id: feedListModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header:
|
||||||
|
Kirigami.SwipeListItem {
|
||||||
|
Controls.Label {
|
||||||
|
text: "All feeds"
|
||||||
|
}
|
||||||
|
|
||||||
|
width: parent.width;
|
||||||
|
height: Kirigami.Units.gridUnit * 2
|
||||||
|
onClicked: {
|
||||||
|
feedList.focus = false
|
||||||
|
pageStack.push("qrc:/EntryListPage.qml", {"name": "All feeds", "url": "all"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delegate: Kirigami.SwipeListItem {
|
delegate: Kirigami.SwipeListItem {
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
text: model.display
|
text: model.display
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include "fetcher.h"
|
#include "fetcher.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
|
||||||
|
#include "alligator-debug.h"
|
||||||
|
|
||||||
EntryListModel::EntryListModel(QObject *parent)
|
EntryListModel::EntryListModel(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
|
@ -67,18 +69,28 @@ bool EntryListModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
|
|
||||||
void EntryListModel::fetch()
|
void EntryListModel::fetch()
|
||||||
{
|
{
|
||||||
connect(&Fetcher::instance(), &Fetcher::finished, this, [this]() {
|
connect(&Fetcher::instance(), &Fetcher::finished, this, &EntryListModel::update);
|
||||||
|
if(m_feed.compare("all") != 0)
|
||||||
|
Fetcher::instance().fetch(m_feed);
|
||||||
|
else
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EntryListModel::update() {
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
|
if(m_feed.compare("all") == 0) {
|
||||||
|
query.prepare(QStringLiteral("SELECT id, title, content FROM Entries;"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
query.prepare(QStringLiteral("SELECT id, title, content FROM Entries WHERE feed=:feed;"));
|
query.prepare(QStringLiteral("SELECT id, title, content FROM Entries WHERE feed=:feed;"));
|
||||||
query.bindValue(QStringLiteral(":feed"), m_feed);
|
query.bindValue(QStringLiteral(":feed"), m_feed);
|
||||||
|
}
|
||||||
Database::instance().execute(query);
|
Database::instance().execute(query);
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
m_entries.append(Entry(query.value(1).toString(), query.value(2).toString(), false, false));
|
m_entries.append(Entry(query.value(1).toString(), query.value(2).toString(), false, false));
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
});
|
|
||||||
Fetcher::instance().fetch(m_feed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EntryListModel::feed() const
|
QString EntryListModel::feed() const
|
||||||
|
|
|
@ -55,4 +55,6 @@ Q_SIGNALS:
|
||||||
private:
|
private:
|
||||||
QVector<Entry> m_entries;
|
QVector<Entry> m_entries;
|
||||||
QString m_feed;
|
QString m_feed;
|
||||||
|
|
||||||
|
void update();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue