mirror of https://github.com/KDE/kasts.git
Revert to non-proxied QueueModel
The proxy model was causing issues with item dragging. The model would reset after each swapped item. This meant that items could only be swapped one position at a time.
This commit is contained in:
parent
8ddb278e8a
commit
761b1dcc5d
|
@ -34,7 +34,6 @@ set(kasts_srcs
|
|||
models/entriesmodel.cpp
|
||||
models/entriesproxymodel.cpp
|
||||
models/queuemodel.cpp
|
||||
models/queueproxymodel.cpp
|
||||
models/episodemodel.cpp
|
||||
models/episodeproxymodel.cpp
|
||||
models/downloadmodel.cpp
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "models/errorlogmodel.h"
|
||||
#include "models/feedsproxymodel.h"
|
||||
#include "models/podcastsearchmodel.h"
|
||||
#include "models/queueproxymodel.h"
|
||||
#include "models/queuemodel.h"
|
||||
#include "networkconnectionmanager.h"
|
||||
#include "settingsmanager.h"
|
||||
#include "storagemanager.h"
|
||||
|
@ -138,7 +138,7 @@ int main(int argc, char *argv[])
|
|||
about.processCommandLine(&parser);
|
||||
|
||||
qmlRegisterType<FeedsProxyModel>("org.kde.kasts", 1, 0, "FeedsProxyModel");
|
||||
qmlRegisterType<QueueProxyModel>("org.kde.kasts", 1, 0, "QueueProxyModel");
|
||||
qmlRegisterType<QueueModel>("org.kde.kasts", 1, 0, "QueueModel");
|
||||
qmlRegisterType<EpisodeProxyModel>("org.kde.kasts", 1, 0, "EpisodeProxyModel");
|
||||
qmlRegisterType<PodcastSearchModel>("org.kde.kasts", 1, 0, "PodcastSearchModel");
|
||||
qmlRegisterType<ChapterModel>("org.kde.kasts", 1, 0, "ChapterModel");
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#include "models/episodeproxymodel.h"
|
||||
#include "models/abstractepisodemodel.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include "datamanager.h"
|
||||
#include "entry.h"
|
||||
#include "models/abstractepisodemodel.h"
|
||||
#include "models/episodeproxymodel.h"
|
||||
|
||||
AbstractEpisodeProxyModel::AbstractEpisodeProxyModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
|
@ -177,7 +177,7 @@ void AbstractEpisodeProxyModel::setSortType(SortType type)
|
|||
}
|
||||
}
|
||||
|
||||
QString AbstractEpisodeProxyModel::getFilterName(FilterType type) const
|
||||
QString AbstractEpisodeProxyModel::getFilterName(FilterType type)
|
||||
{
|
||||
switch (type) {
|
||||
case FilterType::NoFilter:
|
||||
|
@ -199,7 +199,7 @@ QString AbstractEpisodeProxyModel::getFilterName(FilterType type) const
|
|||
}
|
||||
}
|
||||
|
||||
QString AbstractEpisodeProxyModel::getSearchFlagName(SearchFlag flag) const
|
||||
QString AbstractEpisodeProxyModel::getSearchFlagName(SearchFlag flag)
|
||||
{
|
||||
switch (flag) {
|
||||
case SearchFlag::TitleFlag:
|
||||
|
@ -213,7 +213,7 @@ QString AbstractEpisodeProxyModel::getSearchFlagName(SearchFlag flag) const
|
|||
}
|
||||
}
|
||||
|
||||
QString AbstractEpisodeProxyModel::getSortName(SortType type) const
|
||||
QString AbstractEpisodeProxyModel::getSortName(SortType type)
|
||||
{
|
||||
switch (type) {
|
||||
case SortType::DateDescending:
|
||||
|
@ -225,7 +225,7 @@ QString AbstractEpisodeProxyModel::getSortName(SortType type) const
|
|||
}
|
||||
}
|
||||
|
||||
QString AbstractEpisodeProxyModel::getSortIconName(SortType type) const
|
||||
QString AbstractEpisodeProxyModel::getSortIconName(SortType type)
|
||||
{
|
||||
switch (type) {
|
||||
case SortType::DateDescending:
|
||||
|
|
|
@ -66,10 +66,10 @@ public:
|
|||
void setSearchFlags(SearchFlags searchFlags);
|
||||
void setSortType(SortType type);
|
||||
|
||||
Q_INVOKABLE QString getFilterName(FilterType type) const;
|
||||
Q_INVOKABLE QString getSearchFlagName(SearchFlag flag) const;
|
||||
Q_INVOKABLE QString getSortName(SortType type) const;
|
||||
Q_INVOKABLE QString getSortIconName(SortType type) const;
|
||||
Q_INVOKABLE static QString getFilterName(FilterType type);
|
||||
Q_INVOKABLE static QString getSearchFlagName(SearchFlag flag);
|
||||
Q_INVOKABLE static QString getSortName(SortType type);
|
||||
Q_INVOKABLE static QString getSortIconName(SortType type);
|
||||
|
||||
Q_INVOKABLE QItemSelection createSelection(int rowa, int rowb);
|
||||
|
||||
|
|
|
@ -96,7 +96,23 @@ QString QueueModel::formattedTimeLeft() const
|
|||
return format.formatDuration(timeLeft() / rate);
|
||||
}
|
||||
|
||||
QString QueueModel::getSortName(AbstractEpisodeProxyModel::SortType type)
|
||||
{
|
||||
return AbstractEpisodeProxyModel::getSortName(type);
|
||||
}
|
||||
|
||||
QString QueueModel::getSortIconName(AbstractEpisodeProxyModel::SortType type)
|
||||
{
|
||||
return AbstractEpisodeProxyModel::getSortIconName(type);
|
||||
}
|
||||
|
||||
void QueueModel::updateInternalState()
|
||||
{
|
||||
// nothing to do; DataManager already has the updated data.
|
||||
}
|
||||
|
||||
// Hack to get a QItemSelection in QML
|
||||
QItemSelection QueueModel::createSelection(int rowa, int rowb)
|
||||
{
|
||||
return QItemSelection(index(rowa, 0), index(rowb, 0));
|
||||
}
|
||||
|
|
|
@ -6,17 +6,23 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QItemSelection>
|
||||
#include <QModelIndex>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
#include "models/abstractepisodemodel.h"
|
||||
#include "models/abstractepisodeproxymodel.h"
|
||||
|
||||
class QueueModel : public AbstractEpisodeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_PROPERTY(int timeLeft READ timeLeft NOTIFY timeLeftChanged)
|
||||
Q_PROPERTY(QString formattedTimeLeft READ formattedTimeLeft NOTIFY timeLeftChanged)
|
||||
|
||||
static QueueModel &instance()
|
||||
{
|
||||
static QueueModel _instance;
|
||||
|
@ -29,9 +35,14 @@ public:
|
|||
int timeLeft() const;
|
||||
QString formattedTimeLeft() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void timeLeftChanged();
|
||||
Q_INVOKABLE static QString getSortName(AbstractEpisodeProxyModel::SortType type);
|
||||
Q_INVOKABLE static QString getSortIconName(AbstractEpisodeProxyModel::SortType type);
|
||||
|
||||
Q_INVOKABLE QItemSelection createSelection(int rowa, int rowb);
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateInternalState() override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void timeLeftChanged();
|
||||
};
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/**
|
||||
* SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#include "models/queueproxymodel.h"
|
||||
|
||||
QueueProxyModel::QueueProxyModel(QObject *parent)
|
||||
: AbstractEpisodeProxyModel(parent)
|
||||
{
|
||||
m_queueModel = &QueueModel::instance();
|
||||
setSourceModel(m_queueModel);
|
||||
|
||||
connect(m_queueModel, &QueueModel::timeLeftChanged, this, [this]() {
|
||||
Q_EMIT timeLeftChanged();
|
||||
});
|
||||
}
|
||||
|
||||
int QueueProxyModel::timeLeft() const
|
||||
{
|
||||
return m_queueModel->timeLeft();
|
||||
}
|
||||
|
||||
QString QueueProxyModel::formattedTimeLeft() const
|
||||
{
|
||||
return m_queueModel->formattedTimeLeft();
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
* SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "models/abstractepisodeproxymodel.h"
|
||||
#include "models/queuemodel.h"
|
||||
|
||||
class QueueProxyModel : public AbstractEpisodeProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(int timeLeft READ timeLeft NOTIFY timeLeftChanged)
|
||||
Q_PROPERTY(QString formattedTimeLeft READ formattedTimeLeft NOTIFY timeLeftChanged)
|
||||
|
||||
public:
|
||||
explicit QueueProxyModel(QObject *parent = nullptr);
|
||||
|
||||
int timeLeft() const;
|
||||
QString formattedTimeLeft() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void timeLeftChanged();
|
||||
|
||||
private:
|
||||
QueueModel *m_queueModel;
|
||||
};
|
|
@ -77,7 +77,7 @@ Kirigami.ScrollablePage {
|
|||
}
|
||||
}
|
||||
|
||||
model: QueueProxyModel {
|
||||
model: QueueModel {
|
||||
id: queueModel
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue