* implement checkState and fix const'ness of the method signature

* implement updated
* add setChecked(bool)

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=693544
This commit is contained in:
Aaron J. Seigo 2007-07-28 10:06:03 +00:00
parent cfe59991ba
commit bf6fba2b27
2 changed files with 34 additions and 20 deletions

View File

@ -99,7 +99,6 @@ void CheckBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
// }
if (d->hasMouse) {
options.state |= QStyle::State_MouseOver;
options.state |= QStyle::State_HasFocus;
options.state |= QStyle::State_Sunken;
@ -107,11 +106,16 @@ void CheckBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
options.state |= QStyle::State_On;
}
widget-> style()->drawControl(QStyle::CE_CheckBox, &options, painter, widget);
}
void CheckBox::updated(const QString&, const DataEngine::Data&)
void CheckBox::updated(const QString&, const DataEngine::Data& data)
{
foreach (const QVariant& variant, data) {
if (variant.canConvert(QVariant::Bool)) {
setChecked(variant.toBool());
return;
}
}
}
void CheckBox::setText(const QString& text)
@ -178,6 +182,16 @@ void CheckBox::setMaximumWidth(int w)
d->maxWidth= w;
}
Qt::CheckState CheckBox::checkState() const
{
return d->state;
}
void CheckBox::setChecked(bool checked)
{
d->state = checked ? Qt::Checked : Qt::Unchecked;
}
void CheckBox::setCheckState(Qt::CheckState state)
{
d->state = state;
@ -187,8 +201,8 @@ void CheckBox::mouseMoveEvent (QGraphicsSceneMouseEvent * event)
{
event->accept();
d->hasMouse= false;
}
void CheckBox::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
event->accept();
@ -210,7 +224,6 @@ void CheckBox::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
}
update();
emit clicked();
}

View File

@ -53,7 +53,8 @@ class PLASMA_EXPORT CheckBox : public QObject, public QGraphicsItem
void setWidth(int width);
void setHeight(int height);
void setMaximumWidth(int maxwidth);
Qt::CheckState CheckState();
Qt::CheckState checkState() const;
void setChecked(bool checked);
void setCheckState(Qt::CheckState state);