• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Property Editing Library
 

KDevelop Property Editing Library

  • lib
  • widgets
  • propeditor
pstringlistedit.cpp
1/***************************************************************************
2 * Copyright (C) 2003-2004 by Alexander Dymo *
3 * cloudtemple@mskat.net *
4 * *
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. *
9 * *
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. *
14 * *
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20#include "pstringlistedit.h"
21
22#include <tqlayout.h>
23#include <tqdialog.h>
24#include <tqpainter.h>
25#include <klineedit.h>
26
27#ifndef PURE_QT
28#include <keditlistbox.h>
29#include <kpushbutton.h>
30#include <kstdguiitem.h>
31#else
32#include "tqeditlistbox.h"
33#include <tqpushbutton.h>
34#include "compat_tools.h"
35#endif
36
37namespace PropertyLib{
38
39PStringListEdit::PStringListEdit(MultiProperty *property, TQWidget *parent, const char *name)
40 :PropertyWidget(property, parent, name)
41{
42 l = new TQHBoxLayout(this);
43
44 edit = new KLineEdit(this);
45 edit->setReadOnly(true);
46 edit->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding);
47 l->addWidget(edit);
48 pbSelect = new TQPushButton("...", this);
49 pbSelect->setSizePolicy(TQSizePolicy::Maximum, TQSizePolicy::MinimumExpanding);
50 l->addWidget(pbSelect);
51
52 connect(pbSelect, TQ_SIGNAL(clicked()), this, TQ_SLOT(showEditor()));
53}
54
55TQVariant PStringListEdit::value() const
56{
57 return TQVariant(m_list);
58}
59
60void PStringListEdit::setValue(const TQVariant &value, bool emitChange)
61{
62 m_list = value.toStringList();
63 edit->setText(value.toStringList().join(", "));
64 if (emitChange)
65 emit propertyChanged(m_property, value);
66}
67
68void PStringListEdit::showEditor()
69{
70 TQDialog* dia = new TQDialog(this, "stringlist_dialog", true);
71 TQVBoxLayout *dv = new TQVBoxLayout(dia, 2);
72
73#ifdef PURE_QT
74 TQEditListBox *select = new TQEditListBox(dia, "select_char");
75#else
76 KEditListBox *select = new KEditListBox(dia, "select_char");
77#endif
78 dv->addWidget(select);
79
80 TQHBoxLayout *dh = new TQHBoxLayout(dv, 6);
81#ifndef PURE_QT
82 KPushButton *pbOk = new KPushButton(KStdGuiItem::ok(), dia);
83 KPushButton *pbCancel = new KPushButton(KStdGuiItem::cancel(), dia);
84#else
85 TQPushButton *pbOk = new TQPushButton(i18n("Ok"), dia);
86 TQPushButton *pbCancel = new TQPushButton(i18n("Cancel"), dia);
87#endif
88 TQSpacerItem *si = new TQSpacerItem(30, 0, TQSizePolicy::Expanding, TQSizePolicy::Expanding);
89
90 connect(pbOk, TQ_SIGNAL(clicked()), dia, TQ_SLOT(accept()));
91 connect(pbCancel, TQ_SIGNAL(clicked()), dia, TQ_SLOT(reject()));
92
93 dh->addItem(si);
94 dh->addWidget(pbOk);
95 dh->addWidget(pbCancel);
96
97 select->insertStringList(m_list);
98
99 if (dia->exec() == TQDialog::Accepted)
100 {
101 m_list = select->items();
102 edit->setText(select->items().join(", "));
103 }
104 delete dia;
105
106 emit propertyChanged(m_property, m_list);
107}
108
109void PStringListEdit::drawViewer(TQPainter *p, const TQColorGroup &cg, const TQRect &r, const TQVariant &value)
110{
111 p->setPen(TQt::NoPen);
112 p->setBrush(cg.background());
113 p->drawRect(r);
114 p->drawText(r, TQt::AlignLeft | TQt::AlignVCenter | TQt::SingleLine, value.toStringList().join(", "));
115}
116
117}
118
119#ifndef PURE_QT
120#include "pstringlistedit.moc"
121#endif
PropertyLib
Namespace which contain property editing classes.
Definition childproperty.cpp:29

KDevelop Property Editing Library

Skip menu "KDevelop Property Editing Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Property Editing Library

Skip menu "KDevelop Property Editing Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Property Editing Library by doxygen 1.9.8
This website is maintained by Timothy Pearson.