File indexing completed on 2024-04-21 05:30:47

0001 /*
0002     SPDX-FileCopyrightText: 2021 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef VIEWDATA_H
0007 #define VIEWDATA_H
0008 
0009 // local
0010 #include <coretypes.h>
0011 #include "genericdata.h"
0012 #include "../screenpool.h"
0013 
0014 // Qt
0015 #include <QMetaType>
0016 #include <QString>
0017 
0018 // Plasma
0019 #include <Plasma>
0020 
0021 
0022 namespace Latte {
0023 namespace Data {
0024 
0025 class View : public Generic
0026 {
0027 public:
0028     enum State {
0029         IsInvalid = -1,
0030         IsCreated = 0,
0031         OriginFromViewTemplate, /*used for view templates files*/
0032         OriginFromLayout /*used from duplicate, copy, move view functions*/
0033     };
0034 
0035     static const int ISCLONEDNULL;
0036 
0037     View();
0038     View(View &&o);
0039     View(const View &o);
0040     View(const QString &newid, const QString &newname);
0041 
0042     //! View data
0043     bool isActive{false};
0044     bool onPrimary{true};
0045     int isClonedFrom{ISCLONEDNULL};
0046     int screen{Latte::ScreenPool::FIRSTSCREENID};
0047     int screenEdgeMargin{0};
0048     float maxLength{1.0};
0049     Plasma::Types::Location edge{Plasma::Types::BottomEdge};
0050     Latte::Types::Alignment alignment{Latte::Types::Center};
0051     Latte::Types::ScreensGroup screensGroup{Latte::Types::SingleScreenGroup};
0052     GenericTable<Data::Generic> subcontainments;
0053 
0054     int errors{0};
0055     int warnings{0};
0056 
0057     //! View sub-states
0058     bool isMoveOrigin{false};
0059     bool isMoveDestination{false};
0060 
0061     bool isValid() const;
0062     bool isCreated() const;
0063     bool isOriginal() const;
0064     bool isCloned() const;
0065     bool hasViewTemplateOrigin() const;
0066     bool hasLayoutOrigin() const;
0067     bool hasSubContainment(const QString &subId) const;
0068     bool hasErrors() const;
0069     bool hasWarnings() const;
0070 
0071     bool isHorizontal() const;
0072     bool isVertical() const;
0073 
0074     QString originFile() const;
0075     QString originLayout() const;
0076     QString originView() const;    
0077 
0078     View::State state() const;
0079     void setState(View::State state, QString file = QString(), QString layout = QString(), QString view = QString());
0080 
0081     //! Operators
0082     View &operator=(const View &rhs);
0083     View &operator=(View &&rhs);
0084     bool operator==(const View &rhs) const;
0085     bool operator!=(const View &rhs) const;
0086     operator QString() const;
0087 
0088 protected:
0089     View::State m_state{IsInvalid};
0090 
0091     //! Origin Data
0092     QString m_originFile;
0093     QString m_originLayout;
0094     QString m_originView;
0095 };
0096 
0097 }
0098 }
0099 
0100 Q_DECLARE_METATYPE(Latte::Data::View)
0101 
0102 #endif