зеркало из https://github.com/nextcloud/desktop.git
Check for and store indices of shares with duplicate display names
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Родитель
56fbc43e0e
Коммит
5d0924c5ab
|
@ -486,6 +486,38 @@ void ShareModel::slotSharesFetched(const QList<SharePtr> &shares)
|
|||
slotAddShare(share);
|
||||
}
|
||||
|
||||
// Perform forward pass on shares and check for duplicate display names; store these indeces so
|
||||
// we can check for these and display the specific user identifier in the display string later
|
||||
_duplicateDisplayNameShareIndices.clear();
|
||||
const auto shareCount = _shares.count();
|
||||
for (auto i = 0; i < shareCount; ++i) {
|
||||
if (_duplicateDisplayNameShareIndices.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto sharee = _shares.at(i)->getShareWith();
|
||||
if (sharee == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto hasDuplicates = false;
|
||||
for (auto j = i + 1; j < shareCount; ++j) {
|
||||
const auto otherSharee = _shares.at(j)->getShareWith();
|
||||
if (otherSharee == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sharee->format() == otherSharee->format()) {
|
||||
hasDuplicates = true; // Reassign is faster
|
||||
_duplicateDisplayNameShareIndices.insert(j);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDuplicates) {
|
||||
_duplicateDisplayNameShareIndices.insert(i);
|
||||
}
|
||||
}
|
||||
|
||||
handleLinkShare();
|
||||
}
|
||||
|
||||
|
|
|
@ -253,6 +253,7 @@ private:
|
|||
QHash<QString, QPersistentModelIndex> _shareIdIndexHash;
|
||||
QHash<QString, QString> _shareIdRecentlySetPasswords;
|
||||
QVector<ShareePtr> _sharees;
|
||||
QSet<unsigned int> _duplicateDisplayNameShareIndices;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
|
Загрузка…
Ссылка в новой задаче