Commit 60e641ef authored by Halla Rempt's avatar Halla Rempt

Notify the resource models if storages are enabled or disabled

parent 93b6c70e
......@@ -407,6 +407,8 @@ void KisResourceLocator::purge()
bool KisResourceLocator::addStorage(const QString &storageLocation, KisResourceStorageSP storage)
{
qDebug() << "addStorage" << storageLocation << storage;
Q_ASSERT(!d->storages.contains(storageLocation));
d->storages[storageLocation] = storage;
......@@ -416,7 +418,6 @@ bool KisResourceLocator::addStorage(const QString &storageLocation, KisResourceS
return false;
}
emit storageAdded(storage->location());
return true;
}
......
......@@ -16,8 +16,11 @@
#include <KisResourceCacheDb.h>
#include <KisResourceModelProvider.h>
#include <KisStorageModel.h>
#include <KisTagModel.h>
#include <kis_debug.h>
#include "KisResourceQueryMapper.h"
struct KisAllResourcesModel::Private {
......@@ -34,6 +37,8 @@ KisAllResourcesModel::KisAllResourcesModel(const QString &resourceType, QObject
connect(KisResourceLocator::instance(), SIGNAL(storageAdded(const QString&)), this, SLOT(addStorage(const QString&)));
connect(KisResourceLocator::instance(), SIGNAL(storageRemoved(const QString&)), this, SLOT(removeStorage(const QString&)));
connect(KisStorageModel::instance(), SIGNAL(storageEnabled(const QString&)), this, SLOT(addStorage(const QString&)));
connect(KisStorageModel::instance(), SIGNAL(storageDisabled(const QString&)), this, SLOT(removeStorage(const QString&)));
d->resourceType = resourceType;
......@@ -443,7 +448,7 @@ int KisAllResourcesModel::rowCount(const QModelIndex &) const
}
void KisAllResourcesModel::addStorage(const QString &/*location*/)
void KisAllResourcesModel::addStorage(const QString &location)
{
beginResetModel();
resetQuery();
......@@ -451,7 +456,7 @@ void KisAllResourcesModel::addStorage(const QString &/*location*/)
}
void KisAllResourcesModel::removeStorage(const QString &/*location*/)
void KisAllResourcesModel::removeStorage(const QString &location)
{
beginResetModel();
resetQuery();
......
......@@ -229,7 +229,16 @@ bool KisStorageModel::setData(const QModelIndex &index, const QVariant &value, i
}
}
emit dataChanged(index, index, {role});
if (value.toBool()) {
emit storageEnabled(data(index, Qt::UserRole + Location).toString());
}
else {
emit storageDisabled(data(index, Qt::UserRole + Location).toString());
}
return true;
}
......
......@@ -52,6 +52,11 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
Q_SIGNALS:
void storageEnabled(const QString &storage);
void storageDisabled(const QString &storage);
private Q_SLOTS:
/// Called whenever a storage is added
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment