From 5fe81755435a8a03f6d3e166707e3dd39f5ef146 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 24 Jun 2025 14:43:47 -0400 Subject: [PATCH] Fix searching in the Data Explorer I don't know when/how this broke, but it was driving me crazy. Searching for a specific file would break the model, causing it to "loop back" to showing the root folders in children. I just had to make sure the row property was set correctly in the TreeInformation structs. --- apps/sagasu/src/filetreemodel.cpp | 7 +++++-- apps/sagasu/src/filetreewindow.cpp | 4 +--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/sagasu/src/filetreemodel.cpp b/apps/sagasu/src/filetreemodel.cpp index adf56ca..d8e07f8 100644 --- a/apps/sagasu/src/filetreemodel.cpp +++ b/apps/sagasu/src/filetreemodel.cpp @@ -80,6 +80,7 @@ QModelIndex FileTreeModel::index(int row, int column, const QModelIndex &parent) if (childItem) return createIndex(row, column, childItem); + Q_UNREACHABLE(); return {}; } @@ -94,7 +95,7 @@ QModelIndex FileTreeModel::parent(const QModelIndex &index) const if (parentItem == rootItem) return {}; - return createIndex(parentItem->row, 0, parentItem); + return createIndex(parentItem->row, index.column(), parentItem); } QVariant FileTreeModel::data(const QModelIndex &index, int role) const @@ -180,7 +181,7 @@ void FileTreeModel::addKnownFolder(const QString &string) folderItem->name = children[i]; folderItem->type = TreeType::Folder; folderItem->parent = parentItem; - folderItem->row = i + 1; + folderItem->row = parentItem->children.size(); folderItem->hash = hash; parentItem->children.push_back(folderItem); parentItem = folderItem; @@ -200,6 +201,7 @@ void FileTreeModel::addFile(TreeInformation *parentItem, uint32_t name, const QS fileItem->name = realName; fileItem->type = TreeType::File; fileItem->parent = parentItem; + fileItem->row = parentItem->children.size(); parentItem->children.push_back(fileItem); } @@ -214,6 +216,7 @@ void FileTreeModel::addFolder(TreeInformation *parentItem, uint32_t name) fileItem->hash = name; fileItem->type = TreeType::Folder; fileItem->parent = parentItem; + fileItem->row = fileItem->parent->children.size(); parentItem->children.push_back(fileItem); } diff --git a/apps/sagasu/src/filetreewindow.cpp b/apps/sagasu/src/filetreewindow.cpp index 1483edf..85162a0 100644 --- a/apps/sagasu/src/filetreewindow.cpp +++ b/apps/sagasu/src/filetreewindow.cpp @@ -33,9 +33,7 @@ FileTreeWindow::FileTreeWindow(HashDatabase &database, const QString &gamePath, searchEdit->setPlaceholderText(i18nc("@info:placeholder", "Search…")); searchEdit->setClearButtonEnabled(true); searchEdit->setProperty("_breeze_borders_sides", QVariant::fromValue(QFlags{Qt::BottomEdge})); - connect(searchEdit, &QLineEdit::textChanged, this, [this](const QString &text) { - m_searchModel->setFilterRegularExpression(text); - }); + connect(searchEdit, &QLineEdit::textChanged, m_searchModel, &QSortFilterProxyModel::setFilterFixedString); layout->addWidget(searchEdit); // TODO Restore as an action, later. it's currently pretty useless as-is as it's a "please slow down and crash" checkbox