Commit 7309f240 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Replace signal blocking with orphan QTreeWidgetItem

parent 25c39be0
......@@ -816,6 +816,13 @@ QTreeWidgetItem *KatePluginSearchView::rootFileItem(const QString &url, const QS
return nullptr;
}
if (m_isSearchAsYouType) {
if (m_curResults->tree->topLevelItemCount() == 0) {
addHeaderItem();
}
return m_curResults->tree->topLevelItem(0);
}
QUrl fullUrl = QUrl::fromUserInput(url);
QString path = fullUrl.isLocalFile() ? localFileDirUp(fullUrl).path() : fullUrl.url();
if (!path.isEmpty() && !path.endsWith(QLatin1Char('/'))) {
......@@ -828,14 +835,14 @@ QTreeWidgetItem *KatePluginSearchView::rootFileItem(const QString &url, const QS
}
// make sure we have a root item
if (m_curResults->tree->topLevelItemCount() == 0) {
addHeaderItem();
if (!searchRoot) {
searchRoot = new QTreeWidgetItem(static_cast<QTreeWidget*>(nullptr), QStringList());
searchRoot->setCheckState(0, Qt::Checked);
searchRoot->setFlags(searchRoot->flags() | Qt::ItemIsAutoTristate);
searchRoot->setExpanded(true);
}
QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0);
if (m_isSearchAsYouType) {
return root;
}
QTreeWidgetItem *root = searchRoot;
for (int i = 0; i < root->childCount(); i++) {
// qDebug() << root->child(i)->data(0, ReplaceMatches::FileNameRole).toString() << fName;
......@@ -978,8 +985,6 @@ void KatePluginSearchView::matchFound(const QString &url, const QString &fName,
row << i18n("Line: <b>%1</b> Column: <b>%2</b>: %3", startLine + 1, startColumn + 1, pre + QStringLiteral("<b>") + match + QStringLiteral("</b>") + post);
TreeWidgetItem *item = new TreeWidgetItem(rootFileItem(url, fName), row);
m_curResults->tree->model()->blockSignals(true);
item->setData(0, ReplaceMatches::FileUrlRole, url);
item->setData(0, Qt::ToolTipRole, url);
item->setData(0, ReplaceMatches::FileNameRole, fName);
......@@ -992,7 +997,6 @@ void KatePluginSearchView::matchFound(const QString &url, const QString &fName,
item->setData(0, ReplaceMatches::EndLineRole, endLine);
item->setData(0, ReplaceMatches::EndColumnRole, endColumn);
item->setCheckState(0, Qt::Checked);
m_curResults->tree->model()->blockSignals(false);
m_curResults->matches++;
}
......@@ -1365,6 +1369,10 @@ void KatePluginSearchView::searchDone()
m_ui.replaceButton->setDisabled(m_curResults->matches < 1);
m_ui.nextButton->setDisabled(m_curResults->matches < 1);
m_curResults->tree->topLevelItem(0)->addChildren(searchRoot->takeChildren());
delete searchRoot;
searchRoot = nullptr;
m_curResults->tree->sortItems(0, Qt::AscendingOrder);
m_curResults->tree->expandAll();
......
......@@ -206,6 +206,7 @@ private:
QTimer m_changeTimer;
QTimer m_updateSumaryTimer;
QPointer<KTextEditor::Message> m_infoMessage;
QTreeWidgetItem* searchRoot = nullptr;
/**
* current project plugin view, if any
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment