[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt: remove unnecessary Q_GADGET usage

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jul 21 14:14:11 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
61cf6f2a by Fatih Uzunoglu at 2023-07-21T13:52:39+00:00
qt: remove unnecessary Q_GADGET usage

- - - - -
7963aebc by Fatih Uzunoglu at 2023-07-21T13:52:39+00:00
qt: use default constructors in PlaylistPtr

- - - - -
8a4af365 by Fatih Uzunoglu at 2023-07-21T13:52:39+00:00
qt: remove playlist_common.cpp

- - - - -
7bd00edc by Fatih Uzunoglu at 2023-07-21T13:52:39+00:00
qt: rename PlaylistPtr to Playlist

- - - - -


10 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/meson.build
- − modules/gui/qt/playlist/playlist_common.cpp
- modules/gui/qt/playlist/playlist_common.hpp
- modules/gui/qt/playlist/playlist_controller.cpp
- modules/gui/qt/playlist/playlist_controller.hpp
- modules/gui/qt/playlist/playlist_model.cpp
- modules/gui/qt/playlist/playlist_model.hpp
- modules/gui/qt/playlist/qml/PlaylistListView.qml
- modules/gui/qt/qt.cpp


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -277,7 +277,6 @@ libqt_plugin_la_SOURCES = \
 	gui/qt/player/control_list_filter.cpp \
 	gui/qt/player/control_list_filter.hpp \
 	gui/qt/playlist/media.hpp \
-	gui/qt/playlist/playlist_common.cpp \
 	gui/qt/playlist/playlist_common.hpp \
 	gui/qt/playlist/playlist_controller.cpp \
 	gui/qt/playlist/playlist_controller.hpp \


=====================================
modules/gui/qt/meson.build
=====================================
@@ -390,7 +390,6 @@ some_sources = files(
     'player/control_list_filter.cpp',
     'player/control_list_filter.hpp',
     'playlist/media.hpp',
-    'playlist/playlist_common.cpp',
     'playlist/playlist_common.hpp',
     'playlist/playlist_controller.cpp',
     'playlist/playlist_controller.hpp',


=====================================
modules/gui/qt/playlist/playlist_common.cpp deleted
=====================================
@@ -1,45 +0,0 @@
-/*****************************************************************************
- * 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 "playlist_common.hpp"
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include <vlc_playlist.h>
-
-
-
-PlaylistPtr::PlaylistPtr()
-    : m_playlist(nullptr)
-{}
-
-PlaylistPtr::PlaylistPtr(vlc_playlist_t* pl)
-    : m_playlist(pl)
-{}
-
-PlaylistPtr::PlaylistPtr(const PlaylistPtr& ptr)
-    : m_playlist(ptr.m_playlist)
-{
-}
-
-PlaylistPtr&PlaylistPtr::operator=(const PlaylistPtr& ptr)
-{
-    this->m_playlist = ptr.m_playlist;
-    return *this;
-}


=====================================
modules/gui/qt/playlist/playlist_common.hpp
=====================================
@@ -24,17 +24,17 @@ extern "C" {
     typedef struct vlc_playlist vlc_playlist_t;
 }
 
-// QObject wrapper to carry playlist ptr through QML
-class PlaylistPtr
+class Playlist
 {
-    Q_GADGET
 public:
-    PlaylistPtr();
-    PlaylistPtr(vlc_playlist_t* pl);
-    PlaylistPtr(const PlaylistPtr& ptr);
-    PlaylistPtr& operator=(const PlaylistPtr& ptr);
+    Playlist() = default;
+    explicit Playlist(vlc_playlist_t * const playlist)
+        : m_playlist(playlist)
+    { };
 
-    vlc_playlist_t* m_playlist = nullptr;
+    vlc_playlist_t * m_playlist = nullptr;
 };
 
+Q_DECLARE_METATYPE(Playlist)
+
 #endif // PLAYLIST_COMMON_HPP


=====================================
modules/gui/qt/playlist/playlist_controller.cpp
=====================================
@@ -353,7 +353,7 @@ PlaylistController::PlaylistController(vlc_playlist_t *playlist, QObject *parent
     : QObject(parent)
     , d_ptr( new PlaylistControllerPrivate(this) )
 {
-    setPlaylistPtr(playlist);
+    setPlaylist(playlist);
 }
 
 PlaylistController::~PlaylistController()
@@ -672,13 +672,13 @@ void PlaylistController::setRandom(bool random)
     vlc_playlist_SetPlaybackOrder( d->m_playlist, random ? VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM : VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL );
 }
 
-PlaylistPtr PlaylistController::getPlaylistPtr() const
+Playlist PlaylistController::getPlaylist() const
 {
     Q_D(const PlaylistController);
-    return PlaylistPtr(d->m_playlist);
+    return Playlist(d->m_playlist);
 }
 
-void PlaylistController::setPlaylistPtr(vlc_playlist_t* newPlaylist)
+void PlaylistController::setPlaylist(vlc_playlist_t* newPlaylist)
 {
     Q_D(PlaylistController);
     if (d->m_playlist && d->m_listener)
@@ -703,7 +703,7 @@ void PlaylistController::setPlaylistPtr(vlc_playlist_t* newPlaylist)
             emit playlistInitialized();
         });
     }
-    emit playlistPtrChanged( PlaylistPtr(newPlaylist) );
+    emit playlistChanged( Playlist(newPlaylist) );
 }
 
 void PlaylistController::resetSortKey()
@@ -713,9 +713,9 @@ void PlaylistController::resetSortKey()
     emit sortKeyChanged();
 }
 
-void PlaylistController::setPlaylistPtr(PlaylistPtr ptr)
+void PlaylistController::setPlaylist(const Playlist& playlist)
 {
-    setPlaylistPtr(ptr.m_playlist);
+    setPlaylist(playlist.m_playlist);
 }
 
 PlaylistController::PlaybackRepeat PlaylistController::getRepeatMode() const


=====================================
modules/gui/qt/playlist/playlist_controller.hpp
=====================================
@@ -79,7 +79,7 @@ public:
 
     Q_PROPERTY(QVariantList sortKeyTitleList READ getSortKeyTitleList CONSTANT FINAL)
 
-    Q_PROPERTY(PlaylistPtr playlistPtr READ getPlaylistPtr WRITE setPlaylistPtr NOTIFY playlistPtrChanged FINAL)
+    Q_PROPERTY(Playlist playlist READ getPlaylist WRITE setPlaylist NOTIFY playlistChanged FINAL)
 
     Q_PROPERTY(PlaylistItem currentItem READ getCurrentItem NOTIFY currentItemChanged FINAL)
 
@@ -156,14 +156,14 @@ public slots:
     void switchSortOrder();
 
     QVariantList getSortKeyTitleList() const;
-    PlaylistPtr getPlaylistPtr() const;
-    void setPlaylistPtr(PlaylistPtr id);
-    void setPlaylistPtr(vlc_playlist_t* newPlaylist);
+    Playlist getPlaylist() const;
+    void setPlaylist(const Playlist& playlist);
+    void setPlaylist(vlc_playlist_t* newPlaylist);
 
     void resetSortKey();
 
 signals:
-    void playlistPtrChanged( PlaylistPtr );
+    void playlistChanged( Playlist );
 
     void currentItemChanged( );
 


=====================================
modules/gui/qt/playlist/playlist_model.cpp
=====================================
@@ -269,7 +269,7 @@ PlaylistListModel::PlaylistListModel(vlc_playlist_t *raw_playlist, QObject *pare
     : SelectableListModel(parent)
     , d_ptr(new PlaylistListModelPrivate(this))
 {
-    setPlaylistId(PlaylistPtr(raw_playlist));
+    setPlaylist(Playlist(raw_playlist));
 }
 
 PlaylistListModel::~PlaylistListModel()
@@ -449,15 +449,15 @@ QVariantList PlaylistListModel::getItemsForIndexes(const QList<int> & indexes) c
     return items;
 }
 
-PlaylistPtr PlaylistListModel::getPlaylistId() const
+Playlist PlaylistListModel::getPlaylist() const
 {
     Q_D(const PlaylistListModel);
     if (!d->m_playlist)
         return {};
-    return PlaylistPtr(d->m_playlist);
+    return Playlist(d->m_playlist);
 }
 
-void PlaylistListModel::setPlaylistId(vlc_playlist_t* playlist)
+void PlaylistListModel::setPlaylist(vlc_playlist_t* playlist)
 {
     Q_D(PlaylistListModel);
     if (d->m_playlist && d->m_listener)
@@ -473,12 +473,12 @@ void PlaylistListModel::setPlaylistId(vlc_playlist_t* playlist)
         d->m_playlist = playlist;
         d->m_listener = vlc_playlist_AddListener(d->m_playlist, &playlist_callbacks, d, true);
     }
-    emit playlistIdChanged( PlaylistPtr(d->m_playlist) );
+    emit playlistChanged( Playlist(d->m_playlist) );
 }
 
-void PlaylistListModel::setPlaylistId(PlaylistPtr id)
+void PlaylistListModel::setPlaylist(const Playlist& playlist)
 {
-    setPlaylistId(id.m_playlist);
+    setPlaylist(playlist.m_playlist);
 }
 
 QVariant


=====================================
modules/gui/qt/playlist/playlist_model.hpp
=====================================
@@ -35,7 +35,7 @@ class PlaylistListModelPrivate;
 class PlaylistListModel : public SelectableListModel
 {
     Q_OBJECT
-    Q_PROPERTY(PlaylistPtr playlistId READ getPlaylistId WRITE setPlaylistId NOTIFY playlistIdChanged FINAL)
+    Q_PROPERTY(Playlist playlist READ getPlaylist WRITE setPlaylist NOTIFY playlistChanged FINAL)
     Q_PROPERTY(int currentIndex READ getCurrentIndex NOTIFY currentIndexChanged FINAL)
     Q_PROPERTY(int count READ rowCount NOTIFY countChanged FINAL)
     Q_PROPERTY(VLCTick duration READ getDuration NOTIFY countChanged FINAL)
@@ -79,12 +79,12 @@ protected:
     int getSelectedRole() const override;
 
 public slots:
-    PlaylistPtr getPlaylistId() const;
-    void setPlaylistId(PlaylistPtr id);
-    void setPlaylistId(vlc_playlist_t* playlist);
+    Playlist getPlaylist() const;
+    void setPlaylist(const Playlist& playlist);
+    void setPlaylist(vlc_playlist_t* playlist);
 
 signals:
-    void playlistIdChanged(const PlaylistPtr& );
+    void playlistChanged(const Playlist&);
     void currentIndexChanged( int );
     void countChanged(int);
 


=====================================
modules/gui/qt/playlist/qml/PlaylistListView.qml
=====================================
@@ -277,7 +277,7 @@ Control {
             clip: true // else out of view items will overlap with surronding items
 
             model: PlaylistListModel {
-                playlistId: MainPlaylistController.playlistPtr
+                playlist: MainPlaylistController.playlist
             }
 
             dragAutoScrollDragItem: dragItem


=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -675,7 +675,7 @@ static inline void registerMetaTypes()
     qRegisterMetaType<VLCTick>();
     qRegisterMetaType<SharedInputItem>();
     qRegisterMetaType<NetworkTreeItem>();
-    qRegisterMetaType<PlaylistPtr>();
+    qRegisterMetaType<Playlist>();
     qRegisterMetaType<PlaylistItem>();
     qRegisterMetaType<DialogId>();
     qRegisterMetaType<MLItemId>();



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/21e9d4742052d96bc27f4a02ebb39c0ad7ae3e6d...7bd00edc0b7afcd975789251ff80b221b35e3c66

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/21e9d4742052d96bc27f4a02ebb39c0ad7ae3e6d...7bd00edc0b7afcd975789251ff80b221b35e3c66
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