lib/widgets/propeditor/pstringlistedit.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#include <klocale.h>
00020
00021
#include <qlineedit.h>
00022
#include <kpushbutton.h>
00023
#include <qlayout.h>
00024
#include <qdialog.h>
00025
00026
#include <keditlistbox.h>
00027
#include <kstdguiitem.h>
00028
00029
#include "pstringlistedit.h"
00030
#include "propertyeditor.h"
00031
00032 PStringListEdit::PStringListEdit(
const PropertyEditor * editor,
const QString pname,
const QVariant value,
QWidget * parent,
const char * name )
00033 :
QWidget(parent, name)
00034 {
00035
l =
new QHBoxLayout(
this);
00036
00037
edit =
new QLineEdit(
this);
00038
edit->setReadOnly(
true);
00039
l->addWidget(
edit);
00040
pbSelect =
new QPushButton(
"...",
this);
00041
l->addWidget(
pbSelect);
00042
00043 connect(
pbSelect, SIGNAL(clicked()),
this, SLOT(
showEditor()));
00044
setValue(value,
false);
00045 setPName(pname);
00046 connect(
this, SIGNAL(
propertyChanged(
QString,
QVariant)), editor, SLOT(emitPropertyChange(
QString,
QVariant)));
00047 }
00048
00049 QVariant PStringListEdit::value()
const
00050
{
00051
return QVariant(
m_list);
00052 }
00053
00054 void PStringListEdit::setValue(
const QVariant value,
bool emitChange)
00055 {
00056
m_list = value.toStringList();
00057
if (emitChange)
00058 emit
propertyChanged(
pname(), value);
00059 }
00060
00061 void PStringListEdit::showEditor( )
00062 {
00063
QDialog* dia =
new QDialog(
this,
"stringlist_dialog",
true);
00064
QVBoxLayout *dv =
new QVBoxLayout(dia, 2);
00065
00066
KEditListBox *select =
new KEditListBox(dia,
"select_char");
00067 dv->addWidget(select);
00068
00069
QHBoxLayout *dh =
new QHBoxLayout(dv, 6);
00070
KPushButton *pbOk =
new KPushButton(KStdGuiItem::ok(), dia);
00071 KPushButton *pbCancel =
new KPushButton(KStdGuiItem::cancel(), dia);
00072
QSpacerItem *si =
new QSpacerItem(30, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
00073
00074 connect(pbOk, SIGNAL(clicked()), dia, SLOT(accept()));
00075 connect(pbCancel, SIGNAL(clicked()), dia, SLOT(reject()));
00076
00077 dh->addItem(si);
00078 dh->addWidget(pbOk);
00079 dh->addWidget(pbCancel);
00080
00081 select->
insertStringList(
m_list);
00082
00083
if (dia->exec() == QDialog::Accepted)
00084 {
00085
m_list = select->
items();
00086 }
00087
delete dia;
00088
00089 emit
propertyChanged(
pname(),
m_list);
00090 }
00091
00092
#include "pstringlistedit.moc"
This file is part of the documentation for KDevelop Version 3.0.4.