qt: notify dataChanged when a thumbnail is updated from the medialibrary
[vlc.git] / modules / gui / qt / medialibrary / mlgenremodel.hpp
blob2b171e5b428fdfcd705991b8410d74b5e4dca904
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 MLGENREMODEL_HPP
20 #define MLGENREMODEL_HPP
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
26 #include <memory>
27 #include <QObject>
28 #include "mlbasemodel.hpp"
29 #include "mlgenre.hpp"
31 class MLGenreModel : public MLSlidingWindowModel<MLGenre>
33 Q_OBJECT
35 public:
36 explicit MLGenreModel(QObject *parent = nullptr);
37 virtual ~MLGenreModel() = default;
39 QHash<int, QByteArray> roleNames() const override;
40 QVariant data(const QModelIndex &index, int role) const override;
42 private:
43 std::vector<std::unique_ptr<MLGenre>> fetch() override;
44 size_t countTotalElements() const override;
45 void onVlcMlEvent(const vlc_ml_event_t* event) override;
46 void thumbnailUpdated(int idx) override;
47 vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
48 vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
51 static QHash<QByteArray, vlc_ml_sorting_criteria_t> M_names_to_criteria;
55 #endif // MLGENREMODEL_HPP