remove associated items/widgets

This commit is contained in:
Marco Martin 2013-05-02 19:02:06 +02:00
parent 4692c941af
commit 1137b4ea5c
3 changed files with 0 additions and 97 deletions

View File

@ -100,8 +100,6 @@ public:
QMap<QString, QVariantMap> operationsMap;
KConfig *dummyConfig;
DNSSD::PublicService *publicService;
QMultiHash<QWidget *, QString> associatedWidgets;
QMultiHash<QQuickItem *, QString> associatedItems;
QSet<QString> disabledOperations;
};

View File

@ -170,16 +170,6 @@ Service::~Service()
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()
{
if (!dummyConfig) {
@ -259,31 +249,6 @@ ServiceJob *Service::startOperationCall(const QVariantMap &description, QObject
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
{
return d->name;
@ -316,25 +281,6 @@ void Service::setOperationEnabled(const QString &operation, bool enable)
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);
}
@ -359,22 +305,6 @@ void Service::setOperationsScheme(QIODevice *xml)
reader.parse(&source, false);
d->operationsMap = configLoaderHandler.groupsMap();
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()

View File

@ -150,28 +150,6 @@ public:
*/
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:
/**
* Emitted when this service is ready for use
@ -237,9 +215,6 @@ protected:
void setOperationEnabled(const QString &operation, bool enable);
private:
Q_PRIVATE_SLOT(d, void associatedWidgetDestroyed(QObject *))
Q_PRIVATE_SLOT(d, void associatedItemDestroyed(QObject *))
ServicePrivate * const d;
friend class DataEnginePrivate;