-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 | |||
@@ -16,20 +16,23 @@ | |||
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> |
@@ -42,32 +45,32 @@ 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; |
@@ -90,31 +93,31 @@ void KEditListBox::init( bool checkAtEntering, int buttons, | |||
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); |
@@ -199,17 +202,17 @@ void KEditListBox::moveItemUp() | |||
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() |
@@ -222,17 +225,17 @@ void KEditListBox::moveItemDown() | |||
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() |
@@ -344,24 +347,26 @@ void KEditListBox::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 |