Warning, file /office/calligra/libs/main/KoFindOptionSet.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * 0003 * Copyright (c) 2010 Arjen Hiemstra <ahiemstra@heimr.nl> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include "KoFindOptionSet.h" 0022 #include "KoFindOption.h" 0023 0024 #include <QHash> 0025 0026 class Q_DECL_HIDDEN KoFindOptionSet::Private 0027 { 0028 public: 0029 Private() : nextID(0) { } 0030 QHash<QString, KoFindOption *> options; 0031 0032 int nextID; 0033 }; 0034 0035 KoFindOptionSet::KoFindOptionSet(QObject *parent) 0036 : QObject(parent), d(new Private) 0037 { 0038 } 0039 0040 KoFindOptionSet::~KoFindOptionSet() 0041 { 0042 qDeleteAll(d->options.values()); 0043 delete d; 0044 } 0045 0046 KoFindOption *KoFindOptionSet::option(const QString &name) const 0047 { 0048 if(d->options.contains(name)) { 0049 return d->options.value(name); 0050 } 0051 return 0; 0052 } 0053 0054 QList<KoFindOption *> KoFindOptionSet::options() const 0055 { 0056 return d->options.values(); 0057 } 0058 0059 KoFindOption *KoFindOptionSet::addOption(const QString &name) 0060 { 0061 KoFindOption *newOption = new KoFindOption(name); 0062 d->options.insert(name, newOption); 0063 return newOption; 0064 } 0065 0066 KoFindOption *KoFindOptionSet::addOption(const QString &name, const QString &title, const QString &description, const QVariant &value) 0067 { 0068 KoFindOption *newOption = new KoFindOption(name); 0069 newOption->setTitle(title); 0070 newOption->setDescription(description); 0071 newOption->setValue(value); 0072 d->options.insert(name, newOption); 0073 return newOption; 0074 } 0075 0076 void KoFindOptionSet::removeOption(const QString &name) 0077 { 0078 if(d->options.contains(name)) { 0079 d->options.remove(name); 0080 } 0081 } 0082 0083 void KoFindOptionSet::setOptionValue(const QString &name, const QVariant &value) 0084 { 0085 if(d->options.contains(name)) { 0086 d->options.value(name)->setValue(value); 0087 } 0088 } 0089 0090 void KoFindOptionSet::replaceOption(const QString &name, KoFindOption *newOption) 0091 { 0092 Q_ASSERT(newOption); 0093 if(d->options.contains(name)) { 0094 d->options.insert(name, newOption); 0095 } 0096 }