mirror of https://github.com/KDE/kasts.git
Minor improvements
This commit is contained in:
parent
514dc1fa51
commit
03573e69c2
|
@ -56,4 +56,10 @@ Kirigami.ScrollablePage {
|
|||
else entry.enclosure.deleteFile()
|
||||
}
|
||||
}
|
||||
actions.right: Kirigami.Action {
|
||||
text: "Add to queue"
|
||||
icon.name: "media-playlist-append"
|
||||
visible: entry.enclosure
|
||||
onTriggered: { queueModel.addEntry(entry.feed.url, entry.id) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.kde.kirigami 2.12 as Kirigami
|
|||
import org.kde.alligator 1.0
|
||||
|
||||
Kirigami.ScrollablePage {
|
||||
title: "Subscriptions"
|
||||
title: i18n("Subscriptions")
|
||||
|
||||
property var lastFeed: ""
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.kde.alligator 1.0
|
|||
|
||||
Kirigami.ScrollablePage {
|
||||
id: queuepage
|
||||
title: "Queue"
|
||||
title: i18n("Queue")
|
||||
Component {
|
||||
id: delegateComponent
|
||||
Kirigami.SwipeListItem {
|
||||
|
@ -55,12 +55,10 @@ Kirigami.ScrollablePage {
|
|||
}
|
||||
}
|
||||
|
||||
QueueModel { id: queueModel }
|
||||
|
||||
ListView {
|
||||
id: mainList
|
||||
|
||||
model: queueModel
|
||||
model: root.queueModel
|
||||
|
||||
moveDisplaced: Transition {
|
||||
YAnimator {
|
||||
|
|
|
@ -40,6 +40,7 @@ Kirigami.ApplicationWindow {
|
|||
pageStack.push(feedList)
|
||||
}
|
||||
},
|
||||
Kirigami.Action{ separator: true },
|
||||
Kirigami.Action {
|
||||
text: i18n("Settings")
|
||||
iconName: "settings-configure"
|
||||
|
@ -70,6 +71,10 @@ Kirigami.ApplicationWindow {
|
|||
id: feedList
|
||||
}
|
||||
|
||||
QueueModel {
|
||||
id: queueModel
|
||||
}
|
||||
|
||||
QueuePage {
|
||||
id: queuelist
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ QueueModel::QueueModel(QObject *parent)
|
|||
|
||||
void QueueModel::updateQueue()
|
||||
{
|
||||
|
||||
/*
|
||||
QSqlQuery query;
|
||||
query.prepare(QStringLiteral("SELECT * FROM Enclosures"));
|
||||
Database::instance().execute(query);
|
||||
|
@ -89,6 +91,7 @@ void QueueModel::updateQueue()
|
|||
m_entries.append(entry);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
QueueModel::~QueueModel()
|
||||
|
@ -140,3 +143,39 @@ bool QueueModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int co
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QueueModel::addEntry(QString feedurl, QString id) {
|
||||
qDebug() << feedurl << id;
|
||||
|
||||
QSqlQuery feedQuery;
|
||||
feedQuery.prepare(QStringLiteral("SELECT * FROM Feeds WHERE url=:feedurl"));
|
||||
feedQuery.bindValue(QStringLiteral(":feedurl"), feedurl);
|
||||
Database::instance().execute(feedQuery);
|
||||
if (!feedQuery.next()) {
|
||||
qWarning() << "Feed not found:" << feedurl;
|
||||
// TODO: remove enclosures belonging to non-existent feed
|
||||
return;
|
||||
}
|
||||
int feed_index = feedQuery.value(QStringLiteral("rowid")).toInt() - 1;
|
||||
qDebug() << feed_index << feedurl;
|
||||
Feed* feed = new Feed(feed_index);
|
||||
|
||||
// Find query index
|
||||
QSqlQuery entryQuery;
|
||||
entryQuery.prepare(QStringLiteral("SELECT rowid FROM Entries WHERE feed=:feedurl ORDER BY updated;"));
|
||||
entryQuery.bindValue(QStringLiteral(":feedurl"), feedurl);
|
||||
Database::instance().execute(entryQuery);
|
||||
int counter = -1;
|
||||
int entry_index = -1;
|
||||
while (entryQuery.next()) {
|
||||
counter++;
|
||||
QString idquery = entryQuery.value(QStringLiteral("id")).toString();
|
||||
if (idquery == id) entry_index = counter;
|
||||
}
|
||||
if (entry_index == -1) return;
|
||||
|
||||
beginInsertRows(QModelIndex(), rowCount(QModelIndex()) - 1, rowCount(QModelIndex()) - 1);
|
||||
m_entries.append(new Entry(feed, entry_index));
|
||||
endInsertRows();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,10 @@ public:
|
|||
|
||||
Q_INVOKABLE bool move(int from, int to);
|
||||
Q_INVOKABLE bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
|
||||
Q_INVOKABLE void addEntry(QString feedurl, QString id);
|
||||
|
||||
private:
|
||||
void updateQueue();
|
||||
|
||||
mutable QList<Entry *> m_entries;
|
||||
mutable QVector<Entry *> m_entries;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue