Commit fe61dcf2 authored by Vlas Puhov's avatar Vlas Puhov
Browse files

GrepViewPlugin: Search by default in previous location.

BUG: 299751
parent 63328cb3
......@@ -152,7 +152,7 @@ GrepDialog::GrepDialog( GrepViewPlugin * plugin, QWidget *parent, bool setLastUs
caseSensitiveCheck->setChecked(cg.readEntry("case_sens", true));
QList<IProject*> projects = m_plugin->core()->projectController()->projects();
setDirectory( !projects.isEmpty() ? allOpenProjectsString : QDir::homePath() );
setDirectory( cg.readEntry("SearchPath", !projects.isEmpty() ? allOpenProjectsString : QDir::homePath() ));
directoryRequester->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
......@@ -277,6 +277,7 @@ GrepDialog::~GrepDialog()
cg.writeEntry("LastUsedTemplateIndex", templateTypeCombo->currentIndex());
cg.writeEntry("LastUsedTemplateString", qCombo2StringList(templateEdit));
cg.writeEntry("LastUsedReplacementTemplateString", qCombo2StringList(templateEdit));
cg.writeEntry("SearchPath", directoryRequester->lineEdit()->text());
cg.sync();
}
......
......@@ -173,31 +173,11 @@ void GrepViewPlugin::showDialog(bool setLastUsed, QString pattern, bool showOpti
dlg->enableButtonOk( !pattern.isEmpty() );
}
//if directory is empty then use a default value from the config file.
if (!m_directory.isEmpty()) {
dlg->setDirectory(m_directory);
} else {
KUrl currentUrl;
KDevelop::IDocument *document = core()->documentController()->activeDocument();
bool enableProjectBox = false;
if( document )
{
currentUrl = document->url();
}
if( currentUrl.isValid() )
{
KDevelop::IProject *proj = core()->projectController()->findProjectForUrl( currentUrl );
if( proj && proj->folder().isLocalFile() )
{
enableProjectBox = !proj->files().isEmpty();
if (!m_directory.startsWith(proj->folder().toLocalFile()))
{
dlg->setDirectory( proj->folder().toLocalFile() );
}
}
}
dlg->setEnableProjectBox(enableProjectBox);
}
}
if(showOptions)
dlg->show();
else{
......
Supports Markdown
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