1 /*****************************************************************************
2 * Copyright (C) 2020 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 *****************************************************************************/
27 #include "mlbasemodel.hpp"
29 #include <vlc_media_library.h>
30 #include "mlhelper.hpp"
31 #include "mlqmltypes.hpp"
33 class MLUrl
: public MLItem
{
35 MLUrl( const vlc_ml_media_t
*_data
);
37 MLUrl( const MLUrl
& url
);
39 QString
getUrl() const;
40 QString
getLastPlayedDate() const;
46 QString m_lastPlayedDate
;
49 class MLUrlModel
: public MLSlidingWindowModel
<MLUrl
>
55 URL_ID
= Qt::UserRole
+ 1,
61 explicit MLUrlModel(QObject
*parent
= nullptr);
63 virtual ~MLUrlModel() = default;
65 QVariant
data(const QModelIndex
&index
, int role
) const override
;
66 QHash
<int, QByteArray
> roleNames() const override
;
68 Q_INVOKABLE
void addAndPlay( const QString
& url
);
71 ListCacheLoader
<std::unique_ptr
<MLUrl
>> *createLoader() const override
;
74 vlc_ml_sorting_criteria_t
roleToCriteria(int role
) const override
;
75 virtual void onVlcMlEvent( const MLEvent
&event
) override
;
77 struct Loader
: public BaseLoader
79 Loader(const MLUrlModel
&model
) : BaseLoader(model
) {}
80 size_t count() const override
;
81 std::vector
<std::unique_ptr
<MLUrl
>> load(size_t index
, size_t count
) const override
;
85 #endif // MLURLMODEL_H