* rename operationIsEnabled to isOperationEnabled
* add disassociateWidget() methods * don't allow a widget to associated with more than one operation * set the enabled status properly when we associate a widget svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=852983
This commit is contained in:
parent
8355e9e027
commit
9ce3660816
24
service.cpp
24
service.cpp
@ -160,22 +160,32 @@ ServiceJob* Service::startOperationCall(const KConfigGroup &description)
|
||||
|
||||
void Service::associateWidget(QWidget *widget, const QString &operation)
|
||||
{
|
||||
disassociateWidget(widget);
|
||||
d->associatedWidgets.insert(widget, operation);
|
||||
connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(associatedWidgetDestroyed(QObject*)));
|
||||
|
||||
if (d->disabledOperations.contains(operation)) {
|
||||
widget->setEnabled(false);
|
||||
}
|
||||
widget->setEnabled(!d->disabledOperations.contains(operation));
|
||||
}
|
||||
|
||||
void Service::disassociateWidget(QWidget *widget)
|
||||
{
|
||||
disconnect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(associatedWidgetDestroyed(QObject*)));
|
||||
d->associatedWidgets.remove(widget);
|
||||
}
|
||||
|
||||
void Service::associateWidget(QGraphicsWidget *widget, const QString &operation)
|
||||
{
|
||||
disassociateWidget(widget);
|
||||
d->associatedGraphicsWidgets.insert(widget, operation);
|
||||
connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(associatedGraphicsWidgetDestroyed(QObject*)));
|
||||
|
||||
if (d->disabledOperations.contains(operation)) {
|
||||
widget->setEnabled(false);
|
||||
}
|
||||
widget->setEnabled(!d->disabledOperations.contains(operation));
|
||||
}
|
||||
|
||||
void Service::disassociateWidget(QGraphicsWidget *widget)
|
||||
{
|
||||
disconnect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(associatedGraphicsWidgetDestroyed(QObject*)));
|
||||
d->associatedGraphicsWidgets.remove(widget);
|
||||
}
|
||||
|
||||
QString Service::name() const
|
||||
@ -230,7 +240,7 @@ void Service::setOperationEnabled(const QString &operation, bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
bool Service::operationIsEnabled(const QString &operation) const
|
||||
bool Service::isOperationEnabled(const QString &operation) const
|
||||
{
|
||||
return d->config->hasGroup(operation) && !d->disabledOperations.contains(operation);
|
||||
}
|
||||
|
28
service.h
28
service.h
@ -131,7 +131,7 @@ public:
|
||||
* @param operation the name of the operation to check
|
||||
* @return true if the operation is enabled, false otherwise
|
||||
*/
|
||||
bool operationIsEnabled(const QString &operation) const;
|
||||
bool isOperationEnabled(const QString &operation) const;
|
||||
|
||||
/**
|
||||
* The name of this service
|
||||
@ -142,20 +142,46 @@ public:
|
||||
* Assoicates a widget with an operation, which allows the service to
|
||||
* automatically manage, for example, the enabled state of a widget.
|
||||
*
|
||||
* This will remove any previous associations the widget had with
|
||||
* operations on this engine.
|
||||
*
|
||||
* @param widget the QWidget to associate with the service
|
||||
* @param operation the operation to associate the widget with
|
||||
*/
|
||||
void associateWidget(QWidget *widget, const QString &operation);
|
||||
|
||||
/**
|
||||
* Disassociates a widget if it has been associated with an operation
|
||||
* on this service.
|
||||
*
|
||||
* This will not change the enabled state of the widget.
|
||||
*
|
||||
* @param widget the QWidget to disassociate.
|
||||
*/
|
||||
void disassociateWidget(QWidget *widget);
|
||||
|
||||
/**
|
||||
* Assoicates a widget with an operation, which allows the service to
|
||||
* automatically manage, for example, the enabled state of a widget.
|
||||
*
|
||||
* This will remove any previous associations the widget had with
|
||||
* operations on this engine.
|
||||
*
|
||||
* @param widget the QGraphicsItem to associate with the service
|
||||
* @param operation the operation to associate the widget with
|
||||
*/
|
||||
void associateWidget(QGraphicsWidget *widget, const QString &operation);
|
||||
|
||||
/**
|
||||
* Disassociates a widget if it has been associated with an operation
|
||||
* on this service.
|
||||
*
|
||||
* This will not change the enabled state of the widget.
|
||||
*
|
||||
* @param widget the QGraphicsWidget to disassociate.
|
||||
*/
|
||||
void disassociateWidget(QGraphicsWidget *widget);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* Emitted when a job associated with this Service completes its task
|
||||
|
Loading…
Reference in New Issue
Block a user