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: [
|
||||
Kirigami.Action {
|
||||
text: "Details"
|
||||
visible: url != "all"
|
||||
onTriggered: ;//pageStack.push("qrc:/qml/FeedDetailsPage.qml", {"modelData": atomModel})
|
||||
}
|
||||
]
|
||||
|
|
|
@ -61,11 +61,26 @@ Kirigami.ScrollablePage {
|
|||
}
|
||||
|
||||
ListView {
|
||||
id: feedList
|
||||
anchors.fill: parent
|
||||
model: 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 {
|
||||
Controls.Label {
|
||||
text: model.display
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "fetcher.h"
|
||||
#include "database.h"
|
||||
|
||||
#include "alligator-debug.h"
|
||||
|
||||
EntryListModel::EntryListModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
|
@ -67,18 +69,28 @@ bool EntryListModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
|
||||
void EntryListModel::fetch()
|
||||
{
|
||||
connect(&Fetcher::instance(), &Fetcher::finished, this, [this]() {
|
||||
beginResetModel();
|
||||
QSqlQuery query;
|
||||
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();
|
||||
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.bindValue(QStringLiteral(":feed"), m_feed);
|
||||
Database::instance().execute(query);
|
||||
while (query.next()) {
|
||||
m_entries.append(Entry(query.value(1).toString(), query.value(2).toString(), false, false));
|
||||
}
|
||||
endResetModel();
|
||||
});
|
||||
Fetcher::instance().fetch(m_feed);
|
||||
}
|
||||
Database::instance().execute(query);
|
||||
while (query.next()) {
|
||||
m_entries.append(Entry(query.value(1).toString(), query.value(2).toString(), false, false));
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QString EntryListModel::feed() const
|
||||
|
|
|
@ -55,4 +55,6 @@ Q_SIGNALS:
|
|||
private:
|
||||
QVector<Entry> m_entries;
|
||||
QString m_feed;
|
||||
|
||||
void update();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue