Refactor adding/removing to queue
All adding and removing should now go through the entry itself, using queueStatus.
This commit is contained in:
parent
f681ef0f4f
commit
5f4a24a11d
@ -170,7 +170,7 @@ void AudioManager::setEntry(Entry* entry)
|
||||
qDebug() << "Mark as read:" << d->m_entry->title();
|
||||
d->m_entry->setRead(true);
|
||||
d->m_entry->enclosure()->setPlayPosition(0);
|
||||
DataManager::instance().removeQueueItem(d->m_entry); //TODO: put this behind setting
|
||||
d->m_entry->setQueueStatus(false); // i.e. remove from queue TODO: make this a choice in settings
|
||||
}
|
||||
}
|
||||
if (entry != nullptr) {
|
||||
|
@ -290,6 +290,11 @@ QStringList DataManager::getQueue() const
|
||||
return m_queuemap;
|
||||
}
|
||||
|
||||
bool DataManager::entryInQueue(const Entry* entry)
|
||||
{
|
||||
return entryInQueue(entry->feed()->url(), entry->id());
|
||||
}
|
||||
|
||||
bool DataManager::entryInQueue(const QString &feedurl, const QString &id) const
|
||||
{
|
||||
Q_UNUSED(feedurl);
|
||||
@ -325,7 +330,6 @@ void DataManager::addToQueue(const QString &feedurl, const QString &id)
|
||||
|
||||
// Make sure that the QueueModel is aware of the changes
|
||||
Q_EMIT queueEntryAdded(index, id);
|
||||
Q_EMIT getEntry(id)->queueStatusChanged(true);
|
||||
}
|
||||
|
||||
void DataManager::moveQueueItem(const int &from, const int &to)
|
||||
@ -362,7 +366,6 @@ void DataManager::removeQueueItem(const int &index)
|
||||
|
||||
// Make sure that the QueueModel is aware of the change so it can update
|
||||
Q_EMIT queueEntryRemoved(index, id);
|
||||
Q_EMIT getEntry(id)->queueStatusChanged(false);
|
||||
}
|
||||
|
||||
void DataManager::removeQueueItem(const QString id)
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
Entry* getQueueEntry(int const &index) const;
|
||||
int queueCount() const;
|
||||
QStringList getQueue() const;
|
||||
Q_INVOKABLE bool entryInQueue(const Entry* entry);
|
||||
Q_INVOKABLE bool entryInQueue(const QString &feedurl, const QString &id) const;
|
||||
Q_INVOKABLE void addToQueue(const Entry* entry);
|
||||
Q_INVOKABLE void addToQueue(const QString &feedurl, const QString &id);
|
||||
|
@ -122,7 +122,7 @@ QString Entry::baseUrl() const
|
||||
return QUrl(m_link).adjusted(QUrl::RemovePath).toString();
|
||||
}
|
||||
|
||||
void Entry::setRead(bool read)
|
||||
void Entry::setRead(const bool read)
|
||||
{
|
||||
m_read = read;
|
||||
Q_EMIT readChanged(m_read);
|
||||
@ -135,7 +135,7 @@ void Entry::setRead(bool read)
|
||||
Q_EMIT m_feed->unreadEntryCountChanged();
|
||||
}
|
||||
|
||||
void Entry::setNew(bool state)
|
||||
void Entry::setNew(const bool state)
|
||||
{
|
||||
m_new = state;
|
||||
Q_EMIT newChanged(m_new);
|
||||
@ -203,7 +203,18 @@ QString Entry::image() const
|
||||
|
||||
bool Entry::queueStatus() const
|
||||
{
|
||||
return DataManager::instance().entryInQueue(m_feed->url(), m_id);
|
||||
return DataManager::instance().entryInQueue(this);
|
||||
}
|
||||
|
||||
void Entry::setQueueStatus(const bool state)
|
||||
{
|
||||
if (state != DataManager::instance().entryInQueue(this)) {
|
||||
if (state)
|
||||
DataManager::instance().addToQueue(this);
|
||||
else
|
||||
DataManager::instance().removeQueueItem(this);
|
||||
Q_EMIT queueStatusChanged(state);
|
||||
}
|
||||
}
|
||||
|
||||
void Entry::setImage(const QString &image)
|
||||
|
@ -36,7 +36,7 @@ class Entry : public QObject
|
||||
Q_PROPERTY(Enclosure *enclosure READ enclosure CONSTANT);
|
||||
Q_PROPERTY(bool hasEnclosure READ hasEnclosure CONSTANT);
|
||||
Q_PROPERTY(QString image READ image WRITE setImage NOTIFY imageChanged)
|
||||
Q_PROPERTY(bool queueStatus READ queueStatus NOTIFY queueStatusChanged)
|
||||
Q_PROPERTY(bool queueStatus READ queueStatus WRITE setQueueStatus NOTIFY queueStatusChanged)
|
||||
|
||||
public:
|
||||
Entry(Feed *feed, QString id);
|
||||
@ -59,9 +59,10 @@ public:
|
||||
|
||||
QString baseUrl() const;
|
||||
|
||||
void setRead(bool read);
|
||||
void setNew(bool state);
|
||||
void setRead(const bool read);
|
||||
void setNew(const bool state);
|
||||
void setImage(const QString &url);
|
||||
void setQueueStatus(const bool status);
|
||||
|
||||
Q_INVOKABLE QString adjustedContent(int width, int fontSize);
|
||||
|
||||
|
@ -127,7 +127,7 @@ Kirigami.SwipeListItem {
|
||||
text: i18n("Download")
|
||||
icon.name: "download"
|
||||
onTriggered: {
|
||||
DataManager.addToQueue(entry);
|
||||
entry.queueStatus = true;
|
||||
entry.enclosure.download();
|
||||
}
|
||||
visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloadable
|
||||
@ -151,7 +151,7 @@ Kirigami.SwipeListItem {
|
||||
text: i18n("Add to queue")
|
||||
icon.name: "media-playlist-append"
|
||||
visible: !entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded
|
||||
onTriggered: { DataManager.addToQueue(entry) }
|
||||
onTriggered: entry.queueStatus = true
|
||||
} /*,
|
||||
Kirigami.Action {
|
||||
text: i18n("Delete download")
|
||||
|
@ -66,7 +66,7 @@ Kirigami.ScrollablePage {
|
||||
text: "Add to queue"
|
||||
icon.name: "media-playlist-append"
|
||||
visible: entry.enclosure && !entry.queueStatus
|
||||
onTriggered: { DataManager.addToQueue(entry) }
|
||||
onTriggered: entry.queueStatus = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ Kirigami.SwipeListItem {
|
||||
/*Kirigami.Action {
|
||||
text: i18n("Remove from Queue")
|
||||
icon.name: "list-remove"
|
||||
onTriggered: { DataManager.removeQueueItem(entry) }
|
||||
onTriggered: entry.queueStatus = false
|
||||
},*/
|
||||
Kirigami.Action {
|
||||
text: i18n("Download")
|
||||
|
Loading…
x
Reference in New Issue
Block a user