keditlistbox.h
/* This file is part of the KDE libraries
Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KEDITLISTBOX_H
#define KEDITLISTBOX_H
#include <qgroupbox.h>
#include <qlistbox.h>
#include <kdelibs_export.h>
class KLineEdit;
class KComboBox;
class QPushButton;
class KEditListBoxPrivate;
class KDEUI_EXPORT KEditListBox : public QGroupBox
{
Q_OBJECT
Q_SETS( Button )
Q_PROPERTY( Button buttons READ buttons WRITE setButtons )
Q_PROPERTY( QStringList items READ items WRITE setItems )
public:
// ### KDE4: add virtual destructor
class CustomEditor
{
public:
KDEUI_EXPORT CustomEditor()
: m_representationWidget( 0L ),
m_lineEdit( 0L ) {}
KDEUI_EXPORT CustomEditor( QWidget *repWidget, KLineEdit *edit )
: m_representationWidget( repWidget ),
m_lineEdit( edit ) {}
KDEUI_EXPORT CustomEditor( KComboBox *combo );
KDEUI_EXPORT void setRepresentationWidget( QWidget *repWidget ) {
m_representationWidget = repWidget;
}
KDEUI_EXPORT void setLineEdit( KLineEdit *edit ) {
m_lineEdit = edit;
}
KDEUI_EXPORT virtual QWidget *representationWidget() const {
return m_representationWidget;
}
KDEUI_EXPORT virtual KLineEdit *lineEdit() const {
return m_lineEdit;
}
protected:
QWidget *m_representationWidget;
KLineEdit *m_lineEdit;
};
public:
enum Button { Add = 1, Remove = 2, UpDown = 4 };
enum { All = Add|Remove|UpDown }; // separated so that it doesn't appear in Qt designer
KEditListBox(QWidget *parent = 0, const char *name = 0,
bool checkAtEntering=false, int buttons = All );
KEditListBox(const QString& title, QWidget *parent = 0,
const char *name = 0, bool checkAtEntering=false,
int buttons = All );
KEditListBox( const QString& title,
const CustomEditor &customEditor,
QWidget *parent = 0, const char *name = 0,
bool checkAtEntering = false, int buttons = All );
virtual ~KEditListBox();
QListBox* listBox() const { return m_listBox; }
KLineEdit* lineEdit() const { return m_lineEdit; }
QPushButton* addButton() const { return servNewButton; }
QPushButton* removeButton() const { return servRemoveButton; }
QPushButton* upButton() const { return servUpButton; }
QPushButton* downButton() const { return servDownButton; }
int count() const { return int(m_listBox->count()); }
void insertStringList(const QStringList& list, int index=-1);
void insertStrList(const QStrList* list, int index=-1);
void insertStrList(const QStrList& list, int index=-1);
void insertStrList(const char ** list, int numStrings=-1, int index=-1);
void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
void clear();
QString text(int index) const { return m_listBox->text(index); }
int currentItem() const;
QString currentText() const { return m_listBox->currentText(); }
QStringList items() const;
void setItems(const QStringList& items);
int buttons() const;
void setButtons( uint buttons );
signals:
void changed();
void added( const QString & text );
void removed( const QString & text );
protected slots:
//the names should be self-explaining
void moveItemUp();
void moveItemDown();
void addItem();
void removeItem();
void enableMoveButtons(int index);
void typedSomething(const QString& text);
private:
QListBox *m_listBox;
QPushButton *servUpButton, *servDownButton;
QPushButton *servNewButton, *servRemoveButton;
KLineEdit *m_lineEdit;
//this is called in both ctors, to avoid code duplication
void init( bool checkAtEntering, int buttons,
QWidget *representationWidget = 0L );
protected:
virtual void virtual_hook( int id, void* data );
private:
//our lovely private d-pointer
KEditListBoxPrivate* const d;
};
#endif
KEditListBox::removeButton
QPushButton * removeButton() const
Return a pointer to the Remove button.
Definition: keditlistbox.h:156
KEditListBox::listBox
QListBox * listBox() const
Return a pointer to the embedded QListBox.
Definition: keditlistbox.h:144
KEditListBox::currentText
QString currentText() const
See QListBox::currentText()
Definition: keditlistbox.h:205
KEditListBox::text
QString text(int index) const
See QListBox::text()
Definition: keditlistbox.h:197
KEditListBox::upButton
QPushButton * upButton() const
Return a pointer to the Up button.
Definition: keditlistbox.h:160
KEditListBox::CustomEditor
Custom editor class.
Definition: keditlistbox.h:59
KEditListBox::count
int count() const
See QListBox::count()
Definition: keditlistbox.h:169
KEditListBox::insertItem
void insertItem(const QString &text, int index=-1)
See QListBox::insertItem()
Definition: keditlistbox.h:189
KEditListBox::Button
Button
Enumeration of the buttons, the listbox offers.
Definition: keditlistbox.h:95
KEditListBox
An editable listbox.
Definition: keditlistbox.h:44
KLineEdit
An enhanced QLineEdit widget for inputting text.
Definition: klineedit.h:145
KComboBox
An enhanced combo box.
Definition: kcombobox.h:144
KEditListBox::downButton
QPushButton * downButton() const
Return a pointer to the Down button.
Definition: keditlistbox.h:164
KEditListBox::addButton
QPushButton * addButton() const
Return a pointer to the Add button.
Definition: keditlistbox.h:152
KEditListBox::lineEdit
KLineEdit * lineEdit() const
Return a pointer to the embedded QLineEdit.
Definition: keditlistbox.h:148

KDE Home | KDE Accessibility Home | Description of Access Keys