[vlc-devel] [PATCH 16/18] qml: move isValidInstanceOf function in Helpers
Prince Gupta
guptaprince8832 at gmail.com
Thu Apr 1 14:29:51 UTC 2021
---
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml | 10 +++-------
modules/gui/qt/playlist/qml/PlaylistListView.qml | 9 +++------
modules/gui/qt/util/qml/Helpers.js | 4 ++++
3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/modules/gui/qt/medialibrary/qml/PlaylistMedia.qml b/modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
index 2adc81938a..2224e64e22 100644
--- a/modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
+++ b/modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
@@ -24,6 +24,7 @@ import org.videolan.medialib 0.1
import "qrc:///widgets/" as Widgets
import "qrc:///main/" as MainInterface
+import "qrc:///util/Helpers.js" as Helpers
import "qrc:///style/"
MainInterface.MainTableView {
@@ -101,14 +102,9 @@ MainInterface.MainTableView {
//---------------------------------------------------------------------------------------------
// Drop interface
- // FIXME: Maybe this could be a global function ?
- function isValidInstanceOf(object, type) {
- return (!!object && (object instanceof type));
- }
-
function isDroppable(drop, index) {
// NOTE: Internal drop (intra-playlist).
- return isValidInstanceOf(drop.source, Widgets.DragItem);
+ return Helpers.isValidInstanceOf(drop.source, Widgets.DragItem);
}
function applyDrop(drop, index) {
@@ -119,7 +115,7 @@ MainInterface.MainTableView {
model.move(modelSelect.selectedIndexes, index);
// NOTE: Dropping medialibrary content into the playlist.
- } else if (isValidInstanceOf(item, Widgets.DragItem)) {
+ } else if (Helpers.isValidInstanceOf(item, Widgets.DragItem)) {
model.insert(item.getSelectedInputItem(), index);
}
diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index 9b1840422e..0a99057b0a 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -25,6 +25,7 @@ import org.videolan.vlc 0.1
import "qrc:///widgets/" as Widgets
import "qrc:///util/KeyHelper.js" as KeyHelper
+import "qrc:///util/Helpers.js" as Helpers
import "qrc:///style/"
Widgets.NavigableFocusScope {
@@ -48,13 +49,9 @@ Widgets.NavigableFocusScope {
Move // Keyboard item move mode, activated through PlaylistOverlayMenu
}
- function isValidInstanceOf(object, type) {
- return (!!object && (object instanceof type))
- }
-
function isDropAcceptable(drop, index) {
return drop.hasUrls || // external drop (i.e. from filesystem)
- (isValidInstanceOf(drop.source, Widgets.DragItem)) // internal drop (inter-view or intra-playlist)
+ (Helpers.isValidInstanceOf(drop.source, Widgets.DragItem)) // internal drop (inter-view or intra-playlist)
}
function acceptDrop(index, drop) {
@@ -65,7 +62,7 @@ Widgets.NavigableFocusScope {
model.moveItemsPre(model.getSelection(), index);
// NOTE: Dropping medialibrary content into the queue.
- } else if (isValidInstanceOf(item, Widgets.DragItem)) {
+ } else if (Helpers.isValidInstanceOf(item, Widgets.DragItem)) {
mainPlaylistController.insert(index, item.getSelectedInputItem());
// NOTE: Dropping an external item (i.e. filesystem) into the queue.
diff --git a/modules/gui/qt/util/qml/Helpers.js b/modules/gui/qt/util/qml/Helpers.js
index 80768d1c7e..d61211c3d9 100644
--- a/modules/gui/qt/util/qml/Helpers.js
+++ b/modules/gui/qt/util/qml/Helpers.js
@@ -40,3 +40,7 @@ function msToString(time, short) {
function clamp(num, min, max) {
return num <= min ? min : num >= max ? max : num;
}
+
+function isValidInstanceOf(object, type) {
+ return (!!object && (object instanceof type))
+}
--
2.27.0
More information about the vlc-devel
mailing list