1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <[email protected]>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#define _ACTIONS_LISTVIEW_WIDGET_CPP_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "actions_listview_widget.h"
#include <tqheader.h>
#include <tdelocale.h>
#include <kdebug.h>
#include <tqdragobject.h>
#include <khlistview.h>
#include <actions.h>
#include <triggers.h>
#include "kcmkhotkeys.h"
namespace KHotKeys
{
Actions_listview_widget::Actions_listview_widget( TQWidget* parent_P, const char* name_P )
: Actions_listview_widget_ui( parent_P, name_P ), recent_item( NULL ),
saved_current_item( NULL )
{
// actions_listview->setSorting( 0 );
actions_listview->header()->hide();
actions_listview->addColumn( "" );
actions_listview->setRootIsDecorated( true ); // CHECKME
connect( actions_listview, TQ_SIGNAL( current_changed( TQListViewItem* )),
TQ_SLOT( current_changed( TQListViewItem* )));
connect( actions_listview, TQ_SIGNAL( moved( TQListViewItem*, TQListViewItem*, TQListViewItem* )),
TQ_SLOT( item_moved( TQListViewItem*, TQListViewItem*, TQListViewItem* )));
// KHotKeys::Module::changed()
}
void Actions_listview_widget::action_name_changed( const TQString& )
{
current_action()->widthChanged( 0 );
actions_listview->repaintItem( current_action());
}
void Actions_listview_widget::set_action_data( Action_data_base* data_P, bool recent_action_P )
{
if( recent_action_P )
{
assert( recent_item != NULL );
recent_item->set_data( data_P );
}
else
saved_current_item->set_data( data_P );
}
void Actions_listview_widget::current_changed( TQListViewItem* item_P )
{
kdDebug( 1217 ) << "current_changed:" << item_P << endl;
set_current_action( static_cast< Action_listview_item* >( item_P ));
}
void Actions_listview_widget::set_current_action( Action_listview_item* item_P )
{
if( item_P == saved_current_item )
return;
recent_item = saved_current_item;
saved_current_item = item_P;
if( actions_listview->currentItem() != item_P )
{
if( item_P == NULL )
actions_listview->clearSelection();
actions_listview->setCurrentItem( item_P );
}
emit current_action_changed();
}
void Actions_listview_widget::new_action( Action_data_base* data_P )
{
TQListViewItem* parent = NULL;
if( current_action() != NULL )
{
if( dynamic_cast< Action_data_group* >( current_action()->data()) != NULL )
parent = current_action();
else
parent = current_action()->parent();
}
if( parent )
parent->setOpen( true );
Action_listview_item* tmp = create_item( parent, NULL, data_P );
recent_item = saved_current_item;
saved_current_item = tmp;
actions_listview->setSelected( tmp, true );
}
void Actions_listview_widget::delete_action()
{
// while( TQListViewItem* child = current_action()->firstChild())
// delete child;
// TQListViewItem* nw = current_action()->itemAbove();
// if( nw == NULL )
// nw = current_action()->itemBelow();
delete saved_current_item;
saved_current_item = NULL;
recent_item = NULL;
// if( nw != NULL )
// {
// saved_current_item = static_cast< Action_listview_item* >( nw );
// actions_listview->setSelected( nw, true );
// }
// else
// saved_current_item = NULL;
}
void Actions_listview_widget::item_moved( TQListViewItem* item_P, TQListViewItem*, TQListViewItem* )
{
Action_listview_item* item = static_cast< Action_listview_item* >( item_P );
Action_listview_item* parent = static_cast< Action_listview_item* >( item->parent());
if( parent == NULL )
item->data()->reparent( module->actions_root());
else if( Action_data_group* group = dynamic_cast< Action_data_group* >( parent->data()))
item->data()->reparent( group );
else
item->data()->reparent( module->actions_root());
module->changed();
}
void Actions_listview_widget::build_up()
{
build_up_recursively( module->actions_root(), NULL );
}
void Actions_listview_widget::build_up_recursively( Action_data_group* parent_P,
Action_listview_item* item_parent_P )
{
Action_listview_item* prev = NULL;
for( Action_data_group::Iterator it = parent_P->first_child();
it;
++it )
{
prev = create_item( item_parent_P, prev, ( *it ));
Action_data_group* grp = dynamic_cast< Action_data_group* >( *it );
if( grp != NULL )
build_up_recursively( grp, prev );
}
}
Action_listview_item* Actions_listview_widget::create_item( TQListViewItem* parent_P,
TQListViewItem* after_P, Action_data_base* data_P )
{
if( parent_P != NULL )
return new Action_listview_item( parent_P, after_P, data_P );
else
return new Action_listview_item( actions_listview, after_P, data_P );
}
// Actions_listview
Actions_listview::Actions_listview( TQWidget* parent_P, const char* name_P )
: KHListView( parent_P, name_P ), _widget( static_cast< Actions_listview_widget* >( parent_P->parent()))
{
// this relies on the way designer creates the .cpp file from .ui (yes, I'm lazy)
assert( dynamic_cast< Actions_listview_widget_ui* >( parent_P->parent()));
setDragEnabled( true );
setDropVisualizer( true );
setAcceptDrops( true );
}
// Action_listview_item
TQString Action_listview_item::text( int column_P ) const
{
return column_P == 0 ? data()->name() : TQString::null;
}
// CHECKME poradne tohle zkontrolovat po tom prekopani
} // namespace KHotKeys
#include "actions_listview_widget.moc"
|