summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/coreplugin/id.cpp22
-rw-r--r--src/plugins/coreplugin/id.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/plugins/coreplugin/id.cpp b/src/plugins/coreplugin/id.cpp
index 7a0e742b7d..a6161ddc44 100644
--- a/src/plugins/coreplugin/id.cpp
+++ b/src/plugins/coreplugin/id.cpp
@@ -283,6 +283,12 @@ Id Id::withSuffix(const char *suffix) const
return Id(ba.constData());
}
+/*!
+ \overload
+
+ \sa stringSuffix()
+*/
+
Id Id::withSuffix(const QString &suffix) const
{
const QByteArray ba = name() + suffix.toUtf8();
@@ -340,4 +346,20 @@ bool Id::alphabeticallyBefore(Id other) const
return toString().compare(other.toString(), Qt::CaseInsensitive) < 0;
}
+
+/*!
+ Convenience function to extract a part of the id string
+ representation. This can be used to split off the base
+ part used when generating an id with \c{withSuffix()}.
+
+ \sa withSuffix()
+*/
+
+QString Id::suffixAfter(Id baseId) const
+{
+ const QByteArray b = baseId.name();
+ const QByteArray n = name();
+ return n.startsWith(b) ? QString::fromUtf8(n.mid(b.size())) : QString();
+}
+
} // namespace Core
diff --git a/src/plugins/coreplugin/id.h b/src/plugins/coreplugin/id.h
index 1f8ae83bc7..827ffd9c37 100644
--- a/src/plugins/coreplugin/id.h
+++ b/src/plugins/coreplugin/id.h
@@ -57,6 +57,7 @@ public:
QByteArray name() const;
QString toString() const; // Avoid.
QVariant toSetting() const; // Good to use.
+ QString suffixAfter(Id baseId) const;
bool isValid() const { return m_id; }
bool operator==(Id id) const { return m_id == id.m_id; }
bool operator==(const char *name) const;