mirror of
https://github.com/redstrate/Novus.git
synced 2025-06-28 05:47:46 +00:00
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.
This commit is contained in:
parent
46441700af
commit
5fe8175543
2 changed files with 6 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue