summaryrefslogtreecommitdiffabout
path: root/microkde/keditlistbox.cpp
Side-by-side diff
Diffstat (limited to 'microkde/keditlistbox.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/keditlistbox.cpp33
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,136 +1,139 @@
/* This file is part of the KDE libraries
Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org>
2000, 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qstringlist.h>
#include <qpushbutton.h>
#include <qlayout.h>
-#include <qgroupbox.h>
-#include <qlistbox.h>
-#include <qwhatsthis.h>
+#include <q3groupbox.h>
+#include <q3listbox.h>
+#include <q3whatsthis.h>
#include <qlabel.h>
+//Added by qt3to4:
+#include <Q3GridLayout>
+#include <Q3StrList>
#include <kcombobox.h>
#include <kdebug.h>
#include <kdialog.h>
#include <klineedit.h>
#include <klocale.h>
#include <kapplication.h>
#include <knotifyclient.h>
#include "keditlistbox.h"
#include <assert.h>
class KEditListBoxPrivate
{
public:
bool m_checkAtEntering;
int buttons;
};
KEditListBox::KEditListBox(QWidget *parent, const char *name,
bool checkAtEntering, int buttons )
- :QGroupBox(parent, name )
+ :Q3GroupBox(parent, name )
{
init( checkAtEntering, buttons );
}
KEditListBox::KEditListBox(const QString& title, QWidget *parent,
const char *name, bool checkAtEntering, int buttons)
- :QGroupBox(title, parent, name )
+ :Q3GroupBox(title, parent, name )
{
init( checkAtEntering, buttons );
}
KEditListBox::KEditListBox(const QString& title, const CustomEditor& custom,
QWidget *parent, const char *name,
bool checkAtEntering, int buttons)
- :QGroupBox(title, parent, name )
+ :Q3GroupBox(title, parent, name )
{
m_lineEdit = custom.lineEdit();
init( checkAtEntering, buttons, custom.representationWidget() );
}
KEditListBox::~KEditListBox()
{
delete d;
d=0;
}
void KEditListBox::init( bool checkAtEntering, int buttons,
QWidget *representationWidget )
{
d=new KEditListBoxPrivate;
d->m_checkAtEntering=checkAtEntering;
d->buttons = buttons;
int lostButtons = 0;
if ( (buttons & Add) == 0 )
lostButtons++;
if ( (buttons & Remove) == 0 )
lostButtons++;
if ( (buttons & UpDown) == 0 )
lostButtons += 2;
servNewButton = servRemoveButton = servUpButton = servDownButton = 0L;
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::MinimumExpanding));
QWidget * gb = this;
- QGridLayout * grid = new QGridLayout(gb, 7 - lostButtons, 2,
+ Q3GridLayout * grid = new Q3GridLayout(gb, 7 - lostButtons, 2,
KDialog::marginHint(),
KDialog::spacingHint());
grid->addRowSpacing(0, fontMetrics().lineSpacing());
for ( int i = 1; i < 7 - lostButtons; i++ )
grid->setRowStretch(i, 1);
grid->setMargin(15);
if ( representationWidget )
representationWidget->reparent( gb, QPoint(0,0) );
else
m_lineEdit=new KLineEdit(gb);
- m_listBox = new QListBox(gb);
+ m_listBox = new Q3ListBox(gb);
QWidget *editingWidget = representationWidget ?
representationWidget : m_lineEdit;
grid->addMultiCellWidget(editingWidget,1,1,0,1);
grid->addMultiCellWidget(m_listBox, 2, 6 - lostButtons, 0, 0);
int row = 2;
if ( buttons & Add ) {
servNewButton = new QPushButton(i18n("&Add"), gb);
servNewButton->setEnabled(false);
connect(servNewButton, SIGNAL(clicked()), SLOT(addItem()));
grid->addWidget(servNewButton, row++, 1);
}
if ( buttons & Remove ) {
servRemoveButton = new QPushButton(i18n("&Remove"), gb);
servRemoveButton->setEnabled(false);
connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem()));
grid->addWidget(servRemoveButton, row++, 1);
}
if ( buttons & UpDown ) {
servUpButton = new QPushButton(i18n("Move &Up"), gb);
@@ -183,72 +186,72 @@ void KEditListBox::typedSomething(const QString& text)
}
else
{
bool enable = (m_listBox->findItem( text ) == 0L);
servNewButton->setEnabled( enable );
}
}
}
void KEditListBox::moveItemUp()
{
if (!m_listBox->isEnabled())
{
KNotifyClient::beep();
return;
}
unsigned int selIndex = m_listBox->currentItem();
if (selIndex == 0)
{
KNotifyClient::beep();
return;
}
- QListBoxItem *selItem = m_listBox->item(selIndex);
+ Q3ListBoxItem *selItem = m_listBox->item(selIndex);
m_listBox->takeItem(selItem);
m_listBox->insertItem(selItem, selIndex-1);
m_listBox->setCurrentItem(selIndex - 1);
emit changed();
}
void KEditListBox::moveItemDown()
{
if (!m_listBox->isEnabled())
{
KNotifyClient::beep();
return;
}
unsigned int selIndex = m_listBox->currentItem();
if (selIndex == m_listBox->count() - 1)
{
KNotifyClient::beep();
return;
}
- QListBoxItem *selItem = m_listBox->item(selIndex);
+ Q3ListBoxItem *selItem = m_listBox->item(selIndex);
m_listBox->takeItem(selItem);
m_listBox->insertItem(selItem, selIndex+1);
m_listBox->setCurrentItem(selIndex + 1);
emit changed();
}
void KEditListBox::addItem()
{
// when m_checkAtEntering is true, the add-button is disabled, but this
// slot can still be called through Key_Return/Key_Enter. So we guard
// against this.
if ( !servNewButton || !servNewButton->isEnabled() )
return;
const QString& currentTextLE=m_lineEdit->text();
bool alreadyInList(false);
//if we didn't check for dupes at the inserting we have to do it now
if (!d->m_checkAtEntering)
{
// first check current item instead of dumb iterating the entire list
if ( m_listBox->currentText() == currentTextLE )
alreadyInList = true;
else
@@ -328,56 +331,58 @@ void KEditListBox::enableMoveButtons(int index)
}
else
{
servUpButton->setEnabled(true);
servDownButton->setEnabled(true);
}
}
if ( servRemoveButton )
servRemoveButton->setEnabled(true);
}
void KEditListBox::clear()
{
m_lineEdit->clear();
m_listBox->clear();
emit changed();
}
void KEditListBox::insertStringList(const QStringList& list, int index)
{
m_listBox->insertStringList(list,index);
}
-void KEditListBox::insertStrList(const QStrList* list, int index)
+void KEditListBox::insertStrList(const Q3StrList* list, int index)
{
- m_listBox->insertStrList(list,index);
+ for(Q3StrList::const_iterator i=list->begin();i!=list->end();++i)
+ m_listBox->insertItem(*i,index++);
}
-void KEditListBox::insertStrList(const QStrList& list, int index)
+void KEditListBox::insertStrList(const Q3StrList& list, int index)
{
- m_listBox->insertStrList(list,index);
+ for(Q3StrList::const_iterator i=list.begin();i!=list.end();++i)
+ m_listBox->insertItem(*i,index++);
}
void KEditListBox::insertStrList(const char ** list, int numStrings, int index)
{
m_listBox->insertStrList(list,numStrings,index);
}
QStringList KEditListBox::items() const
{
QStringList list;
for ( uint i = 0; i < m_listBox->count(); i++ )
list.append( m_listBox->text( i ));
return list;
}
void KEditListBox::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
KEditListBox::CustomEditor::CustomEditor( KComboBox *combo )