1
/***************************************************************************
2
* Copyright (C) 2003-2004 by Alexander Dymo *
3
* cloudtemple@mskat.net *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU Library General Public License as *
7
* published by the Free Software Foundation; either version 2 of the *
8
* License, or (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU Library General Public *
16
* License along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
20
#include "pstringlistedit.h"
25
#include <klineedit.h>
28
#include <keditlistbox.h>
29
#include <kpushbutton.h>
30
#include <kstdguiitem.h>
32
#include "qeditlistbox.h"
33
#include <qpushbutton.h>
34
#include "compat_tools.h"
37
namespace PropertyLib{
39
PStringListEdit::PStringListEdit(MultiProperty *property, QWidget *parent, const char *name)
40
:PropertyWidget(property, parent, name)
42
l = new QHBoxLayout(this);
44
edit = new KLineEdit(this);
45
edit->setReadOnly(true);
46
edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
48
pbSelect = new QPushButton("...", this);
49
pbSelect->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
50
l->addWidget(pbSelect);
52
connect(pbSelect, SIGNAL(clicked()), this, SLOT(showEditor()));
55
QVariant PStringListEdit::value() const
57
return QVariant(m_list);
60
void PStringListEdit::setValue(const QVariant &value, bool emitChange)
62
m_list = value.toStringList();
63
edit->setText(value.toStringList().join(", "));
65
emit propertyChanged(m_property, value);
68
void PStringListEdit::showEditor()
70
QDialog* dia = new QDialog(this, "stringlist_dialog", true);
71
QVBoxLayout *dv = new QVBoxLayout(dia, 2);
74
QEditListBox *select = new QEditListBox(dia, "select_char");
76
KEditListBox *select = new KEditListBox(dia, "select_char");
78
dv->addWidget(select);
80
QHBoxLayout *dh = new QHBoxLayout(dv, 6);
82
KPushButton *pbOk = new KPushButton(KStdGuiItem::ok(), dia);
83
KPushButton *pbCancel = new KPushButton(KStdGuiItem::cancel(), dia);
85
QPushButton *pbOk = new QPushButton(i18n("Ok"), dia);
86
QPushButton *pbCancel = new QPushButton(i18n("Cancel"), dia);
88
QSpacerItem *si = new QSpacerItem(30, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
90
connect(pbOk, SIGNAL(clicked()), dia, SLOT(accept()));
91
connect(pbCancel, SIGNAL(clicked()), dia, SLOT(reject()));
95
dh->addWidget(pbCancel);
97
select->insertStringList(m_list);
99
if (dia->exec() == QDialog::Accepted)
101
m_list = select->items();
102
edit->setText(select->items().join(", "));
106
emit propertyChanged(m_property, m_list);
109
void PStringListEdit::drawViewer(QPainter *p, const QColorGroup &cg, const QRect &r, const QVariant &value)
111
p->setPen(Qt::NoPen);
112
p->setBrush(cg.background());
114
p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, value.toStringList().join(", "));
120
#include "pstringlistedit.moc"