Skip to content

Commit 5fe8175

Browse files
committed
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.
1 parent 4644170 commit 5fe8175

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

apps/sagasu/src/filetreemodel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ QModelIndex FileTreeModel::index(int row, int column, const QModelIndex &parent)
8080
if (childItem)
8181
return createIndex(row, column, childItem);
8282

83+
Q_UNREACHABLE();
8384
return {};
8485
}
8586

@@ -94,7 +95,7 @@ QModelIndex FileTreeModel::parent(const QModelIndex &index) const
9495
if (parentItem == rootItem)
9596
return {};
9697

97-
return createIndex(parentItem->row, 0, parentItem);
98+
return createIndex(parentItem->row, index.column(), parentItem);
9899
}
99100

100101
QVariant FileTreeModel::data(const QModelIndex &index, int role) const
@@ -180,7 +181,7 @@ void FileTreeModel::addKnownFolder(const QString &string)
180181
folderItem->name = children[i];
181182
folderItem->type = TreeType::Folder;
182183
folderItem->parent = parentItem;
183-
folderItem->row = i + 1;
184+
folderItem->row = parentItem->children.size();
184185
folderItem->hash = hash;
185186
parentItem->children.push_back(folderItem);
186187
parentItem = folderItem;
@@ -200,6 +201,7 @@ void FileTreeModel::addFile(TreeInformation *parentItem, uint32_t name, const QS
200201
fileItem->name = realName;
201202
fileItem->type = TreeType::File;
202203
fileItem->parent = parentItem;
204+
fileItem->row = parentItem->children.size();
203205

204206
parentItem->children.push_back(fileItem);
205207
}
@@ -214,6 +216,7 @@ void FileTreeModel::addFolder(TreeInformation *parentItem, uint32_t name)
214216
fileItem->hash = name;
215217
fileItem->type = TreeType::Folder;
216218
fileItem->parent = parentItem;
219+
fileItem->row = fileItem->parent->children.size();
217220

218221
parentItem->children.push_back(fileItem);
219222
}

apps/sagasu/src/filetreewindow.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ FileTreeWindow::FileTreeWindow(HashDatabase &database, const QString &gamePath,
3333
searchEdit->setPlaceholderText(i18nc("@info:placeholder", "Search…"));
3434
searchEdit->setClearButtonEnabled(true);
3535
searchEdit->setProperty("_breeze_borders_sides", QVariant::fromValue(QFlags{Qt::BottomEdge}));
36-
connect(searchEdit, &QLineEdit::textChanged, this, [this](const QString &text) {
37-
m_searchModel->setFilterRegularExpression(text);
38-
});
36+
connect(searchEdit, &QLineEdit::textChanged, m_searchModel, &QSortFilterProxyModel::setFilterFixedString);
3937
layout->addWidget(searchEdit);
4038

4139
// TODO Restore as an action, later. it's currently pretty useless as-is as it's a "please slow down and crash" checkbox

0 commit comments

Comments
 (0)