[vlc-commits] qt: add sd_source property to networkModel
Abel Tesfaye
git at videolan.org
Wed Aug 21 15:09:02 CEST 2019
vlc | branch: master | Abel Tesfaye <Abeltesfaye45 at gmail.com> | Mon Aug 19 17:19:21 2019 +0300| [eedb771cee1feb32de5a1313b037165f5ddc1c8f] | committer: Jean-Baptiste Kempf
qt: add sd_source property to networkModel
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eedb771cee1feb32de5a1313b037165f5ddc1c8f
---
.../qt/components/mediacenter/mlnetworkmodel.cpp | 27 +++++++++++++++++-----
.../qt/components/mediacenter/mlnetworkmodel.hpp | 18 +++++++++++----
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/modules/gui/qt/components/mediacenter/mlnetworkmodel.cpp b/modules/gui/qt/components/mediacenter/mlnetworkmodel.cpp
index c780e6637d..5dc85bde9e 100644
--- a/modules/gui/qt/components/mediacenter/mlnetworkmodel.cpp
+++ b/modules/gui/qt/components/mediacenter/mlnetworkmodel.cpp
@@ -148,6 +148,13 @@ void MLNetworkModel::setIsOnProviderList(bool b)
emit isOnProviderListChanged();
}
+void MLNetworkModel::setSdSource(QString s)
+{
+ beginResetModel();
+ m_sdSource = s;
+ emit sdSourceChanged();
+ endResetModel();
+}
bool MLNetworkModel::initializeMediaSources()
{
@@ -168,7 +175,16 @@ bool MLNetworkModel::initializeMediaSources()
using SourceMetaPtr = std::unique_ptr<vlc_media_source_meta_list_t,
decltype( &vlc_media_source_meta_list_Delete )>;
- SourceMetaPtr providerList( vlc_media_source_provider_List( provider, SD_CAT_LAN ),
+
+ services_discovery_category_e cat = SD_CAT_LAN;
+ if ( m_sdSource == "SD_CAT_DEVICES" )
+ cat = SD_CAT_DEVICES;
+ else if ( m_sdSource == "SD_CAT_MYCOMPUTER" )
+ cat = SD_CAT_MYCOMPUTER;
+ else if ( m_sdSource == "SD_CAT_INTERNET" )
+ cat = SD_CAT_INTERNET;
+
+ SourceMetaPtr providerList( vlc_media_source_provider_List( provider, cat ),
&vlc_media_source_meta_list_Delete );
if ( providerList == nullptr )
return false;
@@ -276,9 +292,8 @@ void MLNetworkModel::refreshMediaList( MediaSourcePtr mediaSource,
item.name = it->psz_name;
item.protocol = "";
item.indexed = false;
- item.type = (it->i_type == ITEM_TYPE_DIRECTORY || it->i_type == ITEM_TYPE_NODE) ?
- TYPE_DIR : TYPE_FILE;
- item.mainMrl = item.type == TYPE_DIR ?
+ item.type = static_cast<ItemType>(it->i_type);
+ item.mainMrl = (item.type == TYPE_DIRECTORY || item.type == TYPE_NODE) ?
QUrl::fromEncoded(QByteArray(it->psz_uri).append('/')) :
QUrl::fromEncoded(it->psz_uri);
@@ -330,7 +345,7 @@ void MLNetworkModel::refreshDeviceList( MediaSourcePtr mediaSource, input_item_n
item.name = qfu(children[i]->p_item->psz_name);
item.mrls.push_back( item.mainMrl );
item.indexed = false;
- item.type = TYPE_SHARE;
+ item.type = static_cast<ItemType>( children[i]->p_item->i_type );
item.canBeIndexed = canBeIndexed( item.mainMrl , item.type );
item.protocol = item.mainMrl.scheme();
item.tree = NetworkTreeItem{ mediaSource,
@@ -403,5 +418,5 @@ void MLNetworkModel::SourceListener::onItemRemoved( vlc_media_tree_t *, input_it
bool MLNetworkModel::canBeIndexed(const QUrl& url , ItemType itemType )
{
- return itemType != TYPE_FILE && (url.scheme() == "smb" || url.scheme() == "ftp");
+ return itemType != ITEM_TYPE_FILE && (url.scheme() == "smb" || url.scheme() == "ftp");
}
diff --git a/modules/gui/qt/components/mediacenter/mlnetworkmodel.hpp b/modules/gui/qt/components/mediacenter/mlnetworkmodel.hpp
index c41ae0ef0f..a2ffc15d03 100644
--- a/modules/gui/qt/components/mediacenter/mlnetworkmodel.hpp
+++ b/modules/gui/qt/components/mediacenter/mlnetworkmodel.hpp
@@ -67,17 +67,23 @@ class MLNetworkModel : public QAbstractListModel
Q_OBJECT
public:
- enum ItemType
- {
- TYPE_SHARE,
- TYPE_DIR,
+ enum ItemType{
+ // qt version of input_item_type_e
+ TYPE_UNKNOWN = ITEM_TYPE_UNKNOWN,
TYPE_FILE,
+ TYPE_DIRECTORY,
+ TYPE_DISC,
+ TYPE_CARD,
+ TYPE_STREAM,
+ TYPE_PLAYLIST,
+ TYPE_NODE,
};
Q_ENUM( ItemType );
Q_PROPERTY(QmlMainContext* ctx READ getCtx WRITE setCtx NOTIFY ctxChanged)
Q_PROPERTY(QVariant tree READ getTree WRITE setTree NOTIFY treeChanged)
Q_PROPERTY(bool is_on_provider_list READ getIsOnProviderList WRITE setIsOnProviderList NOTIFY isOnProviderListChanged)
+ Q_PROPERTY(QString sd_source READ getSdSource WRITE setSdSource NOTIFY sdSourceChanged)
explicit MLNetworkModel(QObject* parent = nullptr);
MLNetworkModel( QmlMainContext* ctx, QString parentMrl, QObject* parent = nullptr );
@@ -92,15 +98,18 @@ public:
void setCtx(QmlMainContext* ctx);
void setTree(QVariant tree);
void setIsOnProviderList(bool b);
+ void setSdSource(QString s);
inline QmlMainContext* getCtx() { return m_ctx; }
inline QVariant getTree() { return QVariant::fromValue( m_treeItem); }
inline bool getIsOnProviderList() { return m_isOnProviderList; }
+ inline QString getSdSource() { return m_sdSource; }
signals:
void ctxChanged();
void treeChanged();
void isOnProviderListChanged();
+ void sdSourceChanged();
private:
struct Item
@@ -173,6 +182,7 @@ private:
bool m_hasTree = false;
NetworkTreeItem m_treeItem;
bool m_isOnProviderList;
+ QString m_sdSource;
std::vector<std::unique_ptr<SourceListener>> m_listeners;
};
More information about the vlc-commits
mailing list