Qt: correctly display the right treeView columns
[vlc.git] / modules / gui / qt4 / variables.cpp
blob1200f194024918ec1b2ae16417a67f1f6b227fb8
1 /*****************************************************************************
2 * variables.cpp : VLC variable class
3 ****************************************************************************
4 * Copyright (C) 2009 RĂ©mi Denis-Courmont
5 * Copyright (C) 2006 the VideoLAN team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20 *****************************************************************************/
22 #ifdef HAVE_CONFIG_H
23 # include <config.h>
24 #endif
26 #include "qt4.hpp"
27 #include "variables.hpp"
29 QVLCVariable::QVLCVariable (vlc_object_t *obj, const char *varname, int type,
30 bool inherit)
31 : object (obj), name (qfu(varname))
33 vlc_object_hold (object);
35 if (inherit)
36 type |= VLC_VAR_DOINHERIT;
37 var_Create (object, qtu(name), type);
38 var_AddCallback (object, qtu(name), callback, this);
41 QVLCVariable::~QVLCVariable (void)
43 var_DelCallback (object, qtu(name), callback, this);
44 var_Destroy (object, qtu(name));
45 vlc_object_release (object);
48 int QVLCVariable::callback (vlc_object_t *object, const char *,
49 vlc_value_t old, vlc_value_t cur, void *data)
51 VLC_UNUSED(object);
53 QVLCVariable *self = static_cast<QVLCVariable *>(data);
55 self->trigger (self->object, old, cur);
56 return VLC_SUCCESS;
60 QVLCPointer::QVLCPointer (vlc_object_t *obj, const char *varname, bool inherit)
61 : QVLCVariable (obj, varname, VLC_VAR_ADDRESS, inherit)
65 void QVLCPointer::trigger (vlc_object_t *obj, vlc_value_t old, vlc_value_t cur)
67 emit pointerChanged (obj, old.p_address, cur.p_address);
68 emit pointerChanged (obj, cur.p_address);
72 QVLCInteger::QVLCInteger (vlc_object_t *obj, const char *varname, bool inherit)
73 : QVLCVariable (obj, varname, VLC_VAR_INTEGER, inherit)
77 void QVLCInteger::trigger (vlc_object_t *obj, vlc_value_t old, vlc_value_t cur)
79 emit integerChanged (obj, old.i_int, cur.i_int);
80 emit integerChanged (obj, cur.i_int);