Added different search scopes

This commit is contained in:
Hans-Albert Maritz 2015-03-10 16:16:36 +11:00
parent 3c2d3d53d7
commit 9450328581
1 changed files with 30 additions and 5 deletions

View File

@ -98,6 +98,7 @@ class SearchWidget : TabWidget {
HorizontalLayout _layout; HorizontalLayout _layout;
EditLine _findText; EditLine _findText;
SearchLogWidget _resultLog; SearchLogWidget _resultLog;
ComboBox _searchScope;
protected IDEFrame _frame; protected IDEFrame _frame;
protected SearchMatchList[] _matchedList; protected SearchMatchList[] _matchedList;
@ -136,6 +137,10 @@ class SearchWidget : TabWidget {
return true; return true;
}); });
_layout.addChild(goButton); _layout.addChild(goButton);
_searchScope = new ComboBox("searchScope", ["File"d, "Project"d, "Dependencies"d, "Everywhere"d]);
_searchScope.selectedItemIndex = 0;
_layout.addChild(_searchScope);
addChild(_layout); addChild(_layout);
_resultLog = new SearchLogWidget("SearchLogWidget"); _resultLog = new SearchLogWidget("SearchLogWidget");
@ -178,12 +183,32 @@ class SearchWidget : TabWidget {
_resultLog.text = ""d; _resultLog.text = ""d;
_matchedList = []; _matchedList = [];
//TODO Should not crash when in homepage. switch (_searchScope.text) {
case "File": //File
auto currentFileItem = _frame._wsPanel.workspace.findSourceFileItem(_frame.currentEditor.filename);
if(currentFileItem !is null)
searchInProject(currentFileItem, source);
break;
case "Project": //Project
foreach(Project project; _frame._wsPanel.workspace.projects) { foreach(Project project; _frame._wsPanel.workspace.projects) {
Log.d("Searching in project " ~ project.filename); if(!project.isDependency)
searchInProject(project.items, source); searchInProject(project.items, source);
} }
break;
case "Dependencies": //Dependencies
foreach(Project project; _frame._wsPanel.workspace.projects) {
if(project.isDependency)
searchInProject(project.items, source);
}
break;
case "Everywhere": //Everywhere
foreach(Project project; _frame._wsPanel.workspace.projects) {
searchInProject(project.items, source);
}
break;
default:
assert(0);
}
if (_matchedList.length == 0) { if (_matchedList.length == 0) {
_resultLog.appendText(to!dstring("No matches found.\n")); _resultLog.appendText(to!dstring("No matches found.\n"));