diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.0) -set(PIM_VERSION "5.6.43") +set(PIM_VERSION "5.6.44") project(pimcommon VERSION ${PIM_VERSION}) diff --git a/src/pimcommon/CMakeLists.txt b/src/pimcommon/CMakeLists.txt --- a/src/pimcommon/CMakeLists.txt +++ b/src/pimcommon/CMakeLists.txt @@ -33,8 +33,6 @@ set(libpimcommon_sieve_SRCS - sievehighlighter/sievesyntaxhighlighter.cpp - sievehighlighter/sievesyntaxhighlighterrules.cpp sievehighlighter/sievesyntaxhighlighterutil.cpp ) @@ -316,8 +314,6 @@ ecm_generate_headers(PimCommon_Camelcasesievehighlighter_HEADERS HEADER_NAMES SieveSyntaxHighlighterUtil - SieveSyntaxHighlighter - SieveSyntaxHighlighterRules REQUIRED_HEADERS PimCommon_sievehighlighter_HEADERS PREFIX PimCommon RELATIVE sievehighlighter diff --git a/src/pimcommon/sievehighlighter/sievesyntaxhighlighter.h b/src/pimcommon/sievehighlighter/sievesyntaxhighlighter.h deleted file mode 100644 --- a/src/pimcommon/sievehighlighter/sievesyntaxhighlighter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2011-2017 Laurent Montel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef KSIEVE_KSIEVEUI_SIEVESYNTAXHIGHLIGHTER_H -#define KSIEVE_KSIEVEUI_SIEVESYNTAXHIGHLIGHTER_H - -#include "pimcommon_export.h" -#include "sievesyntaxhighlighterrules.h" -#include - -class QTextDocument; - -namespace PimCommon { -class SieveSyntaxHighlighterPrivate; -class PIMCOMMON_EXPORT SieveSyntaxHighlighter : public KPIMTextEdit::SyntaxHighlighterBase -{ - Q_OBJECT - -public: - explicit SieveSyntaxHighlighter(QTextDocument *doc); - ~SieveSyntaxHighlighter(); - void addCapabilities(const QStringList &capabilities); - -private: - void init() override; - SieveSyntaxHighlighterPrivate *const d; -}; -} - -#endif diff --git a/src/pimcommon/sievehighlighter/sievesyntaxhighlighter.cpp b/src/pimcommon/sievehighlighter/sievesyntaxhighlighter.cpp deleted file mode 100644 --- a/src/pimcommon/sievehighlighter/sievesyntaxhighlighter.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2011-2017 Laurent Montel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "sievesyntaxhighlighter.h" -#include "sievesyntaxhighlighterrules.h" - -using namespace PimCommon; -class PimCommon::SieveSyntaxHighlighterPrivate -{ -public: - SieveSyntaxHighlighterPrivate() - { - } - - SieveSyntaxHighlighterRules mRules; -}; - -SieveSyntaxHighlighter::SieveSyntaxHighlighter(QTextDocument *doc) - : SyntaxHighlighterBase(doc) - , d(new PimCommon::SieveSyntaxHighlighterPrivate) -{ - init(); -} - -SieveSyntaxHighlighter::~SieveSyntaxHighlighter() -{ - delete d; -} - -void SieveSyntaxHighlighter::addCapabilities(const QStringList &capabilities) -{ - d->mRules.addCapabilities(capabilities); - m_rules = d->mRules.rules(); -} - -void SieveSyntaxHighlighter::init() -{ - m_rules = d->mRules.rules(); -} diff --git a/src/pimcommon/sievehighlighter/sievesyntaxhighlighterrules.h b/src/pimcommon/sievehighlighter/sievesyntaxhighlighterrules.h deleted file mode 100644 --- a/src/pimcommon/sievehighlighter/sievesyntaxhighlighterrules.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (c) 2015-2017 Montel Laurent - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License, version 2, as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef SIEVESYNTAXHIGHLIGHTERRULES_H -#define SIEVESYNTAXHIGHLIGHTERRULES_H - -#include -#include "pimcommon_export.h" - -namespace KPIMTextEdit { -class Rule; -} - -namespace PimCommon { -class SieveSyntaxHighlighterRulesPrivate; -class PIMCOMMON_EXPORT SieveSyntaxHighlighterRules -{ -public: - SieveSyntaxHighlighterRules(); - ~SieveSyntaxHighlighterRules(); - - void addCapabilities(const QStringList &capabilities); - - QVector rules() const; -private: - SieveSyntaxHighlighterRulesPrivate *const d; -}; -} -#endif // SIEVESYNTAXHIGHLIGHTERRULES_H diff --git a/src/pimcommon/sievehighlighter/sievesyntaxhighlighterrules.cpp b/src/pimcommon/sievehighlighter/sievesyntaxhighlighterrules.cpp deleted file mode 100644 --- a/src/pimcommon/sievehighlighter/sievesyntaxhighlighterrules.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - Copyright (c) 2015-2017 Montel Laurent - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License, version 2, as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "sievesyntaxhighlighterrules.h" - -#include - -#include - -using namespace PimCommon; - -class PimCommon::SieveSyntaxHighlighterRulesPrivate -{ -public: - SieveSyntaxHighlighterRulesPrivate() - { - } - - void init(); - QVector m_rules; -}; - -void SieveSyntaxHighlighterRulesPrivate::init() -{ - // Comments - QTextCharFormat commentFormat; - commentFormat.setForeground(Qt::darkYellow); - QRegularExpression commentRegex(QStringLiteral("#.*$")); - m_rules.append(KPIMTextEdit::Rule(commentRegex, commentFormat)); - - commentRegex = QRegularExpression(QStringLiteral("/*.*/$")); - m_rules.append(KPIMTextEdit::Rule(commentRegex, commentFormat)); - - // Keywords - QTextCharFormat keywordFormat; - keywordFormat.setForeground(Qt::darkMagenta); - keywordFormat.setFontWeight(QFont::Bold); - QStringList keywords; - keywords << QStringLiteral("\\brequire\\b"); - keywords << QStringLiteral("\\binclude\\b"); - keywords << QStringLiteral("\\bglobal\\b"); - keywords << QStringLiteral("\\bforeverypart\\b"); - for (const QString &s : qAsConst(keywords)) { - const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption); - m_rules.append(KPIMTextEdit::Rule(regex, keywordFormat)); - } - - // Text keyword - QTextCharFormat textKeywordFormat; - textKeywordFormat.setForeground(Qt::green); - QStringList textKeywords; - textKeywords << QStringLiteral("\\btext:"); - for (const QString &s : qAsConst(textKeywords)) { - const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption); - m_rules.append(KPIMTextEdit::Rule(regex, textKeywordFormat)); - } - - // Special debug info - QTextCharFormat debugFormat; - debugFormat.setForeground(Qt::red); - debugFormat.setFontWeight(QFont::Bold); - debugFormat.setFontItalic(true); - const QStringList debugKeywords = {QStringLiteral("\\bdebug_log")}; - for (const QString &s : qAsConst(debugKeywords)) { - const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption); - m_rules.append(KPIMTextEdit::Rule(regex, debugFormat)); - } - - // Match Type - QTextCharFormat matchFormat; - matchFormat.setForeground(Qt::red); - QStringList matchType; - matchType << QStringLiteral("\\s:quoteregex\\b") - << QStringLiteral("\\s:content\\b") - << QStringLiteral("\\s:raw\\b") - << QStringLiteral("\\s:type\\b") - << QStringLiteral("\\s:subtype\\b") - << QStringLiteral("\\s:anychild\\b") - << QStringLiteral("\\s:param\\b") - << QStringLiteral("\\s:value\\b") - << QStringLiteral("\\s:count\\b") - << QStringLiteral("\\s:last\\b") - << QStringLiteral("\\s:text\\b") - << QStringLiteral("\\s:lower\\b") - << QStringLiteral("\\s:upper\\b") - << QStringLiteral("\\s:lowerfirst\\b") - << QStringLiteral("\\s:upperfirst\\b") - << QStringLiteral("\\s:quotewilcard\\b") - << QStringLiteral("\\s:length\\b") - << QStringLiteral("\\s:contains\\b") - << QStringLiteral("\\s:matches\\b") - << QStringLiteral("\\s:global\\b") - << QStringLiteral("\\s:once\\b") - << QStringLiteral("\\s:optional\\b") - << QStringLiteral("\\s:personal\\b") - << QStringLiteral("\\s:is\\b") - << QStringLiteral("\\s:over\\b") - << QStringLiteral("\\s:under\\b") - << QStringLiteral("\\s:localpart\\b") - << QStringLiteral("\\s:domain\\b") - << QStringLiteral("\\s:user\\b") - << QStringLiteral("\\s:detail\\b") - << QStringLiteral("\\s:all\\b") - << QStringLiteral("\\s:copy\\b") - << QStringLiteral("\\s:message\\b") - << QStringLiteral("\\s:importance\\b") - << QStringLiteral("\\s:seconds\\b") - << QStringLiteral("\\stext:\\b") - << QStringLiteral("\\s:days\\b") - << QStringLiteral("\\s:addresses\\b") - << QStringLiteral("\\s:regex\\b") - << QStringLiteral("\\s:flags\\b") - << QStringLiteral("\\s:subject\\b") - << QStringLiteral("\\s:create\\b") - << QStringLiteral("\\s:name\\b") - << QStringLiteral("\\s:headers\\b") - << QStringLiteral("\\s:list\\b") - << QStringLiteral("\\s:from\\b") - << QStringLiteral("\\s:first\\b") - << QStringLiteral("\\s:comparator\\b"); - for (const QString &s : qAsConst(matchType)) { - const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption); - m_rules.append(KPIMTextEdit::Rule(regex, matchFormat)); - } - - // Control structure - QTextCharFormat controlFormat; - controlFormat.setForeground(Qt::green); - controlFormat.setFontWeight(QFont::Bold); - const QStringList controlType = {QStringLiteral("\\bif\\b"), QStringLiteral("\\belsif\\b"), QStringLiteral("\\belse\\b")}; - for (const QString &s : controlType) { - const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption); - m_rules.append(KPIMTextEdit::Rule(regex, controlFormat)); - } - - //Action commands: - QTextCharFormat actionFormat; - actionFormat.setForeground(Qt::blue); - actionFormat.setFontWeight(QFont::Bold); - QStringList actionType; - actionType << QStringLiteral("\\bstop\\b") - << QStringLiteral("\\bkeep\\b") - << QStringLiteral("\\breject\\b") - << QStringLiteral("\\bdiscard\\b") - << QStringLiteral("\\bredirect\\b") - << QStringLiteral("\\bfileinto\\b") - << QStringLiteral("\\bsetflag\\b") - << QStringLiteral("\\baddflag\\b") - << QStringLiteral("\\bremoveflag\\b") - << QStringLiteral("\\bhasflag\\b") - << QStringLiteral("\\bdeleteheader\\b") - << QStringLiteral("\\baddheader\\b") - << QStringLiteral("\\bnotify\\b") - << QStringLiteral("\\bset\\b") - << QStringLiteral("\\breturn\\b") - << QStringLiteral("\\bvacation\\b") - << QStringLiteral("\\benclose\\b") - << QStringLiteral("\\breplace\\b") - << QStringLiteral("\\bextracttext\\b") - << QStringLiteral("\\bbreak\\b"); - for (const QString &s : qAsConst(actionType)) { - const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption); - m_rules.append(KPIMTextEdit::Rule(regex, actionFormat)); - } - - //Test commands: - QTextCharFormat testFormat; - testFormat.setForeground(Qt::gray); - testFormat.setFontWeight(QFont::Bold); - QStringList testType; - testType << QStringLiteral("\\benvelope\\b") - << QStringLiteral("\\baddress\\b") - << QStringLiteral("\\ballof\\b") - << QStringLiteral("\\banyof\\b") - << QStringLiteral("\\bexists\\b") - << QStringLiteral("\\bfalse\\b") - << QStringLiteral("\\bheader\\b") - << QStringLiteral("\\bnot\\b") - << QStringLiteral("\\bsize\\b") - << QStringLiteral("\\bdate\\b") - << QStringLiteral("\\bbody\\b") - << QStringLiteral("\\bcurrentdate\\b") - << QStringLiteral("\\bmailboxexists\\b") - << QStringLiteral("\\btrue\\b") - << QStringLiteral("\\bmetadata\\b") - << QStringLiteral("\\benvironment\\b") - << QStringLiteral("\\bspamtest\\b") - << QStringLiteral("\\bvirustest\\b") - << QStringLiteral("\\bihave\\b") - << QStringLiteral("\\bmetadataexists\\b") - << QStringLiteral("\\bservermetadata\\b") - << QStringLiteral("\\bservermetadataexists\\b"); - for (const QString &s : qAsConst(testType)) { - const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption); - m_rules.append(KPIMTextEdit::Rule(regex, testFormat)); - } - - // Literals - QTextCharFormat literalFormat; - literalFormat.setForeground(Qt::darkRed); - QRegularExpression literalRegex(QStringLiteral("(\"[^\"]*\")")); - m_rules.append(KPIMTextEdit::Rule(literalRegex, literalFormat)); -} - -SieveSyntaxHighlighterRules::SieveSyntaxHighlighterRules() - : d(new PimCommon::SieveSyntaxHighlighterRulesPrivate) -{ - d->init(); -} - -SieveSyntaxHighlighterRules::~SieveSyntaxHighlighterRules() -{ - delete d; -} - -void SieveSyntaxHighlighterRules::addCapabilities(const QStringList &capabilities) -{ - // capabilities - QTextCharFormat keywordFormat; - keywordFormat.setForeground(Qt::darkGreen); - keywordFormat.setFontWeight(QFont::Bold); - for (const QString &s : capabilities) { - const QRegularExpression regex(QStringLiteral("\"%1\"").arg(s), QRegularExpression::CaseInsensitiveOption); - d->m_rules.append(KPIMTextEdit::Rule(regex, keywordFormat)); - } -} - -QVector SieveSyntaxHighlighterRules::rules() const -{ - return d->m_rules; -}