[vlc-commits] Qt: add QVLCVariable::addCallback helper

Rémi Denis-Courmont git at videolan.org
Tue Apr 17 18:42:57 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 17 19:42:02 2012 +0300| [0166bb73bc91d6474f6da84d9203e5c77ae07289] | committer: Rémi Denis-Courmont

Qt: add QVLCVariable::addCallback helper

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

 modules/gui/qt4/variables.cpp |   29 +++++++++++++++++++++++++++++
 modules/gui/qt4/variables.hpp |   10 ++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/modules/gui/qt4/variables.cpp b/modules/gui/qt4/variables.cpp
index 23aef37..e0270d3 100644
--- a/modules/gui/qt4/variables.cpp
+++ b/modules/gui/qt4/variables.cpp
@@ -67,6 +67,11 @@ void QVLCPointer::trigger (vlc_value_t, vlc_value_t cur)
     emit pointerChanged (cur.p_address);
 }
 
+bool QVLCPointer::addCallback (QObject *tgt, const char *method,
+                               Qt::ConnectionType type)
+{
+    return tgt->connect (this, SIGNAL(pointerChanged(void *)), method, type);
+}
 
 QVLCInteger::QVLCInteger (vlc_object_t *obj, const char *varname, bool inherit)
     : QVLCVariable (obj, varname, VLC_VAR_INTEGER, inherit)
@@ -78,6 +83,12 @@ void QVLCInteger::trigger (vlc_value_t, vlc_value_t cur)
     emit integerChanged (cur.i_int);
 }
 
+bool QVLCInteger::addCallback (QObject *tgt, const char *method,
+                               Qt::ConnectionType type)
+{
+    return tgt->connect (this, SIGNAL(integerChanged(int64_t)), method, type);
+}
+
 QVLCBool::QVLCBool (vlc_object_t *obj, const char *varname, bool inherit)
     : QVLCVariable (obj, varname, VLC_VAR_BOOL, inherit)
 {
@@ -88,6 +99,12 @@ void QVLCBool::trigger (vlc_value_t, vlc_value_t cur)
     emit boolChanged (cur.b_bool);
 }
 
+bool QVLCBool::addCallback (QObject *tgt, const char *method,
+                            Qt::ConnectionType type)
+{
+    return tgt->connect (this, SIGNAL(boolChanged(bool)), method, type);
+}
+
 QVLCFloat::QVLCFloat (vlc_object_t *obj, const char *varname, bool inherit)
     : QVLCVariable (obj, varname, VLC_VAR_FLOAT, inherit)
 {
@@ -98,6 +115,12 @@ void QVLCFloat::trigger (vlc_value_t, vlc_value_t cur)
     emit floatChanged (cur.f_float);
 }
 
+bool QVLCFloat::addCallback (QObject *tgt, const char *method,
+                            Qt::ConnectionType type)
+{
+    return tgt->connect (this, SIGNAL(floatChanged(float)), method, type);
+}
+
 QVLCString::QVLCString (vlc_object_t *obj, const char *varname, bool inherit)
     : QVLCVariable (obj, varname, VLC_VAR_STRING, inherit)
 {
@@ -108,3 +131,9 @@ void QVLCString::trigger (vlc_value_t, vlc_value_t cur)
     QString str = qfu(cur.psz_string);
     emit stringChanged (str);
 }
+
+bool QVLCString::addCallback (QObject *tgt, const char *method,
+                              Qt::ConnectionType type)
+{
+    return tgt->connect (this, SIGNAL(stringChanged(QString)), method, type);
+}
diff --git a/modules/gui/qt4/variables.hpp b/modules/gui/qt4/variables.hpp
index 84f05b1..096048e 100644
--- a/modules/gui/qt4/variables.hpp
+++ b/modules/gui/qt4/variables.hpp
@@ -51,6 +51,8 @@ private:
 
 public:
     QVLCPointer (vlc_object_t *, const char *, bool inherit = false);
+    bool addCallback (QObject *, const char *,
+                      Qt::ConnectionType type = Qt::AutoConnection);
 
 signals:
     void pointerChanged (void *);
@@ -64,6 +66,8 @@ private:
 
 public:
     QVLCInteger (vlc_object_t *, const char *, bool inherit = false);
+    bool addCallback (QObject *, const char *,
+                      Qt::ConnectionType type = Qt::AutoConnection);
 
 signals:
     void integerChanged (int64_t);
@@ -77,6 +81,8 @@ private:
 
 public:
     QVLCBool (vlc_object_t *, const char *, bool inherit = false);
+    bool addCallback (QObject *, const char *,
+                      Qt::ConnectionType type = Qt::AutoConnection);
 
 signals:
     void boolChanged (bool);
@@ -90,6 +96,8 @@ private:
 
 public:
     QVLCFloat (vlc_object_t *, const char *, bool inherit = false);
+    bool addCallback (QObject *, const char *,
+                      Qt::ConnectionType type = Qt::AutoConnection);
 
 signals:
     void floatChanged (float);
@@ -103,6 +111,8 @@ private:
 
 public:
     QVLCString (vlc_object_t *, const char *, bool inherit = false);
+    bool addCallback (QObject *, const char *,
+                      Qt::ConnectionType type = Qt::AutoConnection);
 
 signals:
     void stringChanged (QString);



More information about the vlc-commits mailing list