7 class ExplorerSearch : Window
12 background = activeBorder;
16 ExplorerSearchViewTree view;
18 SearchThread searchThread { searchPanel = this };
25 view.results.ClearFields();
26 view.results.AddField(DataField { editable = true });
28 view.results.AddField(view.resultsFieldPath);
35 searchThread.active = true;
37 searchThread.optionSubdirs = options.subdirs.checked;
38 searchThread.optionTree = (options.subdirs.checked && options.tree.checked);
39 searchThread.optionBrowser = (options.subdirs.checked && options.browser.checked);
40 searchThread.optionNameMatchCase = findName.optionMatchCase.checked;
41 searchThread.optionNameMatchWord = findName.optionMatchWord.checked;
42 searchThread.optionContentMatchCase = findTextContent.optionMatchCase.checked;
43 searchThread.optionContentMatchWord = findTextContent.optionMatchWord.checked;
45 strcpy(searchThread.location, location.GetText());
46 strcpy(searchThread.nameSearch, findName.GetText());
47 strcpy(searchThread.contentSearch, findTextContent.GetText());
49 actions.startStop.text = "Stop Search";
50 actions.clear.disabled = false;
52 view.results.hasHeader = !searchThread.optionTree;
53 view.results.treeBranches = searchThread.optionTree;
55 ToggleBrowserDisplay(searchThread.optionBrowser);
57 view.browser.text = "Browser";
58 sprintf(text, "Search Results (Searching %s)", location.GetText());
59 view.results.text = text;
61 searchThread.Create();
66 if(searchThread.active)
68 searchThread.terminate = true;
77 void SearchUpdateLabel(char * path)
80 sprintf(text, "Search Results (Searching %s)", path);
81 view.results.text = text;
84 void AddResult(ExplorerFileBranch branch, ExplorerFileBranch addTo)
86 AddBranch(branch, true, false, addTo, view.results);
91 //view.results.Sort(resultsNameField, 1);
94 void AddBrowse(ExplorerFileBranch branch, ExplorerFileBranch addTo)
96 AddBranch(branch, true, false, addTo, view.browser);
101 //view.browser.Sort(browserNameField, 1);
104 void SearchTerminate()
108 if(searchThread.terminate)
109 sprintf(text, "Search Results (%d item(s) found), Search was aborted.", searchThread.matchCount);
111 sprintf(text, "Search Results (%d item(s) found), Search completed successfuly.", searchThread.matchCount);
112 view.results.text = text;
113 sprintf(text, "Browser (%d item(s) searched)", searchThread.count);
114 view.browser.text = text;
116 actions.startStop.text = "Start Search";
119 void ListDirectory(DataRow addTo, char * path)
121 FileListing listing { path };
122 while(listing.Find())
124 DataRow row = addTo.AddString(listing.name);
125 row.collapsed = true;
126 if(listing.stats.attribs.isDirectory)
127 ListDirectory(row, listing.path);
131 void ToggleBrowserDisplay(bool visible)
133 //view.labelBrowser.visible = visible;
134 view.browser.visible = visible;
136 view.results.anchor.bottom = 304;
138 view.results.anchor.bottom = 4;
141 PanelFileName findName
144 anchor = Anchor { left = 4, top = 0, right = 4 };
146 /*PanelFileSize findSize
149 anchor = Anchor { left = 4, top = (int)(findName.position.y + findName.size.h + 4), right = 4 };
151 PanelFileTextContent findTextContent
154 anchor = Anchor { left = 4, top = (int)(findName.position.y + findName.size.h + 4), right = 4 };
156 PanelLocation location
159 anchor = Anchor { left = 4, top = (int)(findTextContent.position.y + findTextContent.size.h + 4), right = 4 };
161 editBox.contents = "D:\\Projects\\Ecere";
167 anchor = Anchor { left = 4, top = (int)(location.position.y + location.size.h + 4), right = 4 };
172 anchor = Anchor { left = 4, top = (int)(options.position.y + options.size.h + 4), right = 4 };
186 class ExplorerSearchView : ExplorerView
188 virtual void AddItem(const FileStats stats, const char * name, bool match);
191 class ExplorerSearchViewTree : ExplorerSearchView
194 DataField resultsFieldPath { "char *" };
200 borderStyle = none; // deep
201 hasHorzScroll = true;
202 hasVertScroll = true;
203 fullRowSelect = false;
205 collapseControl = true;
206 rootCollapseButton = true;
209 size = Size { 600, 200 };
210 //anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
211 //anchor = Anchor { left = 8, top = 24, right = 4, bottom = 304 };
212 anchor = Anchor { left = 0, top = 0, right = 0, bottom = 304 };
213 text = "Search Results", hotKey = Key { r, alt = true };
215 /*hasHeader = true, moveFields = true, resizable = true, sortable = true;*/
217 NotifyKeyHit = CommonNotifyKeyHit;
218 NotifyDoubleClick = Lists_NotifyDoubleClick;
220 DataField resultsNameField { header = "Name", dataType = "ExplorerFileBranch", width = 304, userData = this };
225 borderStyle = none; // deep
226 hasHorzScroll = true;
227 hasVertScroll = true;
228 fullRowSelect = false;
230 collapseControl = true;
231 rootCollapseButton = true;
234 size = Size { 624, 268 };
235 anchor = Anchor { left = 8, right = 4, bottom = 4 };
236 text = "Browser", hotKey = Key { e, alt = true };
238 /*hasHeader = true, moveFields = true, resizable = true, sortable = true;*/
240 NotifyKeyHit = CommonNotifyKeyHit;
241 NotifyDoubleClick = Lists_NotifyDoubleClick;
243 DataField browserNameField { header = "Name", dataType = "ExplorerFileBranch", width = 304, userData = this }; // editable = true
245 bool CommonNotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
247 if((SmartKey)key == del)
249 //DeleteBox { this, source = listBox }.Modal();
251 if(MessageBox { finderWnd, text = "text", contents = "contents", type = yesNo }.Modal() == yes)
256 listBox.GetMultiSelection(selection);
258 for(item = selection.first; item; item = item.next)
260 char path[MAX_LOCATION];
261 DataRow row = item.data;
262 ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
263 branch.GetPath(path);
266 if(!FileExists(path))
267 DeleteBranch(branch, listBox);
269 selection.Free(null);
276 bool Lists_NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
278 if(listBox.currentRow)
280 char path[MAX_LOCATION];
281 ExplorerFileBranch branch = (ExplorerFileBranch)listBox.currentRow.tag;
282 //if(listBox != view.results || searchThread.tree)
283 // GetRowPath(listBox.currentRow, path);
285 // strcpy(path, *(char **)listBox.currentRow.GetData(resultsFieldPath));
286 branch.GetPath(path);
293 ExplorerSearchViewTree()
295 results.AddField(resultsNameField);
296 browser.AddField(browserNameField);