Add AutoTypeAssociations::removeEmpty().

This commit is contained in:
Felix Geyer 2012-07-16 17:37:18 +02:00
parent 7abaf0e215
commit 7db6850528
2 changed files with 12 additions and 0 deletions

View File

@ -64,6 +64,17 @@ void AutoTypeAssociations::remove(int index)
Q_EMIT modified(); Q_EMIT modified();
} }
void AutoTypeAssociations::removeEmpty()
{
QMutableListIterator<AutoTypeAssociations::Association> i(m_associations);
while (i.hasNext()) {
const Association& assoc = i.next();
if (assoc.window.isEmpty() && assoc.sequence.isEmpty()) {
i.remove();
}
}
}
void AutoTypeAssociations::update(int index, const AutoTypeAssociations::Association& association) void AutoTypeAssociations::update(int index, const AutoTypeAssociations::Association& association)
{ {
Q_ASSERT(index >= 0 && index < m_associations.size()); Q_ASSERT(index >= 0 && index < m_associations.size());

View File

@ -40,6 +40,7 @@ public:
void copyDataFrom(const AutoTypeAssociations* other); void copyDataFrom(const AutoTypeAssociations* other);
void add(const AutoTypeAssociations::Association& association); void add(const AutoTypeAssociations::Association& association);
void remove(int index); void remove(int index);
void removeEmpty();
void update(int index, const AutoTypeAssociations::Association& association); void update(int index, const AutoTypeAssociations::Association& association);
AutoTypeAssociations::Association get(int index) const; AutoTypeAssociations::Association get(int index) const;
QList<AutoTypeAssociations::Association> getAll() const; QList<AutoTypeAssociations::Association> getAll() const;