Fix build issue on some versions of clang

This commit is contained in:
Joseph Donofry 2020-06-10 22:34:14 -04:00
parent 39b240e25a
commit 5e355c36fd
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB
11 changed files with 6735 additions and 15143 deletions

View file

@ -248,6 +248,8 @@ set(SRC_FILES
src/emoji/Panel.cpp src/emoji/Panel.cpp
src/emoji/PickButton.cpp src/emoji/PickButton.cpp
src/emoji/Provider.cpp src/emoji/Provider.cpp
src/emoji/Provider_new.cpp
# Timeline # Timeline
src/timeline/ReactionsModel.cpp src/timeline/ReactionsModel.cpp

View file

@ -31,7 +31,7 @@ Page {
height: 6 * 52 height: 6 * 52
colors: palette colors: palette
model: EmojiProxyModel { model: EmojiProxyModel {
category: Emoji.Category.People category: EmojiCategory.People
sourceModel: EmojiModel {} sourceModel: EmojiModel {}
} }
} }

View file

@ -123,7 +123,7 @@ Popup {
interval: 350 // tweak as needed? interval: 350 // tweak as needed?
onTriggered: { onTriggered: {
emojiPopup.model.filter = emojiSearch.text emojiPopup.model.filter = emojiSearch.text
emojiPopup.model.category = Emoji.Category.Search emojiPopup.model.category = EmojiCategory.Search
} }
} }
@ -168,14 +168,14 @@ Popup {
Repeater { Repeater {
model: ListModel { model: ListModel {
// TODO: Would like to get 'simple' icons for the categories // TODO: Would like to get 'simple' icons for the categories
ListElement { image: ":/icons/icons/emoji-categories/people.png"; category: Emoji.Category.People } ListElement { image: ":/icons/icons/emoji-categories/people.png"; category: EmojiCategory.People }
ListElement { image: ":/icons/icons/emoji-categories/nature.png"; category: Emoji.Category.Nature } ListElement { image: ":/icons/icons/emoji-categories/nature.png"; category: EmojiCategory.Nature }
ListElement { image: ":/icons/icons/emoji-categories/foods.png"; category: Emoji.Category.Food } ListElement { image: ":/icons/icons/emoji-categories/foods.png"; category: EmojiCategory.Food }
ListElement { image: ":/icons/icons/emoji-categories/activity.png"; category: Emoji.Category.Activity } ListElement { image: ":/icons/icons/emoji-categories/activity.png"; category: EmojiCategory.Activity }
ListElement { image: ":/icons/icons/emoji-categories/travel.png"; category: Emoji.Category.Travel } ListElement { image: ":/icons/icons/emoji-categories/travel.png"; category: EmojiCategory.Travel }
ListElement { image: ":/icons/icons/emoji-categories/objects.png"; category: Emoji.Category.Objects } ListElement { image: ":/icons/icons/emoji-categories/objects.png"; category: EmojiCategory.Objects }
ListElement { image: ":/icons/icons/emoji-categories/symbols.png"; category: Emoji.Category.Symbols } ListElement { image: ":/icons/icons/emoji-categories/symbols.png"; category: EmojiCategory.Symbols }
ListElement { image: ":/icons/icons/emoji-categories/flags.png"; category: Emoji.Category.Flags } ListElement { image: ":/icons/icons/emoji-categories/flags.png"; category: EmojiCategory.Flags }
} }
delegate: AbstractButton { delegate: AbstractButton {
@ -210,21 +210,21 @@ Popup {
hoverEnabled: true hoverEnabled: true
ToolTip.text: { ToolTip.text: {
switch (model.category) { switch (model.category) {
case Emoji.Category.People: case EmojiCategory.People:
return qsTr('People'); return qsTr('People');
case Emoji.Category.Nature: case EmojiCategory.Nature:
return qsTr('Nature'); return qsTr('Nature');
case Emoji.Category.Food: case EmojiCategory.Food:
return qsTr('Food'); return qsTr('Food');
case Emoji.Category.Activity: case EmojiCategory.Activity:
return qsTr('Activity'); return qsTr('Activity');
case Emoji.Category.Travel: case EmojiCategory.Travel:
return qsTr('Travel'); return qsTr('Travel');
case Emoji.Category.Objects: case EmojiCategory.Objects:
return qsTr('Objects'); return qsTr('Objects');
case Emoji.Category.Symbols: case EmojiCategory.Symbols:
return qsTr('Symbols'); return qsTr('Symbols');
case Emoji.Category.Flags: case EmojiCategory.Flags:
return qsTr('Flags'); return qsTr('Flags');
} }
} }
@ -257,7 +257,7 @@ Popup {
ToolTip.visible: hovered ToolTip.visible: hovered
onClicked: { onClicked: {
// clear any filters // clear any filters
emojiPopup.model.category = Emoji.Category.Search emojiPopup.model.category = EmojiCategory.Search
gridView.positionViewAtBeginning() gridView.positionViewAtBeginning()
emojiSearch.forceActiveFocus() emojiSearch.forceActiveFocus()
} }

View file

@ -16,7 +16,7 @@ def generate_code(emojis, category):
const std::vector<Emoji> emoji::Provider::{{ category }} = { const std::vector<Emoji> emoji::Provider::{{ category }} = {
// {{ category.capitalize() }} // {{ category.capitalize() }}
{%- for e in emoji %} {%- for e in emoji %}
{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", emoji::Emoji::Category::{{ category.capitalize() }}}, Emoji{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", emoji::EmojiCategory::{{ category.capitalize() }}},
{%- endfor %} {%- endfor %}
}; };
''') ''')
@ -30,7 +30,7 @@ const QVector<Emoji> emoji::Provider::emoji = {
{%- for c in kwargs.items() %} {%- for c in kwargs.items() %}
// {{ c[0].capitalize() }} // {{ c[0].capitalize() }}
{%- for e in c[1] %} {%- for e in c[1] %}
{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", emoji::Emoji::Category::{{ c[0].capitalize() }}}, Emoji{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", emoji::EmojiCategory::{{ c[0].capitalize() }}},
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}
}; };

View file

@ -62,12 +62,12 @@ Category::Category(QString category, std::vector<Emoji> emoji, QWidget *parent)
emojiListView_->setEditTriggers(QAbstractItemView::NoEditTriggers); emojiListView_->setEditTriggers(QAbstractItemView::NoEditTriggers);
for (const auto &e : emoji) { for (const auto &e : emoji) {
data_->setUnicode(e.unicode()); data_->unicode = e.unicode;
auto item = new QStandardItem; auto item = new QStandardItem;
item->setSizeHint(QSize(emojiSize, emojiSize)); item->setSizeHint(QSize(emojiSize, emojiSize));
QVariant unicode(data_->unicode()); QVariant unicode(data_->unicode);
item->setData(unicode.toString(), Qt::UserRole); item->setData(unicode.toString(), Qt::UserRole);
itemModel_->appendRow(item); itemModel_->appendRow(item);

View file

@ -36,14 +36,14 @@ EmojiModel::data(const QModelIndex &index, int role) const
switch (role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
case static_cast<int>(EmojiModel::Roles::Unicode): case static_cast<int>(EmojiModel::Roles::Unicode):
return Provider::emoji[index.row()].unicode(); return Provider::emoji[index.row()].unicode;
case Qt::ToolTipRole: case Qt::ToolTipRole:
case static_cast<int>(EmojiModel::Roles::ShortName): case static_cast<int>(EmojiModel::Roles::ShortName):
return Provider::emoji[index.row()].shortName(); return Provider::emoji[index.row()].shortName;
case static_cast<int>(EmojiModel::Roles::Category): case static_cast<int>(EmojiModel::Roles::Category):
return QVariant::fromValue(Provider::emoji[index.row()].category()); return QVariant::fromValue(Provider::emoji[index.row()].category);
case static_cast<int>(EmojiModel::Roles::Emoji): case static_cast<int>(EmojiModel::Roles::Emoji):
return QVariant::fromValue(Provider::emoji[index.row()]); return QVariant::fromValue(Provider::emoji[index.row()]);
@ -59,14 +59,14 @@ EmojiProxyModel::EmojiProxyModel(QObject *parent)
EmojiProxyModel::~EmojiProxyModel() {} EmojiProxyModel::~EmojiProxyModel() {}
Emoji::Category EmojiCategory
EmojiProxyModel::category() const EmojiProxyModel::category() const
{ {
return category_; return category_;
} }
void void
EmojiProxyModel::setCategory(Emoji::Category cat) EmojiProxyModel::setCategory(EmojiCategory cat)
{ {
if (category_ == cat) { if (category_ == cat) {
return; return;
@ -102,9 +102,9 @@ EmojiProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent
const Emoji emoji = index.data(static_cast<int>(EmojiModel::Roles::Emoji)).value<Emoji>(); const Emoji emoji = index.data(static_cast<int>(EmojiModel::Roles::Emoji)).value<Emoji>();
// TODO: Add favorites / recently used // TODO: Add favorites / recently used
if (category_ != Emoji::Category::Search) { if (category_ != EmojiCategory::Search) {
return emoji.category() == category_; return emoji.category == category_;
} }
return filterRegExp().isEmpty() ? true : filterRegExp().indexIn(emoji.shortName()) != -1; return filterRegExp().isEmpty() ? true : filterRegExp().indexIn(emoji.shortName) != -1;
} }

View file

@ -29,10 +29,6 @@ public:
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
// TODO: Need a signal for when an emoji is selected
// public signals:
// void emojiSelected(const QString &emoji);
}; };
class EmojiProxyModel : public QSortFilterProxyModel class EmojiProxyModel : public QSortFilterProxyModel
@ -40,15 +36,15 @@ class EmojiProxyModel : public QSortFilterProxyModel
Q_OBJECT Q_OBJECT
Q_PROPERTY( Q_PROPERTY(
emoji::Emoji::Category category READ category WRITE setCategory NOTIFY categoryChanged) emoji::EmojiCategory category READ category WRITE setCategory NOTIFY categoryChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
public: public:
explicit EmojiProxyModel(QObject *parent = nullptr); explicit EmojiProxyModel(QObject *parent = nullptr);
~EmojiProxyModel() override; ~EmojiProxyModel() override;
Emoji::Category category() const; EmojiCategory category() const;
void setCategory(Emoji::Category cat); void setCategory(EmojiCategory cat);
QString filter() const; QString filter() const;
void setFilter(const QString &filter); void setFilter(const QString &filter);
@ -61,7 +57,7 @@ protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
private: private:
Emoji::Category category_ = Emoji::Category::Search; EmojiCategory category_ = EmojiCategory::Search;
emoji::Provider emoji_provider_; emoji::Provider emoji_provider_;
}; };

File diff suppressed because it is too large Load diff

View file

@ -24,17 +24,9 @@
#include <vector> #include <vector>
namespace emoji { namespace emoji {
Q_NAMESPACE
class Emoji enum class EmojiCategory
{
Q_GADGET
Q_PROPERTY(const QString &unicode READ unicode CONSTANT)
Q_PROPERTY(const QString &shortName READ shortName CONSTANT)
Q_PROPERTY(emoji::Emoji::Category category READ category CONSTANT)
public:
enum class Category
{ {
People, People,
Nature, Nature,
@ -46,25 +38,20 @@ public:
Flags, Flags,
Search Search
}; };
Q_ENUM(Category) Q_ENUM_NS(EmojiCategory)
Emoji(const QString &unicode = {}, struct Emoji
const QString &shortName = {}, {
Emoji::Category cat = Emoji::Category::Search) Q_GADGET
: unicode_(unicode)
, shortName_(shortName)
, category_(cat)
{}
inline const QString &unicode() const { return unicode_; } Q_PROPERTY(const QString &unicode MEMBER unicode)
inline const QString &shortName() const { return shortName_; } Q_PROPERTY(const QString &shortName MEMBER shortName)
inline Emoji::Category category() const { return category_; } Q_PROPERTY(emoji::EmojiCategory category MEMBER category)
inline void setUnicode(const QString &unicode) { unicode_ = unicode; }
private: public:
QString unicode_; QString unicode;
QString shortName_; QString shortName;
Emoji::Category category_; EmojiCategory category;
}; };
class Provider class Provider

3339
src/emoji/Provider_new.cpp Normal file

File diff suppressed because it is too large Load diff

View file

@ -80,6 +80,8 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin
"im.nheko.EmojiModel", 1, 0, "QAbstractItemModel", "Used by proxy models"); "im.nheko.EmojiModel", 1, 0, "QAbstractItemModel", "Used by proxy models");
qmlRegisterUncreatableType<emoji::Emoji>( qmlRegisterUncreatableType<emoji::Emoji>(
"im.nheko.EmojiModel", 1, 0, "Emoji", "Used by emoji models"); "im.nheko.EmojiModel", 1, 0, "Emoji", "Used by emoji models");
qmlRegisterUncreatableMetaObject(emoji::staticMetaObject,
"im.nheko.EmojiModel", 1, 0, "EmojiCategory", "Error: Only enums");
#ifdef USE_QUICK_VIEW #ifdef USE_QUICK_VIEW
view = new QQuickView(); view = new QQuickView();