author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/keditlistbox.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | microkde/keditlistbox.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/microkde/keditlistbox.cpp b/microkde/keditlistbox.cpp index 55b7784..257a44a 100644 --- a/microkde/keditlistbox.cpp +++ b/microkde/keditlistbox.cpp | |||
@@ -1,278 +1,281 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org> | 2 | Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org> |
3 | 2000, 2002 Carsten Pfeiffer <pfeiffer@kde.org> | 3 | 2000, 2002 Carsten Pfeiffer <pfeiffer@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qstringlist.h> | 21 | #include <qstringlist.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qlayout.h> | 23 | #include <qlayout.h> |
24 | #include <qgroupbox.h> | 24 | #include <q3groupbox.h> |
25 | #include <qlistbox.h> | 25 | #include <q3listbox.h> |
26 | #include <qwhatsthis.h> | 26 | #include <q3whatsthis.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | //Added by qt3to4: | ||
29 | #include <Q3GridLayout> | ||
30 | #include <Q3StrList> | ||
28 | 31 | ||
29 | #include <kcombobox.h> | 32 | #include <kcombobox.h> |
30 | #include <kdebug.h> | 33 | #include <kdebug.h> |
31 | #include <kdialog.h> | 34 | #include <kdialog.h> |
32 | #include <klineedit.h> | 35 | #include <klineedit.h> |
33 | #include <klocale.h> | 36 | #include <klocale.h> |
34 | #include <kapplication.h> | 37 | #include <kapplication.h> |
35 | #include <knotifyclient.h> | 38 | #include <knotifyclient.h> |
36 | 39 | ||
37 | #include "keditlistbox.h" | 40 | #include "keditlistbox.h" |
38 | 41 | ||
39 | #include <assert.h> | 42 | #include <assert.h> |
40 | 43 | ||
41 | class KEditListBoxPrivate | 44 | class KEditListBoxPrivate |
42 | { | 45 | { |
43 | public: | 46 | public: |
44 | bool m_checkAtEntering; | 47 | bool m_checkAtEntering; |
45 | int buttons; | 48 | int buttons; |
46 | }; | 49 | }; |
47 | 50 | ||
48 | KEditListBox::KEditListBox(QWidget *parent, const char *name, | 51 | KEditListBox::KEditListBox(QWidget *parent, const char *name, |
49 | bool checkAtEntering, int buttons ) | 52 | bool checkAtEntering, int buttons ) |
50 | :QGroupBox(parent, name ) | 53 | :Q3GroupBox(parent, name ) |
51 | { | 54 | { |
52 | init( checkAtEntering, buttons ); | 55 | init( checkAtEntering, buttons ); |
53 | } | 56 | } |
54 | 57 | ||
55 | KEditListBox::KEditListBox(const QString& title, QWidget *parent, | 58 | KEditListBox::KEditListBox(const QString& title, QWidget *parent, |
56 | const char *name, bool checkAtEntering, int buttons) | 59 | const char *name, bool checkAtEntering, int buttons) |
57 | :QGroupBox(title, parent, name ) | 60 | :Q3GroupBox(title, parent, name ) |
58 | { | 61 | { |
59 | init( checkAtEntering, buttons ); | 62 | init( checkAtEntering, buttons ); |
60 | } | 63 | } |
61 | 64 | ||
62 | KEditListBox::KEditListBox(const QString& title, const CustomEditor& custom, | 65 | KEditListBox::KEditListBox(const QString& title, const CustomEditor& custom, |
63 | QWidget *parent, const char *name, | 66 | QWidget *parent, const char *name, |
64 | bool checkAtEntering, int buttons) | 67 | bool checkAtEntering, int buttons) |
65 | :QGroupBox(title, parent, name ) | 68 | :Q3GroupBox(title, parent, name ) |
66 | { | 69 | { |
67 | m_lineEdit = custom.lineEdit(); | 70 | m_lineEdit = custom.lineEdit(); |
68 | init( checkAtEntering, buttons, custom.representationWidget() ); | 71 | init( checkAtEntering, buttons, custom.representationWidget() ); |
69 | } | 72 | } |
70 | 73 | ||
71 | KEditListBox::~KEditListBox() | 74 | KEditListBox::~KEditListBox() |
72 | { | 75 | { |
73 | delete d; | 76 | delete d; |
74 | d=0; | 77 | d=0; |
75 | } | 78 | } |
76 | 79 | ||
77 | void KEditListBox::init( bool checkAtEntering, int buttons, | 80 | void KEditListBox::init( bool checkAtEntering, int buttons, |
78 | QWidget *representationWidget ) | 81 | QWidget *representationWidget ) |
79 | { | 82 | { |
80 | d=new KEditListBoxPrivate; | 83 | d=new KEditListBoxPrivate; |
81 | d->m_checkAtEntering=checkAtEntering; | 84 | d->m_checkAtEntering=checkAtEntering; |
82 | d->buttons = buttons; | 85 | d->buttons = buttons; |
83 | 86 | ||
84 | int lostButtons = 0; | 87 | int lostButtons = 0; |
85 | if ( (buttons & Add) == 0 ) | 88 | if ( (buttons & Add) == 0 ) |
86 | lostButtons++; | 89 | lostButtons++; |
87 | if ( (buttons & Remove) == 0 ) | 90 | if ( (buttons & Remove) == 0 ) |
88 | lostButtons++; | 91 | lostButtons++; |
89 | if ( (buttons & UpDown) == 0 ) | 92 | if ( (buttons & UpDown) == 0 ) |
90 | lostButtons += 2; | 93 | lostButtons += 2; |
91 | 94 | ||
92 | 95 | ||
93 | servNewButton = servRemoveButton = servUpButton = servDownButton = 0L; | 96 | servNewButton = servRemoveButton = servUpButton = servDownButton = 0L; |
94 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, | 97 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, |
95 | QSizePolicy::MinimumExpanding)); | 98 | QSizePolicy::MinimumExpanding)); |
96 | 99 | ||
97 | QWidget * gb = this; | 100 | QWidget * gb = this; |
98 | QGridLayout * grid = new QGridLayout(gb, 7 - lostButtons, 2, | 101 | Q3GridLayout * grid = new Q3GridLayout(gb, 7 - lostButtons, 2, |
99 | KDialog::marginHint(), | 102 | KDialog::marginHint(), |
100 | KDialog::spacingHint()); | 103 | KDialog::spacingHint()); |
101 | grid->addRowSpacing(0, fontMetrics().lineSpacing()); | 104 | grid->addRowSpacing(0, fontMetrics().lineSpacing()); |
102 | for ( int i = 1; i < 7 - lostButtons; i++ ) | 105 | for ( int i = 1; i < 7 - lostButtons; i++ ) |
103 | grid->setRowStretch(i, 1); | 106 | grid->setRowStretch(i, 1); |
104 | 107 | ||
105 | grid->setMargin(15); | 108 | grid->setMargin(15); |
106 | 109 | ||
107 | if ( representationWidget ) | 110 | if ( representationWidget ) |
108 | representationWidget->reparent( gb, QPoint(0,0) ); | 111 | representationWidget->reparent( gb, QPoint(0,0) ); |
109 | else | 112 | else |
110 | m_lineEdit=new KLineEdit(gb); | 113 | m_lineEdit=new KLineEdit(gb); |
111 | 114 | ||
112 | m_listBox = new QListBox(gb); | 115 | m_listBox = new Q3ListBox(gb); |
113 | 116 | ||
114 | QWidget *editingWidget = representationWidget ? | 117 | QWidget *editingWidget = representationWidget ? |
115 | representationWidget : m_lineEdit; | 118 | representationWidget : m_lineEdit; |
116 | grid->addMultiCellWidget(editingWidget,1,1,0,1); | 119 | grid->addMultiCellWidget(editingWidget,1,1,0,1); |
117 | grid->addMultiCellWidget(m_listBox, 2, 6 - lostButtons, 0, 0); | 120 | grid->addMultiCellWidget(m_listBox, 2, 6 - lostButtons, 0, 0); |
118 | int row = 2; | 121 | int row = 2; |
119 | if ( buttons & Add ) { | 122 | if ( buttons & Add ) { |
120 | servNewButton = new QPushButton(i18n("&Add"), gb); | 123 | servNewButton = new QPushButton(i18n("&Add"), gb); |
121 | servNewButton->setEnabled(false); | 124 | servNewButton->setEnabled(false); |
122 | connect(servNewButton, SIGNAL(clicked()), SLOT(addItem())); | 125 | connect(servNewButton, SIGNAL(clicked()), SLOT(addItem())); |
123 | 126 | ||
124 | grid->addWidget(servNewButton, row++, 1); | 127 | grid->addWidget(servNewButton, row++, 1); |
125 | } | 128 | } |
126 | 129 | ||
127 | if ( buttons & Remove ) { | 130 | if ( buttons & Remove ) { |
128 | servRemoveButton = new QPushButton(i18n("&Remove"), gb); | 131 | servRemoveButton = new QPushButton(i18n("&Remove"), gb); |
129 | servRemoveButton->setEnabled(false); | 132 | servRemoveButton->setEnabled(false); |
130 | connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem())); | 133 | connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem())); |
131 | 134 | ||
132 | grid->addWidget(servRemoveButton, row++, 1); | 135 | grid->addWidget(servRemoveButton, row++, 1); |
133 | } | 136 | } |
134 | 137 | ||
135 | if ( buttons & UpDown ) { | 138 | if ( buttons & UpDown ) { |
136 | servUpButton = new QPushButton(i18n("Move &Up"), gb); | 139 | servUpButton = new QPushButton(i18n("Move &Up"), gb); |
137 | servUpButton->setEnabled(false); | 140 | servUpButton->setEnabled(false); |
138 | connect(servUpButton, SIGNAL(clicked()), SLOT(moveItemUp())); | 141 | connect(servUpButton, SIGNAL(clicked()), SLOT(moveItemUp())); |
139 | 142 | ||
140 | servDownButton = new QPushButton(i18n("Move &Down"), gb); | 143 | servDownButton = new QPushButton(i18n("Move &Down"), gb); |
141 | servDownButton->setEnabled(false); | 144 | servDownButton->setEnabled(false); |
142 | connect(servDownButton, SIGNAL(clicked()), SLOT(moveItemDown())); | 145 | connect(servDownButton, SIGNAL(clicked()), SLOT(moveItemDown())); |
143 | 146 | ||
144 | grid->addWidget(servUpButton, row++, 1); | 147 | grid->addWidget(servUpButton, row++, 1); |
145 | grid->addWidget(servDownButton, row++, 1); | 148 | grid->addWidget(servDownButton, row++, 1); |
146 | } | 149 | } |
147 | 150 | ||
148 | connect(m_lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(typedSomething(const QString&))); | 151 | connect(m_lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(typedSomething(const QString&))); |
149 | m_lineEdit->setTrapReturnKey(true); | 152 | m_lineEdit->setTrapReturnKey(true); |
150 | connect(m_lineEdit,SIGNAL(returnPressed()),this,SLOT(addItem())); | 153 | connect(m_lineEdit,SIGNAL(returnPressed()),this,SLOT(addItem())); |
151 | connect(m_listBox, SIGNAL(highlighted(int)), SLOT(enableMoveButtons(int))); | 154 | connect(m_listBox, SIGNAL(highlighted(int)), SLOT(enableMoveButtons(int))); |
152 | 155 | ||
153 | // maybe supplied lineedit has some text already | 156 | // maybe supplied lineedit has some text already |
154 | typedSomething( m_lineEdit->text() ); | 157 | typedSomething( m_lineEdit->text() ); |
155 | } | 158 | } |
156 | 159 | ||
157 | void KEditListBox::typedSomething(const QString& text) | 160 | void KEditListBox::typedSomething(const QString& text) |
158 | { | 161 | { |
159 | if(currentItem() >= 0) { | 162 | if(currentItem() >= 0) { |
160 | if(currentText() != m_lineEdit->text()) | 163 | if(currentText() != m_lineEdit->text()) |
161 | { | 164 | { |
162 | // IMHO changeItem() shouldn't do anything with the value | 165 | // IMHO changeItem() shouldn't do anything with the value |
163 | // of currentItem() ... like changing it or emitting signals ... | 166 | // of currentItem() ... like changing it or emitting signals ... |
164 | // but TT disagree with me on this one (it's been that way since ages ... grrr) | 167 | // but TT disagree with me on this one (it's been that way since ages ... grrr) |
165 | bool block = m_listBox->signalsBlocked(); | 168 | bool block = m_listBox->signalsBlocked(); |
166 | m_listBox->blockSignals( true ); | 169 | m_listBox->blockSignals( true ); |
167 | m_listBox->changeItem(text, currentItem()); | 170 | m_listBox->changeItem(text, currentItem()); |
168 | m_listBox->blockSignals( block ); | 171 | m_listBox->blockSignals( block ); |
169 | emit changed(); | 172 | emit changed(); |
170 | } | 173 | } |
171 | } | 174 | } |
172 | 175 | ||
173 | if ( !servNewButton ) | 176 | if ( !servNewButton ) |
174 | return; | 177 | return; |
175 | 178 | ||
176 | if (!d->m_checkAtEntering) | 179 | if (!d->m_checkAtEntering) |
177 | servNewButton->setEnabled(!text.isEmpty()); | 180 | servNewButton->setEnabled(!text.isEmpty()); |
178 | else | 181 | else |
179 | { | 182 | { |
180 | if (text.isEmpty()) | 183 | if (text.isEmpty()) |
181 | { | 184 | { |
182 | servNewButton->setEnabled(false); | 185 | servNewButton->setEnabled(false); |
183 | } | 186 | } |
184 | else | 187 | else |
185 | { | 188 | { |
186 | bool enable = (m_listBox->findItem( text ) == 0L); | 189 | bool enable = (m_listBox->findItem( text ) == 0L); |
187 | servNewButton->setEnabled( enable ); | 190 | servNewButton->setEnabled( enable ); |
188 | } | 191 | } |
189 | } | 192 | } |
190 | } | 193 | } |
191 | 194 | ||
192 | void KEditListBox::moveItemUp() | 195 | void KEditListBox::moveItemUp() |
193 | { | 196 | { |
194 | if (!m_listBox->isEnabled()) | 197 | if (!m_listBox->isEnabled()) |
195 | { | 198 | { |
196 | KNotifyClient::beep(); | 199 | KNotifyClient::beep(); |
197 | return; | 200 | return; |
198 | } | 201 | } |
199 | 202 | ||
200 | unsigned int selIndex = m_listBox->currentItem(); | 203 | unsigned int selIndex = m_listBox->currentItem(); |
201 | if (selIndex == 0) | 204 | if (selIndex == 0) |
202 | { | 205 | { |
203 | KNotifyClient::beep(); | 206 | KNotifyClient::beep(); |
204 | return; | 207 | return; |
205 | } | 208 | } |
206 | 209 | ||
207 | QListBoxItem *selItem = m_listBox->item(selIndex); | 210 | Q3ListBoxItem *selItem = m_listBox->item(selIndex); |
208 | m_listBox->takeItem(selItem); | 211 | m_listBox->takeItem(selItem); |
209 | m_listBox->insertItem(selItem, selIndex-1); | 212 | m_listBox->insertItem(selItem, selIndex-1); |
210 | m_listBox->setCurrentItem(selIndex - 1); | 213 | m_listBox->setCurrentItem(selIndex - 1); |
211 | 214 | ||
212 | emit changed(); | 215 | emit changed(); |
213 | } | 216 | } |
214 | 217 | ||
215 | void KEditListBox::moveItemDown() | 218 | void KEditListBox::moveItemDown() |
216 | { | 219 | { |
217 | if (!m_listBox->isEnabled()) | 220 | if (!m_listBox->isEnabled()) |
218 | { | 221 | { |
219 | KNotifyClient::beep(); | 222 | KNotifyClient::beep(); |
220 | return; | 223 | return; |
221 | } | 224 | } |
222 | 225 | ||
223 | unsigned int selIndex = m_listBox->currentItem(); | 226 | unsigned int selIndex = m_listBox->currentItem(); |
224 | if (selIndex == m_listBox->count() - 1) | 227 | if (selIndex == m_listBox->count() - 1) |
225 | { | 228 | { |
226 | KNotifyClient::beep(); | 229 | KNotifyClient::beep(); |
227 | return; | 230 | return; |
228 | } | 231 | } |
229 | 232 | ||
230 | QListBoxItem *selItem = m_listBox->item(selIndex); | 233 | Q3ListBoxItem *selItem = m_listBox->item(selIndex); |
231 | m_listBox->takeItem(selItem); | 234 | m_listBox->takeItem(selItem); |
232 | m_listBox->insertItem(selItem, selIndex+1); | 235 | m_listBox->insertItem(selItem, selIndex+1); |
233 | m_listBox->setCurrentItem(selIndex + 1); | 236 | m_listBox->setCurrentItem(selIndex + 1); |
234 | 237 | ||
235 | emit changed(); | 238 | emit changed(); |
236 | } | 239 | } |
237 | 240 | ||
238 | void KEditListBox::addItem() | 241 | void KEditListBox::addItem() |
239 | { | 242 | { |
240 | // when m_checkAtEntering is true, the add-button is disabled, but this | 243 | // when m_checkAtEntering is true, the add-button is disabled, but this |
241 | // slot can still be called through Key_Return/Key_Enter. So we guard | 244 | // slot can still be called through Key_Return/Key_Enter. So we guard |
242 | // against this. | 245 | // against this. |
243 | if ( !servNewButton || !servNewButton->isEnabled() ) | 246 | if ( !servNewButton || !servNewButton->isEnabled() ) |
244 | return; | 247 | return; |
245 | 248 | ||
246 | const QString& currentTextLE=m_lineEdit->text(); | 249 | const QString& currentTextLE=m_lineEdit->text(); |
247 | bool alreadyInList(false); | 250 | bool alreadyInList(false); |
248 | //if we didn't check for dupes at the inserting we have to do it now | 251 | //if we didn't check for dupes at the inserting we have to do it now |
249 | if (!d->m_checkAtEntering) | 252 | if (!d->m_checkAtEntering) |
250 | { | 253 | { |
251 | // first check current item instead of dumb iterating the entire list | 254 | // first check current item instead of dumb iterating the entire list |
252 | if ( m_listBox->currentText() == currentTextLE ) | 255 | if ( m_listBox->currentText() == currentTextLE ) |
253 | alreadyInList = true; | 256 | alreadyInList = true; |
254 | else | 257 | else |
255 | { | 258 | { |
256 | alreadyInList =(m_listBox->findItem(currentTextLE) != 0); | 259 | alreadyInList =(m_listBox->findItem(currentTextLE) != 0); |
257 | } | 260 | } |
258 | } | 261 | } |
259 | 262 | ||
260 | if ( servNewButton ) | 263 | if ( servNewButton ) |
261 | servNewButton->setEnabled(false); | 264 | servNewButton->setEnabled(false); |
262 | 265 | ||
263 | bool block = m_lineEdit->signalsBlocked(); | 266 | bool block = m_lineEdit->signalsBlocked(); |
264 | m_lineEdit->blockSignals(true); | 267 | m_lineEdit->blockSignals(true); |
265 | m_lineEdit->clear(); | 268 | m_lineEdit->clear(); |
266 | m_lineEdit->blockSignals(block); | 269 | m_lineEdit->blockSignals(block); |
267 | 270 | ||
268 | m_listBox->setSelected(currentItem(), false); | 271 | m_listBox->setSelected(currentItem(), false); |
269 | 272 | ||
270 | if (!alreadyInList) | 273 | if (!alreadyInList) |
271 | { | 274 | { |
272 | block = m_listBox->signalsBlocked(); | 275 | block = m_listBox->signalsBlocked(); |
273 | m_listBox->blockSignals( true ); | 276 | m_listBox->blockSignals( true ); |
274 | m_listBox->insertItem(currentTextLE); | 277 | m_listBox->insertItem(currentTextLE); |
275 | m_listBox->blockSignals( block ); | 278 | m_listBox->blockSignals( block ); |
276 | emit changed(); | 279 | emit changed(); |
277 | } | 280 | } |
278 | } | 281 | } |
@@ -304,86 +307,88 @@ void KEditListBox::removeItem() | |||
304 | void KEditListBox::enableMoveButtons(int index) | 307 | void KEditListBox::enableMoveButtons(int index) |
305 | { | 308 | { |
306 | // Update the lineEdit when we select a different line. | 309 | // Update the lineEdit when we select a different line. |
307 | if(currentText() != m_lineEdit->text()) | 310 | if(currentText() != m_lineEdit->text()) |
308 | m_lineEdit->setText(currentText()); | 311 | m_lineEdit->setText(currentText()); |
309 | 312 | ||
310 | bool moveEnabled = servUpButton && servDownButton; | 313 | bool moveEnabled = servUpButton && servDownButton; |
311 | 314 | ||
312 | if (moveEnabled ) | 315 | if (moveEnabled ) |
313 | { | 316 | { |
314 | if (m_listBox->count() <= 1) | 317 | if (m_listBox->count() <= 1) |
315 | { | 318 | { |
316 | servUpButton->setEnabled(false); | 319 | servUpButton->setEnabled(false); |
317 | servDownButton->setEnabled(false); | 320 | servDownButton->setEnabled(false); |
318 | } | 321 | } |
319 | else if ((uint) index == (m_listBox->count() - 1)) | 322 | else if ((uint) index == (m_listBox->count() - 1)) |
320 | { | 323 | { |
321 | servUpButton->setEnabled(true); | 324 | servUpButton->setEnabled(true); |
322 | servDownButton->setEnabled(false); | 325 | servDownButton->setEnabled(false); |
323 | } | 326 | } |
324 | else if (index == 0) | 327 | else if (index == 0) |
325 | { | 328 | { |
326 | servUpButton->setEnabled(false); | 329 | servUpButton->setEnabled(false); |
327 | servDownButton->setEnabled(true); | 330 | servDownButton->setEnabled(true); |
328 | } | 331 | } |
329 | else | 332 | else |
330 | { | 333 | { |
331 | servUpButton->setEnabled(true); | 334 | servUpButton->setEnabled(true); |
332 | servDownButton->setEnabled(true); | 335 | servDownButton->setEnabled(true); |
333 | } | 336 | } |
334 | } | 337 | } |
335 | 338 | ||
336 | if ( servRemoveButton ) | 339 | if ( servRemoveButton ) |
337 | servRemoveButton->setEnabled(true); | 340 | servRemoveButton->setEnabled(true); |
338 | } | 341 | } |
339 | 342 | ||
340 | void KEditListBox::clear() | 343 | void KEditListBox::clear() |
341 | { | 344 | { |
342 | m_lineEdit->clear(); | 345 | m_lineEdit->clear(); |
343 | m_listBox->clear(); | 346 | m_listBox->clear(); |
344 | emit changed(); | 347 | emit changed(); |
345 | } | 348 | } |
346 | 349 | ||
347 | void KEditListBox::insertStringList(const QStringList& list, int index) | 350 | void KEditListBox::insertStringList(const QStringList& list, int index) |
348 | { | 351 | { |
349 | m_listBox->insertStringList(list,index); | 352 | m_listBox->insertStringList(list,index); |
350 | } | 353 | } |
351 | 354 | ||
352 | void KEditListBox::insertStrList(const QStrList* list, int index) | 355 | void KEditListBox::insertStrList(const Q3StrList* list, int index) |
353 | { | 356 | { |
354 | m_listBox->insertStrList(list,index); | 357 | for(Q3StrList::const_iterator i=list->begin();i!=list->end();++i) |
358 | m_listBox->insertItem(*i,index++); | ||
355 | } | 359 | } |
356 | 360 | ||
357 | void KEditListBox::insertStrList(const QStrList& list, int index) | 361 | void KEditListBox::insertStrList(const Q3StrList& list, int index) |
358 | { | 362 | { |
359 | m_listBox->insertStrList(list,index); | 363 | for(Q3StrList::const_iterator i=list.begin();i!=list.end();++i) |
364 | m_listBox->insertItem(*i,index++); | ||
360 | } | 365 | } |
361 | 366 | ||
362 | void KEditListBox::insertStrList(const char ** list, int numStrings, int index) | 367 | void KEditListBox::insertStrList(const char ** list, int numStrings, int index) |
363 | { | 368 | { |
364 | m_listBox->insertStrList(list,numStrings,index); | 369 | m_listBox->insertStrList(list,numStrings,index); |
365 | } | 370 | } |
366 | 371 | ||
367 | QStringList KEditListBox::items() const | 372 | QStringList KEditListBox::items() const |
368 | { | 373 | { |
369 | QStringList list; | 374 | QStringList list; |
370 | for ( uint i = 0; i < m_listBox->count(); i++ ) | 375 | for ( uint i = 0; i < m_listBox->count(); i++ ) |
371 | list.append( m_listBox->text( i )); | 376 | list.append( m_listBox->text( i )); |
372 | 377 | ||
373 | return list; | 378 | return list; |
374 | } | 379 | } |
375 | 380 | ||
376 | void KEditListBox::virtual_hook( int, void* ) | 381 | void KEditListBox::virtual_hook( int, void* ) |
377 | { /*BASE::virtual_hook( id, data );*/ } | 382 | { /*BASE::virtual_hook( id, data );*/ } |
378 | 383 | ||
379 | 384 | ||
380 | /////////////////////////////////////////////////////////////////// | 385 | /////////////////////////////////////////////////////////////////// |
381 | /////////////////////////////////////////////////////////////////// | 386 | /////////////////////////////////////////////////////////////////// |
382 | 387 | ||
383 | KEditListBox::CustomEditor::CustomEditor( KComboBox *combo ) | 388 | KEditListBox::CustomEditor::CustomEditor( KComboBox *combo ) |
384 | { | 389 | { |
385 | m_representationWidget = combo; | 390 | m_representationWidget = combo; |
386 | m_lineEdit = static_cast<KLineEdit*>( combo->lineEdit() ); | 391 | m_lineEdit = static_cast<KLineEdit*>( combo->lineEdit() ); |
387 | assert( m_lineEdit ); | 392 | assert( m_lineEdit ); |
388 | } | 393 | } |
389 | 394 | ||