mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-27 06:03:51 +03:00
storage:provide orphaned subcontainments checker
This commit is contained in:
parent
a2bf28054f
commit
849e66fd80
@ -73,6 +73,21 @@ bool ViewsTable::operator!=(const ViewsTable &rhs) const
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
bool ViewsTable::hasContainmentId(const QString &cid) const
|
||||
{
|
||||
if (containsId(cid)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(int i=0; i<rowCount(); ++i) {
|
||||
if (m_list[i].subcontainments.containsId(cid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ViewsTable ViewsTable::subtracted(const ViewsTable &rhs) const
|
||||
{
|
||||
ViewsTable subtract;
|
||||
|
@ -45,6 +45,8 @@ public:
|
||||
|
||||
void appendTemporaryView(const Data::View &view);
|
||||
|
||||
bool hasContainmentId(const QString &cid) const;
|
||||
|
||||
//! Operators
|
||||
ViewsTable &operator=(const ViewsTable &rhs);
|
||||
ViewsTable &operator=(ViewsTable &&rhs);
|
||||
|
@ -837,6 +837,47 @@ bool Storage::exportTemplate(const Layout::GenericLayout *layout, Plasma::Contai
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Storage::hasOrphanedSubContainments(const Layout::GenericLayout *layout, Data::Error &warning)
|
||||
{
|
||||
if (!layout || layout->file().isEmpty() || !QFile(layout->file()).exists()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
warning.id = m_knownErrors[Data::Error::ORPHANEDSUBCONTAINMENTS].id;
|
||||
warning.name = m_knownErrors[Data::Error::ORPHANEDSUBCONTAINMENTS].name;
|
||||
|
||||
Data::ViewsTable views = Layouts::Storage::self()->views(layout);
|
||||
|
||||
if (!layout->isActive()) {
|
||||
for (const auto containment : *layout->containments()) {
|
||||
QString cid = QString::number(containment->id());
|
||||
|
||||
if (views.hasContainmentId(cid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Data::ErrorInformation errorinfo;
|
||||
errorinfo.containment = metadata(containment->pluginMetaData().pluginId());
|
||||
warning.information << errorinfo;
|
||||
}
|
||||
} else {
|
||||
KSharedConfigPtr lfile = KSharedConfig::openConfig(layout->file());
|
||||
KConfigGroup containmentsEntries = KConfigGroup(lfile, "Containments");
|
||||
|
||||
for (const auto &cId : containmentsEntries.groupList()) {
|
||||
if (views.hasContainmentId(cId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Data::ErrorInformation errorinfo;
|
||||
errorinfo.containment = metadata(containmentsEntries.group(cId).readEntry("plugin", ""));
|
||||
warning.information << errorinfo;
|
||||
}
|
||||
}
|
||||
|
||||
return !warning.information.isEmpty();
|
||||
}
|
||||
|
||||
bool Storage::isBroken(const Layout::GenericLayout *layout, QStringList &errors) const
|
||||
{
|
||||
if (layout->file().isEmpty() || !QFile(layout->file()).exists()) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
// local
|
||||
#include "../data/appletdata.h"
|
||||
#include "../data/errordata.h"
|
||||
#include "../data/genericdata.h"
|
||||
#include "../data/generictable.h"
|
||||
#include "../data/viewstable.h"
|
||||
@ -131,6 +132,7 @@ private:
|
||||
QStringList containmentsIds(const QString &filepath);
|
||||
QStringList appletsIds(const QString &filepath);
|
||||
|
||||
bool hasOrphanedSubContainments(const Layout::GenericLayout *layout, Data::Error &warning);
|
||||
private:
|
||||
QTemporaryDir m_storageTmpDir;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user