forked from qt-creator/qt-creator
Utils: Add StringAspect::{append,remove}Value{,s} convenience functions
Change-Id: I3893d9512b7600328e127693da9dc07c771b305a Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -1703,6 +1703,38 @@ void StringListAspect::setValue(const QStringList &value)
|
||||
BaseAspect::setValue(value);
|
||||
}
|
||||
|
||||
void StringListAspect::appendValue(const QString &s, bool allowDuplicates)
|
||||
{
|
||||
QStringList val = value();
|
||||
if (allowDuplicates || !val.contains(s))
|
||||
val.append(s);
|
||||
setValue(val);
|
||||
}
|
||||
|
||||
void StringListAspect::removeValue(const QString &s)
|
||||
{
|
||||
QStringList val = value();
|
||||
val.removeAll(s);
|
||||
setValue(val);
|
||||
}
|
||||
|
||||
void StringListAspect::appendValues(const QStringList &values, bool allowDuplicates)
|
||||
{
|
||||
QStringList val = value();
|
||||
for (const QString &s : values) {
|
||||
if (allowDuplicates || !val.contains(s))
|
||||
val.append(s);
|
||||
}
|
||||
setValue(val);
|
||||
}
|
||||
|
||||
void StringListAspect::removeValues(const QStringList &values)
|
||||
{
|
||||
QStringList val = value();
|
||||
for (const QString &s : values)
|
||||
val.removeAll(s);
|
||||
setValue(val);
|
||||
}
|
||||
/*!
|
||||
\class Utils::TextDisplay
|
||||
|
||||
|
@@ -428,6 +428,11 @@ public:
|
||||
QStringList value() const;
|
||||
void setValue(const QStringList &val);
|
||||
|
||||
void appendValue(const QString &value, bool allowDuplicates = true);
|
||||
void removeValue(const QString &value);
|
||||
void appendValues(const QStringList &values, bool allowDuplicates = true);
|
||||
void removeValues(const QStringList &values);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Internal::StringListAspectPrivate> d;
|
||||
};
|
||||
|
Reference in New Issue
Block a user