1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : a modifier for deleting duplicate words
9
* Copyright (C) 2009 by Andi Clemens <andi dot clemens at gmx dot net>
11
* This program is free software; you can redistribute it
12
* and/or modify it under the terms of the GNU General
13
* Public License as published by the Free Software Foundation;
14
* either version 2, or (at your option)
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* ============================================================ */
24
#include "removedoublesmodifier.moc"
30
#include <QStringList>
34
#include <kiconloader.h>
35
#include <klineedit.h>
41
RemoveDoublesModifier::RemoveDoublesModifier()
42
: Modifier(i18n("Remove Doubles"),
43
i18n("Remove duplicate words"),
44
SmallIcon("edit-copy"))
46
addToken("{removedoubles}", description());
48
QRegExp reg("\\{removedoubles\\}");
53
QString RemoveDoublesModifier::parseOperation(ParseSettings& settings)
55
QString result = settings.str2Modify;
57
QSet<QString> knownWords;
58
QStringList words = result.split(QChar(' '));
59
QStringList newString;
60
foreach (const QString& word, words)
62
if (!knownWords.contains(word))
64
knownWords.insert(word);
69
if (!newString.isEmpty())
71
result = newString.join(QChar(' '));
77
} // namespace Digikam