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