KFileItemListView contents are periodically scanned by KFileItemModelRolesUpdater.
It uses then KDirectoryContentsCounter to scan directories to determine their size possibly recursively.
Introduce a scanDirectories setting to disable directory scanning by KFileItemModelRolesUpdater.
BUG: 426617
FIXED-IN: 20.08.3
KStandardItemListView(parent),
m_modelRolesUpdater(nullptr),
m_updateVisibleIndexRangeTimer(nullptr),
- m_updateIconSizeTimer(nullptr)
+ m_updateIconSizeTimer(nullptr),
+ m_scanDirectories(true)
{
setAcceptDrops(true);
return m_modelRolesUpdater ? m_modelRolesUpdater->localFileSizePreviewLimit() : 0;
}
+void KFileItemListView::setScanDirectories(bool enabled)
+{
+ m_scanDirectories = enabled;
+ if (m_modelRolesUpdater) {
+ m_modelRolesUpdater->setScanDirectories(m_scanDirectories);
+ }
+}
+
+bool KFileItemListView::scanDirectories()
+{
+ return m_scanDirectories;
+}
+
QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
{
if (!model()) {
if (current) {
m_modelRolesUpdater = new KFileItemModelRolesUpdater(static_cast<KFileItemModel*>(current), this);
m_modelRolesUpdater->setIconSize(availableIconSize());
+ m_modelRolesUpdater->setScanDirectories(scanDirectories());
applyRolesToModel();
}
void setLocalFileSizePreviewLimit(qlonglong size);
qlonglong localFileSizePreviewLimit() const;
+ /**
+ * If set to true, directories contents are scanned to determine their size
+ * Default true
+ */
+ void setScanDirectories(bool enabled);
+ bool scanDirectories();
+
QPixmap createDragPixmap(const KItemSet& indexes) const override;
protected:
KFileItemModelRolesUpdater* m_modelRolesUpdater;
QTimer* m_updateVisibleIndexRangeTimer;
QTimer* m_updateIconSizeTimer;
+ bool m_scanDirectories;
friend class KFileItemListViewTest; // For unit testing
};
m_resolvableRoles(),
m_enabledPlugins(),
m_localFileSizePreviewLimit(0),
+ m_scanDirectories(true),
m_pendingSortRoleItems(),
m_pendingIndexes(),
m_pendingPreviewItems(),
return m_localFileSizePreviewLimit;
}
+void KFileItemModelRolesUpdater::setScanDirectories(bool enabled)
+{
+ m_scanDirectories = enabled;
+}
+
+bool KFileItemModelRolesUpdater::scanDirectories() const
+{
+ return m_scanDirectories;
+}
+
void KFileItemModelRolesUpdater::slotItemsInserted(const KItemRangeList& itemRanges)
{
QElapsedTimer timer;
data.insert("type", item.mimeComment());
} else if (m_model->sortRole() == "size" && item.isLocalFile() && item.isDir()) {
const QString path = item.localPath();
- m_directoryContentsCounter->scanDirectory(path);
+ if (m_scanDirectories) {
+ m_directoryContentsCounter->scanDirectory(path);
+ }
} else {
// Probably the sort role is a baloo role - just determine all roles.
data = rolesData(item);
const bool getIsExpandableRole = m_roles.contains("isExpandable");
if ((getSizeRole || getIsExpandableRole) && item.isDir()) {
- if (item.isLocalFile()) {
+ if (item.isLocalFile() && !item.isSlow()) {
// Tell m_directoryContentsCounter that we want to count the items
// inside the directory. The result will be received in slotDirectoryContentsCountReceived.
- const QString path = item.localPath();
- m_directoryContentsCounter->scanDirectory(path);
+ if (m_scanDirectories) {
+ const QString path = item.localPath();
+ m_directoryContentsCounter->scanDirectory(path);
+ }
} else if (getSizeRole) {
data.insert("size", -1); // -1 indicates an unknown number of items
}
void setLocalFileSizePreviewLimit(qlonglong size);
qlonglong localFileSizePreviewLimit() const;
+ /**
+ * If set to true, directories contents are scanned to determine their size
+ * Default true
+ */
+ void setScanDirectories(bool enabled);
+ bool scanDirectories() const;
+
private slots:
void slotItemsInserted(const KItemRangeList& itemRanges);
void slotItemsRemoved(const KItemRangeList& itemRanges);
QSet<QByteArray> m_resolvableRoles;
QStringList m_enabledPlugins;
qulonglong m_localFileSizePreviewLimit;
+ bool m_scanDirectories;
// Items for which the sort role still has to be determined.
QSet<KFileItem> m_pendingSortRoleItems;
// This assures that no performance and memory overhead is given when the folders panel is not
// used at all and stays invisible.
KFileItemListView* view = new KFileItemListView();
+ view->setScanDirectories(false);
view->setWidgetCreator(new KItemListWidgetCreator<FoldersItemListWidget>());
view->setSupportsItemExpanding(true);
// Set the opacity to 0 initially. The opacity will be increased after the loading of the initial tree