File indexing completed on 2024-07-21 06:28:22

0001 /*
0002     SPDX-FileCopyrightText: 2003 Jasem Mutlaq <mutlaqja@ikarustech.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <indiproperty.h>
0010 
0011 #include <QString>
0012 #include <QList>
0013 #include <QScrollArea>
0014 #include <QPointer>
0015 
0016 class INDI_P;
0017 class INDI_D;
0018 
0019 class QFrame;
0020 class QVBoxLayout;
0021 class QSpacerItem;
0022 class QScrollArea;
0023 
0024 /**
0025  * @class INDI_G
0026  * INDI_G represents a collection of INDI properties that share a common group. The group is usually represented in the GUI as a separate tab with the device tab.
0027  *
0028  * @author Jasem Mutlaq
0029  */
0030 class INDI_G: public QScrollArea
0031 {
0032     public:
0033         INDI_G(INDI_D *idv, const QString &inName);
0034 
0035         bool addProperty(const INDI::Property newProperty);
0036 
0037         bool removeProperty(const QString &name);
0038         INDI_P *getProperty(const QString &name) const;
0039         QFrame *getContainer() const
0040         {
0041             return m_PropertiesContainer;
0042         }
0043         const QString &getName() const
0044         {
0045             return name;
0046         }
0047 
0048         INDI_D *getDevice() const
0049         {
0050             return dp;
0051         }
0052 
0053         QList<INDI_P *> getProperties() const
0054         {
0055             return m_PropertiesList;
0056         }
0057 
0058         int size() const
0059         {
0060             return m_PropertiesList.count();
0061         }
0062 
0063     private:
0064         // Group name
0065         QString name;
0066         // Parent device
0067         INDI_D *dp {nullptr};
0068         // Properties container
0069         QPointer<QFrame> m_PropertiesContainer;
0070         // Properties layout
0071         QPointer<QVBoxLayout> m_PropertiesLayout;
0072         // Vertical spacer
0073         QSpacerItem *m_VerticalSpacer {nullptr};
0074         QList<INDI_P *> m_PropertiesList;
0075         bool m_Dirty { false };
0076 };