Commit d265fa4e authored by David Faure's avatar David Faure

Port KListBoxDialog from KDialog to QDialog

parent e0592941
......@@ -19,43 +19,48 @@
#include "klistboxdialog.h"
#include <QLabel>
#include <kvbox.h>
#include "klocale.h"
#include <QVBoxLayout>
#include <QDialogButtonBox>
KListBoxDialog::KListBoxDialog(const QString &text, QWidget *parent)
: KDialog( parent )
: QDialog(parent)
{
setModal(true);
setButtons( Ok | Cancel );
setModal(true);
QVBoxLayout *vLayout = new QVBoxLayout(this);
label = new QLabel(text, this);
vLayout->addWidget(label);
label->setAlignment(Qt::AlignCenter);
table = new QListWidget(this);
vLayout->addWidget(table);
table->setFocus();
KVBox *page = new KVBox(this);
setMainWidget(page);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
vLayout->addWidget(buttonBox);
label = new QLabel(text, page);
label->setAlignment(Qt::AlignCenter);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
table = new QListWidget(page);
table->setFocus();
}
void KListBoxDialog::insertItem(const QString& item)
{
table->addItem(item);
table->setCurrentItem(0);
table->addItem(item);
table->setCurrentItem(0);
}
void KListBoxDialog::setCurrentItem(const QString& item)
{
for ( int i=0; i < (int) table->count(); i++ ) {
if ( table->item(i)->text() == item ) {
table->setCurrentItem(table->item(i));
break;
for (int i=0; i < table->count(); ++i) {
if (table->item(i)->text() == item) {
table->setCurrentItem(table->item(i));
break;
}
}
}
}
int KListBoxDialog::currentItem() const
{
return table->currentRow();
return table->currentRow();
}
......@@ -21,13 +21,13 @@
#ifndef KLISTBOXDIALOG_H
#define KLISTBOXDIALOG_H
#include <kdialog.h>
#include <qdialog.h>
#include <QListWidget>
class QLabel;
class KListBoxDialog : public KDialog
class KListBoxDialog : public QDialog
{
Q_OBJECT
......
......@@ -35,6 +35,7 @@
#include <kpassworddialog.h>
#include <kcombobox.h>
#include <kdebug.h>
#include <kdialog.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <ktextedit.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment