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/PickButton.cpp
src/emoji/Provider.cpp
src/emoji/Provider_new.cpp
# Timeline
src/timeline/ReactionsModel.cpp

View file

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

View file

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

View file

@ -16,7 +16,7 @@ def generate_code(emojis, category):
const std::vector<Emoji> emoji::Provider::{{ category }} = {
// {{ category.capitalize() }}
{%- 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 %}
};
''')
@ -30,7 +30,7 @@ const QVector<Emoji> emoji::Provider::emoji = {
{%- for c in kwargs.items() %}
// {{ c[0].capitalize() }}
{%- 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 %}
};

View file

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

View file

@ -36,14 +36,14 @@ EmojiModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DisplayRole:
case static_cast<int>(EmojiModel::Roles::Unicode):
return Provider::emoji[index.row()].unicode();
return Provider::emoji[index.row()].unicode;
case Qt::ToolTipRole:
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):
return QVariant::fromValue(Provider::emoji[index.row()].category());
return QVariant::fromValue(Provider::emoji[index.row()].category);
case static_cast<int>(EmojiModel::Roles::Emoji):
return QVariant::fromValue(Provider::emoji[index.row()]);
@ -59,14 +59,14 @@ EmojiProxyModel::EmojiProxyModel(QObject *parent)
EmojiProxyModel::~EmojiProxyModel() {}
Emoji::Category
EmojiCategory
EmojiProxyModel::category() const
{
return category_;
}
void
EmojiProxyModel::setCategory(Emoji::Category cat)
EmojiProxyModel::setCategory(EmojiCategory cat)
{
if (category_ == cat) {
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>();
// TODO: Add favorites / recently used
if (category_ != Emoji::Category::Search) {
return emoji.category() == category_;
if (category_ != EmojiCategory::Search) {
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;
int rowCount(const QModelIndex &parent = QModelIndex()) 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
@ -40,15 +36,15 @@ class EmojiProxyModel : public QSortFilterProxyModel
Q_OBJECT
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)
public:
explicit EmojiProxyModel(QObject *parent = nullptr);
~EmojiProxyModel() override;
Emoji::Category category() const;
void setCategory(Emoji::Category cat);
EmojiCategory category() const;
void setCategory(EmojiCategory cat);
QString filter() const;
void setFilter(const QString &filter);
@ -61,7 +57,7 @@ protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
private:
Emoji::Category category_ = Emoji::Category::Search;
EmojiCategory category_ = EmojiCategory::Search;
emoji::Provider emoji_provider_;
};

File diff suppressed because it is too large Load diff

View file

@ -24,47 +24,34 @@
#include <vector>
namespace emoji {
Q_NAMESPACE
class Emoji
enum class EmojiCategory
{
People,
Nature,
Food,
Activity,
Travel,
Objects,
Symbols,
Flags,
Search
};
Q_ENUM_NS(EmojiCategory)
struct Emoji
{
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)
Q_PROPERTY(const QString &unicode MEMBER unicode)
Q_PROPERTY(const QString &shortName MEMBER shortName)
Q_PROPERTY(emoji::EmojiCategory category MEMBER category)
public:
enum class Category
{
People,
Nature,
Food,
Activity,
Travel,
Objects,
Symbols,
Flags,
Search
};
Q_ENUM(Category)
Emoji(const QString &unicode = {},
const QString &shortName = {},
Emoji::Category cat = Emoji::Category::Search)
: unicode_(unicode)
, shortName_(shortName)
, category_(cat)
{}
inline const QString &unicode() const { return unicode_; }
inline const QString &shortName() const { return shortName_; }
inline Emoji::Category category() const { return category_; }
inline void setUnicode(const QString &unicode) { unicode_ = unicode; }
private:
QString unicode_;
QString shortName_;
Emoji::Category category_;
QString unicode;
QString shortName;
EmojiCategory category;
};
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");
qmlRegisterUncreatableType<emoji::Emoji>(
"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
view = new QQuickView();