Warning, file /office/skrooge/skgbasegui/skgtabpage.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 SKGTABPAGE_H
0007 #define SKGTABPAGE_H
0008 /** @file
0009  * This file is a class managing widget.
0010  *
0011  * @author Stephane MANKOWSKI / Guillaume DE BURE
0012  */
0013 
0014 #include <qlist.h>
0015 #include <qwidget.h>
0016 
0017 #include "skgbasegui_export.h"
0018 #include "skgwidget.h"
0019 
0020 /**
0021  * This file is a tab widget used by plugins
0022  */
0023 class SKGBASEGUI_EXPORT SKGTabPage : public SKGWidget
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     /**
0029      * Describe a history item
0030      */
0031     struct SKGPageHistoryItem {
0032         QString plugin;     /**< The plugin name */
0033         QString name;       /**< The name */
0034         QString state;      /**< The state */
0035         QString icon;       /**< The icon */
0036         QString bookmarkID;     /**< The bookmarkID */
0037     };
0038 
0039     /**
0040      * List of history item
0041      */
0042     using SKGPageHistoryItemList = QVector<SKGTabPage::SKGPageHistoryItem>;
0043 
0044 
0045     /**
0046      * Default Constructor
0047      * @param iParent the parent widget
0048      * @param iDocument the document
0049      */
0050     explicit SKGTabPage(QWidget* iParent, SKGDocument* iDocument);
0051 
0052     /**
0053      * Default Destructor
0054      */
0055     ~SKGTabPage() override;
0056 
0057     /**
0058      * Set the bookmark id
0059      * @param iId bookmark id
0060      */
0061     virtual void setBookmarkID(const QString& iId);
0062 
0063     /**
0064      * Get the bookmark id
0065      * @return bookmark id
0066      */
0067     virtual QString getBookmarkID();
0068 
0069     /**
0070      * To know if an overwrite is needed
0071      */
0072     virtual bool isOverwriteNeeded();
0073 
0074     /**
0075      * Overwrite bookmark if page is opened from a bookmark
0076      * Overwrite context if page is opened from a context
0077      * @param iUserConfirmation to display a confirmation panel
0078      */
0079     virtual void overwrite(bool iUserConfirmation = true);
0080 
0081     /**
0082      * Get previous pages
0083      * @return the list
0084      */
0085     virtual SKGTabPage::SKGPageHistoryItemList getPreviousPages();
0086 
0087     /**
0088      * Set previous pages
0089      * @param iPages the list
0090      */
0091     virtual void setPreviousPages(const SKGTabPage::SKGPageHistoryItemList& iPages);
0092 
0093     /**
0094      * Get next pages
0095      * @return the list
0096      */
0097     virtual SKGTabPage::SKGPageHistoryItemList getNextPages();
0098 
0099     /**
0100      * Set next pages
0101      * @param iPages the list
0102      */
0103     virtual void setNextPages(const SKGTabPage::SKGPageHistoryItemList& iPages);
0104 
0105     /**
0106      * To know if this page contains an editor. MUST BE OVERWRITTEN
0107      * @return the editor state
0108      */
0109     virtual bool isEditor();
0110 
0111     /**
0112      * To activate the editor by setting focus on right widget. MUST BE OVERWRITTEN
0113      */
0114     virtual void activateEditor();
0115 
0116     /**
0117      * Get the zoomable widget.
0118      * The default implementation returns the main widget.
0119      * @return the zoomable widget.
0120      */
0121     virtual QWidget* zoomableWidget();
0122 
0123     /**
0124      * Get the printable widgets.
0125      * The default implementation returns the main widget.
0126      * @return the printable widgets.
0127      */
0128     virtual QList<QWidget*> printableWidgets();
0129 
0130     /**
0131      * To know if this page is zoomable. MUST BE OVERWRITTEN
0132      * @return true or false
0133      */
0134     virtual bool isZoomable();
0135 
0136     /**
0137      * Get the zoom position. MUST BE OVERWRITTEN
0138      * @return the position (-10<=value<=10)
0139      */
0140     virtual int zoomPosition();
0141 
0142     /**
0143      * Set the zoom position. MUST BE OVERWRITTEN
0144      * @param iValue the position (-10<=value<=10)
0145      */
0146     virtual void setZoomPosition(int iValue);
0147 
0148     /**
0149      * Get the tab page of a widget
0150      * @param iWidget the widget
0151      * @return the iParent tab page or nullptr
0152      */
0153     static SKGTabPage* parentTabPage(QWidget* iWidget);
0154 
0155     /**
0156      * Get the pin status
0157      * @return the pin status
0158      */
0159     virtual bool isPin() const;
0160 
0161 public Q_SLOTS:
0162     /**
0163      * Set the pin status
0164      * @param iPin the pin status
0165      */
0166     virtual void setPin(bool iPin);
0167 
0168     /**
0169      * Closes this widget
0170      * @param iForce to close pinned pages too
0171      * @return true if the widget was closed; otherwise returns false.
0172      */
0173     virtual bool close(bool iForce = false);
0174 
0175 private:
0176     Q_DISABLE_COPY(SKGTabPage)
0177 
0178     QString       m_bookmarkID;
0179     SKGTabPage::SKGPageHistoryItemList m_previousPages;
0180     SKGTabPage::SKGPageHistoryItemList m_nextPages;
0181     int m_fontOriginalPointSize;
0182     bool m_pin;
0183 };
0184 #endif  // SKGTABPAGE_H