Commit 1d00a620 authored by Boudewijn Rempt's avatar Boudewijn Rempt Committed by Boudewijn Rempt

Run astyle on KoInterfaces and fix up manually

parent d9e6e5ab
......@@ -58,7 +58,10 @@ class KoGenericRegistry
{
public:
KoGenericRegistry() { }
virtual ~KoGenericRegistry() { m_hash.clear(); }
virtual ~KoGenericRegistry()
{
m_hash.clear();
}
public:
/**
......@@ -68,10 +71,11 @@ public:
*
* @param item the item to add (NOTE: T must have an QString id() const function)
*/
void add(T item) {
Q_ASSERT( item );
void add(T item)
{
Q_ASSERT(item);
QString id = item->id();
if(m_hash.contains(id)) {
if (m_hash.contains(id)) {
m_doubleEntries << value(id);
remove(id);
}
......@@ -83,9 +87,10 @@ public:
* @param id the id of the object
* @param item the item to add
*/
void add(const QString &id, T item) {
Q_ASSERT( item );
if(m_hash.contains(id)) {
void add(const QString &id, T item)
{
Q_ASSERT(item);
if (m_hash.contains(id)) {
m_doubleEntries << value(id);
remove(id);
}
......@@ -95,7 +100,8 @@ public:
/**
* This function removes an item from the registry
*/
void remove(const QString &id) {
void remove(const QString &id)
{
m_hash.remove(id);
}
......@@ -105,7 +111,8 @@ public:
*
* @param id the id
*/
T get(const QString& id) const {
T get(const QString &id) const
{
return value(id);
}
......@@ -114,7 +121,8 @@ public:
* by the id.
* @param id the unique identifier string
*/
bool contains(const QString &id) const {
bool contains(const QString &id) const
{
return m_hash.contains(id);
}
......@@ -122,26 +130,31 @@ public:
* Retrieve the object from the registry based on the unique identifier string
* @param id the id
*/
const T value(const QString &id) const {
const T value(const QString &id) const
{
return m_hash.value(id);
}
/**
* @return a list of all keys
*/
QList<QString> keys() const {
QList<QString> keys() const
{
return m_hash.keys();
}
int count() const {
int count() const
{
return m_hash.count();
}
QList<T> values() const {
QList<T> values() const
{
return m_hash.values();
}
QList<T> doubleEntries() const {
QList<T> doubleEntries() const
{
return m_doubleEntries;
}
......
......@@ -35,20 +35,24 @@
class KoID
{
public:
KoID() : m_id(), m_name() {}
KoID()
: m_id()
, m_name()
{}
/**
* Construct a KoID with the given id, and name, id is the untranslated
* official name of the id, name should be translatable as it will be used
* in the UI.
*
*
* @code
* KoID("id", i18n("name"))
* @endcode
*/
explicit KoID(const QString & id, const QString & name = QString())
: m_id(id),
m_name(name) {}
explicit KoID(const QString &id, const QString &name = QString())
: m_id(id)
, m_name(name)
{}
/**
* Use this constructore for static KoID. as KoID("id", ki18n("name"));
......@@ -56,10 +60,10 @@ public:
* important because static objects are constructed before translations
* are initialized.
*/
explicit KoID(const QString & id, const KLocalizedString& name )
: m_id(id),
m_localizedString(name) {}
explicit KoID(const QString &id, const KLocalizedString &name)
: m_id(id)
, m_localizedString(name)
{}
KoID(const KoID &rhs)
{
......@@ -67,11 +71,13 @@ public:
m_name = rhs.name();
}
QString id() const {
QString id() const
{
return m_id;
}
QString name() const {
QString name() const
{
if (m_name.isEmpty() && !m_localizedString.isEmpty()) {
m_name = m_localizedString.toString();
}
......@@ -103,13 +109,11 @@ inline bool operator!=(const KoID &v1, const KoID &v2)
return v1.m_id != v2.m_id;
}
inline bool operator<(const KoID &v1, const KoID &v2)
{
return v1.m_id < v2.m_id;
}
inline bool operator>(const KoID &v1, const KoID &v2)
{
return v1.m_id > v2.m_id;
......@@ -122,5 +126,4 @@ inline QDebug operator<<(QDebug dbg, const KoID &id)
return dbg.space();
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment