Changeset View
Changeset View
Standalone View
Standalone View
src/models/gridviewproxymodel.cpp
Show All 12 Lines | |||||
13 | * Lesser General Public License for more details. | 13 | * Lesser General Public License for more details. | ||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public License | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "gridviewproxymodel.h" | 19 | #include "gridviewproxymodel.h" | ||
20 | 20 | | |||
21 | #include "databaseinterface.h" | 21 | #include "datatypes.h" | ||
22 | #include "elisautils.h" | 22 | #include "elisautils.h" | ||
23 | 23 | | |||
24 | #include <QStringList> | 24 | #include <QStringList> | ||
25 | #include <QReadLocker> | 25 | #include <QReadLocker> | ||
26 | #include <QtConcurrentRun> | 26 | #include <QtConcurrentRun> | ||
27 | 27 | | |||
28 | GridViewProxyModel::GridViewProxyModel(QObject *parent) : AbstractMediaProxyModel(parent) | 28 | GridViewProxyModel::GridViewProxyModel(QObject *parent) : AbstractMediaProxyModel(parent) | ||
29 | { | 29 | { | ||
Show All 11 Lines | |||||
41 | 41 | | |||
42 | bool GridViewProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | 42 | bool GridViewProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | ||
43 | { | 43 | { | ||
44 | bool result = false; | 44 | bool result = false; | ||
45 | 45 | | |||
46 | auto currentIndex = sourceModel()->index(source_row, 0, source_parent); | 46 | auto currentIndex = sourceModel()->index(source_row, 0, source_parent); | ||
47 | 47 | | |||
48 | const auto &mainValue = sourceModel()->data(currentIndex, Qt::DisplayRole).toString(); | 48 | const auto &mainValue = sourceModel()->data(currentIndex, Qt::DisplayRole).toString(); | ||
49 | const auto &artistValue = sourceModel()->data(currentIndex, DatabaseInterface::ArtistRole).toString(); | 49 | const auto &artistValue = sourceModel()->data(currentIndex, DataTypes::ArtistRole).toString(); | ||
50 | const auto &allArtistsValue = sourceModel()->data(currentIndex, DatabaseInterface::AllArtistsRole).toStringList(); | 50 | const auto &allArtistsValue = sourceModel()->data(currentIndex, DataTypes::AllArtistsRole).toStringList(); | ||
51 | const auto maximumRatingValue = sourceModel()->data(currentIndex, DatabaseInterface::HighestTrackRating).toInt(); | 51 | const auto maximumRatingValue = sourceModel()->data(currentIndex, DataTypes::HighestTrackRating).toInt(); | ||
52 | 52 | | |||
53 | if (maximumRatingValue < mFilterRating) { | 53 | if (maximumRatingValue < mFilterRating) { | ||
54 | result = false; | 54 | result = false; | ||
55 | return result; | 55 | return result; | ||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | if (mFilterExpression.match(mainValue).hasMatch()) { | 58 | if (mFilterExpression.match(mainValue).hasMatch()) { | ||
59 | result = true; | 59 | result = true; | ||
Show All 19 Lines | 78 | void GridViewProxyModel::genericEnqueueToPlayList(ElisaUtils::PlayListEnqueueMode enqueueMode, | |||
79 | ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay) | 79 | ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay) | ||
80 | { | 80 | { | ||
81 | QtConcurrent::run(&mThreadPool, [=] () { | 81 | QtConcurrent::run(&mThreadPool, [=] () { | ||
82 | QReadLocker locker(&mDataLock); | 82 | QReadLocker locker(&mDataLock); | ||
83 | auto allData = ElisaUtils::EntryDataList{}; | 83 | auto allData = ElisaUtils::EntryDataList{}; | ||
84 | allData.reserve(rowCount()); | 84 | allData.reserve(rowCount()); | ||
85 | for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) { | 85 | for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) { | ||
86 | auto currentIndex = index(rowIndex, 0); | 86 | auto currentIndex = index(rowIndex, 0); | ||
87 | allData.push_back(ElisaUtils::EntryData{data(currentIndex, DatabaseInterface::DatabaseIdRole).toULongLong(), | 87 | allData.push_back(ElisaUtils::EntryData{data(currentIndex, DataTypes::DatabaseIdRole).toULongLong(), | ||
88 | data(currentIndex, Qt::DisplayRole).toString()}); | 88 | data(currentIndex, Qt::DisplayRole).toString()}); | ||
89 | } | 89 | } | ||
90 | Q_EMIT entriesToEnqueue(allData, mDataType, enqueueMode, triggerPlay); | 90 | Q_EMIT entriesToEnqueue(allData, mDataType, enqueueMode, triggerPlay); | ||
91 | }); | 91 | }); | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | void GridViewProxyModel::enqueueToPlayList() | 94 | void GridViewProxyModel::enqueueToPlayList() | ||
95 | { | 95 | { | ||
Show All 21 Lines |