"Fossies" - the Fresh Open Source Software Archive

Member "qt-creator-opensource-src-4.15.1/src/plugins/qmldesigner/designercore/include/annotation.h" (8 Jun 2021, 5294 Bytes) of package /linux/misc/qt-creator-opensource-src-4.15.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "annotation.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: opensource-src-4.15.0_vs_opensource-src-4.15.1.

    1 /****************************************************************************
    2 **
    3 ** Copyright (C) 2020 The Qt Company Ltd.
    4 ** Contact: https://www.qt.io/licensing/
    5 **
    6 ** This file is part of Qt Creator.
    7 **
    8 ** Commercial License Usage
    9 ** Licensees holding valid commercial Qt licenses may use this file in
   10 ** accordance with the commercial license agreement provided with the
   11 ** Software or, alternatively, in accordance with the terms contained in
   12 ** a written agreement between you and The Qt Company. For licensing terms
   13 ** and conditions see https://www.qt.io/terms-conditions. For further
   14 ** information use the contact form at https://www.qt.io/contact-us.
   15 **
   16 ** GNU General Public License Usage
   17 ** Alternatively, this file may be used under the terms of the GNU
   18 ** General Public License version 3 as published by the Free Software
   19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
   20 ** included in the packaging of this file. Please review the following
   21 ** information to ensure the GNU General Public License requirements will
   22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
   23 **
   24 ****************************************************************************/
   25 
   26 #pragma once
   27 
   28 #include <QDataStream>
   29 #include <QDebug>
   30 #include <QJsonObject>
   31 #include <QObject>
   32 
   33 #include "nodeinstanceglobal.h"
   34 #include "qmldesignercorelib_global.h"
   35 
   36 namespace QmlDesigner {
   37 
   38 static const PropertyName customIdProperty = {("customId")};
   39 static const PropertyName annotationProperty = {("annotation")};
   40 static const PropertyName globalAnnotationProperty = {("globalAnnotation")};
   41 static const PropertyName globalAnnotationStatus = {("globalAnnotationStatus")};
   42 
   43 class QMLDESIGNERCORE_EXPORT GlobalAnnotationStatus
   44 {
   45 public:
   46     enum Status {
   47         NoStatus = -1,
   48         InProgress = 0,
   49         InReview = 1,
   50         Done = 2
   51     };
   52 
   53     GlobalAnnotationStatus();
   54     GlobalAnnotationStatus(Status status);
   55 
   56     ~GlobalAnnotationStatus() = default;
   57 
   58     void setStatus(int statusId);
   59     void setStatus(Status status);
   60     Status status() const;
   61 
   62     QString toQString() const;
   63     void fromQString(const QString &str);
   64 
   65 private:
   66     Status m_status;
   67 };
   68 
   69 class QMLDESIGNERCORE_EXPORT Comment
   70 {
   71 public:
   72     Comment();
   73     Comment(const QString &title, const QString &author = QString(), const QString &text = QString(), qint64 timestamp = 0);
   74 
   75     ~Comment() = default;
   76 
   77     QString title() const;
   78     void setTitle(const QString &title);
   79 
   80     QString text() const;
   81     void setText(const QString &text);
   82 
   83     QString deescapedText() const;
   84 
   85     QString author() const;
   86     void setAuthor(const QString &author);
   87 
   88     QString timestampStr() const;
   89     QString timestampStr(const QString &format) const;
   90     qint64 timestamp() const;
   91     void setTimestamp(qint64 timestamp);
   92     void updateTimestamp();
   93 
   94     bool sameContent(const Comment &comment) const; //everything is similar besides timestamp
   95     static bool sameContent(const Comment &a, const Comment &b);
   96     bool operator==(const Comment &comment) const; //everything is similar.
   97 
   98     bool isEmpty() const;
   99 
  100     QString toQString() const;
  101     QJsonValue toJsonValue() const;
  102     bool fromJsonValue(QJsonValue const &);
  103 
  104     friend QDebug &operator<<(QDebug &stream, const Comment &comment);
  105 
  106     QMLDESIGNERCORE_EXPORT friend QDataStream &operator<<(QDataStream &stream,
  107                                                           const Comment &comment);
  108     QMLDESIGNERCORE_EXPORT friend QDataStream &operator>>(QDataStream &stream, Comment &comment);
  109 
  110 private:
  111     QString m_title;
  112     QString m_author;
  113     QString m_text;
  114     qint64 m_timestamp;
  115 };
  116 
  117 class QMLDESIGNERCORE_EXPORT Annotation
  118 {
  119 public:
  120     Annotation();
  121     ~Annotation() = default;
  122 
  123     QVector<Comment> comments() const;
  124     bool hasComments() const;
  125     void setComments(const QVector<Comment> &comments);
  126     void removeComments();
  127     int commentsSize() const;
  128 
  129     Comment comment(int n) const;
  130     void addComment(const Comment &comment);
  131     bool updateComment(const Comment &comment, int n);
  132     bool removeComment(int n);
  133 
  134     QString toQString() const;
  135     void fromQString(const QString &str);
  136     QJsonValue toJsonValue() const;
  137     bool fromJsonValue(QJsonValue const &);
  138 
  139     friend QDebug &operator<<(QDebug &stream, const Annotation &annotation);
  140 
  141     QMLDESIGNERCORE_EXPORT friend QDataStream &operator<<(QDataStream &stream,
  142                                                           const Annotation &annotation);
  143     QMLDESIGNERCORE_EXPORT friend QDataStream &operator>>(QDataStream &stream,
  144                                                           Annotation &annotation);
  145 
  146 private:
  147     QVector<Comment> m_comments;
  148 };
  149 
  150 QDebug &operator<<(QDebug &stream, const Comment &comment);
  151 QDebug &operator<<(QDebug &stream, const Annotation &annotation);
  152 
  153 QMLDESIGNERCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const Comment &comment);
  154 QMLDESIGNERCORE_EXPORT QDataStream &operator>>(QDataStream &stream, Comment &comment);
  155 QMLDESIGNERCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const Annotation &annotation);
  156 QMLDESIGNERCORE_EXPORT QDataStream &operator>>(QDataStream &stream, Annotation &annotation);
  157 } // namespace QmlDesigner
  158 
  159 Q_DECLARE_METATYPE(QmlDesigner::Comment);
  160 Q_DECLARE_METATYPE(QmlDesigner::Annotation);