lib
stringedit.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "stringedit.h"
00022
00023 #include <qlayout.h>
00024 #include <qlineedit.h>
00025 #include <qvariant.h>
00026
00027 using namespace KoProperty;
00028
00029 StringEdit::StringEdit(Property *property, QWidget *parent, const char *name)
00030 : Widget(property, parent, name)
00031 {
00032 QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
00033 m_edit = new QLineEdit(this);
00034 m_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00035 m_edit->setMargin(1);
00036 m_edit->setMinimumHeight(5);
00037 l->addWidget(m_edit);
00038 setFocusWidget(m_edit);
00039
00040 connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(slotValueChanged(const QString&)));
00041 }
00042
00043 StringEdit::~StringEdit()
00044 {}
00045
00046 QVariant
00047 StringEdit::value() const
00048 {
00049 return m_edit->text();
00050 }
00051
00052 void
00053 StringEdit::setValue(const QVariant &value, bool emitChange)
00054 {
00055 m_edit->blockSignals(true);
00056 m_edit->setText(value.toString());
00057 m_edit->blockSignals(false);
00058 if (emitChange)
00059 emit valueChanged(this);
00060 }
00061
00062 void
00063 StringEdit::slotValueChanged(const QString &)
00064 {
00065 emit valueChanged(this);
00066 }
00067
00068 void
00069 StringEdit::setReadOnlyInternal(bool readOnly)
00070 {
00071 m_edit->setReadOnly(readOnly);
00072 }
00073
00074 #include "stringedit.moc"
|