[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:22:40 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=7405ae6
The following commit has been merged in the master branch:
commit 7405ae696c520f9126f3959672cc2d9223fbb5b6
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
Date: Tue Aug 28 16:05:01 2012 +0200
Filter recursively all the matched patterns
---
filters/formatting/format-filter.cpp | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/filters/formatting/format-filter.cpp b/filters/formatting/format-filter.cpp
index c0753e2..938d3d5 100644
--- a/filters/formatting/format-filter.cpp
+++ b/filters/formatting/format-filter.cpp
@@ -29,14 +29,25 @@ typedef QPair<QRegExp, QString> FormatTag;
class FormatFilter::Private {
public:
QList<FormatTag> tags;
+ QString mainPattern;
+ QString allTagsPattern;
void addTag (const char *markingCharacter, char htmlTag);
QString filterString(QString string);
};
FormatFilter::FormatFilter (QObject* parent, const QVariantList&) :
- AbstractMessageFilter (parent), d(new Private())
+ AbstractMessageFilter (parent),
+ d(new Private())
{
+ d->mainPattern = QLatin1String("(^|\s)%1(\S|\S.*\S)%1(\s|$)");
+
+ d->allTagsPattern = QLatin1String("(") + QRegExp::escape(QLatin1String("_")) +
+ QLatin1String("|") + QRegExp::escape(QLatin1String("*")) +
+ QLatin1String("|") + QRegExp::escape(QLatin1String("-")) +
+ QLatin1String("|") + QRegExp::escape(QLatin1String("/")) +
+ QLatin1String(")");
+
d->addTag("_", 'u');
d->addTag("\*", 'b');
d->addTag("-", 's');
@@ -51,16 +62,21 @@ FormatFilter::~FormatFilter()
void FormatFilter::filterMessage (Message& message)
{
message.setMainMessagePart(d->filterString(message.mainMessagePart()));
-
}
QString FormatFilter::Private::filterString(QString string)
{
+ QRegExp rx(mainPattern.arg(allTagsPattern));
+ rx.setMinimal(true);
+
+ int pos = 0;
+ while ((pos = string.indexOf(rx, pos)) != -1) {
+ string = string.replace(rx.cap(3), filterString(rx.cap(3)));
+ pos += rx.matchedLength();
+ }
+
Q_FOREACH(FormatTag tag, tags) {
- if (string.indexOf(tag.first) >= 0) {
- string = string.replace(tag.first.cap(2), filterString(tag.first.cap(2)));
- string = string.replace(tag.first, tag.second);
- }
+ string = string.replace(tag.first, tag.second);
}
return string;
@@ -68,13 +84,10 @@ QString FormatFilter::Private::filterString(QString string)
void FormatFilter::Private::addTag (const char *markingCharacter, char htmlTag)
{
- QString pattern = QLatin1String("(^|\s)%1(\S|\S.*\S)%1(\s|$)");
- pattern = pattern.arg(QLatin1String(markingCharacter));
-
QString repl = QLatin1String("\1<%1>%2\2%2</%1>\3");
repl = repl.arg(htmlTag).arg(QLatin1String(markingCharacter));
- QRegExp exp = QRegExp(pattern);
+ QRegExp exp = QRegExp(mainPattern.arg(QLatin1String(markingCharacter)));
exp.setMinimal(true);
tags.append(FormatTag(exp, repl));
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list