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 *****************************************************************************/
19 #ifndef MLNetworkSourcesModel_HPP
20 #define MLNetworkSourcesModel_HPP
26 #include <QAbstractListModel>
28 #include <vlc_media_library.h>
29 #include <vlc_media_source.h>
30 #include <vlc_threads.h>
31 #include <vlc_cxx_helpers.hpp>
33 #include <util/qml_main_context.hpp>
34 #include "networksourcelistener.hpp"
38 class NetworkSourcesModel
: public QAbstractListModel
42 Q_PROPERTY(QmlMainContext
* ctx READ getCtx WRITE setCtx NOTIFY ctxChanged
)
43 Q_PROPERTY(int count READ getCount NOTIFY countChanged
)
47 SOURCE_NAME
= Qt::UserRole
+ 1,
55 TYPE_DUMMY
= -1, // provided for UI for entry "Add a service"
60 NetworkSourcesModel( QObject
* parent
= nullptr );
62 QVariant
data(const QModelIndex
& index
, int role
) const override
;
63 QHash
<int, QByteArray
> roleNames() const override
;
64 int rowCount(const QModelIndex
& parent
= {}) const override
;
66 void setCtx(QmlMainContext
* ctx
);
68 inline QmlMainContext
* getCtx() { return m_ctx
; }
72 Q_INVOKABLE QMap
<QString
, QVariant
> getDataAt(int index
);
86 bool initializeMediaSources();
89 std::vector
<Item
> m_items
;
90 QmlMainContext
* m_ctx
= nullptr;
91 vlc_medialibrary_t
* m_ml
= nullptr;
92 services_discovery_category_e m_sdSource
= services_discovery_category_e::SD_CAT_INTERNET
;
95 #endif // MLNetworkSourcesModel_HPP