1
// FirstSearchController.cs
3
// GNOME Do is the legal property of its developers. Please refer to the
4
// COPYRIGHT file distributed with this source distribution.
6
// This program is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program. If not, see <http://www.gnu.org/licenses/>.
22
using System.Collections.Generic;
31
public class FirstSearchController : SimpleSearchController
33
public FirstSearchController() : base ()
37
public override bool ToggleSecondaryCursor (int cursorLocation)
39
bool update = (SecondaryCursors.Length == 0);
40
bool result = base.ToggleSecondaryCursor (cursorLocation);
47
public override void Reset ()
53
public override IEnumerable<Type> SearchTypes {
56
yield return typeof (ITextItem);
57
} else if (context.SecondaryCursors.Any ()) {
58
// This is pretty bad.
59
yield return Results [SecondaryCursors [0]].GetType ();
61
foreach (Type t in defaultFilter) yield return t;
66
public override bool TextMode {
68
return textMode || ImplicitTextMode;
71
if (context.ParentContext != null) return;
73
textModeFinalize = false;
75
BuildNewContextFromQuery ();
79
protected override void UpdateResults ()
81
context.Results = InitialResults ();
82
bool searchChanged = context.LastContext == null || context.LastContext.Selection != context.Selection;
83
base.OnSearchFinished (searchChanged, true, Selection, Query);
86
public override void SetString (string str)
89
BuildNewContextFromQuery ();
92
private void BuildNewContextFromQuery ()
97
context = new SimpleSearchContext ();
99
foreach (char c in query.ToCharArray ()) {
100
context.LastContext = context.Clone () as SimpleSearchContext;
102
context.Results = InitialResults ();
104
base.OnSearchFinished (true, true, Selection, Query);