1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-02-10 09:57:35 +03:00

introduce ViewData Origin data

This commit is contained in:
Michail Vourlakos 2021-03-20 23:48:53 +02:00
parent e7eeb4f9fd
commit a48786a5e2
2 changed files with 86 additions and 2 deletions

View File

@ -23,6 +23,8 @@
namespace Latte {
namespace Data {
const char *TEMPIDPREFIX = "temp:";
View::View()
: Generic()
{
@ -33,7 +35,10 @@ View::View(View &&o)
onPrimary(o.onPrimary),
screen(o.screen),
maxLength(o.maxLength),
alignment(o.alignment)
alignment(o.alignment),
originType(o.originType),
originFile(o.originFile),
originView(o.originView)
{
}
@ -42,7 +47,10 @@ View::View(const View &o)
onPrimary(o.onPrimary),
screen(o.screen),
maxLength(o.maxLength),
alignment(o.alignment)
alignment(o.alignment),
originType(o.originType),
originFile(o.originFile),
originView(o.originView)
{
}
@ -54,6 +62,9 @@ View &View::operator=(const View &rhs)
screen = rhs.screen;
maxLength = rhs.maxLength;
alignment = rhs.alignment;
originType = rhs.originType;
originFile = rhs.originFile;
originView = rhs.originView;
return (*this);
}
@ -66,9 +77,60 @@ View &View::operator=(View &&rhs)
screen = rhs.screen;
maxLength = rhs.maxLength;
alignment = rhs.alignment;
originType = rhs.originType;
originFile = rhs.originFile;
originView = rhs.originView;
return (*this);
}
bool View::operator==(const View &rhs) const
{
return (id == rhs.id)
&& (name == rhs.name)
&& (onPrimary == rhs.onPrimary)
&& (screen == rhs.screen)
&& (maxLength == rhs.maxLength)
&& (alignment == rhs.alignment)
&& (originType == rhs.originType)
&& (originFile == rhs.originFile)
&& (originView == rhs.originView);
}
bool View::operator!=(const View &rhs) const
{
return !(*this == rhs);
}
bool View::hasViewTemplateOrigin() const
{
return originType == OriginFromViewTemplate;
}
bool View::hasLayoutOrigin() const
{
return originType == OriginFromLayout;
}
QString View::tempId() const
{
if (originType == IsCreated) {
return id;
}
QString tid = id;
tid.remove(0, QString(TEMPIDPREFIX).count());
return tid;
}
void View::setOrigin(OriginType origin, QString file, QString view)
{
originType = origin;
originFile = file;
originView = view;
}
}
}

View File

@ -38,6 +38,12 @@ namespace Data {
class View : public Generic
{
public:
enum OriginType {
IsCreated = 0,
OriginFromViewTemplate,
OriginFromLayout
};
View();
View(View &&o);
View(const View &o);
@ -48,9 +54,25 @@ public:
float maxLength{1.0};
Latte::Types::Alignment alignment{Latte::Types::Center};
bool hasViewTemplateOrigin() const;
bool hasLayoutOrigin() const;
QString tempId() const;
void setOrigin(OriginType origin, QString file = QString(), QString view = QString());
//! Operators
View &operator=(const View &rhs);
View &operator=(View &&rhs);
bool operator==(const View &rhs) const;
bool operator!=(const View &rhs) const;
protected:
OriginType originType{IsCreated};
//! Origin Data
QString originFile;
QString originView;
};
}