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

Regexeditor interface was removed and not sure if someone will work on

it => remove it
parent cb892dbf
Pipeline #65611 canceled with stage
add_definitions(-DTRANSLATION_DOMAIN=\"sieveeditor_plugins\")
add_subdirectory(imapfoldercompletion)
add_subdirectory(regexeditorlineedit)
add_subdirectory(emaillineedit)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(sieveeditorregexp_plugin_categories_SRCS)
ecm_qt_declare_logging_category(sieveeditorregexp_plugin_categories_SRCS HEADER regexpeditorlineeditplugin_debug.h IDENTIFIER
REGEXPEDITORLINEEDITPLUGIN_LOG CATEGORY_NAME org.kde.pim.regexpeditorlineedit
DESCRIPTION "kdepim-addons (SieveEditor Regexp Editor plugin)"
EXPORT KDEPIMADDONS
)
if(BUILD_TESTING)
add_subdirectory(tests)
add_subdirectory(autotests)
endif()
set(regexpeditorlineeditplugin_SRCS
regexpeditorlineedit.cpp
${sieveeditorregexp_plugin_categories_SRCS}
)
kcoreaddons_add_plugin(regexpeditorlineeditplugin JSON regexepeditorlineedit.json SOURCES
${regexpeditorlineeditplugin_SRCS} INSTALL_NAMESPACE libksieve)
if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
set_target_properties(regexpeditorlineeditplugin PROPERTIES UNITY_BUILD ON)
endif()
target_link_libraries(regexpeditorlineeditplugin
KF5::I18n KF5::KSieveUi KF5::TextWidgets KF5::Service
)
macro(add_regexpeditorplugin_unittest _source _additional)
set( _test ${_source} ${_additional})
get_filename_component(_name ${_source} NAME_WE)
add_executable( ${_name} ${_test})
add_test(NAME ${_name} COMMAND ${_name} )
ecm_mark_as_test(sieveeditorplugin-${_name})
target_link_libraries( ${_name} Qt::Widgets Qt::Test KF5::I18n KF5::KSieveUi KF5::TextWidgets KF5::Service)
endmacro ()
add_regexpeditorplugin_unittest(regexpeditorlineedittest.cpp "../regexpeditorlineedit.cpp;${sieveeditorregexp_plugin_categories_SRCS}")
/*
SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "regexpeditorlineedittest.h"
#include "../regexpeditorlineedit.h"
#include <QHBoxLayout>
#include <QLineEdit>
#include <QTest>
#include <QToolButton>
RegexpEditorLineEditTest::RegexpEditorLineEditTest(QObject *parent)
: QObject(parent)
{
}
void RegexpEditorLineEditTest::shouldHaveDefaultValue()
{
RegexpEditorLineEdit w;
auto mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
auto mLineEdit = w.findChild<QLineEdit *>(QStringLiteral("lineedit"));
QVERIFY(mLineEdit);
QVERIFY(mLineEdit->text().isEmpty());
auto mRegExpEditorButton = w.findChild<QToolButton *>(QStringLiteral("regexpbutton"));
QVERIFY(mRegExpEditorButton);
QVERIFY(!mRegExpEditorButton->text().isEmpty());
QVERIFY(!mRegExpEditorButton->toolTip().isEmpty());
}
QTEST_MAIN(RegexpEditorLineEditTest)
/*
SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
class RegexpEditorLineEditTest : public QObject
{
Q_OBJECT
public:
explicit RegexpEditorLineEditTest(QObject *parent = nullptr);
~RegexpEditorLineEditTest() override = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
{
"KPlugin": {
"Id": "regexpeditorlineedit",
"Version": "1.0"
}
}
/*
SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "regexpeditorlineedit.h"
#include "regexpeditorlineeditplugin_debug.h"
#include <KPluginFactory>
#include <KLocalizedString>
#include <KServiceTypeTrader>
#include <QDialog>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QToolButton>
#include <KTextWidgets/kregexpeditorinterface.h>
K_PLUGIN_CLASS_WITH_JSON(RegexpEditorLineEdit, "regexepeditorlineedit.json")
struct InfoRegExp {
enum RegexpEditorStatus {
Unknown = 0,
Installed,
NotInstalled,
};
RegexpEditorStatus status = Unknown;
QDialog *mEditorDialog = nullptr;
};
Q_GLOBAL_STATIC(InfoRegExp, s_regexpeditorinstalled)
RegexpEditorLineEdit::RegexpEditorLineEdit(QWidget *parent, const QList<QVariant> &)
: KSieveUi::AbstractRegexpEditorLineEdit(parent)
{
auto mainLayout = new QHBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mainLayout->setContentsMargins({});
mLineEdit = new QLineEdit(this);
connect(mLineEdit, &QLineEdit::textChanged, this, &RegexpEditorLineEdit::textChanged);
mLineEdit->setObjectName(QStringLiteral("lineedit"));
mainLayout->addWidget(mLineEdit);
mRegExpEditorButton = new QToolButton(this);
mRegExpEditorButton->setText(i18n("..."));
mRegExpEditorButton->setObjectName(QStringLiteral("regexpbutton"));
mRegExpEditorButton->setToolTip(i18n("Create Regular Expression"));
mainLayout->addWidget(mRegExpEditorButton);
// Disable for the moment until we fix kregexeditor
s_regexpeditorinstalled->status = InfoRegExp::NotInstalled;
if (s_regexpeditorinstalled->status == InfoRegExp::Unknown) {
if (KServiceTypeTrader::self()->query(QStringLiteral("KRegExpEditor/KRegExpEditor")).isEmpty()) {
s_regexpeditorinstalled->status = InfoRegExp::NotInstalled;
} else {
s_regexpeditorinstalled->status = InfoRegExp::Installed;
}
}
if (s_regexpeditorinstalled->status == InfoRegExp::Installed) {
connect(mRegExpEditorButton, &QToolButton::clicked, this, &RegexpEditorLineEdit::slotOpenRegexpEditor);
} else {
qCDebug(REGEXPEDITORLINEEDITPLUGIN_LOG) << "KRegExpEditor is not installed on system.";
}
// Hidden by default
mRegExpEditorButton->setVisible(false);
}
RegexpEditorLineEdit::~RegexpEditorLineEdit()
{
}
void RegexpEditorLineEdit::slotOpenRegexpEditor()
{
if (!s_regexpeditorinstalled->mEditorDialog) {
QString error;
s_regexpeditorinstalled->mEditorDialog =
KServiceTypeTrader::createInstanceFromQuery<QDialog>(QStringLiteral("KRegExpEditor/KRegExpEditor"), this, this, {}, {}, &error);
if (!s_regexpeditorinstalled->mEditorDialog) {
qCWarning(REGEXPEDITORLINEEDITPLUGIN_LOG) << " Impossible to create regexpeditor " << error;
return;
}
}
#if 0
KRegExpEditorInterface *iface = qobject_cast<KRegExpEditorInterface *>(s_regexpeditorinstalled->mEditorDialog);
Q_ASSERT(iface); // This should not fail!
// now use the editor.
iface->setRegExp(mLineEdit->text());
if (s_regexpeditorinstalled->mEditorDialog->exec() == QDialog::Accepted) {
mLineEdit->setText(iface->regExp());
}
#else
qCWarning(REGEXPEDITORLINEEDITPLUGIN_LOG) << "KRegExpEditorInterface is deprecated. Need to adapt KRegExpEditor first ";
#endif
}
void RegexpEditorLineEdit::switchToRegexpEditorLineEdit(bool regexpEditor)
{
if (s_regexpeditorinstalled->status == InfoRegExp::Installed) {
mRegExpEditorButton->setVisible(regexpEditor);
}
}
void RegexpEditorLineEdit::setCode(const QString &str)
{
mLineEdit->setText(str);
}
QString RegexpEditorLineEdit::code() const
{
return mLineEdit->text();
}
void RegexpEditorLineEdit::setClearButtonEnabled(bool b)
{
mLineEdit->setClearButtonEnabled(b);
}
void RegexpEditorLineEdit::setPlaceholderText(const QString &str)
{
mLineEdit->setPlaceholderText(str);
}
#include "regexpeditorlineedit.moc"
/*
SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <KSieveUi/AbstractRegexpEditorLineEdit>
class QWidget;
class QLineEdit;
class QToolButton;
class RegexpEditorLineEdit : public KSieveUi::AbstractRegexpEditorLineEdit
{
Q_OBJECT
public:
explicit RegexpEditorLineEdit(QWidget *parent = nullptr, const QList<QVariant> & = {});
~RegexpEditorLineEdit() override;
void switchToRegexpEditorLineEdit(bool regexpEditor) override;
void setCode(const QString &str) override;
QString code() const override;
void setClearButtonEnabled(bool b) override;
void setPlaceholderText(const QString &str) override;
private:
void slotOpenRegexpEditor();
QLineEdit *mLineEdit = nullptr;
QToolButton *mRegExpEditorButton = nullptr;
};
set(sieveeditor_regexpeditor_SRCS
main.cpp
regexpeditorwidget.cpp
../regexpeditorlineedit.cpp
${sieveeditorregexp_plugin_categories_SRCS}
)
add_executable(sieveeditorregexpeditor_gui ${sieveeditor_regexpeditor_SRCS})
target_link_libraries(sieveeditorregexpeditor_gui
KF5::PimCommon KF5::I18n KF5::KSieveUi KF5::TextWidgets KF5::Service
)
/*
SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "regexpeditorwidget.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QStandardPaths>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QStandardPaths::setTestModeEnabled(true);
QCommandLineParser parser;
parser.addVersionOption();
parser.addHelpOption();
parser.process(app);
auto w = new RegExpEditorWidget;
w->resize(800, 600);
w->show();
app.exec();
delete w;
return 0;
}
/*
SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "regexpeditorwidget.h"
#include "../regexpeditorlineedit.h"
#include <QCheckBox>
#include <QVBoxLayout>
#include <QVariant>
RegExpEditorWidget::RegExpEditorWidget(QWidget *parent)
: QWidget(parent)
{
auto layout = new QVBoxLayout(this);
for (int i = 0; i < 4; ++i) {
auto switchToRegexp = new QCheckBox(QStringLiteral("Switch to regexp line edit"), this);
layout->addWidget(switchToRegexp);
auto lineEdit = new RegexpEditorLineEdit(this);
layout->addWidget(lineEdit);
connect(switchToRegexp, &QCheckBox::toggled, lineEdit, &RegexpEditorLineEdit::switchToRegexpEditorLineEdit);
}
layout->addStretch(1);
}
/*
SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QWidget>
class RegExpEditorWidget : public QWidget
{
Q_OBJECT
public:
explicit RegExpEditorWidget(QWidget *parent = nullptr);
~RegExpEditorWidget() override = default;
};
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