mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-25 22:16:01 -05:00
Don't add new entries to EntryModel when in search mode.
Only allow moving entries from one group to the other.
This commit is contained in:
parent
f6e1af30b3
commit
33b4cd8636
@ -452,7 +452,7 @@ void Group::addEntry(Entry* entry)
|
||||
}
|
||||
|
||||
Q_EMIT modified();
|
||||
Q_EMIT entryAdded();
|
||||
Q_EMIT entryAdded(entry);
|
||||
}
|
||||
|
||||
void Group::removeEntry(Entry* entry)
|
||||
@ -467,7 +467,7 @@ void Group::removeEntry(Entry* entry)
|
||||
}
|
||||
m_entries.removeAll(entry);
|
||||
Q_EMIT modified();
|
||||
Q_EMIT entryRemoved();
|
||||
Q_EMIT entryRemoved(entry);
|
||||
}
|
||||
|
||||
void Group::recSetDatabase(Database* db)
|
||||
|
@ -104,9 +104,9 @@ Q_SIGNALS:
|
||||
void moved();
|
||||
|
||||
void entryAboutToAdd(Entry* entry);
|
||||
void entryAdded();
|
||||
void entryAdded(Entry* entry);
|
||||
void entryAboutToRemove(Entry* entry);
|
||||
void entryRemoved();
|
||||
void entryRemoved(Entry* entry);
|
||||
|
||||
void entryDataChanged(Entry* entry);
|
||||
|
||||
|
@ -55,7 +55,9 @@ void EntryModel::setGroup(Group* group)
|
||||
severConnections();
|
||||
|
||||
m_group = group;
|
||||
m_allGroups.clear();
|
||||
m_entries = group->entries();
|
||||
m_orgEntries.clear();
|
||||
|
||||
makeConnections(group);
|
||||
|
||||
@ -72,6 +74,7 @@ void EntryModel::setEntries(const QList<Entry*>& entries)
|
||||
m_group = Q_NULLPTR;
|
||||
m_allGroups.clear();
|
||||
m_entries = entries;
|
||||
m_orgEntries = entries;
|
||||
|
||||
if (entries.count() > 0) {
|
||||
m_allGroups = entries.at(0)->group()->database()->rootGroup()->groupsRecursive(true);
|
||||
@ -215,7 +218,9 @@ QMimeData* EntryModel::mimeData(const QModelIndexList& indexes) const
|
||||
|
||||
void EntryModel::entryAboutToAdd(Entry* entry)
|
||||
{
|
||||
Q_UNUSED(entry);
|
||||
if (!m_group && !m_orgEntries.contains(entry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(), m_entries.size(), m_entries.size());
|
||||
if (!m_group) {
|
||||
@ -223,8 +228,12 @@ void EntryModel::entryAboutToAdd(Entry* entry)
|
||||
}
|
||||
}
|
||||
|
||||
void EntryModel::entryAdded()
|
||||
void EntryModel::entryAdded(Entry* entry)
|
||||
{
|
||||
if (!m_group && !m_orgEntries.contains(entry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_group) {
|
||||
m_entries = m_group->entries();
|
||||
}
|
||||
@ -268,8 +277,8 @@ void EntryModel::severConnections()
|
||||
void EntryModel::makeConnections(const Group* group)
|
||||
{
|
||||
connect(group, SIGNAL(entryAboutToAdd(Entry*)), SLOT(entryAboutToAdd(Entry*)));
|
||||
connect(group, SIGNAL(entryAdded()), SLOT(entryAdded()));
|
||||
connect(group, SIGNAL(entryAdded(Entry*)), SLOT(entryAdded(Entry*)));
|
||||
connect(group, SIGNAL(entryAboutToRemove(Entry*)), SLOT(entryAboutToRemove(Entry*)));
|
||||
connect(group, SIGNAL(entryRemoved()), SLOT(entryRemoved()));
|
||||
connect(group, SIGNAL(entryRemoved(Entry*)), SLOT(entryRemoved()));
|
||||
connect(group, SIGNAL(entryDataChanged(Entry*)), SLOT(entryDataChanged(Entry*)));
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public Q_SLOTS:
|
||||
|
||||
private Q_SLOTS:
|
||||
void entryAboutToAdd(Entry* entry);
|
||||
void entryAdded();
|
||||
void entryAdded(Entry* entry);
|
||||
void entryAboutToRemove(Entry* entry);
|
||||
void entryRemoved();
|
||||
void entryDataChanged(Entry* entry);
|
||||
@ -65,6 +65,7 @@ private:
|
||||
|
||||
Group* m_group;
|
||||
QList<Entry*> m_entries;
|
||||
QList<Entry*> m_orgEntries;
|
||||
QList<const Group*> m_allGroups;
|
||||
};
|
||||
|
||||
|
@ -271,7 +271,7 @@ void TestGroup::testDeleteSignals()
|
||||
Entry* entry = new Entry();
|
||||
entry->setGroup(group);
|
||||
QSignalSpy spyEntryAboutToRemove(group, SIGNAL(entryAboutToRemove(Entry*)));
|
||||
QSignalSpy spyEntryRemoved(group, SIGNAL(entryRemoved()));
|
||||
QSignalSpy spyEntryRemoved(group, SIGNAL(entryRemoved(Entry*)));
|
||||
|
||||
delete entry;
|
||||
QVERIFY(group->entries().isEmpty());
|
||||
@ -286,7 +286,7 @@ void TestGroup::testDeleteSignals()
|
||||
Entry* entry2 = new Entry();
|
||||
entry2->setGroup(group2);
|
||||
QSignalSpy spyEntryAboutToRemove2(group2, SIGNAL(entryAboutToRemove(Entry*)));
|
||||
QSignalSpy spyEntryRemoved2(group2, SIGNAL(entryRemoved()));
|
||||
QSignalSpy spyEntryRemoved2(group2, SIGNAL(entryRemoved(Entry*)));
|
||||
|
||||
delete group2;
|
||||
QCOMPARE(spyEntryAboutToRemove2.count(), 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user