forked from qt-creator/qt-creator
Core: simplify ILocator interface
Use data members instead of virtual functions for id, displayName and priority, use Core::Id, not QStrings for id, de-pimpl CommandLocator. Change-Id: Id8b41f184cb995138b2d76c923d6d3ae02b7e3f5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -270,9 +270,9 @@ public:
|
||||
// Helpers to sort by category. id
|
||||
bool optionsPageLessThan(const IOptionsPage *p1, const IOptionsPage *p2)
|
||||
{
|
||||
if (const int cc = p1->category().toString().compare(p2->category().toString()))
|
||||
return cc < 0;
|
||||
return p1->id().toString().compare(p2->id().toString()) < 0;
|
||||
if (p1->category() != p2->category())
|
||||
return p1->category().alphabeticallyBefore(p2->category());
|
||||
return p1->id().alphabeticallyBefore(p2->id());
|
||||
}
|
||||
|
||||
static inline QList<Core::IOptionsPage*> sortedOptionsPages()
|
||||
|
||||
@@ -323,4 +323,9 @@ CORE_EXPORT const char *nameForId(int id)
|
||||
return stringFromId.value(id).str;
|
||||
}
|
||||
|
||||
bool Id::alphabeticallyBefore(Id other) const
|
||||
{
|
||||
return toString().compare(other.toString(), Qt::CaseInsensitive) < 0;
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
bool operator!=(const char *name) const { return !operator==(name); }
|
||||
bool operator<(Id id) const { return m_id < id.m_id; }
|
||||
bool operator>(Id id) const { return m_id > id.m_id; }
|
||||
bool alphabeticallyBefore(Id other) const;
|
||||
int uniqueIdentifier() const { return m_id; }
|
||||
static Id fromUniqueIdentifier(int uid) { return Id(uid); }
|
||||
static Id fromString(const QString &str); // FIXME: avoid.
|
||||
|
||||
Reference in New Issue
Block a user