File indexing completed on 2025-03-09 03:57:06
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-09-14 0007 * Description : trimmed token modifier 0008 * 0009 * SPDX-FileCopyrightText: 2009-2012 by Andi Clemens <andi dot clemens at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "trimmedmodifier.h" 0016 0017 // Qt includes 0018 0019 #include <QRegularExpression> 0020 0021 // KDE includes 0022 0023 #include <klocalizedstring.h> 0024 0025 namespace Digikam 0026 { 0027 0028 TrimmedModifier::TrimmedModifier() 0029 : Modifier(i18n("Trimmed"), 0030 i18n("Remove leading, trailing and extra whitespace"), 0031 QLatin1String("edit-cut")) 0032 { 0033 QString token(QLatin1String("{trim}")); 0034 addToken(token, description()); 0035 0036 QRegularExpression reg(escapeToken(token)); 0037 reg.setPatternOptions(QRegularExpression::InvertedGreedinessOption); 0038 setRegExp(reg); 0039 } 0040 0041 QString TrimmedModifier::parseOperation(ParseSettings& settings, const QRegularExpressionMatch& /*match*/) 0042 { 0043 return settings.str2Modify.simplified(); 0044 } 0045 0046 } // namespace Digikam 0047 0048 #include "moc_trimmedmodifier.cpp"