Fix query history for the new result panel

This commit is contained in:
bao-qian 2015-11-08 02:50:33 +00:00
parent d946e18fa2
commit e3cdfe27d1
3 changed files with 15 additions and 13 deletions

View File

@ -473,6 +473,7 @@ namespace Wox
private void ResetQueryHistoryIndex()
{
pnlResult.RemoveResultsFor(QueryHistoryStorage.MetaData);
QueryHistoryStorage.Instance.Reset();
}
private void Query(string text)
@ -487,18 +488,18 @@ namespace Wox
{
if (!string.IsNullOrEmpty(keyword))
{
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword]);
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
}
}
else
{
if (string.IsNullOrEmpty(keyword))
{
pnlResult.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword]);
pnlResult.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword].Metadata);
}
else if (lastKeyword != keyword)
{
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword]);
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
}
}
_lastQuery = query;
@ -738,14 +739,11 @@ namespace Wox
{
if (history != null)
{
var historyMetadata = new PluginMetadata
{
ID = "Query history",
Name = "Query history"
};
var historyMetadata = QueryHistoryStorage.MetaData;
ChangeQueryText(history.Query, true);
var executeQueryHistoryTitle = GetTranslation("executeQuery");
var lastExecuteTime = GetTranslation("lastExecuteTime");
pnlResult.RemoveResultsExcept(historyMetadata);
UpdateResultViewInternal(new List<Result>()
{
new Result(){

View File

@ -40,19 +40,19 @@ namespace Wox
public int MaxResultsToShow { get { return UserSettingStorage.Instance.MaxResultsToShow * 50; } }
internal void RemoveResultsFor(PluginPair plugin)
internal void RemoveResultsFor(PluginMetadata metadata)
{
lock (_resultsUpdateLock)
{
_results.RemoveAll(r => r.PluginID == plugin.Metadata.ID);
_results.RemoveAll(r => r.PluginID == metadata.ID);
}
}
internal void RemoveResultsExcept(PluginPair plugin)
internal void RemoveResultsExcept(PluginMetadata metadata)
{
lock (_resultsUpdateLock)
{
_results.RemoveAll(r => r.PluginID != plugin.Metadata.ID);
_results.RemoveAll(r => r.PluginID != metadata.ID);
}
}

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
namespace Wox.Storage
{
@ -16,6 +17,9 @@ namespace Wox.Storage
private int MaxHistory = 300;
private int cursor = 0;
public static PluginMetadata MetaData { get; } = new PluginMetadata
{ ID = "Query history", Name = "Query history" };
protected override string ConfigFolder
{
get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); }