mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Make sure we don't add entries/groups multiple times to the drag'n'drop data.
This commit is contained in:
parent
ef46b3e8ad
commit
91868969ca
@ -211,12 +211,20 @@ QMimeData* EntryModel::mimeData(const QModelIndexList& indexes) const
|
||||
QByteArray encoded;
|
||||
QDataStream stream(&encoded, QIODevice::WriteOnly);
|
||||
|
||||
QSet<Entry*> seenEntries;
|
||||
|
||||
for (int i = 0; i < indexes.size(); i++) {
|
||||
if (!indexes[i].isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Entry* entry = entryFromIndex(indexes[i]);
|
||||
if (!seenEntries.contains(entry)) {
|
||||
// make sure we don't add entries multiple times when we get indexes
|
||||
// with the same row but different columns
|
||||
stream << entry->group()->database()->uuid() << entry->uuid();
|
||||
seenEntries.insert(entry);
|
||||
}
|
||||
}
|
||||
|
||||
data->setData(mimeTypes().first(), encoded);
|
||||
|
@ -297,11 +297,20 @@ QMimeData* GroupModel::mimeData(const QModelIndexList& indexes) const
|
||||
QByteArray encoded;
|
||||
QDataStream stream(&encoded, QIODevice::WriteOnly);
|
||||
|
||||
QSet<Group*> seenGroups;
|
||||
|
||||
for (int i = 0; i < indexes.size(); i++) {
|
||||
if (!indexes[i].isValid()) {
|
||||
continue;
|
||||
}
|
||||
stream << m_db->uuid() << groupFromIndex(indexes[i])->uuid();
|
||||
|
||||
Group* group = groupFromIndex(indexes[i]);
|
||||
if (!seenGroups.contains(group)) {
|
||||
// make sure we don't add groups multiple times when we get indexes
|
||||
// with the same row but different columns
|
||||
stream << m_db->uuid() << group->uuid();
|
||||
seenGroups.insert(group);
|
||||
}
|
||||
}
|
||||
|
||||
data->setData(mimeTypes().first(), encoded);
|
||||
|
Loading…
Reference in New Issue
Block a user