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:
hjk
2013-01-18 11:16:53 +01:00
parent e7003283a5
commit baffa492d9
45 changed files with 168 additions and 211 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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.