qt: medialib: define a super-type for list items
[vlc.git] / modules / gui / qt / medialibrary / mlgenre.hpp
blob8f47e631cd8da2b9852a290c745bcf1f1db8ab8f
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 MLGENRE_HPP
20 #define MLGENRE_HPP
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 #include "vlc_common.h"
27 #include <memory>
28 #include <QObject>
29 #include <QString>
30 #include <QList>
31 #include <QRunnable>
32 #include <vlc_media_library.h>
33 #include "mlhelper.hpp"
34 #include "mlqmltypes.hpp"
36 class MLGenre : public QObject, public MLItem
38 Q_OBJECT
40 Q_PROPERTY(MLItemId id READ getId CONSTANT)
41 Q_PROPERTY(QString name READ getName CONSTANT)
42 Q_PROPERTY(unsigned int nbtracks READ getNbTracks CONSTANT)
43 Q_PROPERTY(QString cover READ getCover WRITE setCover NOTIFY coverChanged)
45 public:
46 MLGenre( vlc_medialibrary_t* _ml, const vlc_ml_genre_t *_data, QObject *_parent = nullptr);
47 ~MLGenre();
49 QString getName() const;
50 unsigned int getNbTracks() const;
51 QString getCover() const;
53 MLGenre* clone(QObject *parent = nullptr) const;
55 signals:
56 void coverChanged( const QString );
57 void askGenerateCover( QPrivateSignal ) const;
59 public slots:
60 void setCover(const QString cover);
62 private slots:
63 void generateThumbnail();
65 private:
66 MLGenre( const MLGenre& genre, QObject *_parent = nullptr);
68 vlc_medialibrary_t* m_ml;
70 QString m_name;
71 QString m_cover;
72 QRunnable* m_coverTask = nullptr;
73 unsigned int m_nbTracks;
76 #endif