pyesnobutton.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
00020 #include "pyesnobutton.h"
00021
00022 #include <qlayout.h>
00023 #include <qpainter.h>
00024 #include <qpushbutton.h>
00025
00026 #include <klocale.h>
00027
00028 namespace PropertyLib{
00029
00030 PYesNoButton::PYesNoButton(MultiProperty* property, QWidget* parent, const char* name)
00031 :PropertyWidget(property, parent, name)
00032 {
00033 QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
00034 m_edit = new QPushButton(this);
00035 m_edit->setToggleButton(true);
00036 m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
00037 l->addWidget(m_edit);
00038
00039 connect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
00040 }
00041
00042 QVariant PYesNoButton::value() const
00043 {
00044 return QVariant(m_edit->isOn());
00045 }
00046
00047 void PYesNoButton::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
00048 {
00049 PropertyWidget::drawViewer(p, cg, r, value.toBool() ? i18n("Yes") : i18n("No"));
00050 }
00051
00052 void PYesNoButton::setValue(const QVariant& value, bool emitChange)
00053 {
00054 disconnect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
00055 m_edit->setDown(value.toBool());
00056 value.toBool() ? m_edit->setText(i18n("Yes")) : m_edit->setText(i18n("No"));
00057 connect(m_edit, SIGNAL(toggled(bool)), this, SLOT(updateProperty(bool)));
00058 if (emitChange)
00059 emit propertyChanged(m_property, value);
00060 }
00061
00062 void PYesNoButton::updateProperty(bool toggled)
00063 {
00064 toggled ? m_edit->setText(i18n("Yes")) : m_edit->setText(i18n("No"));
00065 emit propertyChanged(m_property, value());
00066 }
00067
00068 }
00069
00070 #include "pyesnobutton.moc"
This file is part of the documentation for KDevelop Version 3.1.2.