forked from qt-creator/qt-creator
Core::Feature: Add some functionality currently implemented in Core::Feature
Convert a QSet<Id> to/from a stringlist and add the methods to create versioned ids and id sets. Most of the code goes into Core::Id, but the code to generate sets of versioned ids moves into BaseQtVersion which is the only user. Change-Id: Id52474fac2aa0563e48b2b714dcfef533350c729 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "id.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QByteArray>
|
||||
@@ -245,6 +246,29 @@ Id Id::fromSetting(const QVariant &variant)
|
||||
return Id(theId(ba));
|
||||
}
|
||||
|
||||
Id Id::versionedId(const QByteArray &prefix, int major, int minor)
|
||||
{
|
||||
if (major < 0)
|
||||
return fromName(prefix);
|
||||
|
||||
QByteArray result = prefix + '.';
|
||||
result += QString::number(major).toLatin1();
|
||||
|
||||
if (minor < 0)
|
||||
return fromName(result);
|
||||
return fromName(result + '.' + QString::number(minor).toLatin1());
|
||||
}
|
||||
|
||||
QSet<Id> Id::fromStringList(const QStringList &list)
|
||||
{
|
||||
return QSet<Id>::fromList(Utils::transform(list, [](const QString &s) { return Id::fromString(s); }));
|
||||
}
|
||||
|
||||
QStringList Id::toStringList(const QSet<Id> &ids)
|
||||
{
|
||||
return Utils::transform(ids.toList(), [](Id i) { return i.toString(); });
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a derived id.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user