diff options
| -rw-r--r-- | src/datatab.cpp | 2 | ||||
| -rw-r--r-- | src/filetree.cpp | 21 | ||||
| -rw-r--r-- | src/filetreemodel.cpp | 16 | ||||
| -rw-r--r-- | src/filetreemodel.h | 5 |
4 files changed, 43 insertions, 1 deletions
diff --git a/src/datatab.cpp b/src/datatab.cpp index 212d6754..db9151f8 100644 --- a/src/datatab.cpp +++ b/src/datatab.cpp @@ -90,6 +90,7 @@ void DataTab::activated() void DataTab::onRefresh() { if (QGuiApplication::keyboardModifiers() & Qt::ShiftModifier) { + m_filetree->model()->setEnabled(false); m_filetree->clear(); } @@ -98,6 +99,7 @@ void DataTab::onRefresh() void DataTab::updateTree() { + m_filetree->model()->setEnabled(true); m_filetree->refresh(); if (!m_filter.empty()) { diff --git a/src/filetree.cpp b/src/filetree.cpp index 4316021a..af6ef70b 100644 --- a/src/filetree.cpp +++ b/src/filetree.cpp @@ -157,7 +157,28 @@ void FileTree::clear() void FileTree::ensureFullyLoaded() { + QAbstractProxyModel* proxy = nullptr; + + if (m_tree->model() != m_model) { + // looks like there's a proxy on the tree, disable it + proxy = dynamic_cast<QAbstractProxyModel*>(m_tree->model()); + + m_tree->setModel(m_model); + + if (proxy) { + if (proxy->sourceModel() != m_model) + DebugBreak(); + + proxy->setSourceModel(nullptr); + } + } + m_model->ensureFullyLoaded(); + + if (proxy) { + proxy->setSourceModel(m_model); + m_tree->setModel(proxy); + } } FileTreeItem* FileTree::singleSelection() diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp index 912e2007..169d0a02 100644 --- a/src/filetreemodel.cpp +++ b/src/filetreemodel.cpp @@ -137,7 +137,7 @@ void* makeInternalPointer(FileTreeItem* item) FileTreeModel::FileTreeModel(OrganizerCore& core, QObject* parent) : - QAbstractItemModel(parent), m_core(core), + QAbstractItemModel(parent), m_core(core), m_enabled(true), m_root(FileTreeItem::createDirectory(nullptr, L"", L"")), m_flags(NoFlags), m_fullyLoaded(false) { @@ -183,6 +183,16 @@ void FileTreeModel::ensureFullyLoaded() } } +bool FileTreeModel::enabled() const +{ + return m_enabled; +} + +void FileTreeModel::setEnabled(bool b) +{ + m_enabled = b; +} + bool FileTreeModel::showArchives() const { return (m_flags.testFlag(Archives) && m_core.getArchiveParsing()); @@ -243,6 +253,10 @@ bool FileTreeModel::hasChildren(const QModelIndex& parent) const bool FileTreeModel::canFetchMore(const QModelIndex& parent) const { + if (!m_enabled) { + return false; + } + if (auto* item=itemFromIndex(parent)) { return !item->isLoaded(); } diff --git a/src/filetreemodel.h b/src/filetreemodel.h index 3e846a0f..1bc7f73b 100644 --- a/src/filetreemodel.h +++ b/src/filetreemodel.h @@ -45,6 +45,9 @@ public: void clear(); void ensureFullyLoaded(); + bool enabled() const; + void setEnabled(bool b); + QModelIndex index(int row, int col, const QModelIndex& parent={}) const override; QModelIndex parent(const QModelIndex& index) const override; int rowCount(const QModelIndex& parent={}) const override; @@ -69,7 +72,9 @@ private: class Range; using DirectoryIterator = std::vector<MOShared::DirectoryEntry*>::const_iterator; + OrganizerCore& m_core; + bool m_enabled; mutable FileTreeItem::Ptr m_root; Flags m_flags; mutable IconFetcher m_iconFetcher; |
