Rev 83 | Rev 87 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 83 | Rev 86 | ||
---|---|---|---|
1 | unit RecyclerListingMain; |
1 | unit RecyclerListingMain; |
2 | 2 | ||
- | 3 | // TODO: Doubleclick to open file! |
|
- | 4 | ||
3 | interface |
5 | interface |
4 | 6 | ||
5 | uses |
7 | uses |
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
8 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 | Dialogs, StdCtrls, ComCtrls, ExtCtrls, ImgList; |
9 | Dialogs, StdCtrls, ComCtrls, ExtCtrls, ImgList; |
8 | 10 | ||
9 | type |
11 | type |
10 | TRecyclerListingMainForm = class(TForm) |
12 | TRecyclerListingMainForm = class(TForm) |
11 | TreeView1: TTreeView; |
13 | TreeView1: TTreeView; |
12 | Panel1: TPanel; |
14 | Panel1: TPanel; |
13 | Button1: TButton; |
15 | Button1: TButton; |
14 | CheckBox1: TCheckBox; |
16 | CheckBox1: TCheckBox; |
15 | Button2: TButton; |
17 | Button2: TButton; |
16 | OpenDialog1: TOpenDialog; |
18 | OpenDialog1: TOpenDialog; |
17 | LabeledEdit1: TLabeledEdit; |
19 | LabeledEdit1: TLabeledEdit; |
18 | ImageList1: TImageList; |
20 | ImageList1: TImageList; |
19 | CheckBox2: TCheckBox; |
21 | CheckBox2: TCheckBox; |
20 | procedure Button1Click(Sender: TObject); |
22 | procedure Button1Click(Sender: TObject); |
21 | procedure Button2Click(Sender: TObject); |
23 | procedure Button2Click(Sender: TObject); |
22 | procedure FormShow(Sender: TObject); |
24 | procedure FormShow(Sender: TObject); |
23 | private |
25 | private |
24 | localRecyclersNode: TTreeNode; |
26 | localRecyclersNode: TTreeNode; |
25 | individualRecyclersNode: TTreeNode; |
27 | individualRecyclersNode: TTreeNode; |
26 | end; |
28 | end; |
27 | 29 | ||
28 | var |
30 | var |
29 | RecyclerListingMainForm: TRecyclerListingMainForm; |
31 | RecyclerListingMainForm: TRecyclerListingMainForm; |
30 | 32 | ||
31 | implementation |
33 | implementation |
32 | 34 | ||
33 | {$R *.dfm} |
35 | {$R *.dfm} |
34 | 36 | ||
35 | uses |
37 | uses |
36 | RecBinUnit2, ContNrs, SIDUnit; |
38 | RecBinUnit2, ContNrs, SIDUnit; |
37 | 39 | ||
38 | // TODO: SID Namen auflösen und dementsprechend anzeigen |
40 | // TODO: SID Namen auflösen und dementsprechend anzeigen |
39 | // TODO: zu jedem element mehr informationen anzeigen, nicht nur den ursprungsnamen |
41 | // TODO: zu jedem element mehr informationen anzeigen, nicht nur den ursprungsnamen |
40 | // TODO: Einstellungen usw anzeigen, so wie im alten Demo |
42 | // TODO: Einstellungen usw anzeigen, so wie im alten Demo |
41 | 43 | ||
42 | procedure TRecyclerListingMainForm.Button1Click(Sender: TObject); |
44 | procedure TRecyclerListingMainForm.Button1Click(Sender: TObject); |
43 | var |
45 | var |
44 | drives: TObjectList{TRbDrive}; |
46 | drives: TObjectList{TRbDrive}; |
45 | iDrive: integer; |
47 | iDrive: integer; |
46 | drive: TRbDrive; |
48 | drive: TRbDrive; |
47 | nDrive: TTreeNode; |
49 | nDrive: TTreeNode; |
48 | 50 | ||
49 | bins: TObjectList{TRbRecycleBin}; |
51 | bins: TObjectList{TRbRecycleBin}; |
50 | iBin: integer; |
52 | iBin: integer; |
51 | bin: TRbRecycleBin; |
53 | bin: TRbRecycleBin; |
52 | nBin: TTreeNode; |
54 | nBin: TTreeNode; |
53 | 55 | ||
54 | items: TObjectList{TRbRecycleBinItem}; |
56 | items: TObjectList{TRbRecycleBinItem}; |
55 | iItem: integer; |
57 | iItem: integer; |
56 | item: TRbRecycleBinItem; |
58 | item: TRbRecycleBinItem; |
57 | nItem: TTreeNode; |
59 | nItem: TTreeNode; |
- | 60 | sCaption: string; |
|
- | 61 | resourcestring |
|
- | 62 | S_DRIVE = 'Drive %s'; |
|
58 | begin |
63 | begin |
59 | localRecyclersNode.DeleteChildren; |
64 | localRecyclersNode.DeleteChildren; |
60 | 65 | ||
61 | TreeView1.Items.BeginUpdate; |
66 | TreeView1.Items.BeginUpdate; |
62 | drives := TObjectList.Create(true); |
67 | drives := TObjectList.Create(true); |
63 | bins := TObjectList.Create(true); |
68 | bins := TObjectList.Create(true); |
64 | items := TObjectList.Create(true); |
69 | items := TObjectList.Create(true); |
65 | try |
70 | try |
66 | drives.Clear; |
71 | drives.Clear; |
67 | TRecycleBinManager.ListDrives(drives); |
72 | TRecycleBinManager.ListDrives(drives); |
68 | for iDrive := 0 to drives.Count - 1 do |
73 | for iDrive := 0 to drives.Count - 1 do |
69 | begin |
74 | begin |
70 | drive := drives.Items[iDrive] as TRbDrive; |
75 | drive := drives.Items[iDrive] as TRbDrive; |
71 | 76 | ||
72 | if drive.VolumeGUIDAvailable then |
77 | if drive.VolumeGUIDAvailable then |
73 | nDrive := TreeView1.Items.AddChildObject(localRecyclersNode, 'Drive '+drive.DriveLetter+': ' + GUIDToString(drive.VolumeGUID), drive) |
78 | nDrive := TreeView1.Items.AddChildObject(localRecyclersNode, Format(S_DRIVE, [drive.DriveLetter])+': ' + GUIDToString(drive.VolumeGUID), drive) |
74 | else |
79 | else |
75 | nDrive := TreeView1.Items.AddChildObject(localRecyclersNode, 'Drive '+drive.DriveLetter+':', drive); |
80 | nDrive := TreeView1.Items.AddChildObject(localRecyclersNode, Format(S_DRIVE, [drive.DriveLetter])+':', drive); |
76 | nDrive.ImageIndex := 6; |
81 | nDrive.ImageIndex := 6; |
77 | nDrive.SelectedIndex := nDrive.ImageIndex; |
82 | nDrive.SelectedIndex := nDrive.ImageIndex; |
78 | 83 | ||
79 | bins.Clear; |
84 | bins.Clear; |
80 | if CheckBox1.Checked then |
85 | if CheckBox1.Checked then |
81 | drive.ListRecycleBins(bins, GetMySID) |
86 | drive.ListRecycleBins(bins, GetMySID) |
82 | else |
87 | else |
83 | drive.ListRecycleBins(bins); |
88 | drive.ListRecycleBins(bins); |
84 | for iBin := 0 to bins.Count - 1 do |
89 | for iBin := 0 to bins.Count - 1 do |
85 | begin |
90 | begin |
86 | bin := bins.Items[iBin] as TRbRecycleBin; |
91 | bin := bins.Items[iBin] as TRbRecycleBin; |
87 | 92 | ||
88 | nBin := TreeView1.Items.AddChildObject(nDrive, bin.FileOrDirectory, bin); |
93 | nBin := TreeView1.Items.AddChildObject(nDrive, bin.FileOrDirectory, bin); |
89 | nBin.ImageIndex := 4; |
94 | nBin.ImageIndex := 4; |
90 | nBin.SelectedIndex := nBin.ImageIndex; |
95 | nBin.SelectedIndex := nBin.ImageIndex; |
91 | 96 | ||
92 | items.Clear; |
97 | items.Clear; |
93 | bin.ListItems(items); |
98 | bin.ListItems(items); |
94 | for iItem := 0 to items.Count - 1 do |
99 | for iItem := 0 to items.Count - 1 do |
95 | begin |
100 | begin |
96 | item := items.Items[iItem] as TRbRecycleBinItem; |
101 | item := items.Items[iItem] as TRbRecycleBinItem; |
97 | 102 | ||
98 | if not FileExists(item.PhysicalFile) and CheckBox2.Checked then continue; |
103 | if not FileExists(item.PhysicalFile) and |
- | 104 | not DirectoryExists(item.PhysicalFile) and |
|
- | 105 | CheckBox2.Checked then continue; |
|
99 | 106 | ||
- | 107 | sCaption := item.Source; |
|
- | 108 | if item.IndexFile <> '' then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
|
100 | nItem := TreeView1.Items.AddChildObject(nBin, item.Source, bin); |
109 | nItem := TreeView1.Items.AddChildObject(nBin, sCaption, bin); |
101 | 110 | ||
102 | if FileExists(item.PhysicalFile) then |
111 | if FileExists(item.PhysicalFile) then |
103 | nItem.ImageIndex := 0 |
112 | nItem.ImageIndex := 0 |
- | 113 | 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") |
|
104 | else |
115 | else |
105 | nItem.ImageIndex := 8; |
116 | nItem.ImageIndex := 8; |
106 | nItem.SelectedIndex := nItem.ImageIndex; |
117 | nItem.SelectedIndex := nItem.ImageIndex; |
107 | end; |
118 | end; |
108 | end; |
119 | end; |
109 | end; |
120 | end; |
110 | finally |
121 | finally |
111 | drives.Free; |
122 | drives.Free; |
112 | bins.Free; |
123 | bins.Free; |
113 | items.Free; |
124 | items.Free; |
114 | TreeView1.Items.EndUpdate; |
125 | TreeView1.Items.EndUpdate; |
115 | end; |
126 | end; |
116 | 127 | ||
117 | localRecyclersNode.Expand(false); |
128 | localRecyclersNode.Expand(false); |
118 | end; |
129 | end; |
119 | 130 | ||
120 | procedure TRecyclerListingMainForm.Button2Click(Sender: TObject); |
131 | procedure TRecyclerListingMainForm.Button2Click(Sender: TObject); |
121 | var |
132 | var |
122 | bin: TRbRecycleBin; |
133 | bin: TRbRecycleBin; |
123 | nBin: TTreeNode; |
134 | nBin: TTreeNode; |
124 | 135 | ||
125 | items: TObjectList{TRbRecycleBinItem}; |
136 | items: TObjectList{TRbRecycleBinItem}; |
126 | iItem: integer; |
137 | iItem: integer; |
127 | item: TRbRecycleBinItem; |
138 | item: TRbRecycleBinItem; |
128 | nItem: TTreeNode; |
139 | nItem: TTreeNode; |
- | 140 | sCaption: string; |
|
129 | begin |
141 | begin |
130 | bin := TRbRecycleBin.Create(LabeledEdit1.Text); |
142 | bin := TRbRecycleBin.Create(LabeledEdit1.Text); |
131 | 143 | ||
132 | nBin := TreeView1.Items.AddChildObject(individualRecyclersNode, bin.FileOrDirectory, bin); |
144 | nBin := TreeView1.Items.AddChildObject(individualRecyclersNode, bin.FileOrDirectory, bin); |
133 | individualRecyclersNode.Expand(false); |
145 | individualRecyclersNode.Expand(false); |
134 | 146 | ||
135 | items := TObjectList.Create(true); |
147 | items := TObjectList.Create(true); |
136 | try |
148 | try |
137 | items.Clear; |
149 | items.Clear; |
138 | bin.ListItems(items); |
150 | bin.ListItems(items); |
139 | for iItem := 0 to items.Count - 1 do |
151 | for iItem := 0 to items.Count - 1 do |
140 | begin |
152 | begin |
141 | item := items.Items[iItem] as TRbRecycleBinItem; |
153 | item := items.Items[iItem] as TRbRecycleBinItem; |
142 | 154 | ||
143 | if not FileExists(item.PhysicalFile) and CheckBox2.Checked then continue; |
155 | if not FileExists(item.PhysicalFile) and |
- | 156 | not DirectoryExists(item.PhysicalFile) and |
|
- | 157 | CheckBox2.Checked then continue; |
|
144 | 158 | ||
- | 159 | sCaption := item.Source; |
|
- | 160 | if item.IndexFile <> '' then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
|
145 | nItem := TreeView1.Items.AddChildObject(nBin, item.Source, bin); |
161 | nItem := TreeView1.Items.AddChildObject(nBin, sCaption, bin); |
146 | 162 | ||
147 | if FileExists(item.PhysicalFile) then |
163 | if FileExists(item.PhysicalFile) then |
148 | nItem.ImageIndex := 0 |
164 | nItem.ImageIndex := 0 |
- | 165 | 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") |
|
149 | else |
167 | else |
150 | nItem.ImageIndex := 8; |
168 | nItem.ImageIndex := 8; |
151 | nItem.SelectedIndex := nItem.ImageIndex; |
169 | nItem.SelectedIndex := nItem.ImageIndex; |
152 | end; |
170 | end; |
153 | finally |
171 | finally |
154 | items.Free; |
172 | items.Free; |
155 | end; |
173 | end; |
156 | 174 | ||
157 | nBin.Expand(false); |
175 | nBin.Expand(false); |
158 | end; |
176 | end; |
159 | 177 | ||
160 | procedure TRecyclerListingMainForm.FormShow(Sender: TObject); |
178 | procedure TRecyclerListingMainForm.FormShow(Sender: TObject); |
- | 179 | resourcestring |
|
- | 180 | S_LOCAL_RECYCLE_BINS = 'Local recycle bins'; |
|
- | 181 | S_MANUAL_RECYCLE_BINS ='Manually added recycle bins'; |
|
161 | begin |
182 | begin |
162 | localRecyclersNode := TreeView1.Items.Add(nil, 'Local recyclers'); |
183 | localRecyclersNode := TreeView1.Items.Add(nil, S_LOCAL_RECYCLE_BINS); |
163 | localRecyclersNode.ImageIndex := 2; |
184 | localRecyclersNode.ImageIndex := 2; |
164 | localRecyclersNode.SelectedIndex := localRecyclersNode.ImageIndex; |
185 | localRecyclersNode.SelectedIndex := localRecyclersNode.ImageIndex; |
165 | 186 | ||
166 | individualRecyclersNode := TreeView1.Items.Add(nil, 'Manually added recycle bins'); |
187 | individualRecyclersNode := TreeView1.Items.Add(nil, S_MANUAL_RECYCLE_BINS); |
167 | individualRecyclersNode.ImageIndex := 2; |
188 | individualRecyclersNode.ImageIndex := 2; |
168 | individualRecyclersNode.SelectedIndex := individualRecyclersNode.ImageIndex; |
189 | individualRecyclersNode.SelectedIndex := individualRecyclersNode.ImageIndex; |
169 | end; |
190 | end; |
170 | 191 | ||
171 | end. |
192 | end. |
172 | 193 |