[vlc-commits] commit: Qt/ML: VLC Model (Srikanth Raju )

git at videolan.org git at videolan.org
Sun Jan 9 19:53:10 CET 2011


vlc | branch: master | Srikanth Raju <srikiraju at gmail.com> | Wed Dec 29 19:47:50 2010 +0530| [e51eb917d6dc82245164c51857562755f40c1e31] | committer: Srikanth Raju 

Qt/ML: VLC Model

Base parent model for playlist

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

 modules/gui/qt4/Modules.am                        |    3 +
 modules/gui/qt4/components/playlist/vlc_model.cpp |   33 ++++++++
 modules/gui/qt4/components/playlist/vlc_model.hpp |   92 +++++++++++++++++++++
 3 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am
index 6a20402..5ed7332 100644
--- a/modules/gui/qt4/Modules.am
+++ b/modules/gui/qt4/Modules.am
@@ -59,6 +59,7 @@ nodist_SOURCES_qt4 = \
 		components/epg/EPGView.moc.cpp \
 		components/epg/EPGWidget.moc.cpp \
 		components/playlist/views.moc.cpp \
+		components/playlist/vlc_model.moc.cpp \
 		components/playlist/playlist_model.moc.cpp \
 		components/playlist/playlist.moc.cpp \
 		components/playlist/standardpanel.moc.cpp \
@@ -275,6 +276,7 @@ SOURCES_qt4 = 	qt4.cpp \
 		components/epg/EPGView.cpp \
 		components/epg/EPGWidget.cpp \
 		components/playlist/views.cpp \
+		components/playlist/vlc_model.cpp \
 		components/playlist/playlist_model.cpp \
 		components/playlist/playlist_item.cpp \
 		components/playlist/standardpanel.cpp \
@@ -341,6 +343,7 @@ noinst_HEADERS = \
 	components/epg/EPGView.hpp \
 	components/epg/EPGWidget.hpp \
 	components/playlist/views.hpp \
+	components/playlist/vlc_model.hpp \
 	components/playlist/playlist_model.hpp \
 	components/playlist/playlist_item.hpp \
 	components/playlist/standardpanel.hpp \
diff --git a/modules/gui/qt4/components/playlist/vlc_model.cpp b/modules/gui/qt4/components/playlist/vlc_model.cpp
new file mode 100644
index 0000000..04d0ac0
--- /dev/null
+++ b/modules/gui/qt4/components/playlist/vlc_model.cpp
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * vlc_model.cpp : base for playlist and ml model
+ ****************************************************************************
+ * Copyright (C) 2010 the VideoLAN team and AUTHORS
+ * $Id$
+ *
+ * Authors: Srikanth Raju <srikiraju#gmail#com>
+ *
+ * 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 "vlc_model.hpp"
+
+VLCModel::VLCModel( intf_thread_t *_p_intf, QObject *parent )
+        : p_intf(_p_intf), QAbstractItemModel( parent )
+{
+}
+
+VLCModel::~VLCModel()
+{
+}
diff --git a/modules/gui/qt4/components/playlist/vlc_model.hpp b/modules/gui/qt4/components/playlist/vlc_model.hpp
new file mode 100644
index 0000000..9f4a904
--- /dev/null
+++ b/modules/gui/qt4/components/playlist/vlc_model.hpp
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * vlc_model.hpp : base for playlist and ml model
+ ****************************************************************************
+ * Copyright (C) 2010 the VideoLAN team and AUTHORS
+ * $Id$
+ *
+ * Authors: Srikanth Raju <srikiraju#gmail#com>
+ *
+ * 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.
+ *****************************************************************************/
+
+#ifndef _VLC_MODEL_H_
+#define _VLC_MODEL_H_
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "qt4.hpp"
+#include "sorting.h"
+
+#include <vlc_input.h>
+
+#include <QModelIndex>
+#include <QAbstractItemModel>
+
+
+class VLCModel : public QAbstractItemModel
+{
+    Q_OBJECT
+public:
+    enum {
+      IsCurrentRole = Qt::UserRole,
+      IsLeafNodeRole,
+      IsCurrentsParentNodeRole
+    };
+
+    VLCModel( intf_thread_t *_p_intf, QObject *parent = 0 );
+    virtual int getId( QModelIndex index ) const = 0;
+    virtual QModelIndex currentIndex() const = 0;
+    virtual bool popup( const QModelIndex & index,
+            const QPoint &point, const QModelIndexList &list ) = 0;
+    virtual ~VLCModel();
+
+public slots:
+    virtual void activateItem( const QModelIndex &index ) = 0;
+
+protected:
+    intf_thread_t *p_intf;
+};
+
+static int columnToMeta( int _column )
+{
+    int meta = 1;
+    int column = 0;
+
+    while( column != _column && meta != COLUMN_END )
+    {
+        meta <<= 1;
+        column++;
+    }
+
+    return meta;
+}
+
+static int columnFromMeta( int meta_col )
+{
+    int meta = 1;
+    int column = 0;
+
+    while( meta != meta_col && meta != COLUMN_END )
+    {
+        meta <<= 1;
+        column++;
+    }
+
+    return column;
+}
+
+#endif



More information about the vlc-commits mailing list