Changeset View
Changeset View
Standalone View
Standalone View
src/models/alltracksproxymodel.cpp
Show All 11 Lines | |||||
12 | * Lesser General Public License for more details. | 12 | * Lesser General Public License for more details. | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public License | 14 | * You should have received a copy of the GNU Lesser General Public License | ||
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "alltracksproxymodel.h" | 18 | #include "alltracksproxymodel.h" | ||
19 | 19 | | |||
20 | #include "databaseinterface.h" | 20 | #include "datatypes.h" | ||
21 | 21 | | |||
22 | #include <QReadLocker> | 22 | #include <QReadLocker> | ||
23 | #include <QtConcurrentRun> | 23 | #include <QtConcurrentRun> | ||
24 | 24 | | |||
25 | AllTracksProxyModel::AllTracksProxyModel(QObject *parent) : AbstractMediaProxyModel(parent) | 25 | AllTracksProxyModel::AllTracksProxyModel(QObject *parent) : AbstractMediaProxyModel(parent) | ||
26 | { | 26 | { | ||
27 | setSortCaseSensitivity(Qt::CaseInsensitive); | 27 | setSortCaseSensitivity(Qt::CaseInsensitive); | ||
28 | } | 28 | } | ||
29 | 29 | | |||
30 | AllTracksProxyModel::~AllTracksProxyModel() = default; | 30 | AllTracksProxyModel::~AllTracksProxyModel() = default; | ||
31 | 31 | | |||
32 | bool AllTracksProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | 32 | bool AllTracksProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | ||
33 | { | 33 | { | ||
34 | bool result = false; | 34 | bool result = false; | ||
35 | 35 | | |||
36 | auto currentIndex = sourceModel()->index(source_row, 0, source_parent); | 36 | auto currentIndex = sourceModel()->index(source_row, 0, source_parent); | ||
37 | 37 | | |||
38 | const auto &titleValue = sourceModel()->data(currentIndex, Qt::DisplayRole).toString(); | 38 | const auto &titleValue = sourceModel()->data(currentIndex, Qt::DisplayRole).toString(); | ||
39 | const auto &artistValue = sourceModel()->data(currentIndex, DatabaseInterface::ColumnsRoles::ArtistRole).toString(); | 39 | const auto &artistValue = sourceModel()->data(currentIndex, DataTypes::ColumnsRoles::ArtistRole).toString(); | ||
40 | const auto maximumRatingValue = sourceModel()->data(currentIndex, DatabaseInterface::ColumnsRoles::RatingRole).toInt(); | 40 | const auto maximumRatingValue = sourceModel()->data(currentIndex, DataTypes::ColumnsRoles::RatingRole).toInt(); | ||
41 | 41 | | |||
42 | if (maximumRatingValue < mFilterRating) { | 42 | if (maximumRatingValue < mFilterRating) { | ||
43 | return result; | 43 | return result; | ||
44 | } | 44 | } | ||
45 | 45 | | |||
46 | if (mFilterExpression.match(titleValue).hasMatch()) { | 46 | if (mFilterExpression.match(titleValue).hasMatch()) { | ||
47 | result = true; | 47 | result = true; | ||
48 | } | 48 | } | ||
Show All 9 Lines | 57 | void AllTracksProxyModel::genericEnqueueToPlayList(ElisaUtils::PlayListEnqueueMode enqueueMode, | |||
58 | ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay) | 58 | ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay) | ||
59 | { | 59 | { | ||
60 | QtConcurrent::run(&mThreadPool, [=] () { | 60 | QtConcurrent::run(&mThreadPool, [=] () { | ||
61 | QReadLocker locker(&mDataLock); | 61 | QReadLocker locker(&mDataLock); | ||
62 | auto allTracks = ElisaUtils::EntryDataList{}; | 62 | auto allTracks = ElisaUtils::EntryDataList{}; | ||
63 | allTracks.reserve(rowCount()); | 63 | allTracks.reserve(rowCount()); | ||
64 | for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) { | 64 | for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) { | ||
65 | auto currentIndex = index(rowIndex, 0); | 65 | auto currentIndex = index(rowIndex, 0); | ||
66 | allTracks.push_back(ElisaUtils::EntryData{data(currentIndex, DatabaseInterface::ColumnsRoles::DatabaseIdRole).toULongLong(), | 66 | allTracks.push_back(ElisaUtils::EntryData{data(currentIndex, DataTypes::ColumnsRoles::DatabaseIdRole).toULongLong(), | ||
67 | data(currentIndex, DatabaseInterface::ColumnsRoles::TitleRole).toString()}); | 67 | data(currentIndex, DataTypes::ColumnsRoles::TitleRole).toString()}); | ||
68 | } | 68 | } | ||
69 | Q_EMIT entriesToEnqueue(allTracks, ElisaUtils::Track, enqueueMode, triggerPlay); | 69 | Q_EMIT entriesToEnqueue(allTracks, ElisaUtils::Track, enqueueMode, triggerPlay); | ||
70 | }); | 70 | }); | ||
71 | } | 71 | } | ||
72 | 72 | | |||
73 | void AllTracksProxyModel::enqueueToPlayList() | 73 | void AllTracksProxyModel::enqueueToPlayList() | ||
74 | { | 74 | { | ||
75 | genericEnqueueToPlayList(ElisaUtils::AppendPlayList, ElisaUtils::DoNotTriggerPlay); | 75 | genericEnqueueToPlayList(ElisaUtils::AppendPlayList, ElisaUtils::DoNotTriggerPlay); | ||
Show All 9 Lines |