1 //******************************************************************************
2 //  Copyright (c) 2005-2013 by Jan Van hijfte
3 //
4 //  See the included file COPYING.TXT for details about the copyright.
5 //
6 //  This program is distributed in the hope that it will be useful,
7 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 //******************************************************************************
10 
11 
12 #ifndef QTABWIDGET_HOOK_H
13 #define QTABWIDGET_HOOK_H
14 
15 #include <qtabwidget.h>
16 
17 #include "qwidget_hook.h"
18 
19 class QTabWidget_hook : public QWidget_hook {
20   Q_OBJECT
21   public:
QTabWidget_hook(QObject * handle)22     QTabWidget_hook(QObject *handle) : QWidget_hook(handle) {
23       currentChanged_event.func = NULL;
24       tabCloseRequested_event.func = NULL;
25     }
hook_currentChanged(QHook & hook)26     void hook_currentChanged(QHook &hook) {
27       if ( !currentChanged_event.func )
28         connect(handle, SIGNAL(currentChanged(int)), this, SLOT(currentChanged_hook(int)));
29       currentChanged_event = hook;
30       if ( !hook.func )
31         disconnect(handle, SIGNAL(currentChanged(int)), this, SLOT(currentChanged_hook(int)));
32     }
hook_tabCloseRequested(QHook & hook)33     void hook_tabCloseRequested(QHook &hook) {
34       if ( !tabCloseRequested_event.func )
35         connect(handle, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested_hook(int)));
36       tabCloseRequested_event = hook;
37       if ( !hook.func )
38         disconnect(handle, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested_hook(int)));
39     }
40 
41   private slots:
currentChanged_hook(int index)42     void currentChanged_hook(int index) {
43       if ( currentChanged_event.func ) {
44         typedef void (*func_type)(void *data, int index);
45 	(*(func_type)currentChanged_event.func)(currentChanged_event.data, index);
46       }
47     }
tabCloseRequested_hook(int index)48     void tabCloseRequested_hook(int index) {
49       if ( tabCloseRequested_event.func ) {
50         typedef void (*func_type)(void *data, int index);
51 	(*(func_type)tabCloseRequested_event.func)(tabCloseRequested_event.data, index);
52       }
53     }
54   private:
55     QHook currentChanged_event;
56     QHook tabCloseRequested_event;
57 };
58 
59 
60 #endif
61