[vlc-commits] qml: move isValidInstanceOf function in Helpers

Prince Gupta git at videolan.org
Tue Apr 6 13:12:11 UTC 2021


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Wed Mar 17 20:55:39 2021 +0530| [bfe351149560e7fd70416a78bee8cdcaaa1ba144] | committer: Pierre Lamot

qml: move isValidInstanceOf function in Helpers

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bfe351149560e7fd70416a78bee8cdcaaa1ba144
---

 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))
+}



More information about the vlc-commits mailing list