File indexing completed on 2024-05-05 17:18:59

0001 /***************************************************************************
0002  * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr
0003  * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  ***************************************************************************/
0006 #ifndef SKGBOARDWIDGET_H
0007 #define SKGBOARDWIDGET_H
0008 /** @file
0009 * This file is a generic for board widget.
0010 * @see SKGReport
0011 *
0012 * @author Stephane MANKOWSKI / Guillaume DE BURE
0013 */
0014 #include "skgbasegui_export.h"
0015 #include "skgwidget.h"
0016 
0017 class QAction;
0018 class QMenu;
0019 class QToolButton;
0020 class QFrame;
0021 class QGridLayout;
0022 class QLabel;
0023 class QAction;
0024 class QMenu;
0025 class SKGZoomSelector;
0026 
0027 /**
0028  * This file is a generic for board widget
0029  */
0030 class SKGBASEGUI_EXPORT SKGBoardWidget : public SKGWidget
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     /**
0036      * Default Constructor
0037      * @param iParent the parent widget
0038      * @param iDocument the document
0039      * @param iTitle the title
0040      * @param iZoomable for a zoomable widget
0041      */
0042     explicit SKGBoardWidget(QWidget* iParent, SKGDocument* iDocument, const QString& iTitle, bool iZoomable = false);
0043 
0044     /**
0045      * Default Destructor
0046      */
0047     ~SKGBoardWidget() override;
0048 
0049     /**
0050      * Get the current state
0051      * MUST BE OVERWRITTEN
0052      * @return a string containing all information needed to set the same state.
0053      * Could be an XML stream
0054      */
0055     QString getState() override;
0056 
0057     /**
0058      * Set the current state
0059      * MUST BE OVERWRITTEN
0060      * @param iState must be interpreted to set the state of the widget
0061      */
0062     void setState(const QString& iState) override;
0063 
0064     /**
0065      * Get the widget for drag and drop
0066      * MUST BE OVERWRITTEN
0067      * @return the widget.
0068      */
0069     virtual QWidget* getDragWidget();
0070 
0071     /**
0072      * Set the main widget
0073      * @param iWidget the main widget
0074      */
0075     virtual void setMainWidget(QWidget* iWidget);
0076 
0077     /**
0078      * Set the main title
0079      * @param iTitle the main title
0080      */
0081     virtual void setMainTitle(const QString& iTitle);
0082 
0083     /**
0084      * Get the main title
0085      * @return the main title
0086      */
0087     virtual QString getMainTitle();
0088 
0089     /**
0090      * Get the original title
0091      * @return the original title
0092      */
0093     virtual QString getOriginalTitle();
0094 
0095     /**
0096      * Set the zoom ratio
0097      * @param iRatio the zoom ratio (1 <= iRatio <=5)
0098      */
0099     virtual void setZoomRatio(double iRatio);
0100 
0101     /**
0102      * Get the zoom ratio
0103      * @return the zoom ratio
0104      */
0105     virtual double getZoomRatio();
0106 
0107     /**
0108      * Add an action
0109      * @param iAction the action to add
0110      */
0111     virtual void addAction(QAction* iAction);
0112 
0113     /**
0114      * Add a sub menu
0115      * @param iMenu the menu to add
0116      */
0117 
0118     virtual void addMenu(QMenu* iMenu);
0119 
0120     /**
0121      * Get the menu
0122      */
0123     virtual QMenu* getMenu();
0124 
0125     /**
0126      * Insert an action
0127      * @param iPos the position of the insertion
0128      * @param iAction the action to add
0129      */
0130     virtual void insertAction(int iPos, QAction* iAction);
0131 
0132     /**
0133      * Hide title and configuration widget
0134      */
0135     virtual void hideTitle();
0136 
0137 
0138 Q_SIGNALS:
0139 
0140     /**
0141      * Sent when the remove is requested
0142      */
0143     void requestRemove();
0144 
0145     /**
0146     * Sent when the move is requested
0147     * @param iMove the move to apply
0148     */
0149     void requestMove(int iMove);
0150 
0151 private Q_SLOTS:
0152     void onZoom(int iZoom);
0153     void requestMoveBefore();
0154     void requestMoveAfter();
0155     void requestMoveFirst();
0156     void requestMoveLast();
0157     void onRenameTitle();
0158 
0159 private:
0160     Q_DISABLE_COPY(SKGBoardWidget)
0161 
0162     QLabel* m_Title{};
0163     QGridLayout* m_gridLayout{};
0164     QFrame* m_frame;
0165     QToolButton* m_toolButton;
0166     QMenu* m_menu;
0167     SKGZoomSelector* m_zoomMenu;
0168     double m_zoomRatio;
0169     QSize m_initialSize;
0170     QFrame* m_line;
0171     QAction* m_menuRename;
0172     QString m_title;
0173     QString m_titleDefault;
0174 };
0175 
0176 #endif  // SKGBOARDWIDGET_H