File indexing completed on 2024-04-14 14:11:38

0001 /*
0002     SPDX-FileCopyrightText: 2015 Jasem Mutlaq <mutlaqja@ikarustech.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "ui_horizonmanager.h"
0010 
0011 #include <QDialog>
0012 
0013 #include <memory>
0014 
0015 class QStandardItem;
0016 class QStandardItemModel;
0017 
0018 class ArtificialHorizonComponent;
0019 class ArtificialHorizonEntity;
0020 class LineList;
0021 class SkyPoint;
0022 
0023 class HorizonManagerUI : public QFrame, public Ui::HorizonManager
0024 {
0025         Q_OBJECT
0026 
0027     public:
0028         /** @short Constructor */
0029         explicit HorizonManagerUI(QWidget *parent);
0030 };
0031 
0032 /**
0033  * @class HorizonManager
0034  * @short Manages adding/removing and editing regions and points associated with
0035  * user-customized artificial horizons.
0036  *
0037  * @version 1.0
0038  * @author Jasem Mutlaq
0039  */
0040 class HorizonManager : public QDialog
0041 {
0042         Q_OBJECT
0043     public:
0044         /** @short Constructor */
0045         explicit HorizonManager(QWidget *ks);
0046 
0047         /** @short Destructor */
0048         virtual ~HorizonManager() override = default;
0049 
0050         void showRegion(const int regionID);
0051 
0052         bool validate(int regionID);
0053 
0054         void deleteRegion(int regionID);
0055 
0056     protected:
0057         void closeEvent(QCloseEvent *event) override;
0058         void showEvent(QShowEvent *event) override;
0059 
0060     public slots:
0061         /** @short Add region */
0062         void slotAddRegion();
0063 
0064         /** @short Delete region */
0065         void slotRemoveRegion();
0066 
0067         void slotToggleCeiling();
0068 
0069         void addSkyPoint(SkyPoint *skypoint);
0070         void slotAddPoint();
0071         void slotRemovePoint();
0072         void slotClosed();
0073 
0074         void clearPoints();
0075 
0076         void setSelectPoints(bool);
0077         void slotCurrentPointChanged(const QModelIndex &current, const QModelIndex &previous);
0078 
0079     private slots:
0080         void verifyItemValue(QStandardItem *item);
0081         void slotSaveChanges();
0082         void slotSetShownRegion(QModelIndex idx);
0083 
0084     private:
0085         void addPoint(SkyPoint *skyPoint);
0086         void terminateLivePreview();
0087         void setPointSelection(bool enable);
0088         void removeEmptyRows(int regionID);
0089         void setupLivePreview(QStandardItem *item);
0090         void setupValidation(int regionID);
0091 
0092         HorizonManagerUI *ui { nullptr };
0093 
0094         QStandardItemModel *m_RegionsModel { nullptr };
0095         ArtificialHorizonComponent *horizonComponent { nullptr };
0096 
0097         std::shared_ptr<LineList> livePreview;
0098         bool selectPoints { false };
0099 
0100         friend class TestArtificialHorizon;
0101 };