Fix build issue on some versions of clang

pull/217/head
Joseph Donofry 5 years ago
parent 39b240e25a
commit 5e355c36fd
No known key found for this signature in database
GPG Key ID: E8A1D78EF044B0CB
  1. 2
      CMakeLists.txt
  2. 2
      resources/qml/TimelineView.qml
  3. 36
      resources/qml/emoji/EmojiPicker.qml
  4. 4
      scripts/emoji_codegen.py
  5. 4
      src/emoji/Category.cpp
  6. 16
      src/emoji/EmojiModel.cpp
  7. 12
      src/emoji/EmojiModel.h
  8. 18386
      src/emoji/Provider.cpp
  9. 39
      src/emoji/Provider.h
  10. 3339
      src/emoji/Provider_new.cpp
  11. 2
      src/timeline/TimelineViewManager.cpp

@ -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

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

@ -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()
}

@ -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 %}
};

@ -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);

@ -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;
}

@ -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

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

File diff suppressed because it is too large Load Diff

@ -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();

Loading…
Cancel
Save