Only emit signals from clear() when the internal data is non-empty.
Also make sure that m_attributes always contains the default attributes.
This commit is contained in:
@@ -22,9 +22,7 @@ const QStringList EntryAttributes::m_defaultAttibutes(QStringList() << "Title" <
|
||||
EntryAttributes::EntryAttributes(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
Q_FOREACH (const QString& key, m_defaultAttibutes) {
|
||||
set(key, "");
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
QList<QString> EntryAttributes::keys() const
|
||||
@@ -123,11 +121,19 @@ void EntryAttributes::copyFrom(const EntryAttributes* other)
|
||||
|
||||
void EntryAttributes::clear()
|
||||
{
|
||||
if (m_attributes.keys().size() == m_defaultAttibutes.size() && m_protectedAttributes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_EMIT aboutToBeReset();
|
||||
|
||||
m_attributes.clear();
|
||||
m_protectedAttributes.clear();
|
||||
|
||||
Q_FOREACH (const QString& key, m_defaultAttibutes) {
|
||||
m_attributes.insert(key, "");
|
||||
}
|
||||
|
||||
Q_EMIT reset();
|
||||
Q_EMIT modified();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user