diff options
Diffstat (limited to 'src/filetreemodel.cpp')
| -rw-r--r-- | src/filetreemodel.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp index 01a10afc..40cded09 100644 --- a/src/filetreemodel.cpp +++ b/src/filetreemodel.cpp @@ -208,6 +208,7 @@ QModelIndex FileTreeModel::index( { if (auto* parentItem=itemFromIndex(parentIndex)) { if (row < 0 || row >= parentItem->children().size()) { + log::error("row {} out of range for {}", row, parentItem->debugName()); return {}; } @@ -378,13 +379,10 @@ Qt::ItemFlags FileTreeModel::flags(const QModelIndex& index) const return f; } -void FileTreeModel::sort(int column, Qt::SortOrder order) +void FileTreeModel::sortItem(FileTreeItem& item) { emit layoutAboutToBeChanged(); - m_sort.column = column; - m_sort.order = order; - const auto oldList = persistentIndexList(); std::vector<std::pair<FileTreeItem*, int>> oldItems; @@ -396,7 +394,7 @@ void FileTreeModel::sort(int column, Qt::SortOrder order) oldItems.push_back({itemFromIndex(index), index.column()}); } - m_root->sort(column, order); + item.sort(m_sort.column, m_sort.order); QModelIndexList newList; newList.reserve(itemCount); @@ -411,6 +409,14 @@ void FileTreeModel::sort(int column, Qt::SortOrder order) emit layoutChanged({}, QAbstractItemModel::VerticalSortHint); } +void FileTreeModel::sort(int column, Qt::SortOrder order) +{ + m_sort.column = column; + m_sort.order = order; + + sortItem(*m_root); +} + FileTreeItem* FileTreeModel::itemFromIndex(const QModelIndex& index) const { if (!index.isValid()) { |
