Commit b890a9c8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

USe new EmoticonUnicodeProxyModel

parent af808028
......@@ -15,7 +15,11 @@ class KPIMTEXTEDIT_TESTS_EXPORT EmoticonUnicodeModel : public QAbstractListModel
{
Q_OBJECT
public:
enum EmoticonsRoles { UnicodeEmoji = Qt::UserRole + 1, Identifier, Category };
enum EmoticonsRoles {
UnicodeEmoji = Qt::UserRole + 1,
Identifier,
Category,
};
Q_ENUM(EmoticonsRoles)
explicit EmoticonUnicodeModel(QObject *parent = nullptr);
......
......@@ -5,10 +5,13 @@
*/
#include "emoticonunicodeproxymodel.h"
#include "emoticonunicodemodel.h"
#include <QDebug>
using namespace KPIMTextEdit;
EmoticonUnicodeProxyModel::EmoticonUnicodeProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
{
setFilterCaseSensitivity(Qt::CaseInsensitive);
setFilterRole(EmoticonUnicodeModel::UnicodeEmoji);
}
EmoticonUnicodeProxyModel::~EmoticonUnicodeProxyModel()
......@@ -18,6 +21,10 @@ EmoticonUnicodeProxyModel::~EmoticonUnicodeProxyModel()
bool EmoticonUnicodeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
if (mCategories.isEmpty()) {
const QModelIndex sourceIndex = sourceModel()->index(source_row, 0, source_parent);
const QString identifier = sourceIndex.data(EmoticonUnicodeModel::UnicodeEmoji).toString();
qDebug() << " identifier " << identifier;
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
const QModelIndex sourceIndex = sourceModel()->index(source_row, 0, source_parent);
......
......@@ -8,8 +8,10 @@
#include "emoticonlistview.h"
#include "emoticonlistwidgetselector.h"
#include "emoticonunicodemodel.h"
#include "emoticonunicodeproxymodel.h"
#include "textutils.h"
#include <KLocalizedString>
#include <QDebug>
using namespace KPIMTextEdit;
EmoticonUnicodeTab::EmoticonUnicodeTab(QWidget *parent)
......@@ -29,17 +31,19 @@ EmoticonUnicodeTab::~EmoticonUnicodeTab()
void EmoticonUnicodeTab::searchUnicode(const QString &str)
{
qDebug() << " str" << str;
mEmoticonUnicodeProxyModel->setFilterFixedString(str);
// TODO show search page + update proxyfilter + switch to search page
}
void EmoticonUnicodeTab::createSearchTab()
{
auto allEmojisView = new EmoticonListView(this);
// auto emoticonFilterProxyModel = new EmoticonModelFilterProxyModel(this);
// emoticonFilterProxyModel->setSourceModel(account->emoticonModel());
auto m = new EmoticonUnicodeModel(this);
m->setEmoticonList(EmoticonUnicodeUtils::unicodeFaceEmoji() + EmoticonUnicodeUtils::unicodeAnimalsEmoji());
allEmojisView->setModel(m);
auto emoticonModel = new EmoticonUnicodeModel(this);
mEmoticonUnicodeProxyModel = new EmoticonUnicodeProxyModel(this);
mEmoticonUnicodeProxyModel->setSourceModel(emoticonModel);
emoticonModel->setEmoticonList(EmoticonUnicodeUtils::unicodeFaceEmoji() + EmoticonUnicodeUtils::unicodeAnimalsEmoji());
allEmojisView->setModel(emoticonModel);
const int index = addTab(allEmojisView, i18n("full"));
// if (!str.isEmpty()) {
// setTabToolTip(index, str);
......
......@@ -13,6 +13,7 @@
namespace KPIMTextEdit
{
class EmoticonUnicodeProxyModel;
/**
* @brief The EmoticonUnicodeTab class
* @author Laurent Montel <montel@kde.org>
......@@ -33,6 +34,7 @@ Q_SIGNALS:
private:
void createPlainTextEmoticonTab(const QString &str, const QVector<EmoticonUnicodeUtils::EmoticonStruct> &emoticons);
void createSearchTab();
EmoticonUnicodeProxyModel *mEmoticonUnicodeProxyModel = nullptr;
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment