Commit 5aabba45 authored by Kåre Särs's avatar Kåre Särs

Search&Replace-plugin: -Be smarter with jumping to first match

-Do not add new tabs if not needed
-Select the search text when the view is opened
parent e4659ad7
......@@ -153,6 +153,7 @@ KatePluginSearchView::KatePluginSearchView(Kate::MainWindow *mainWin, Kate::Appl
Kate::XMLGUIClient(KatePluginSearchFactory::componentData()),
m_kateApp(application),
m_curResults(0),
m_searchJustOpened(false),
m_projectPluginView(0)
{
m_toolView = mainWin->createToolView ("kate_plugin_katesearch",
......@@ -172,7 +173,7 @@ m_projectPluginView(0)
connect(a, SIGNAL(triggered(bool)), this, SLOT(openSearchView()));
connect(a, SIGNAL(triggered(bool)), this, SLOT(addTab()));
connect(a, SIGNAL(triggered(bool)), m_ui.displayOptions, SLOT(toggle()));
// toggle works her because addTab() sets it to a not pressed
// toggle works her because addTab() sets it to not pressed
a = actionCollection()->addAction("go_to_next_match");
a->setText(i18n("Go to Next Match"));
......@@ -346,6 +347,8 @@ void KatePluginSearchView::openSearchView()
m_ui.searchCombo->lineEdit()->setText(selection);
}
}
m_ui.searchCombo->lineEdit()->selectAll();
m_searchJustOpened = true;
searchPatternChanged();
}
}
......@@ -668,6 +671,7 @@ void KatePluginSearchView::searchDone()
indicateMatch(m_curResults->tree->topLevelItemCount() > 0);
m_curResults = 0;
m_toolView->unsetCursor();
m_searchJustOpened = false;
}
void KatePluginSearchView::searchWhileTypingDone()
......@@ -681,9 +685,13 @@ void KatePluginSearchView::searchWhileTypingDone()
connect(m_curResults->tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), m_curResults, SLOT(checkCheckedState()));
if (!m_searchJustOpened && (m_curResults->tree->topLevelItemCount() > 0)) {
itemSelected(m_curResults->tree->topLevelItem(0));
}
indicateMatch(m_curResults->tree->topLevelItemCount() > 0);
m_curResults = 0;
m_ui.searchCombo->lineEdit()->setFocus();
m_searchJustOpened = false;
}
void KatePluginSearchView::indicateMatch(bool hasMatch) {
......@@ -881,6 +889,13 @@ void KatePluginSearchView::writeSessionConfig(KConfigBase* config, const QString
void KatePluginSearchView::addTab()
{
if ((sender() != m_ui.newTabButton) &&
(m_ui.resultTabWidget->count() > 0) &&
m_ui.resultTabWidget->tabText(m_ui.resultTabWidget->currentIndex()).isEmpty())
{
return;
}
Results *res = new Results();
connect(res->tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
......
......@@ -148,6 +148,7 @@ private:
KAction *m_matchCase;
KAction *m_useRegExp;
Results *m_curResults;
bool m_searchJustOpened;
QList<KTextEditor::MovingRange*> m_matchRanges;
/**
......
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