1 /*****************************************************************************
2 * Copyright (C) 2019 VLC authors and VideoLAN
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * ( at your option ) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17 *****************************************************************************/
19 #ifndef MLTRACKMODEL_HPP
20 #define MLTRACKMODEL_HPP
27 #include "mlbasemodel.hpp"
28 #include "mlalbumtrack.hpp"
31 class MLAlbumTrackModel
: public MLSlidingWindowModel
<MLAlbumTrack
>
37 TRACK_ID
= Qt::UserRole
+ 1,
47 TRACK_TITLE_FIRST_SYMBOL
,
48 TRACK_ALBUM_FIRST_SYMBOL
,
49 TRACK_ARTIST_FIRST_SYMBOL
,
53 explicit MLAlbumTrackModel(QObject
*parent
= nullptr);
55 virtual ~MLAlbumTrackModel() = default;
57 QVariant
data(const QModelIndex
&index
, int role
) const override
;
58 QHash
<int, QByteArray
> roleNames() const override
;
61 ListCacheLoader
<std::unique_ptr
<MLAlbumTrack
>> *createLoader() const override
;
64 vlc_ml_sorting_criteria_t
roleToCriteria(int role
) const override
;
65 vlc_ml_sorting_criteria_t
nameToCriteria(QByteArray name
) const override
;
66 QByteArray
criteriaToName(vlc_ml_sorting_criteria_t criteria
) const override
;
67 virtual void onVlcMlEvent( const MLEvent
&event
) override
;
69 static QHash
<QByteArray
, vlc_ml_sorting_criteria_t
> M_names_to_criteria
;
71 struct Loader
: public BaseLoader
73 Loader(const MLAlbumTrackModel
&model
) : BaseLoader(model
) {}
74 size_t count() const override
;
75 std::vector
<std::unique_ptr
<MLAlbumTrack
>> load(size_t index
, size_t count
) const override
;
78 #endif // MLTRACKMODEL_HPP