Document emojimodel
This commit is contained in:
@@ -51,12 +51,30 @@ struct Emoji {
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(Emoji)
|
Q_DECLARE_METATYPE(Emoji)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class EmojiModel
|
||||||
|
*
|
||||||
|
* This class defines the model for visualising a list of emojis.
|
||||||
|
*/
|
||||||
class EmojiModel : public QAbstractListModel
|
class EmojiModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a list of recently used emojis.
|
||||||
|
*/
|
||||||
Q_PROPERTY(QVariantList history READ history NOTIFY historyChanged)
|
Q_PROPERTY(QVariantList history READ history NOTIFY historyChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a list of emoji categories.
|
||||||
|
*
|
||||||
|
* @note No custom emoji categories will be included.
|
||||||
|
*/
|
||||||
Q_PROPERTY(QVariantList categories READ categories CONSTANT)
|
Q_PROPERTY(QVariantList categories READ categories CONSTANT)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a list of emoji categories with custom emojis.
|
||||||
|
*/
|
||||||
Q_PROPERTY(QVariantList categoriesWithCustom READ categoriesWithCustom CONSTANT)
|
Q_PROPERTY(QVariantList categoriesWithCustom READ categoriesWithCustom CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -66,47 +84,92 @@ public:
|
|||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Defines the model roles.
|
||||||
|
*/
|
||||||
enum RoleNames {
|
enum RoleNames {
|
||||||
ShortNameRole = Qt::DisplayRole,
|
ShortNameRole = Qt::DisplayRole, /**< The name of the emoji. */
|
||||||
UnicodeRole,
|
UnicodeRole, /**< The unicode character of the emoji. */
|
||||||
InvalidRole = 50,
|
InvalidRole = 50, /**< Invalid, reserved. */
|
||||||
DisplayRole = 51,
|
DisplayRole = 51, /**< The display text for an emoji. */
|
||||||
ReplacedTextRole = 52,
|
ReplacedTextRole = 52, /**< The text to replace the short name with (i.e. the unicode character). */
|
||||||
DescriptionRole = 53,
|
DescriptionRole = 53, /**< The long description of an emoji. */
|
||||||
};
|
};
|
||||||
Q_ENUM(RoleNames);
|
Q_ENUM(RoleNames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Defines the potential categories an emoji can be placed in.
|
||||||
|
*/
|
||||||
enum Category {
|
enum Category {
|
||||||
Custom,
|
Custom, /**< A custom user emoji. */
|
||||||
Search,
|
Search, /**< The results of a filter. */
|
||||||
SearchNoCustom,
|
SearchNoCustom, /**< The results of a filter with no custom emojis. */
|
||||||
History,
|
History, /**< Recently used emojis. */
|
||||||
HistoryNoCustom,
|
HistoryNoCustom, /**< Recently used emojis with no custom emojis. */
|
||||||
Smileys,
|
Smileys, /**< Smileys & emotion emojis. */
|
||||||
People,
|
People, /**< People & Body emojis. */
|
||||||
Nature,
|
Nature, /**< Animals & Nature emojis. */
|
||||||
Food,
|
Food, /**< Food & Drink emojis. */
|
||||||
Activities,
|
Activities, /**< Activities emojis. */
|
||||||
Travel,
|
Travel, /**< Travel & Places emojis. */
|
||||||
Objects,
|
Objects, /**< Objects emojis. */
|
||||||
Symbols,
|
Symbols, /**< Symbols emojis. */
|
||||||
Flags,
|
Flags, /**< Flags emojis. */
|
||||||
Component,
|
Component, /**< ??? */
|
||||||
};
|
};
|
||||||
Q_ENUM(Category)
|
Q_ENUM(Category)
|
||||||
|
|
||||||
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
/**
|
||||||
|
* @brief Get the given role value at the given index.
|
||||||
|
*
|
||||||
|
* @sa QAbstractItemModel::data
|
||||||
|
*/
|
||||||
[[nodiscard]] QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
|
[[nodiscard]] QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of rows in the model.
|
||||||
|
*
|
||||||
|
* @sa QAbstractItemModel::rowCount
|
||||||
|
*/
|
||||||
|
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a mapping from Role enum values to role names.
|
||||||
|
*
|
||||||
|
* @sa RoleNames, QAbstractItemModel::roleNames()
|
||||||
|
*/
|
||||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
Q_INVOKABLE QVariantList history() const;
|
/**
|
||||||
|
* @brief Return a filtered list of emojis.
|
||||||
|
*
|
||||||
|
* @note This includes custom emojis, use filterModelNoCustom to return a result
|
||||||
|
* without custom emojis.
|
||||||
|
*
|
||||||
|
* @sa filterModelNoCustom
|
||||||
|
*/
|
||||||
Q_INVOKABLE static QVariantList filterModel(const QString &filter, bool limit = true);
|
Q_INVOKABLE static QVariantList filterModel(const QString &filter, bool limit = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a filtered list of emojis without custom emojis.
|
||||||
|
*
|
||||||
|
* @note Use filterModel to return a result with custom emojis.
|
||||||
|
*
|
||||||
|
* @sa filterModel
|
||||||
|
*/
|
||||||
Q_INVOKABLE static QVariantList filterModelNoCustom(const QString &filter, bool limit = true);
|
Q_INVOKABLE static QVariantList filterModelNoCustom(const QString &filter, bool limit = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a list of emojis for the given category.
|
||||||
|
*/
|
||||||
Q_INVOKABLE QVariantList emojis(Category category) const;
|
Q_INVOKABLE QVariantList emojis(Category category) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a list of emoji tones for the given base emoji.
|
||||||
|
*/
|
||||||
Q_INVOKABLE QVariantList tones(const QString &baseEmoji) const;
|
Q_INVOKABLE QVariantList tones(const QString &baseEmoji) const;
|
||||||
|
|
||||||
|
Q_INVOKABLE QVariantList history() const;
|
||||||
QVariantList categories() const;
|
QVariantList categories() const;
|
||||||
QVariantList categoriesWithCustom() const;
|
QVariantList categoriesWithCustom() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user