File indexing completed on 2024-04-14 05:24:21

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "layoutdata.h"
0007 
0008 // Qt
0009 #include <QDir>
0010 
0011 namespace Latte {
0012 namespace Data {
0013 
0014 Layout::Layout()
0015     : Generic()
0016 {
0017 }
0018 
0019 Layout::Layout(Layout &&o)
0020     : Generic(o),
0021       icon(o.icon),
0022       color(o.color),
0023       background(o.background),
0024       textColor(o.textColor),
0025       lastUsedActivity(o.lastUsedActivity),
0026       isActive(o.isActive),
0027       isConsideredActive(o.isConsideredActive),
0028       isLocked(o.isLocked),
0029       isShownInMenu(o.isShownInMenu),
0030       isTemplate(o.isTemplate),
0031       hasDisabledBorders(o.hasDisabledBorders),
0032       popUpMargin(o.popUpMargin),
0033       schemeFile(o.schemeFile),
0034       activities(o.activities),
0035       backgroundStyle(o.backgroundStyle),
0036       errors(o.errors),
0037       warnings(o.warnings),
0038       views(o.views)
0039 {
0040 }
0041 
0042 Layout::Layout(const Layout &o)
0043     : Generic(o),
0044       icon(o.icon),
0045       color(o.color),
0046       background(o.background),
0047       textColor(o.textColor),
0048       lastUsedActivity(o.lastUsedActivity),
0049       isActive(o.isActive),
0050       isConsideredActive(o.isConsideredActive),
0051       isLocked(o.isLocked),
0052       isShownInMenu(o.isShownInMenu),
0053       isTemplate(o.isTemplate),
0054       hasDisabledBorders(o.hasDisabledBorders),
0055       popUpMargin(o.popUpMargin),
0056       schemeFile(o.schemeFile),
0057       activities(o.activities),
0058       backgroundStyle(o.backgroundStyle),
0059       errors(o.errors),
0060       warnings(o.warnings),
0061       views(o.views)
0062 {
0063 }
0064 
0065 Layout &Layout::operator=(Layout &&rhs)
0066 {
0067     id = rhs.id;
0068     name = rhs.name;
0069     icon = rhs.icon;
0070     color = rhs.color;
0071     background = rhs.background;
0072     textColor = rhs.textColor;
0073     lastUsedActivity = rhs.lastUsedActivity;
0074     isActive = rhs.isActive;
0075     isConsideredActive = rhs.isConsideredActive;
0076     isLocked = rhs.isLocked;
0077     isShownInMenu = rhs.isShownInMenu;
0078     isTemplate = rhs.isTemplate;
0079     hasDisabledBorders = rhs.hasDisabledBorders;
0080     popUpMargin = rhs.popUpMargin;
0081     schemeFile = rhs.schemeFile;
0082     activities = rhs.activities;
0083     backgroundStyle = rhs.backgroundStyle;
0084     errors = rhs.errors;
0085     warnings = rhs.warnings;
0086     views = rhs.views;
0087 
0088     return (*this);
0089 }
0090 
0091 Layout &Layout::operator=(const Layout &rhs)
0092 {
0093     id = rhs.id;
0094     name = rhs.name;
0095     icon = rhs.icon;
0096     color = rhs.color;
0097     background = rhs.background;
0098     textColor = rhs.textColor;
0099     lastUsedActivity = rhs.lastUsedActivity;
0100     isActive = rhs.isActive;
0101     isConsideredActive = rhs.isConsideredActive;
0102     isLocked = rhs.isLocked;
0103     isShownInMenu = rhs.isShownInMenu;
0104     isTemplate = rhs.isTemplate;
0105     hasDisabledBorders = rhs.hasDisabledBorders;
0106     popUpMargin = rhs.popUpMargin;
0107     schemeFile = rhs.schemeFile;
0108     activities = rhs.activities;
0109     backgroundStyle = rhs.backgroundStyle;
0110     errors = rhs.errors;
0111     warnings = rhs.warnings;
0112     views = rhs.views;
0113 
0114     return (*this);
0115 }
0116 
0117 bool Layout::operator==(const Layout &rhs) const
0118 {
0119     return (id == rhs.id)
0120             && (name == rhs.name)
0121             && (icon == rhs.icon)
0122             && (color == rhs.color)
0123             && (background == rhs.background)
0124             && (textColor == rhs.textColor)
0125             //&& (lastUsedActivity == rhs.lastUsedActivity) /*Disabled because this is not needed in order to track layout changes for saving*/
0126             //&& (isActive == rhs.isActive) /*Disabled because this is not needed in order to track layout changes for saving*/
0127             //&& (isConsideredActive == rhs.isConsideredActive) /*Disabled because this is not needed in order to track layout changes for saving*/
0128             && (isLocked == rhs.isLocked)
0129             && (isShownInMenu == rhs.isShownInMenu)
0130             && (isTemplate == rhs.isTemplate)
0131             && (hasDisabledBorders == rhs.hasDisabledBorders)
0132             && (popUpMargin == rhs.popUpMargin)
0133             && (schemeFile == rhs.schemeFile)
0134             && (activities == rhs.activities)
0135             && (backgroundStyle == rhs.backgroundStyle)
0136             //&& (errors == rhs.errors) /*Disabled because this is not needed in order to track layout changes for saving*/
0137             //&& (warnings == rhs.warnings) /*Disabled because this is not needed in order to track layout changes for saving*/
0138             && (views == rhs.views);
0139 }
0140 
0141 bool Layout::operator!=(const Layout &rhs) const
0142 {
0143     return !(*this == rhs);
0144 }
0145 
0146 bool Layout::isOnAllActivities() const
0147 {
0148     return ((activities.count() == 1) && (activities[0] == ALLACTIVITIESID));
0149 }
0150 
0151 bool Layout::isForFreeActivities() const
0152 {
0153     return ((activities.count() == 1) && (activities[0] == FREEACTIVITIESID));
0154 }
0155 
0156 bool Layout::isTemporary() const
0157 {
0158     return id.startsWith("/tmp");
0159 }
0160 
0161 bool Layout::isEmpty() const
0162 {
0163     return isNull();
0164 }
0165 
0166 bool Layout::isNull() const
0167 {
0168     return (id.isEmpty() && name.isEmpty());
0169 }
0170 
0171 bool Layout::isSystemTemplate() const
0172 {
0173     return isTemplate && !id.startsWith(QDir::tempPath()) && !id.startsWith(QDir::homePath());
0174 }
0175 
0176 bool Layout::hasErrors() const
0177 {
0178     return errors > 0;
0179 }
0180 
0181 bool Layout::hasWarnings() const
0182 {
0183     return warnings > 0;
0184 }
0185 
0186 }
0187 }
0188