[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt/networkmediamodel: Add file 'size' and 'modified' roles
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Jul 24 17:23:20 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
02f8badc by Benjamin Arnaud at 2022-07-24T17:08:36+00:00
qt/networkmediamodel: Add file 'size' and 'modified' roles
- - - - -
5ec8be6c by Benjamin Arnaud at 2022-07-24T17:08:36+00:00
qml/NetworkBrowseDisplay: Add file 'size' and 'modified' sorting criterias
- - - - -
3 changed files:
- modules/gui/qt/network/networkmediamodel.cpp
- modules/gui/qt/network/networkmediamodel.hpp
- modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
Changes:
=====================================
modules/gui/qt/network/networkmediamodel.cpp
=====================================
@@ -73,6 +73,10 @@ QVariant NetworkMediaModel::data( const QModelIndex& index, int role ) const
return item.mediaSource->description;
case NETWORK_ARTWORK:
return item.artworkUrl;
+ case NETWORK_FILE_SIZE:
+ return item.fileSize;
+ case NETWORK_FILE_MODIFIED:
+ return item.fileModified;
default:
return {};
}
@@ -90,6 +94,8 @@ QHash<int, QByteArray> NetworkMediaModel::roleNames() const
{ NETWORK_TREE, "tree" },
{ NETWORK_SOURCE, "source" },
{ NETWORK_ARTWORK, "artwork" },
+ { NETWORK_FILE_SIZE, "fileSizeRaw64" },
+ { NETWORK_FILE_MODIFIED, "fileModified" }
};
}
@@ -567,11 +573,37 @@ void NetworkMediaModel::refreshMediaList( MediaSourcePtr mediaSource,
item.canBeIndexed = canBeIndexed( item.mainMrl , item.type );
item.mediaSource = mediaSource;
- char* artwork = input_item_GetArtworkURL(it.get());
- if (artwork)
+ input_item_t * inputItem = it.get();
+
+ char * str = input_item_GetArtworkURL(inputItem);
+
+ if (str)
{
- item.artworkUrl = QUrl::fromEncoded(artwork);
- free(artwork);
+ item.artworkUrl = QUrl::fromEncoded(str);
+ free(str);
+ }
+
+ str = input_item_GetInfo(inputItem, ".stat", "size");
+
+ if (str)
+ {
+ item.fileSize = QString(str).toLongLong();
+ free(str);
+ }
+ else
+ item.fileSize = 0;
+
+ str = input_item_GetInfo(inputItem, ".stat", "mtime");
+
+ if (str)
+ {
+ bool ok;
+
+ qint64 time = QString(str).toLongLong(&ok);
+ free(str);
+
+ if (ok)
+ item.fileModified = QDateTime::fromSecsSinceEpoch(time);
}
if ( m_mediaLib && item.canBeIndexed == true )
=====================================
modules/gui/qt/network/networkmediamodel.hpp
=====================================
@@ -34,6 +34,7 @@
#include <maininterface/mainctx.hpp>
#include <QSemaphore>
+#include <QDateTime>
#include <memory>
@@ -116,6 +117,8 @@ public:
NETWORK_TREE,
NETWORK_SOURCE,
NETWORK_ARTWORK,
+ NETWORK_FILE_SIZE,
+ NETWORK_FILE_MODIFIED,
};
enum ItemType{
@@ -209,9 +212,10 @@ private:
NetworkTreeItem tree;
MediaSourcePtr mediaSource;
QUrl artworkUrl;
+ qint64 fileSize;
+ QDateTime fileModified;
};
-
bool initializeMediaSources();
void onItemCleared( MediaSourcePtr mediaSource, input_item_node_t* node ) override;
void onItemAdded( MediaSourcePtr mediaSource, input_item_node_t* parent, input_item_node_t *const children[], size_t count ) override;
=====================================
modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
=====================================
@@ -42,7 +42,9 @@ FocusScope {
property var initialIndex: 0
property var sortModel: [
{ text: I18n.qtr("Alphabetic"), criteria: "name"},
- { text: I18n.qtr("Url"), criteria: "mrl" }
+ { text: I18n.qtr("Url"), criteria: "mrl" },
+ { text: I18n.qtr("File size"), criteria: "fileSizeRaw64" },
+ { text: I18n.qtr("File modified"), criteria: "fileModified" }
]
property alias _currentView: view.currentItem
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f25ac47e0f468897438287b06869adf2555ad506...5ec8be6cac3e563d83b7bd6b80a488972dec7f30
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f25ac47e0f468897438287b06869adf2555ad506...5ec8be6cac3e563d83b7bd6b80a488972dec7f30
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list