mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
IndexSearch use ResultManager
This commit is contained in:
parent
b737811bdc
commit
f8a4b924c8
3 changed files with 23 additions and 33 deletions
|
|
@ -12,7 +12,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
[TestFixture]
|
||||
public class ExplorerTest
|
||||
{
|
||||
private List<Result> MethodWindowsIndexSearchReturnsZeroResults(string dummyString)
|
||||
private List<Result> MethodWindowsIndexSearchReturnsZeroResults(Query dummyQuery, string dummyString)
|
||||
{
|
||||
return new List<Result>();
|
||||
}
|
||||
|
|
@ -141,8 +141,6 @@ namespace Flow.Launcher.Test.Plugins
|
|||
$"Actual number of results is {results.Count} {Environment.NewLine}");
|
||||
}
|
||||
|
||||
public void GivenWindowsIndexSearch_WhenSearchPatternHotKeyIsSearchAll_ThenQueryWhereRestrictionsShouldUseScopeString() { }
|
||||
|
||||
[TestCase(@"c:\\", false)]
|
||||
[TestCase(@"i:\", true)]
|
||||
[TestCase(@"\c:\", false)]
|
||||
|
|
@ -160,5 +158,7 @@ namespace Flow.Launcher.Test.Plugins
|
|||
$"Actual check result is {result} {Environment.NewLine}");
|
||||
|
||||
}
|
||||
|
||||
public void GivenWindowsIndexSearch_WhenSearchPatternHotKeyIsSearchAll_ThenQueryWhereRestrictionsShouldUseScopeString() { }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
querySearch);
|
||||
}
|
||||
|
||||
return WindowsIndexFilesAndFoldersSearch(querySearch);
|
||||
return WindowsIndexFilesAndFoldersSearch(query, querySearch);
|
||||
}
|
||||
|
||||
private List<Result> DirectoryInfoClassSearch(Query query, string querySearch)
|
||||
|
|
@ -64,13 +64,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
}
|
||||
|
||||
public List<Result> TopLevelFolderSearchBehaviour(
|
||||
Func<string, List<Result>> windowsIndexSearch,
|
||||
Func<Query, string, List<Result>> windowsIndexSearch,
|
||||
Func<Query, string, List<Result>> directoryInfoClassSearch,
|
||||
Func<string, bool> indexExists,
|
||||
Query query,
|
||||
string querySearchString)
|
||||
{
|
||||
var results = windowsIndexSearch(querySearchString);
|
||||
var results = windowsIndexSearch(query, querySearchString);
|
||||
|
||||
if (results.Count == 0 && !indexExists(querySearchString))
|
||||
return directoryInfoClassSearch(query, querySearchString);
|
||||
|
|
@ -78,22 +78,24 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return results;
|
||||
}
|
||||
|
||||
private List<Result> WindowsIndexFilesAndFoldersSearch(string querySearchString)
|
||||
private List<Result> WindowsIndexFilesAndFoldersSearch(Query query, string querySearchString)
|
||||
{
|
||||
var queryConstructor = new QueryConstructor(_settings);
|
||||
|
||||
return searcher.WindowsIndexSearch(querySearchString,
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForAllFilesAndFolders);
|
||||
queryConstructor.QueryForAllFilesAndFolders,
|
||||
query);
|
||||
}
|
||||
|
||||
private List<Result> WindowsIndexTopLevelFolderSearch(string path)
|
||||
private List<Result> WindowsIndexTopLevelFolderSearch(Query query, string path)
|
||||
{
|
||||
var queryConstructor = new QueryConstructor(_settings);
|
||||
|
||||
return searcher.WindowsIndexSearch(path,
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForTopLevelDirectorySearch);
|
||||
queryConstructor.QueryForTopLevelDirectorySearch,
|
||||
query);
|
||||
}
|
||||
|
||||
private bool WindowsIndexExists(string path)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
_context = context;
|
||||
}
|
||||
|
||||
internal List<Result> ExecuteWindowsIndexSearch(string searchString, string connectionString)
|
||||
internal List<Result> ExecuteWindowsIndexSearch(string searchString, string connectionString, Query query)
|
||||
{
|
||||
var results = new List<Result>();
|
||||
|
||||
|
|
@ -54,7 +54,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
results.Add(CreateResult(
|
||||
dataReaderResults.GetString(0),
|
||||
dataReaderResults.GetString(1),
|
||||
dataReaderResults.GetString(2)));
|
||||
dataReaderResults.GetString(2),
|
||||
query));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,30 +75,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
return results;
|
||||
}
|
||||
|
||||
private Result CreateResult(string filename, string path, string fileType)
|
||||
private Result CreateResult(string filename, string path, string fileType, Query query)
|
||||
{
|
||||
return new Result
|
||||
if (fileType == "Directory")
|
||||
return ResultManager.CreateFolderResult(filename, path, path, query);
|
||||
else
|
||||
{
|
||||
Title = filename,
|
||||
SubTitle = path,
|
||||
IcoPath = fileType == "Directory" ? Constants.FolderImagePath : Constants.FileImagePath,
|
||||
Action = c =>
|
||||
{
|
||||
try
|
||||
{
|
||||
FilesFolders.OpenPath(path);
|
||||
}
|
||||
catch (Win32Exception)
|
||||
{
|
||||
_context.API.ShowMsg("Explorer plugin: ", "Unable to open the selected file", string.Empty); //<=========
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return ResultManager.CreateFileResult(path, query);
|
||||
}
|
||||
}
|
||||
|
||||
internal List<Result> WindowsIndexSearch(string searchString, string connectionString, Func<string, string> constructQuery)
|
||||
internal List<Result> WindowsIndexSearch(string searchString, string connectionString, Func<string, string> constructQuery, Query query)
|
||||
{
|
||||
var regexMatch = Regex.Match(searchString, ReservedStringPattern);
|
||||
|
||||
|
|
@ -107,7 +95,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
lock (_lock)
|
||||
{
|
||||
var constructedQuery = constructQuery(searchString);
|
||||
return ExecuteWindowsIndexSearch(constructedQuery, connectionString);
|
||||
return ExecuteWindowsIndexSearch(constructedQuery, connectionString, query);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue