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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
/***************************************************************************
actions.cpp - description
-------------------
begin : Tue Jul 10 2001
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
email : lvanek@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "actions.h"
// include files for TQT
#include <tqwhatsthis.h>
#include <tqdragobject.h>
#include <tqcombobox.h>
#include <tqapplication.h>
// include files for KDE
#include <tdetoolbar.h>
#include <kiconloader.h>
#include <kmimetype.h>
#include <kdebug.h>
//-------------------------------------------------------------------
//
// KXmlEditorComboAction member functions
//
//-------------------------------------------------------------------
KXmlEditorComboAction::KXmlEditorComboAction(const TQString& text,
int accel,
const TQObject *receiver,
const char *member,
TQObject* parent,
const char* name)
: TDEAction(text, accel, parent, name),
m_pCombo(0)
{
m_receiver = receiver;
m_member = member;
}
KXmlEditorComboAction::~KXmlEditorComboAction()
{
//delete m_pCombo; // L.V. this cause crash !!!
}
TQComboBox* KXmlEditorComboAction::comboBox()
{
return m_pCombo;
}
int KXmlEditorComboAction::plug(TQWidget *w, int index)
{
// if ( !w->inherits( "TDEToolBar" ) );
// return -1;
TDEToolBar *toolBar = (TDEToolBar *) w;
int id = TDEAction::getToolButtonID();
//kdDebug() << "KXmlEditorComboAction::plug id=" << id << endl;
m_pCombo = new TQComboBox( toolBar, "Path Combo" );
m_pCombo->setEditable(true);
m_pCombo->setInsertionPolicy(TQComboBox::NoInsertion);
toolBar->insertWidget( id, 70, m_pCombo, index );
connect( m_pCombo, TQ_SIGNAL(activated(const TQString&)), m_receiver, m_member );
addContainer( toolBar, id );
connect(toolBar, TQ_SIGNAL(destroyed()), this, TQ_SLOT(slotDestroyed()));
toolBar->setItemAutoSized(id, true);
TQWhatsThis::add( m_pCombo, whatsThis() );
return containerCount() - 1;
}
void KXmlEditorComboAction::unplug(TQWidget *w)
{
// if ( !w->inherits( "TDEToolBar" ) )
// return;
TDEToolBar *toolBar = (TDEToolBar *)w;
int idx = findContainer( w );
//kdDebug() << "KXmlEditorComboAction::unplug idx=" << idx << " menuId=" << menuId(idx) << endl;
toolBar->removeItem( menuId( idx ) );
removeContainer( idx );
m_pCombo = 0;
}
void KXmlEditorComboAction::slotClear()
{
if ( containerCount() == 0 )
{
kdWarning() << "[KXmlEditorComboAction::slotClear] action not plugged" << endl;
return;
}
m_pCombo->clear();
}
void KXmlEditorComboAction::slotClearEdit()
{
if ( containerCount() == 0 )
{
kdWarning() << "[KXmlEditorComboAction::slotClearEdit] action not plugged" << endl;
return;
}
m_pCombo->clearEdit();
}
void KXmlEditorComboAction::slotFocusEdit()
{
if ( containerCount() == 0 )
{
kdWarning() << "[KXmlEditorComboAction::slotFocusEdit] action not plugged" << endl;
return;
}
m_pCombo->setFocus();
}
TQString KXmlEditorComboAction::currentText() const
{
if ( containerCount() == 0 )
{
kdWarning() << "[KXmlEditorComboAction::currentText] action not plugged" << endl;
return TQString::null;
}
return m_pCombo->currentText();
}
const TQPixmap * KXmlEditorComboAction::currentPixmap() const
{
if ( containerCount() == 0 )
{
kdWarning() << "[KXmlEditorComboAction::currentPixmap] action not plugged" << endl;
return 0;
}
return m_pCombo->pixmap( m_pCombo->currentItem() );
}
void KXmlEditorComboAction::insertItem( const TQPixmap & pixmap, const TQString & text )
{
if ( containerCount() == 0 )
{
kdWarning() << "[KXmlEditorComboAction::insertItem] action not plugged" << endl;
return;
}
if ( text.isEmpty() )
kdWarning() << "[KXmlEditorComboAction::insertItem] empty string as parameter" << endl;
int nIndex = findItem(text);
if ( nIndex != -1 )
m_pCombo->removeItem(nIndex);
m_pCombo->insertItem( pixmap, text, 0 );
m_pCombo->setCurrentItem(0);
if ( m_pCombo->count() > 15 )
m_pCombo->removeItem(15);
}
void KXmlEditorComboAction::removeItem( const TQString & text )
{
if ( containerCount() == 0 )
{
kdWarning() << "[KXmlEditorComboAction::removeItem] action not plugged" << endl;
return;
}
int nIndex = findItem(text);
if ( nIndex == -1 )
{
kdDebug() << "KXmlEditorComboAction::removeItem] item not found" << endl;
return;
}
m_pCombo->removeItem(nIndex);
}
int KXmlEditorComboAction::findItem( const TQString & text )
{
if ( containerCount() == 0 )
{
kdWarning() << "[KXmlEditorComboAction::findItem] action not plugged" << endl;
return -1;
}
int nIndex = -1;
int i=0;
while ( ( i < m_pCombo->count() ) && ( nIndex == -1 ) )
{
if ( m_pCombo->text(i) == text )
nIndex = i;
i++;
}
return nIndex;
}
ToolbarLabel::ToolbarLabel( const TQString& text )
: TQLabel( text, 0L, "tde toolbar widget" ) // Use this name for it to be styled!
// , m_mw(mw)
{
setBackgroundMode( TQt::PaletteButton );
setAlignment( (TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft) |
TQt::AlignVCenter | TQt::ShowPrefix );
adjustSize();
}
#include "actions.moc"
|