Optimize the logic for selecting file sizes

This commit is contained in:
reionwong 2021-09-27 12:54:47 +08:00
parent 48056de990
commit b0a06e944a

View file

@ -1198,6 +1198,15 @@ void FolderModel::selectionChanged(const QItemSelection &selected, const QItemSe
} }
} }
updateActions();
emit selectionCountChanged();
// The desktop does not need to calculate the selected file size.
if (m_isDesktop)
return;
// Start calculating file size.
if (m_sizeJob == nullptr) { if (m_sizeJob == nullptr) {
m_sizeJob = new CFileSizeJob; m_sizeJob = new CFileSizeJob;
@ -1223,13 +1232,22 @@ void FolderModel::selectionChanged(const QItemSelection &selected, const QItemSe
m_selectedItemSize = ""; m_selectedItemSize = "";
emit selectedItemSizeChanged(); emit selectedItemSizeChanged();
} else { } else {
m_sizeJob->blockSignals(false); bool fileExists = false;
m_sizeJob->start(selectedUrls());
for (const QModelIndex &index : m_selectionModel->selectedIndexes()) {
if (itemForIndex(index).isFile()) {
fileExists = true;
break;
}
}
// Reion: The size label at the bottom needs to be updated
// only if you select the include file.
if (fileExists) {
m_sizeJob->blockSignals(false);
m_sizeJob->start(selectedUrls());
}
} }
updateActions();
emit selectionCountChanged();
} }
void FolderModel::dragSelectedInternal(int x, int y) void FolderModel::dragSelectedInternal(int x, int y)