[vlc-devel] [PATCH 7/9] qt: medialibrary: Move MsToString helper to mlhelper

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Jun 18 17:40:21 CEST 2020


---
 modules/gui/qt/Makefile.am               |  1 +
 modules/gui/qt/medialibrary/mlhelper.cpp | 40 ++++++++++++++++++++++++
 modules/gui/qt/medialibrary/mlhelper.hpp |  2 ++
 modules/gui/qt/medialibrary/mlvideo.cpp  | 24 --------------
 4 files changed, 43 insertions(+), 24 deletions(-)
 create mode 100644 modules/gui/qt/medialibrary/mlhelper.cpp

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 58082e5439..800b96b633 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -146,6 +146,7 @@ libqt_plugin_la_SOURCES = \
 	gui/qt/medialibrary/mlgenre.hpp \
 	gui/qt/medialibrary/mlgenremodel.cpp \
 	gui/qt/medialibrary/mlgenremodel.hpp \
+	gui/qt/medialibrary/mlhelper.cpp \
 	gui/qt/medialibrary/mlhelper.hpp \
 	gui/qt/medialibrary/mlqmltypes.hpp \
 	gui/qt/medialibrary/mlrecentsvideomodel.cpp \
diff --git a/modules/gui/qt/medialibrary/mlhelper.cpp b/modules/gui/qt/medialibrary/mlhelper.cpp
new file mode 100644
index 0000000000..4bfa3b0101
--- /dev/null
+++ b/modules/gui/qt/medialibrary/mlhelper.cpp
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "mlhelper.hpp"
+
+QString MsToString( int64_t time )
+{
+    if (time < 0)
+        return "--:--";
+
+    int t_sec = time / 1000;
+    int sec = t_sec % 60;
+    int min = (t_sec / 60) % 60;
+    int hour = t_sec / 3600;
+    if (hour == 0)
+        return QString("%1:%2")
+                .arg(min, 2, 10, QChar('0'))
+                .arg(sec, 2, 10, QChar('0'));
+    else
+        return QString("%1:%2:%3")
+                .arg(hour, 2, 10, QChar('0'))
+                .arg(min, 2, 10, QChar('0'))
+                .arg(sec, 2, 10, QChar('0'));
+
+}
diff --git a/modules/gui/qt/medialibrary/mlhelper.hpp b/modules/gui/qt/medialibrary/mlhelper.hpp
index e4369b2795..778418df08 100644
--- a/modules/gui/qt/medialibrary/mlhelper.hpp
+++ b/modules/gui/qt/medialibrary/mlhelper.hpp
@@ -26,6 +26,7 @@
 #endif
 
 #include "vlc_media_library.h"
+#include <QString>
 
 template<typename T>
 class MLDeleter
@@ -70,5 +71,6 @@ MLListRange<T> ml_range_iterate(L& list)
     return MLListRange<T>{ list->p_items, list->p_items + list->i_nb_items };
 }
 
+QString MsToString( int64_t time );
 
 #endif // MLHELPER_HPP
diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp b/modules/gui/qt/medialibrary/mlvideo.cpp
index a4452aac51..1308e05b33 100644
--- a/modules/gui/qt/medialibrary/mlvideo.cpp
+++ b/modules/gui/qt/medialibrary/mlvideo.cpp
@@ -22,30 +22,6 @@
 
 #include <vlc_thumbnailer.h>
 
-namespace
-{
-QString MsToString( int64_t time )
-{
-    if (time < 0)
-        return "--:--";
-
-    int t_sec = time / 1000;
-    int sec = t_sec % 60;
-    int min = (t_sec / 60) % 60;
-    int hour = t_sec / 3600;
-    if (hour == 0)
-        return QString("%1:%2")
-                .arg(min, 2, 10, QChar('0'))
-                .arg(sec, 2, 10, QChar('0'));
-    else
-        return QString("%1:%2:%3")
-                .arg(hour, 2, 10, QChar('0'))
-                .arg(min, 2, 10, QChar('0'))
-                .arg(sec, 2, 10, QChar('0'));
-
-}
-}
-
 MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data, QObject* parent)
     : QObject( parent )
     , m_ml( ml )
-- 
2.20.1



More information about the vlc-devel mailing list