forked from zsdwxm/KernowSoftwareFMX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ksListViewHelper.pas
109 lines (84 loc) · 2.93 KB
/
ksListViewHelper.pas
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
106
107
108
unit ksListViewHelper;
interface
{$I ksComponents.inc}
uses
System.SysUtils, System.Types, System.UITypes, System.UIConsts, System.Classes,
ksTableView;
type
TListItemPurpose = TksTableViewItemPurpose;
TListItemAppearence = (ListItemRightDetail, ListItemBottomDetail);
TListViewItem = class (TksTableViewItem)
private
FItemAppearence: TListItemAppearence;
FListItemAppearence: TListItemAppearence;
function GetText() : String;
function GetDetail() : String;
procedure SetText(Value : String);
procedure SetDetail(Value : String);
procedure SetListItemAppearence(const Value: TListItemAppearence);
public
property Text : String read GetText write SetText;
property Detail : String read GetDetail write SetDetail;
property ItemAppearence: TListItemAppearence read FListItemAppearence write SetListItemAppearence;
end;
TksTableViewItemsHelper = class helper for TksTableViewItems
public
function Add(): TListViewItem; overload;
end;
implementation
//------------------------------------------------------------------------------
function TListViewItem.GetText() : String;
begin
Result := Title.Text;
end;
//------------------------------------------------------------------------------
function TListViewItem.GetDetail() : String;
begin
case FItemAppearence of
ListItemRightDetail: Result := TksTableViewItem(Self).Detail.Text;
ListItemBottomDetail: Result := SubTitle.Text;
end;
end;
//------------------------------------------------------------------------------
procedure TListViewItem.SetText(Value : String);
begin
Title.Text := Value;
end;
//------------------------------------------------------------------------------
procedure TListViewItem.SetDetail(Value : String);
begin
case FItemAppearence of
ListItemRightDetail: TksTableViewItem(Self).Detail.Text := Value;
ListItemBottomDetail: SubTitle.Text := Value;
end;
end;
procedure TListViewItem.SetListItemAppearence(const Value: TListItemAppearence);
begin
if FListItemAppearence <> Value then
begin
FListItemAppearence := Value;
if FListItemAppearence = ListItemRightDetail then
begin
TksTableViewItem(Self).Detail.Text := TksTableViewItem(Self).SubTitle.Text;
TksTableViewItem(Self).SubTitle.Text := '';
end
else
begin
TksTableViewItem(Self).SubTitle.Text := TksTableViewItem(Self).Detail.Text;
TksTableViewItem(Self).Detail.Text := '';
end;
end;
end;
//------------------------------------------------------------------------------
function TksTableViewItemsHelper.Add(): TListViewItem;
begin
Result := TListViewItem.Create(Self.FTableView);
Result.Height := Self.FTableView.ItemHeight;
Result.ItemAppearence := ListItemBottomDetail;
Self.Add(Result);
Self.UpdateIndexes;
Self.FTableView.UpdateItemRects(False);
Self.FTableView.UpdateScrollingLimits;
end;
//------------------------------------------------------------------------------
end.