From ad463f276f11192fcd6ab9a00fffba2b3cca6761 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Fri, 24 Feb 2017 16:31:05 +0100
Subject: Fix sorting of emoji categories in the emoji dialog

This also changes the minimal height of the emoji dialog
to hold about 8 emoji rows.

Test-Information:

Tested on macOS 10.12.3 with Qt 5.7.1 that the categories
are sorted in a more sensible manner and that the dialog
at least shows about 8 emoji rows.

Change-Id: I8c5518f8d552a581d5073b5f155425580f72938a

diff --git a/BuildTools/EmojisGenerator/EmojiMapper.cpp b/BuildTools/EmojisGenerator/EmojiMapper.cpp
index b93a191..097ddcc 100644
--- a/BuildTools/EmojisGenerator/EmojiMapper.cpp
+++ b/BuildTools/EmojisGenerator/EmojiMapper.cpp
@@ -6,6 +6,7 @@
 
 #include <SwifTools/EmojiMapper.h>
 
+#include <algorithm>
 #include <string>
 #include <unordered_map>
 
@@ -15,9 +16,21 @@ namespace Swift {
     <%= mapping %>
 
     std::vector<std::string> EmojiMapper::getCategories() {
-        std::vector<std::string> categories;
+        std::vector<std::string> categories = {
+            "people",
+            "nature",
+            "food",
+            "activity",
+            "travel",
+            "objects",
+            "symbols",
+            "flags"
+        };
+
         for (const auto& keyValuePair : emojisInCategory) {
-            categories.push_back(keyValuePair.first);
+            if (std::find(std::begin(categories), std::end(categories), keyValuePair.first) == std::end(categories)) {
+                categories.push_back(keyValuePair.first);
+            }
         }
         return categories;
     }
diff --git a/SwifTools/EmojiMapper.cpp b/SwifTools/EmojiMapper.cpp
index 74b3537..4381cf0 100644
--- a/SwifTools/EmojiMapper.cpp
+++ b/SwifTools/EmojiMapper.cpp
@@ -6,6 +6,7 @@
 
 #include <SwifTools/EmojiMapper.h>
 
+#include <algorithm>
 #include <string>
 #include <unordered_map>
 
@@ -27,9 +28,21 @@ namespace Swift {
 
 
     std::vector<std::string> EmojiMapper::getCategories() {
-        std::vector<std::string> categories;
+        std::vector<std::string> categories = {
+            "people",
+            "nature",
+            "food",
+            "activity",
+            "travel",
+            "objects",
+            "symbols",
+            "flags"
+        };
+
         for (const auto& keyValuePair : emojisInCategory) {
-            categories.push_back(keyValuePair.first);
+            if (std::find(std::begin(categories), std::end(categories), keyValuePair.first) == std::end(categories)) {
+                categories.push_back(keyValuePair.first);
+            }
         }
         return categories;
     }
diff --git a/Swift/QtUI/QtEmojisScroll.cpp b/Swift/QtUI/QtEmojisScroll.cpp
index 9765aa5..27963a1 100644
--- a/Swift/QtUI/QtEmojisScroll.cpp
+++ b/Swift/QtUI/QtEmojisScroll.cpp
@@ -24,5 +24,6 @@ namespace Swift {
         this->setLayout(new QVBoxLayout);
         this->layout()->addWidget(scrollArea);
         this->layout()->setContentsMargins(0,0,0,0);
+        setMinimumHeight(emojiLayout->itemAt(0)->minimumSize().height() * 8);
     }
 }
-- 
cgit v0.10.2-6-g49f6