diff --git a/source/src/tagdata.cpp b/source/src/tagdata.cpp index 71aa094..2043129 100644 --- a/source/src/tagdata.cpp +++ b/source/src/tagdata.cpp @@ -1,56 +1,56 @@ -#include "tagdata.h" +#include "tagdata.h" // 包含TagData类的头文件 -TagData::TagData() +TagData::TagData()// TagData类的构造函数 : m_id{ SpecialTagID::InvalidTagId }, m_relativePosition{ -1 }, m_childNotesCount{ 0 } -{ +{ // 初始化标签ID为无效值,相对位置为-1,子笔记数量为0 } int TagData::id() const { - return m_id; + return m_id;// 返回标签ID } void TagData::setId(int newId) { - m_id = newId; + m_id = newId;// 设置新的标签ID } const QString &TagData::name() const { - return m_name; + return m_name; // 返回标签名称 } void TagData::setName(const QString &newName) { - m_name = newName; + m_name = newName; // 设置新的标签名称 } const QString &TagData::color() const { - return m_color; + return m_color;// 返回标签颜色 } void TagData::setColor(const QString &newColor) { - m_color = newColor; + m_color = newColor;// 设置新的标签颜色 } int TagData::relativePosition() const { - return m_relativePosition; + return m_relativePosition;// 返回标签的相对位置 } void TagData::setRelativePosition(int newRelativePosition) { - m_relativePosition = newRelativePosition; + m_relativePosition = newRelativePosition; // 设置新的标签相对位置 } int TagData::childNotesCount() const { - return m_childNotesCount; + return m_childNotesCount;// 返回标签下的子笔记数量 } void TagData::setChildNotesCount(int newChildCount) { - m_childNotesCount = newChildCount; + m_childNotesCount = newChildCount; // 设置新的子笔记数量 } diff --git a/source/src/tagdata.h b/source/src/tagdata.h index 0309969..6144f1c 100644 --- a/source/src/tagdata.h +++ b/source/src/tagdata.h @@ -1,43 +1,43 @@ #ifndef TAGDATA_H #define TAGDATA_H -#include -#include +#include // 包含QString类的头文件,QString是Qt中用于处理字符串的类 +#include // 包含QMetaClassInfo类的头文件,用于元信息支持 -namespace SpecialTagID { +namespace SpecialTagID {// 定义SpecialTagID命名空间,用于特定的标签ID值 enum Value { - InvalidTagId = -1, + InvalidTagId = -1, // 无效的标签ID值 }; } -class TagData +class TagData// 定义TagData类,用于表示标签的数据 { public: - TagData(); + TagData();// 构造函数 - int id() const; - void setId(int newId); + int id() const;// 获取标签ID + void setId(int newId); // 设置标签ID - const QString &name() const; - void setName(const QString &newName); + const QString &name() const;// 获取标签名称 + void setName(const QString &newName); // 设置标签名称 - const QString &color() const; - void setColor(const QString &newColor); + const QString &color() const;// 获取标签颜色 + void setColor(const QString &newColor); // 设置标签颜色 - int relativePosition() const; - void setRelativePosition(int newRelativePosition); + int relativePosition() const; // 获取标签的相对位置 + void setRelativePosition(int newRelativePosition); // 设置标签的相对位置 - int childNotesCount() const; - void setChildNotesCount(int newChildCount); + int childNotesCount() const; // 获取标签下的子笔记数量 + void setChildNotesCount(int newChildCount); // 设置标签下的子笔记数量 private: - int m_id; - QString m_name; - QString m_color; - int m_relativePosition; - int m_childNotesCount; + int m_id; // 私有成员变量,存储标签ID + QString m_name; // 私有成员变量,存储标签名称 + QString m_color; // 私有成员变量,存储标签颜色 + int m_relativePosition; // 私有成员变量,存储标签的相对位置 + int m_childNotesCount; // 私有成员变量,存储标签下的子笔记数量 }; -Q_DECLARE_METATYPE(TagData) +Q_DECLARE_METATYPE(TagData)// 声明TagData为元类型,以便在信号和槽中使用 #endif // TAGDATA_H