Commit 82b0a087 authored by Alex Neundorf's avatar Alex Neundorf

Search & Replace: move code for setting the root item into separate function

parent 75f81b03
......@@ -1163,49 +1163,9 @@ void KatePluginSearchView::searchDone()
}
// expand the "header item " to display all files and all results if configured
QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0);
expandResults();
if (root) {
switch (m_ui.searchPlaceCombo->currentIndex())
{
case CurrentFile:
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in current file</i></b>",
"<b><i>%1 matches found in current file</i></b>",
m_curResults->matches));
break;
case OpenFiles:
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in open files</i></b>",
"<b><i>%1 matches found in open files</i></b>",
m_curResults->matches));
break;
case Folder:
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in folder %2</i></b>",
"<b><i>%1 matches found in folder %2</i></b>",
m_curResults->matches,
m_resultBaseDir));
break;
case Project:
{
QString projectName;
if (m_projectPluginView) {
projectName = m_projectPluginView->property("projectName").toString();
}
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in project %2 (%3)</i></b>",
"<b><i>%1 matches found in project %2 (%3)</i></b>",
m_curResults->matches,
projectName,
m_resultBaseDir));
break;
}
case AllProjects: // "in Open Projects"
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in all open projects (common parent: %2)</i></b>",
"<b><i>%1 matches found in all open projects (common parent: %2)</i></b>",
m_curResults->matches,
m_resultBaseDir));
break;
}
}
updateResultsRootItem();
indicateMatch(m_curResults->matches > 0);
m_curResults = nullptr;
......@@ -1554,6 +1514,52 @@ void KatePluginSearchView::expandResults()
}
}
void KatePluginSearchView::updateResultsRootItem()
{
QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0);
if (root) {
switch (m_ui.searchPlaceCombo->currentIndex())
{
case CurrentFile:
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in current file</i></b>",
"<b><i>%1 matches found in current file</i></b>",
m_curResults->matches));
break;
case OpenFiles:
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in open files</i></b>",
"<b><i>%1 matches found in open files</i></b>",
m_curResults->matches));
break;
case Folder:
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in folder %2</i></b>",
"<b><i>%1 matches found in folder %2</i></b>",
m_curResults->matches,
m_resultBaseDir));
break;
case Project:
{
QString projectName;
if (m_projectPluginView) {
projectName = m_projectPluginView->property("projectName").toString();
}
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in project %2 (%3)</i></b>",
"<b><i>%1 matches found in project %2 (%3)</i></b>",
m_curResults->matches,
projectName,
m_resultBaseDir));
break;
}
case AllProjects: // "in Open Projects"
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in all open projects (common parent: %2)</i></b>",
"<b><i>%1 matches found in all open projects (common parent: %2)</i></b>",
m_curResults->matches,
m_resultBaseDir));
break;
}
}
}
void KatePluginSearchView::itemSelected(QTreeWidgetItem *item)
{
if (!item) return;
......
......@@ -166,6 +166,8 @@ private Q_SLOTS:
void expandResults();
void updateResultsRootItem();
/**
* keep track if the project plugin is alive and if the project file did change
*/
......
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