And more work on queue

This commit is contained in:
Bart De Vries 2021-04-01 22:23:07 +02:00
parent f75c29dda6
commit d3107dc096
7 changed files with 36 additions and 41 deletions

View File

@ -49,7 +49,8 @@ bool Database::migrateTo1()
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Feeds (name TEXT, url TEXT, image TEXT, link TEXT, description TEXT, deleteAfterCount INTEGER, deleteAfterType INTEGER, subscribed INTEGER, lastUpdated INTEGER, notify BOOL);"))); TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Feeds (name TEXT, url TEXT, image TEXT, link TEXT, description TEXT, deleteAfterCount INTEGER, deleteAfterType INTEGER, subscribed INTEGER, lastUpdated INTEGER, notify BOOL);")));
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Entries (feed TEXT, id TEXT UNIQUE, title TEXT, content TEXT, created INTEGER, updated INTEGER, link TEXT, read bool, hasEnclosure BOOL);"))); TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Entries (feed TEXT, id TEXT UNIQUE, title TEXT, content TEXT, created INTEGER, updated INTEGER, link TEXT, read bool, hasEnclosure BOOL);")));
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Authors (feed TEXT, id TEXT, name TEXT, uri TEXT, email TEXT);"))); TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Authors (feed TEXT, id TEXT, name TEXT, uri TEXT, email TEXT);")));
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Enclosures (feed TEXT, id TEXT, duration INTEGER, size INTEGER, title TEXT, type STRING, url STRING);"))); TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Enclosures (feed TEXT, id TEXT, duration INTEGER, size INTEGER, title TEXT, type TEXT, url TEXT);"))); //, playposition INTEGER, filename TEXT);")));
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Queue (listnr INTEGER, feed TEXT, id TEXT);")));
TRUE_OR_RETURN(execute(QStringLiteral("PRAGMA user_version = 1;"))); TRUE_OR_RETURN(execute(QStringLiteral("PRAGMA user_version = 1;")));
return true; return true;
} }

View File

@ -37,7 +37,7 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
onLinkActivated: Qt.openUrlExternally(link) onLinkActivated: Qt.openUrlExternally(link)
onWidthChanged: entry.adjustedContent(width, font.pixelSize) //onWidthChanged: { text = entry.adjustedContent(width, font.pixelSize) }
} }
//} //}
actions.main: Kirigami.Action { actions.main: Kirigami.Action {

View File

@ -20,6 +20,12 @@ Item {
//margins.bottom: miniprogressbar.height //margins.bottom: miniprogressbar.height
visible: (audio.entry !== undefined) && !audio.playerOpen visible: (audio.entry !== undefined) && !audio.playerOpen
// Set background
Rectangle {
anchors.fill: parent
color: Kirigami.Theme.backgroundColor
}
// progress bar for limited width (phones) // progress bar for limited width (phones)
Rectangle { Rectangle {
id: miniprogressbar id: miniprogressbar

View File

@ -23,7 +23,7 @@ Kirigami.ScrollablePage {
Kirigami.ListItemDragHandle { Kirigami.ListItemDragHandle {
listItem: listItem listItem: listItem
listView: mainList listView: mainList
onMoveRequested: queueModel.moveRows(oldIndex, newIndex, 1) onMoveRequested: queueModel.move(oldIndex, newIndex)
} }
Controls.Label { Controls.Label {
@ -55,26 +55,12 @@ Kirigami.ScrollablePage {
} }
} }
QueueModel { id: queueModel }
ListView { ListView {
id: mainList id: mainList
Timer {
id: refreshRequestTimer
interval: 3000
onTriggered: page.refreshing = false
}
/*model: ListModel { model: queueModel
id: listModel
Component.onCompleted: {
for (var i = 0; i < 200; ++i) {
listModel.append({"title": "Item " + i,
"actions": [{text: "Action 1", icon: "document-decrypt"},
{text: "Action 2", icon: "mail-reply-sender"}]
})
}
}
}*/
model: QueueModel { id: queueModel }
moveDisplaced: Transition { moveDisplaced: Transition {
YAnimator { YAnimator {
@ -83,7 +69,7 @@ Kirigami.ScrollablePage {
} }
} }
delegate: Kirigami.DelegateRecycler { delegate: Kirigami.DelegateRecycler {
width: parent ? parent.width : implicitWidth width: mainList.width
sourceComponent: delegateComponent sourceComponent: delegateComponent
} }
} }

View File

@ -27,14 +27,18 @@ Kirigami.ApplicationWindow {
Kirigami.Action { Kirigami.Action {
text: i18n("Feed List") text: i18n("Feed List")
iconName: "rss" iconName: "rss"
onTriggered: root.pageStack.clear(), root.pageStack.push(feedList) onTriggered: {
enabled: pageStack.layers.currentItem.title !== i18n("Feed List") pageStack.clear()
pageStack.push(feedList)
}
}, },
Kirigami.Action { Kirigami.Action {
text: i18n("Podcast Queue") text: i18n("Podcast Queue")
iconName: "source-playlist" iconName: "source-playlist"
onTriggered: root.pageStack.clear(), root.pageStack.push(queuelist) onTriggered: {
enabled: pageStack.layers.currentItem.title !== i18n("Podcast Queue") pageStack.clear()
pageStack.push(queuelist)
}
}, },
Kirigami.Action { Kirigami.Action {
text: i18n("Settings") text: i18n("Settings")
@ -97,7 +101,7 @@ Kirigami.ApplicationWindow {
} }
*/ */
footer: MinimizedPlayerControls {} footer: MinimizedPlayerControls { }
/*Item { /*Item {
visible: (audio.entry !== undefined) visible: (audio.entry !== undefined)
height: footerLoader.minimizedSize height: footerLoader.minimizedSize

View File

@ -32,8 +32,6 @@ QueueModel::QueueModel(QObject *parent)
void QueueModel::updateQueue() void QueueModel::updateQueue()
{ {
qDebug() << "Begin create queuemodel object";
QSqlQuery query; QSqlQuery query;
query.prepare(QStringLiteral("SELECT * FROM Enclosures")); query.prepare(QStringLiteral("SELECT * FROM Enclosures"));
Database::instance().execute(query); Database::instance().execute(query);
@ -120,24 +118,23 @@ int QueueModel::rowCount(const QModelIndex &parent) const
return m_entries.size(); return m_entries.size();
} }
bool QueueModel::move(int from, int to)
{
return moveRows(QModelIndex(), from, 1, QModelIndex(), to);
}
bool QueueModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) bool QueueModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
{ {
if (sourceParent != destinationParent) { Q_ASSERT(count == 1); // Only implemented the case of moving one row at a time
Q_ASSERT(sourceParent == destinationParent); // No moving between lists
int to = (sourceRow < destinationChild) ? destinationChild + 1 : destinationChild;
if (!beginMoveRows(sourceParent, sourceRow, sourceRow, destinationParent, to)) {
return false; return false;
} }
if (!beginMoveRows(sourceParent, sourceRow, sourceRow + count - 1, destinationParent, destinationChild)) { m_entries.move(sourceRow, destinationChild);
return false;
}
for (auto cptItem = 0; cptItem < count; ++cptItem) {
if (sourceRow < destinationChild) {
m_entries.move(sourceRow, destinationChild - 1);
} else {
m_entries.move(sourceRow, destinationChild);
}
}
endMoveRows(); endMoveRows();

View File

@ -24,7 +24,8 @@ public:
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent) const override; int rowCount(const QModelIndex &parent) const override;
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override; 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;
private: private:
void updateQueue(); void updateQueue();