mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 01:33:50 +03:00
layout:provide errors/warnings structured nicely
This commit is contained in:
parent
2be67b11c5
commit
51044ce630
@ -2,6 +2,7 @@ set(lattedock-app_SRCS
|
||||
${lattedock-app_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/activitydata.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/appletdata.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/errordata.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/errorinformationdata.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/genericbasictable.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/genericdata.cpp
|
||||
|
@ -62,7 +62,7 @@ bool Error::operator==(const Error &rhs) const
|
||||
{
|
||||
return (id == rhs.id)
|
||||
&& (name == rhs.name)
|
||||
&& (information == rhs.information)
|
||||
&& (information == rhs.information);
|
||||
}
|
||||
|
||||
bool Error::operator!=(const Error &rhs) const
|
||||
|
@ -18,8 +18,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ERRORDATA_H
|
||||
#define ERRORDATA_H
|
||||
#ifndef GENERICERRORDATA_H
|
||||
#define GENERICERRORDATA_H
|
||||
|
||||
//! local
|
||||
#include "genericdata.h"
|
||||
@ -55,15 +55,16 @@ public:
|
||||
|
||||
GenericTable<Data::ErrorInformation> information;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
typedef QList<Error> ErrorList;
|
||||
typedef Error Warning;
|
||||
typedef QList<Error> ErrorsList;
|
||||
typedef QList<Warning> WarningsList;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(Latte::Data::Error)
|
||||
Q_DECLARE_METATYPE(Latte::Data::ErrorsList)
|
||||
|
||||
#endif
|
||||
|
@ -52,6 +52,8 @@ public:
|
||||
bool operator!=(const ErrorInformation &rhs) const;
|
||||
};
|
||||
|
||||
typedef ErrorInformation WarningInformation;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@ Layout::Layout(Layout &&o)
|
||||
hasDisabledBorders(o.hasDisabledBorders),
|
||||
activities(o.activities),
|
||||
backgroundStyle(o.backgroundStyle),
|
||||
errors(o.errors),
|
||||
warnings(o.warnings),
|
||||
views(o.views)
|
||||
{
|
||||
}
|
||||
@ -67,6 +69,8 @@ Layout::Layout(const Layout &o)
|
||||
hasDisabledBorders(o.hasDisabledBorders),
|
||||
activities(o.activities),
|
||||
backgroundStyle(o.backgroundStyle),
|
||||
errors(o.errors),
|
||||
warnings(o.warnings),
|
||||
views(o.views)
|
||||
{
|
||||
}
|
||||
@ -89,6 +93,8 @@ Layout &Layout::operator=(Layout &&rhs)
|
||||
hasDisabledBorders = rhs.hasDisabledBorders;
|
||||
activities = rhs.activities;
|
||||
backgroundStyle = rhs.backgroundStyle;
|
||||
errors = rhs.errors;
|
||||
warnings = rhs.warnings;
|
||||
views = rhs.views;
|
||||
|
||||
return (*this);
|
||||
@ -112,6 +118,8 @@ Layout &Layout::operator=(const Layout &rhs)
|
||||
hasDisabledBorders = rhs.hasDisabledBorders;
|
||||
activities = rhs.activities;
|
||||
backgroundStyle = rhs.backgroundStyle;
|
||||
errors = rhs.errors;
|
||||
warnings = rhs.warnings;
|
||||
views = rhs.views;
|
||||
|
||||
return (*this);
|
||||
@ -135,6 +143,8 @@ bool Layout::operator==(const Layout &rhs) const
|
||||
&& (hasDisabledBorders == rhs.hasDisabledBorders)
|
||||
&& (activities == rhs.activities)
|
||||
&& (backgroundStyle == rhs.backgroundStyle)
|
||||
&& (errors == rhs.errors)
|
||||
&& (warnings == rhs.warnings)
|
||||
&& (views == rhs.views);
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
bool isTemplate{false};
|
||||
bool hasDisabledBorders{false};
|
||||
QStringList activities;
|
||||
int errors{0};
|
||||
int warnings{0};
|
||||
|
||||
Latte::Layout::BackgroundStyle backgroundStyle{Latte::Layout::ColorBackgroundStyle};
|
||||
|
||||
|
@ -155,6 +155,9 @@ Data::Layout CentralLayout::data() const
|
||||
cdata.activities = activities();
|
||||
cdata.lastUsedActivity = lastUsedActivity();
|
||||
|
||||
cdata.errors = errors().count();
|
||||
cdata.warnings = warnings().count();
|
||||
|
||||
return cdata;
|
||||
}
|
||||
|
||||
|
@ -1675,6 +1675,16 @@ bool GenericLayout::isBroken() const
|
||||
return Layouts::Storage::self()->isBroken(this, errors);
|
||||
}
|
||||
|
||||
Data::ErrorsList GenericLayout::errors() const
|
||||
{
|
||||
return Layouts::Storage::self()->errors(this);
|
||||
}
|
||||
|
||||
Data::WarningsList GenericLayout::warnings() const
|
||||
{
|
||||
return Layouts::Storage::self()->warnings(this);
|
||||
}
|
||||
|
||||
Latte::Data::ViewsTable GenericLayout::viewsTable() const
|
||||
{
|
||||
return Layouts::Storage::self()->views(this);
|
||||
|
@ -23,6 +23,7 @@
|
||||
// local
|
||||
#include <coretypes.h>
|
||||
#include "abstractlayout.h"
|
||||
#include "../data/errordata.h"
|
||||
#include "../data/viewdata.h"
|
||||
#include "../data/viewstable.h"
|
||||
|
||||
@ -148,6 +149,10 @@ public:
|
||||
|
||||
Latte::Data::ViewsTable viewsTable() const;
|
||||
|
||||
//! errors/warnings
|
||||
Data::ErrorsList errors() const;
|
||||
Data::WarningsList warnings() const;
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE int viewsWithTasks() const;
|
||||
virtual Q_INVOKABLE QList<int> qmlFreeEdges(int screen) const; //change <Plasma::Types::Location> to <int> types
|
||||
|
@ -924,7 +924,7 @@ bool Storage::hasDifferentAppletsWithSameId(const Layout::GenericLayout *layout,
|
||||
return !error.information.isEmpty();
|
||||
}
|
||||
|
||||
bool Storage::hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *layout, Data::Error &warning)
|
||||
bool Storage::hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *layout, Data::Warning &warning)
|
||||
{
|
||||
if (!layout || layout->file().isEmpty() || !QFile(layout->file()).exists()) {
|
||||
return false;
|
||||
@ -968,11 +968,11 @@ bool Storage::hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *l
|
||||
QString cid = QString::number(containment->id());
|
||||
|
||||
if (conflicted.contains(cid)) {
|
||||
Data::ErrorInformation errorinfo;
|
||||
errorinfo.containment = metadata(containment->pluginMetaData().pluginId());
|
||||
errorinfo.containment.storageId = cid;
|
||||
Data::WarningInformation warninginfo;
|
||||
warninginfo.containment = metadata(containment->pluginMetaData().pluginId());
|
||||
warninginfo.containment.storageId = cid;
|
||||
|
||||
warning.information << errorinfo;
|
||||
warning.information << warninginfo;
|
||||
}
|
||||
|
||||
for (const auto applet : containment->applets()) {
|
||||
@ -982,13 +982,13 @@ bool Storage::hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *l
|
||||
continue;
|
||||
}
|
||||
|
||||
Data::ErrorInformation errorinfo;
|
||||
errorinfo.containment = metadata(containment->pluginMetaData().pluginId());
|
||||
errorinfo.containment.storageId = cid;
|
||||
errorinfo.applet = metadata(applet->pluginMetaData().pluginId());
|
||||
errorinfo.applet.storageId = aid;
|
||||
Data::WarningInformation warninginfo;
|
||||
warninginfo.containment = metadata(containment->pluginMetaData().pluginId());
|
||||
warninginfo.containment.storageId = cid;
|
||||
warninginfo.applet = metadata(applet->pluginMetaData().pluginId());
|
||||
warninginfo.applet.storageId = aid;
|
||||
|
||||
warning.information << errorinfo;
|
||||
warning.information << warninginfo;
|
||||
}
|
||||
}
|
||||
} else { // inactive layout
|
||||
@ -1021,11 +1021,11 @@ bool Storage::hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *l
|
||||
//! create warning data
|
||||
for (const auto &cid : containmentsEntries.groupList()) {
|
||||
if (conflicted.contains(cid)) {
|
||||
Data::ErrorInformation errorinfo;
|
||||
errorinfo.containment = metadata(containmentsEntries.group(cid).readEntry("plugin", ""));
|
||||
errorinfo.containment.storageId = cid;
|
||||
Data::WarningInformation warninginfo;
|
||||
warninginfo.containment = metadata(containmentsEntries.group(cid).readEntry("plugin", ""));
|
||||
warninginfo.containment.storageId = cid;
|
||||
|
||||
warning.information << errorinfo;
|
||||
warning.information << warninginfo;
|
||||
}
|
||||
|
||||
for (const auto &aid : containmentsEntries.group(cid).group("Applets").groupList()) {
|
||||
@ -1033,13 +1033,13 @@ bool Storage::hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *l
|
||||
continue;
|
||||
}
|
||||
|
||||
Data::ErrorInformation errorinfo;
|
||||
errorinfo.containment = metadata(containmentsEntries.group(cid).readEntry("plugin", ""));
|
||||
errorinfo.containment.storageId = cid;
|
||||
errorinfo.applet = metadata(containmentsEntries.group(cid).group("Applets").group(aid).readEntry("plugin", ""));
|
||||
errorinfo.applet.storageId = aid;
|
||||
Data::WarningInformation warninginfo;
|
||||
warninginfo.containment = metadata(containmentsEntries.group(cid).readEntry("plugin", ""));
|
||||
warninginfo.containment.storageId = cid;
|
||||
warninginfo.applet = metadata(containmentsEntries.group(cid).group("Applets").group(aid).readEntry("plugin", ""));
|
||||
warninginfo.applet.storageId = aid;
|
||||
|
||||
warning.information << errorinfo;
|
||||
warning.information << warninginfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1047,7 +1047,7 @@ bool Storage::hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *l
|
||||
return !warning.information.isEmpty();
|
||||
}
|
||||
|
||||
bool Storage::hasOrphanedSubContainments(const Layout::GenericLayout *layout, Data::Error &warning)
|
||||
bool Storage::hasOrphanedSubContainments(const Layout::GenericLayout *layout, Data::Warning &warning)
|
||||
{
|
||||
if (!layout || layout->file().isEmpty() || !QFile(layout->file()).exists()) {
|
||||
return false;
|
||||
@ -1067,10 +1067,10 @@ bool Storage::hasOrphanedSubContainments(const Layout::GenericLayout *layout, Da
|
||||
continue;
|
||||
}
|
||||
|
||||
Data::ErrorInformation errorinfo;
|
||||
errorinfo.containment = metadata(containment->pluginMetaData().pluginId());
|
||||
errorinfo.containment.storageId = cid;
|
||||
warning.information << errorinfo;
|
||||
Data::WarningInformation warninginfo;
|
||||
warninginfo.containment = metadata(containment->pluginMetaData().pluginId());
|
||||
warninginfo.containment.storageId = cid;
|
||||
warning.information << warninginfo;
|
||||
}
|
||||
|
||||
} else { // inactive layout
|
||||
@ -1083,16 +1083,57 @@ bool Storage::hasOrphanedSubContainments(const Layout::GenericLayout *layout, Da
|
||||
continue;
|
||||
}
|
||||
|
||||
Data::ErrorInformation errorinfo;
|
||||
errorinfo.containment = metadata(containmentsEntries.group(cid).readEntry("plugin", ""));
|
||||
errorinfo.containment.storageId = cid;
|
||||
warning.information << errorinfo;
|
||||
Data::WarningInformation warninginfo;
|
||||
warninginfo.containment = metadata(containmentsEntries.group(cid).readEntry("plugin", ""));
|
||||
warninginfo.containment.storageId = cid;
|
||||
warning.information << warninginfo;
|
||||
}
|
||||
}
|
||||
|
||||
return !warning.information.isEmpty();
|
||||
}
|
||||
|
||||
Data::ErrorsList Storage::errors(const Layout::GenericLayout *layout)
|
||||
{
|
||||
Data::ErrorsList errs;
|
||||
|
||||
if (!layout || layout->file().isEmpty() || !QFile(layout->file()).exists()) {
|
||||
return errs;
|
||||
}
|
||||
|
||||
Data::Error error1;
|
||||
|
||||
if (hasDifferentAppletsWithSameId(layout, error1)) {
|
||||
errs << error1;
|
||||
}
|
||||
|
||||
return errs;
|
||||
}
|
||||
|
||||
Data::WarningsList Storage::warnings(const Layout::GenericLayout *layout)
|
||||
{
|
||||
Data::WarningsList warns;
|
||||
|
||||
if (!layout || layout->file().isEmpty() || !QFile(layout->file()).exists()) {
|
||||
return warns;
|
||||
}
|
||||
|
||||
Data::Warning warning1;
|
||||
|
||||
if (hasAppletsAndContainmentsWithSameId(layout, warning1)) {
|
||||
warns << warning1;
|
||||
}
|
||||
|
||||
Data::Warning warning2;
|
||||
|
||||
if (hasOrphanedSubContainments(layout, warning2)) {
|
||||
warns << warning2;
|
||||
}
|
||||
|
||||
return warns;
|
||||
}
|
||||
|
||||
|
||||
bool Storage::isBroken(const Layout::GenericLayout *layout, QStringList &errors) const
|
||||
{
|
||||
if (layout->file().isEmpty() || !QFile(layout->file()).exists()) {
|
||||
|
@ -110,6 +110,10 @@ public:
|
||||
Data::ViewsTable views(const QString &file);
|
||||
Data::ViewsTable views(const Layout::GenericLayout *layout);
|
||||
|
||||
//! errors/warning;
|
||||
Data::ErrorsList errors(const Layout::GenericLayout *layout);
|
||||
Data::WarningsList warnings(const Layout::GenericLayout *layout);
|
||||
|
||||
private:
|
||||
Storage();
|
||||
|
||||
@ -134,8 +138,8 @@ private:
|
||||
|
||||
//! errors/warnings checkers
|
||||
bool hasDifferentAppletsWithSameId(const Layout::GenericLayout *layout, Data::Error &error);
|
||||
bool hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *layout, Data::Error &warning);
|
||||
bool hasOrphanedSubContainments(const Layout::GenericLayout *layout, Data::Error &warning);
|
||||
bool hasAppletsAndContainmentsWithSameId(const Layout::GenericLayout *layout, Data::Warning &warning);
|
||||
bool hasOrphanedSubContainments(const Layout::GenericLayout *layout, Data::Warning &warning);
|
||||
private:
|
||||
QTemporaryDir m_storageTmpDir;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user