remove associated items/widgets
This commit is contained in:
parent
4692c941af
commit
1137b4ea5c
@ -100,8 +100,6 @@ public:
|
|||||||
QMap<QString, QVariantMap> operationsMap;
|
QMap<QString, QVariantMap> operationsMap;
|
||||||
KConfig *dummyConfig;
|
KConfig *dummyConfig;
|
||||||
DNSSD::PublicService *publicService;
|
DNSSD::PublicService *publicService;
|
||||||
QMultiHash<QWidget *, QString> associatedWidgets;
|
|
||||||
QMultiHash<QQuickItem *, QString> associatedItems;
|
|
||||||
QSet<QString> disabledOperations;
|
QSet<QString> disabledOperations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -170,16 +170,6 @@ Service::~Service()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServicePrivate::associatedWidgetDestroyed(QObject *obj)
|
|
||||||
{
|
|
||||||
associatedWidgets.remove(static_cast<QWidget*>(obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServicePrivate::associatedItemDestroyed(QObject *obj)
|
|
||||||
{
|
|
||||||
associatedItems.remove(static_cast<QQuickItem*>(obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
KConfigGroup ServicePrivate::dummyGroup()
|
KConfigGroup ServicePrivate::dummyGroup()
|
||||||
{
|
{
|
||||||
if (!dummyConfig) {
|
if (!dummyConfig) {
|
||||||
@ -259,31 +249,6 @@ ServiceJob *Service::startOperationCall(const QVariantMap &description, QObject
|
|||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::associateItem(QQuickItem *widget, const QString &operation)
|
|
||||||
{
|
|
||||||
if (!widget) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
disassociateItem(widget);
|
|
||||||
d->associatedItems.insert(widget, operation);
|
|
||||||
connect(widget, SIGNAL(destroyed(QObject*)),
|
|
||||||
this, SLOT(associatedItemDestroyed(QObject*)));
|
|
||||||
|
|
||||||
widget->setEnabled(!d->disabledOperations.contains(operation));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::disassociateItem(QQuickItem *widget)
|
|
||||||
{
|
|
||||||
if (!widget) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
disconnect(widget, SIGNAL(destroyed(QObject*)),
|
|
||||||
this, SLOT(associatedItemDestroyed(QObject*)));
|
|
||||||
d->associatedItems.remove(widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Service::name() const
|
QString Service::name() const
|
||||||
{
|
{
|
||||||
return d->name;
|
return d->name;
|
||||||
@ -316,25 +281,6 @@ void Service::setOperationEnabled(const QString &operation, bool enable)
|
|||||||
d->disabledOperations.insert(operation);
|
d->disabledOperations.insert(operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
QHashIterator<QWidget *, QString> it(d->associatedWidgets);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
if (it.value() == operation) {
|
|
||||||
it.key()->setEnabled(enable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
QHashIterator<QQuickItem *, QString> it(d->associatedItems);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
if (it.value() == operation) {
|
|
||||||
it.key()->setEnabled(enable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit operationEnabledChanged(operation, enable);
|
emit operationEnabledChanged(operation, enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,22 +305,6 @@ void Service::setOperationsScheme(QIODevice *xml)
|
|||||||
reader.parse(&source, false);
|
reader.parse(&source, false);
|
||||||
d->operationsMap = configLoaderHandler.groupsMap();
|
d->operationsMap = configLoaderHandler.groupsMap();
|
||||||
delete configLoaderPrivate;
|
delete configLoaderPrivate;
|
||||||
|
|
||||||
{
|
|
||||||
QHashIterator<QWidget *, QString> it(d->associatedWidgets);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
it.key()->setEnabled(d->operationsMap.contains(it.value()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
QHashIterator<QQuickItem *, QString> it(d->associatedItems);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
it.key()->setEnabled(d->operationsMap.contains(it.value()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::registerOperationsScheme()
|
void Service::registerOperationsScheme()
|
||||||
|
@ -150,28 +150,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE QString name() const;
|
Q_INVOKABLE QString name() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Associates a graphics item with an operation, which allows the service to
|
|
||||||
* automatically manage, for example, the enabled state of the item.
|
|
||||||
*
|
|
||||||
* This will remove any previous associations the item had with
|
|
||||||
* operations on this engine.
|
|
||||||
*
|
|
||||||
* @param item the QGraphicsObject to associate with the service
|
|
||||||
* @param operation the operation to associate the item with
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void associateItem(QQuickItem *item, const QString &operation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disassociates a graphics item if it has been associated with an operation
|
|
||||||
* on this service.
|
|
||||||
*
|
|
||||||
* This will not change the enabled state of the item.
|
|
||||||
*
|
|
||||||
* @param widget the QGraphicsItem to disassociate.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void disassociateItem(QQuickItem *widget);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* Emitted when this service is ready for use
|
* Emitted when this service is ready for use
|
||||||
@ -237,9 +215,6 @@ protected:
|
|||||||
void setOperationEnabled(const QString &operation, bool enable);
|
void setOperationEnabled(const QString &operation, bool enable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PRIVATE_SLOT(d, void associatedWidgetDestroyed(QObject *))
|
|
||||||
Q_PRIVATE_SLOT(d, void associatedItemDestroyed(QObject *))
|
|
||||||
|
|
||||||
ServicePrivate * const d;
|
ServicePrivate * const d;
|
||||||
|
|
||||||
friend class DataEnginePrivate;
|
friend class DataEnginePrivate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user