Rev 86 | Rev 88 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 86 | Rev 87 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | unit RecyclerListingMain; |
1 | unit RecyclerListingMain; |
2 | 2 | ||
3 | // TODO: Doubleclick to open file! |
- | |
4 | - | ||
5 | interface |
3 | interface |
6 | 4 | ||
7 | uses |
5 | uses |
8 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
9 | Dialogs, StdCtrls, ComCtrls, ExtCtrls, ImgList; |
7 | Dialogs, StdCtrls, ComCtrls, ExtCtrls, ImgList; |
Line 20... | Line 18... | ||
20 | ImageList1: TImageList; |
18 | ImageList1: TImageList; |
21 | CheckBox2: TCheckBox; |
19 | CheckBox2: TCheckBox; |
22 | procedure Button1Click(Sender: TObject); |
20 | procedure Button1Click(Sender: TObject); |
23 | procedure Button2Click(Sender: TObject); |
21 | procedure Button2Click(Sender: TObject); |
24 | procedure FormShow(Sender: TObject); |
22 | procedure FormShow(Sender: TObject); |
- | 23 | procedure TreeView1DblClick(Sender: TObject); |
|
25 | private |
24 | private |
26 | localRecyclersNode: TTreeNode; |
25 | localRecyclersNode: TTreeNode; |
27 | individualRecyclersNode: TTreeNode; |
26 | individualRecyclersNode: TTreeNode; |
28 | end; |
27 | end; |
29 | 28 | ||
Line 33... | Line 32... | ||
33 | implementation |
32 | implementation |
34 | 33 | ||
35 | {$R *.dfm} |
34 | {$R *.dfm} |
36 | 35 | ||
37 | uses |
36 | uses |
38 | RecBinUnit2, ContNrs, SIDUnit; |
37 | RecBinUnit2, ContNrs, SIDUnit, ShellAPI; |
39 | 38 | ||
40 | // TODO: SID Namen auflösen und dementsprechend anzeigen |
39 | // TODO: SID Namen auflösen und dementsprechend anzeigen |
41 | // TODO: zu jedem element mehr informationen anzeigen, nicht nur den ursprungsnamen |
40 | // TODO: zu jedem element mehr informationen anzeigen, nicht nur den ursprungsnamen |
42 | // TODO: Einstellungen usw anzeigen, so wie im alten Demo |
41 | // TODO: Einstellungen usw anzeigen, so wie im alten Demo |
43 | 42 | ||
Line 59... | Line 58... | ||
59 | nItem: TTreeNode; |
58 | nItem: TTreeNode; |
60 | sCaption: string; |
59 | sCaption: string; |
61 | resourcestring |
60 | resourcestring |
62 | S_DRIVE = 'Drive %s'; |
61 | S_DRIVE = 'Drive %s'; |
63 | begin |
62 | begin |
64 | localRecyclersNode.DeleteChildren; |
63 | localRecyclersNode.DeleteChildren; // TODO: Will the objects be freed? This is important to avoid memory leaks. |
65 | 64 | ||
66 | TreeView1.Items.BeginUpdate; |
65 | TreeView1.Items.BeginUpdate; |
67 | drives := TObjectList.Create(true); |
66 | drives := TObjectList.Create(false); |
68 | bins := TObjectList.Create(true); |
67 | bins := TObjectList.Create(false); |
69 | items := TObjectList.Create(true); |
68 | items := TObjectList.Create(false); |
70 | try |
69 | try |
71 | drives.Clear; |
70 | drives.Clear; |
72 | TRecycleBinManager.ListDrives(drives); |
71 | TRecycleBinManager.ListDrives(drives); |
73 | for iDrive := 0 to drives.Count - 1 do |
72 | for iDrive := 0 to drives.Count - 1 do |
74 | begin |
73 | begin |
Line 103... | Line 102... | ||
103 | if not FileExists(item.PhysicalFile) and |
102 | if not FileExists(item.PhysicalFile) and |
104 | not DirectoryExists(item.PhysicalFile) and |
103 | not DirectoryExists(item.PhysicalFile) and |
105 | CheckBox2.Checked then continue; |
104 | CheckBox2.Checked then continue; |
106 | 105 | ||
107 | sCaption := item.Source; |
106 | sCaption := item.Source; |
108 | if item.IndexFile <> '' then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
107 | if item is TRbVistaItem (*item.IndexFile <> ''*) then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
109 | nItem := TreeView1.Items.AddChildObject(nBin, sCaption, bin); |
108 | nItem := TreeView1.Items.AddChildObject(nBin, sCaption, item); |
110 | 109 | ||
111 | if FileExists(item.PhysicalFile) then |
110 | if FileExists(item.PhysicalFile) then |
112 | nItem.ImageIndex := 0 |
111 | nItem.ImageIndex := 0 |
113 | else if DirectoryExists(item.PhysicalFile) then |
112 | else if DirectoryExists(item.PhysicalFile) then |
114 | nItem.ImageIndex := 10 // TODO: Feature: Read folder contents and display them in this graph. (Also change icon to "open folder") |
113 | nItem.ImageIndex := 10 // TODO: Feature: Read folder contents and display them in this treeview. (Also change icon to "open folder") |
115 | else |
114 | else |
116 | nItem.ImageIndex := 8; |
115 | nItem.ImageIndex := 8; |
117 | nItem.SelectedIndex := nItem.ImageIndex; |
116 | nItem.SelectedIndex := nItem.ImageIndex; |
118 | end; |
117 | end; |
119 | end; |
118 | end; |
Line 142... | Line 141... | ||
142 | bin := TRbRecycleBin.Create(LabeledEdit1.Text); |
141 | bin := TRbRecycleBin.Create(LabeledEdit1.Text); |
143 | 142 | ||
144 | nBin := TreeView1.Items.AddChildObject(individualRecyclersNode, bin.FileOrDirectory, bin); |
143 | nBin := TreeView1.Items.AddChildObject(individualRecyclersNode, bin.FileOrDirectory, bin); |
145 | individualRecyclersNode.Expand(false); |
144 | individualRecyclersNode.Expand(false); |
146 | 145 | ||
147 | items := TObjectList.Create(true); |
146 | items := TObjectList.Create(false); |
148 | try |
147 | try |
149 | items.Clear; |
148 | items.Clear; |
150 | bin.ListItems(items); |
149 | bin.ListItems(items); |
151 | for iItem := 0 to items.Count - 1 do |
150 | for iItem := 0 to items.Count - 1 do |
152 | begin |
151 | begin |
Line 155... | Line 154... | ||
155 | if not FileExists(item.PhysicalFile) and |
154 | if not FileExists(item.PhysicalFile) and |
156 | not DirectoryExists(item.PhysicalFile) and |
155 | not DirectoryExists(item.PhysicalFile) and |
157 | CheckBox2.Checked then continue; |
156 | CheckBox2.Checked then continue; |
158 | 157 | ||
159 | sCaption := item.Source; |
158 | sCaption := item.Source; |
160 | if item.IndexFile <> '' then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
159 | if item is TRbVistaItem (*item.IndexFile <> ''*) then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
161 | nItem := TreeView1.Items.AddChildObject(nBin, sCaption, bin); |
160 | nItem := TreeView1.Items.AddChildObject(nBin, sCaption, item); |
162 | 161 | ||
163 | if FileExists(item.PhysicalFile) then |
162 | if FileExists(item.PhysicalFile) then |
164 | nItem.ImageIndex := 0 |
163 | nItem.ImageIndex := 0 |
165 | else if DirectoryExists(item.PhysicalFile) then |
164 | else if DirectoryExists(item.PhysicalFile) then |
166 | nItem.ImageIndex := 10 // TODO: Feature: Read folder contents and display them in this graph. (Also change icon to "open folder") |
165 | nItem.ImageIndex := 10 // TODO: Feature: Read folder contents and display them in this treeview. (Also change icon to "open folder") |
167 | else |
166 | else |
168 | nItem.ImageIndex := 8; |
167 | nItem.ImageIndex := 8; |
169 | nItem.SelectedIndex := nItem.ImageIndex; |
168 | nItem.SelectedIndex := nItem.ImageIndex; |
170 | end; |
169 | end; |
171 | finally |
170 | finally |
Line 187... | Line 186... | ||
187 | individualRecyclersNode := TreeView1.Items.Add(nil, S_MANUAL_RECYCLE_BINS); |
186 | individualRecyclersNode := TreeView1.Items.Add(nil, S_MANUAL_RECYCLE_BINS); |
188 | individualRecyclersNode.ImageIndex := 2; |
187 | individualRecyclersNode.ImageIndex := 2; |
189 | individualRecyclersNode.SelectedIndex := individualRecyclersNode.ImageIndex; |
188 | individualRecyclersNode.SelectedIndex := individualRecyclersNode.ImageIndex; |
190 | end; |
189 | end; |
191 | 190 | ||
- | 191 | procedure TRecyclerListingMainForm.TreeView1DblClick(Sender: TObject); |
|
- | 192 | var |
|
- | 193 | item: TRbRecycleBinItem; |
|
- | 194 | tempFile, tempDir: string; |
|
- | 195 | begin |
|
- | 196 | if TreeView1.Selected.ImageIndex = 0 then |
|
- | 197 | begin |
|
- | 198 | // File |
|
- | 199 | item := TRbRecycleBinItem(TreeView1.Selected.Data); |
|
- | 200 | // TODO: Does not work if the file type is unknown |
|
- | 201 | ShellExecute(Handle, 'open', PChar(item.PhysicalFile), '', '', SW_NORMAL); |
|
- | 202 | end; |
|
- | 203 | if TreeView1.Selected.ImageIndex = 10 then |
|
- | 204 | begin |
|
- | 205 | // Folder |
|
- | 206 | item := TRbRecycleBinItem(TreeView1.Selected.Data); |
|
- | 207 | ShellExecute(Handle, 'open', PChar(item.PhysicalFile), '', '', SW_NORMAL); |
|
- | 208 | end; |
|
- | 209 | end; |
|
- | 210 | ||
192 | end. |
211 | end. |