From 9ad9c8ddf07495ac6581edf7ca11463d7c0f78c9 Mon Sep 17 00:00:00 2001 From: Jussi Kuokkanen Date: Sat, 29 Aug 2020 00:26:45 +0300 Subject: [PATCH] fix build and remove commented code --- CMakeLists.txt | 2 -- scripts/emoji_codegen.py | 9 ++++++--- src/TextInputWidget.cpp | 5 +---- src/emoji/EmojiSearchModel.h | 7 +------ 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2dffccd..7295cc54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,7 +245,6 @@ set(SRC_FILES src/emoji/Category.cpp src/emoji/EmojiModel.cpp src/emoji/ItemDelegate.cpp - src/emoji/KeyboardSelector.cpp src/emoji/Panel.cpp src/emoji/PickButton.cpp src/emoji/Provider.cpp @@ -460,7 +459,6 @@ qt5_wrap_cpp(MOC_HEADERS src/emoji/Category.h src/emoji/EmojiModel.h src/emoji/ItemDelegate.h - src/emoji/KeyboardSelector.h src/emoji/Panel.h src/emoji/PickButton.h src/emoji/Provider.h diff --git a/scripts/emoji_codegen.py b/scripts/emoji_codegen.py index b39feb34..466246ed 100755 --- a/scripts/emoji_codegen.py +++ b/scripts/emoji_codegen.py @@ -11,12 +11,15 @@ class Emoji(object): self.code = repr(code.encode('utf-8'))[1:].strip("'") self.shortname = shortname +def to_shortcode(shortname): + return shortname.replace(" ", "-").replace(":", "-") + def generate_code(emojis, category): tmpl = Template(''' const std::vector emoji::Provider::{{ category }} = { // {{ category.capitalize() }} {%- for e in emoji %} - Emoji{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", emoji::EmojiCategory::{{ category.capitalize() }}}, + Emoji{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", "{{ to_shortcode(e.shortname) }}", emoji::EmojiCategory::{{ category.capitalize() }}}, {%- endfor %} }; ''') @@ -30,7 +33,7 @@ const QVector emoji::Provider::emoji = { {%- for c in kwargs.items() %} // {{ c[0].capitalize() }} {%- for e in c[1] %} - Emoji{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", emoji::EmojiCategory::{{ c[0].capitalize() }}}, + Emoji{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", "{{ to_shortcode(e.shortname) }}", emoji::EmojiCategory::{{ c[0].capitalize() }}}, {%- endfor %} {%- endfor %} }; @@ -101,4 +104,4 @@ if __name__ == '__main__': generate_code(objects, 'objects') generate_code(symbols, 'symbols') generate_code(flags, 'flags') - generate_qml_list(people=people, nature=nature, food=food, activity=activity, travel=travel, objects=objects, symbols=symbols, flags=flags) \ No newline at end of file + generate_qml_list(people=people, nature=nature, food=food, activity=activity, travel=travel, objects=objects, symbols=symbols, flags=flags) diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp index 17018392..08883cca 100644 --- a/src/TextInputWidget.cpp +++ b/src/TextInputWidget.cpp @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -36,7 +37,6 @@ #include "TextInputWidget.h" #include "Utils.h" #include "emoji/EmojiSearchModel.h" -#include "emoji/KeyboardSelector.h" #include "emoji/Provider.h" #include "ui/FlatButton.h" #include "ui/LoadingIndicator.h" @@ -250,7 +250,6 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event) QTextEdit::keyPressEvent(event); emoji_popup_open_ = true; emoji_completion_model_->setFilterRegExp(wordUnderCursor()); - // completer_->setCompletionPrefix(wordUnderCursor()); completer_->popup()->setCurrentIndex(completer_->completionModel()->index(0, 0)); completer_->complete(completerRect()); break; @@ -310,9 +309,7 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event) if (emoji_popup_open_) { // Update completion - emoji_completion_model_->setFilterRegExp(wordUnderCursor()); - // completer_->setCompletionPrefix(wordUnderCursor()); completer_->popup()->setCurrentIndex( completer_->completionModel()->index(0, 0)); completer_->complete(completerRect()); diff --git a/src/emoji/EmojiSearchModel.h b/src/emoji/EmojiSearchModel.h index 87fa0403..1ff5f4e9 100644 --- a/src/emoji/EmojiSearchModel.h +++ b/src/emoji/EmojiSearchModel.h @@ -5,8 +5,6 @@ #include #include #include -#include -#include namespace emoji { @@ -28,10 +26,7 @@ public: } return QSortFilterProxyModel::data(index, role); } - /*int rowCount(const QModelIndex &parent) const override { - auto row_count = QSortFilterProxyModel::rowCount(parent); - return (row_count < 7) ? row_count : 7; - }*/ + private: QString toShortcode(QString shortname) const {