stringedit.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "stringedit.h"
22
23#include <tqlayout.h>
24#include <tqlineedit.h>
25#include <tqvariant.h>
26
27using namespace KoProperty;
28
29StringEdit::StringEdit(Property *property, TQWidget *parent, const char *name)
30 : Widget(property, parent, name)
31{
32 TQHBoxLayout *l = new TQHBoxLayout(this, 0, 0);
33 m_edit = new TQLineEdit(this);
34 m_edit->setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding);
35 m_edit->setMargin(1);
36 m_edit->setMinimumHeight(5);
37 l->addWidget(m_edit);
38 setFocusWidget(m_edit);
39
40 connect(m_edit, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(slotValueChanged(const TQString&)));
41}
42
43StringEdit::~StringEdit()
44{}
45
46TQVariant
47StringEdit::value() const
48{
49 return m_edit->text();
50}
51
52void
53StringEdit::setValue(const TQVariant &value, bool emitChange)
54{
55 m_edit->blockSignals(true);
56 m_edit->setText(value.toString());
57 m_edit->blockSignals(false);
58 if (emitChange)
59 emit valueChanged(this);
60}
61
62void
63StringEdit::slotValueChanged(const TQString &)
64{
65 emit valueChanged(this);
66}
67
68void
69StringEdit::setReadOnlyInternal(bool readOnly)
70{
71 m_edit->setReadOnly(readOnly);
72}
73
74#include "stringedit.moc"
The base class representing a single property.
Definition property.h:177
The base class for all item editors used in Editor.
Definition widget.h:37
const char * name(StdAction id)
Namespace for a set of classes implementing generic properties framework.