File indexing completed on 2024-04-28 16:30:28

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 SKGADVICE_H
0007 #define SKGADVICE_H
0008 /** @file
0009  * This file defines classes SKGAdvice .
0010  *
0011  * @author Stephane MANKOWSKI / Guillaume DE BURE
0012  */
0013 #include <qmetatype.h>
0014 #include <qobject.h>
0015 #include <qstring.h>
0016 #include <qstringlist.h>
0017 #include <qvector.h>
0018 
0019 #include "skgbasemodeler_export.h"
0020 
0021 /**
0022 * This class manages errors
0023 */
0024 class SKGBASEMODELER_EXPORT SKGAdvice final : public QObject
0025 {
0026     Q_OBJECT
0027 public:
0028     /**
0029      * Advice action
0030      */
0031     struct SKGAdviceAction {
0032         /** The id of the action */
0033         QString id;
0034 
0035         /** The title of the action */
0036         QString Title;
0037 
0038         /** The name of the icon of the action */
0039         QString IconName;
0040 
0041         /** To know if this action is recommended*/
0042         bool IsRecommended{};
0043     };
0044 
0045     /**
0046      * List of advice action
0047      */
0048     using SKGAdviceActionList = QVector<SKGAdvice::SKGAdviceAction>;
0049 
0050     /**
0051      * Priotity
0052      */
0053     Q_PROPERTY(int priority READ getPriority WRITE setPriority NOTIFY modified)
0054     /**
0055      * Unique identifier
0056      */
0057     Q_PROPERTY(QString uuid READ getUUID WRITE setUUID NOTIFY modified)
0058     /**
0059      * Short message
0060      */
0061     Q_PROPERTY(QString shortMessage READ getShortMessage WRITE setShortMessage NOTIFY modified)
0062     /**
0063      * Long message
0064      */
0065     Q_PROPERTY(QString longMessage READ getLongMessage WRITE setLongMessage NOTIFY modified)
0066     /**
0067      * Auto corrections
0068      */
0069     Q_PROPERTY(SKGAdvice::SKGAdviceActionList autoCorrections READ getAutoCorrections WRITE setAutoCorrections NOTIFY modified)
0070 
0071     /**
0072     * Constructor
0073     */
0074     explicit SKGAdvice();
0075 
0076     /**
0077     * Copy constructor
0078     * @param iAdvice the advice to copy
0079     */
0080     SKGAdvice(const SKGAdvice& iAdvice);
0081 
0082     /**
0083     * Destructor
0084     */
0085     ~SKGAdvice() override;
0086 
0087     /**
0088     * Operator affectation
0089     * @param iAdvice the advice to copy
0090     */
0091     SKGAdvice& operator= (const SKGAdvice& iAdvice);
0092 
0093 
0094     /**
0095     * Return the unique identifier
0096     * @return the unique identifier
0097     */
0098     QString getUUID() const;
0099 
0100     /**
0101     * Return the priority
0102     * @return the priority
0103     */
0104     int getPriority() const;
0105 
0106     /**
0107     * Return the short message
0108     * @return the short message
0109     */
0110     QString getShortMessage() const;
0111 
0112     /**
0113     * Return the long message
0114     * @return the long message
0115     */
0116     QString getLongMessage() const;
0117 
0118     /**
0119     * Return the auto corrections
0120     * @return the auto corrections
0121     */
0122     SKGAdvice::SKGAdviceActionList getAutoCorrections() const;
0123 
0124 public Q_SLOTS:
0125     /**
0126     * Set the unique identifier
0127     * @param iUUID the unique identifier
0128     */
0129     void setUUID(const QString& iUUID);
0130 
0131     /**
0132     * Set the priority
0133     * @param iPriority the priority
0134     */
0135     void setPriority(int iPriority);
0136 
0137     /**
0138     * Set the short message
0139     * @param iMessage the short message
0140     */
0141     void setShortMessage(const QString& iMessage);
0142 
0143     /**
0144     * Set the long message
0145     * @param iMessage the long message
0146     */
0147     void setLongMessage(const QString& iMessage);
0148 
0149     /**
0150     * Set the auto corrections
0151     * @param iCorrections the auto corrections
0152     */
0153     void setAutoCorrections(const QStringList& iCorrections);
0154 
0155     /**
0156     * Set the auto corrections
0157     * @param iCorrections the auto corrections
0158     */
0159     void setAutoCorrections(const SKGAdvice::SKGAdviceActionList& iCorrections);
0160 
0161 Q_SIGNALS:
0162     /**
0163      * This signal is launched when the object is modified
0164      */
0165     void modified();
0166 
0167 private:
0168     /**
0169      * the unique identifier
0170      */
0171     QString m_uuid;
0172 
0173     /**
0174     * the priority
0175     */
0176     int m_priority{1};
0177 
0178     /**
0179      * the short message
0180      */
0181     QString m_shortMessage;
0182 
0183     /**
0184      * the short message
0185      */
0186     QString m_longMessage;
0187 
0188     /**
0189      * the list of auto corrections
0190      */
0191     SKGAdvice::SKGAdviceActionList m_autoCorrections;
0192 };
0193 /**
0194  * Declare the meta type
0195  */
0196 Q_DECLARE_METATYPE(SKGAdvice)
0197 
0198 /**
0199  * Declare the class
0200  */
0201 Q_DECLARE_TYPEINFO(SKGAdvice, Q_MOVABLE_TYPE);
0202 
0203 /**
0204  * the SKGAdviceList
0205  */
0206 using SKGAdviceList = QVector<SKGAdvice>;
0207 
0208 /**
0209  * Declare the meta type
0210  */
0211 Q_DECLARE_METATYPE(QVector<SKGAdvice>)
0212 #endif  // SKGADVICE_H