vlc | branch: master | Hugo Beauzée-Luyssen <[email protected]> | Thu Mar 12 13:51:08 2020 +0100| [65bcc592852f3b616137571fd567e559a86eacdc] | committer: Hugo Beauzée-Luyssen
qt: medialibrary: Move MsToString helper to mlhelper > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=65bcc592852f3b616137571fd567e559a86eacdc --- modules/gui/qt/Makefile.am | 1 + modules/gui/qt/medialibrary/mlhelper.cpp | 44 ++++++++++++++++++++++++++++++++ modules/gui/qt/medialibrary/mlhelper.hpp | 2 ++ modules/gui/qt/medialibrary/mlvideo.cpp | 28 -------------------- 4 files changed, 47 insertions(+), 28 deletions(-) diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am index f804bcbd6a..8ec393460c 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..b3a216b5d4 --- /dev/null +++ b/modules/gui/qt/medialibrary/mlhelper.cpp @@ -0,0 +1,44 @@ +/***************************************************************************** + * 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 , bool doShort ) +{ + 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 if ( doShort ) + return QString("%1h%2") + .arg(hour) + .arg(min, 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..df84d2b2a1 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, bool doShort = false ); #endif // MLHELPER_HPP diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp b/modules/gui/qt/medialibrary/mlvideo.cpp index 8dbe58bb74..075bc2adc0 100644 --- a/modules/gui/qt/medialibrary/mlvideo.cpp +++ b/modules/gui/qt/medialibrary/mlvideo.cpp @@ -22,34 +22,6 @@ #include <vlc_thumbnailer.h> -namespace -{ -QString MsToString( int64_t time , bool doShort = false ) -{ - 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 if ( doShort ) - return QString("%1h%2") - .arg(hour) - .arg(min, 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 ) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
