Verified Commit 5a607c33 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

wallpapers/image: Add roleNames() in SlideFilterModel

parent cca481b7
......@@ -6,9 +6,9 @@
#include "slidefiltermodel.h"
#include "backgroundlistmodel.h"
#include "slidemodel.h"
#include <QDateTime>
#include <QDir>
#include <QRandomGenerator>
......@@ -28,10 +28,19 @@ SlideFilterModel::SlideFilterModel(QObject *parent)
connect(this, &SlideFilterModel::usedInConfigChanged, this, &SlideFilterModel::invalidateFilter);
}
QHash<int, QByteArray> SlideFilterModel::roleNames() const
{
if (sourceModel()) {
return sourceModel()->roleNames();
}
return QSortFilterProxyModel::roleNames();
}
bool SlideFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
auto index = sourceModel()->index(source_row, 0, source_parent);
return m_usedInConfig || index.data(BackgroundListModel::ToggleRole).toBool();
return m_usedInConfig || index.data(ImageRoles::ToggleRole).toBool();
}
void SlideFilterModel::setSourceModel(QAbstractItemModel *sourceModel)
......@@ -184,7 +193,7 @@ void SlideFilterModel::buildRandomOrder()
QString SlideFilterModel::getLocalFilePath(const QModelIndex &modelIndex) const
{
return modelIndex.data(BackgroundListModel::PathRole).toUrl().toLocalFile();
return modelIndex.data(ImageRoles::PathRole).toUrl().toLocalFile();
}
QString SlideFilterModel::getFilePathWithDir(const QFileInfo &fileInfo) const
......
......@@ -22,6 +22,9 @@ class SlideFilterModel : public QSortFilterProxyModel
public:
explicit SlideFilterModel(QObject *parent);
QHash<int, QByteArray> roleNames() const override;
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
void setSourceModel(QAbstractItemModel *sourceModel) override;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment