-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeletedProperty.pas
More file actions
105 lines (92 loc) · 3.3 KB
/
DeletedProperty.pas
File metadata and controls
105 lines (92 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
unit DeletedProperty;
interface
uses
MRC_Helper, CloudMailRu, CMLTypes, DateUtils, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TDeletedPropertyForm = class(TForm)
DelNameLB: TLabel;
DelFromLB: TLabel;
DelAtLB: TLabel;
DelByLB: TLabel;
RestoreBTN: TButton;
CancelBTN: TButton;
NameLB: TLabel;
FromLB: TLabel;
AtLB: TLabel;
ByLB: TLabel;
SizeLB: TLabel;
RestoreAllBTN: TButton;
EmptyBTN: TButton;
DelSizeLB: TLabel;
private
{Private declarations}
public
{Public declarations}
class function ShowProperties(parentWindow: HWND; Items: TCloudMailRuDirListing; TrashDir: boolean = false; AccountName: WideString = ''): integer;
end;
implementation
{$R *.dfm}
{TDeletedPropertyForm}
class function TDeletedPropertyForm.ShowProperties(parentWindow: HWND; Items: TCloudMailRuDirListing; TrashDir: boolean = false; AccountName: WideString = ''): integer;
var
DeletedPropertyForm: TDeletedPropertyForm;
FormCaption, NameCaption, FromCaption, AtCaption, ByCaption, SizeCaption: WideString;
function summary_size(Items: TCloudMailRuDirListing): integer;
var
Item: TCloudMailRuDirListingItem;
begin
result := 0;
for Item in Items do
result := result + Item.size;
end;
begin
try
DeletedPropertyForm := TDeletedPropertyForm.Create(nil);
DeletedPropertyForm.parentWindow := parentWindow;
if Length(Items) = 0 then
begin
NameCaption := 'Empty';
FormCaption := AccountName + ' trash';
DeletedPropertyForm.RestoreBTN.Enabled := false;
DeletedPropertyForm.RestoreAllBTN.Enabled := false;
DeletedPropertyForm.EmptyBTN.Enabled := false;
end else if Length(Items) = 1 then
begin
NameCaption := Items[0].name;
FromCaption := Items[0].deleted_from;
AtCaption := DateTimeToStr(UnixToDateTime(Items[0].deleted_at));
ByCaption := Items[0].deleted_by.ToString; //display user id as is, because no conversation api method performed
SizeCaption := FormatSize(Items[0].size, TYPE_BYTES);
FormCaption := 'Deleted item: ' + NameCaption;
DeletedPropertyForm.RestoreAllBTN.Enabled := false;
end else begin
NameCaption := '<Multiple items>';
FromCaption := '-';
AtCaption := '-';
ByCaption := '-';
SizeCaption := FormatSize(summary_size(Items), TYPE_BYTES);
FormCaption := 'Multiple deleted items';
end;
if TrashDir then //свойства для самой корзины, даём выбор Очистить/Восстановить все/Отмена
begin
FormCaption := AccountName + TrashPostfix;
NameCaption := FormCaption;
FromCaption := '-';
AtCaption := '-';
ByCaption := '-';
DeletedPropertyForm.RestoreBTN.Enabled := false;
DeletedPropertyForm.RestoreAllBTN.Enabled := true;
end else begin //свойства для пачки файлов, даём выбор Восстановить/Отмена
end;
DeletedPropertyForm.Caption := FormCaption;
DeletedPropertyForm.DelNameLB.Caption := NameCaption;
DeletedPropertyForm.DelFromLB.Caption := FromCaption;
DeletedPropertyForm.DelAtLB.Caption := AtCaption;
DeletedPropertyForm.DelByLB.Caption := ByCaption;
DeletedPropertyForm.DelSizeLB.Caption := SizeCaption;
result := DeletedPropertyForm.ShowModal;
finally
FreeAndNil(DeletedPropertyForm);
end;
end;
end.