Commit 56fdd25c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove dead code

parent 0c2ab78b
include(ECMAddTests)
ecm_add_tests( textutilstest.cpp editorutiltest.cpp emoticonlistwidgetselectortest.cpp emoticonunicodetabtest.cpp NAME_PREFIX "kpimtextedit-" LINK_LIBRARIES Qt::Test Qt::Widgets KF5::Codecs KF5PimTextEdit KF5::TextWidgets KF5::XmlGui)
ecm_add_tests( textutilstest.cpp editorutiltest.cpp emoticonunicodetabtest.cpp NAME_PREFIX "kpimtextedit-" LINK_LIBRARIES Qt::Test Qt::Widgets KF5::Codecs KF5PimTextEdit KF5::TextWidgets KF5::XmlGui)
ecm_add_test(slidecontainertest.cpp
TEST_NAME slidecontainertest
NAME_PREFIX kpimtextedit-widget
......
/*
SPDX-FileCopyrightText: 2019-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "emoticonlistwidgetselectortest.h"
#include "emoticon/emoticonlistwidgetselector.h"
#include <QTest>
QTEST_MAIN(EmoticonListWidgetSelectorTest)
EmoticonListWidgetSelectorTest::EmoticonListWidgetSelectorTest(QObject *parent)
: QObject(parent)
{
}
void EmoticonListWidgetSelectorTest::shouldHaveDefaultValues()
{
KPIMTextEdit::EmoticonListWidgetSelector w;
QCOMPARE(w.viewMode(), QListView::IconMode);
QCOMPARE(w.selectionMode(), QAbstractItemView::SingleSelection);
QVERIFY(!w.dragEnabled());
}
/*
SPDX-FileCopyrightText: 2019-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include <QObject>
class EmoticonListWidgetSelectorTest : public QObject
{
Q_OBJECT
public:
explicit EmoticonListWidgetSelectorTest(QObject *parent = nullptr);
~EmoticonListWidgetSelectorTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
......@@ -53,7 +53,6 @@ target_sources(KF5PimTextEdit PRIVATE
emoticon/emoticontexteditaction.cpp
emoticon/emoticontexteditselector.cpp
emoticon/emoticonunicodetab.cpp
emoticon/emoticonlistwidgetselector.cpp
emoticon/emoticonunicodeutils.cpp
emoticon/emoticonunicodemodel.cpp
emoticon/emoticonlistview.cpp
......
/*
SPDX-FileCopyrightText: 2019-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "emoticonlistwidgetselector.h"
#include "kpimtextedit_debug.h"
using namespace KPIMTextEdit;
EmoticonTextEditItem::EmoticonTextEditItem(const QString &emoticonText, const QString &tooltip, QListWidget *parent)
: QListWidgetItem(emoticonText, parent)
, mText(emoticonText)
{
setToolTip(tooltip);
}
QString EmoticonTextEditItem::text() const
{
return mText;
}
EmoticonListWidgetSelector::EmoticonListWidgetSelector(QWidget *parent)
: QListWidget(parent)
{
setViewMode(QListView::IconMode);
setSelectionMode(QAbstractItemView::SingleSelection);
setMouseTracking(true);
setDragEnabled(false);
connect(this, &EmoticonListWidgetSelector::itemEntered, this, &EmoticonListWidgetSelector::slotMouseOverItem);
connect(this, &EmoticonListWidgetSelector::itemClicked, this, &EmoticonListWidgetSelector::slotEmoticonClicked);
setIconSize(QSize(32, 32));
QFont f;
f.setPointSize(22);
f.setFamily(QStringLiteral("NotoColorEmoji"));
setFont(f);
}
EmoticonListWidgetSelector::~EmoticonListWidgetSelector()
{
}
void EmoticonListWidgetSelector::slotMouseOverItem(QListWidgetItem *item)
{
item->setSelected(true);
if (!hasFocus()) {
setFocus();
}
}
void EmoticonListWidgetSelector::setEmoticons(const QVector<EmoticonUnicodeUtils::EmoticonStruct> &emoticons)
{
for (const auto &emoji : emoticons) {
new KPIMTextEdit::EmoticonTextEditItem(emoji.emoticonCode, emoji.emoticonName, this);
}
}
void EmoticonListWidgetSelector::slotEmoticonClicked(QListWidgetItem *item)
{
if (!item) {
return;
}
auto itemEmoticon = static_cast<EmoticonTextEditItem *>(item);
Q_EMIT itemSelected(itemEmoticon->text());
}
/*
SPDX-FileCopyrightText: 2019-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "emoticonunicodeutils.h"
#include "kpimtextedit_private_export.h"
#include <QListWidget>
namespace KPIMTextEdit
{
class KPIMTEXTEDIT_TESTS_EXPORT EmoticonTextEditItem : public QListWidgetItem
{
public:
explicit EmoticonTextEditItem(const QString &emoticonText, const QString &tooltip, QListWidget *parent);
Q_REQUIRED_RESULT QString text() const;
private:
const QString mText;
};
class KPIMTEXTEDIT_TESTS_EXPORT EmoticonListWidgetSelector : public QListWidget
{
Q_OBJECT
public:
explicit EmoticonListWidgetSelector(QWidget *parent = nullptr);
~EmoticonListWidgetSelector() override;
void setEmoticons(const QVector<EmoticonUnicodeUtils::EmoticonStruct> &emoticons);
Q_SIGNALS:
void itemSelected(const QString &);
private:
void slotMouseOverItem(QListWidgetItem *item);
void slotEmoticonClicked(QListWidgetItem *item);
};
}
......@@ -6,7 +6,6 @@
#include "emoticonunicodetab.h"
#include "emoticonlistview.h"
#include "emoticonlistwidgetselector.h"
#include "emoticonunicodemodel.h"
#include "emoticonunicodeproxymodel.h"
#include "textutils.h"
......
Supports Markdown
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