Procedure

TfrmReminderTree.ResetlbItems

Module

fReminderTree

Last Modified

7/15/2014 3:26:38 PM

Visibility

Protected

Owner

TfrmReminderTree

Declaration

procedure ResetlbItems(RootNode: TTreeNode);

Calls Hierarchy


TfrmReminderTree.ResetlbItems
 └IsVis

Called-By Hierarchy


       TfrmReminderTree.ResetlbItems
 TfrmReminderTree.RemindersChanged┤ 
     TfrmReminderTree.FormCreate┤ │ 
    TfrmReminderTree.FormDestroy┘ │ 
    TfrmReminderTree.tvRemExpanded┤ 
   TfrmReminderTree.tvRemCollapsed┤ 
TfrmReminderTree.hcRemSectionClick┘ 

Calls

Name Declaration Comments
IsVis function IsVis(Node: TTreeNode): boolean; -

Called-By

Name Declaration Comments
TfrmReminderTree.hcRemSectionClick procedure hcRemSectionClick(HeaderControl: THeaderControl; Section: THeaderSection); -
TfrmReminderTree.RemindersChanged procedure RemindersChanged(Sender: TObject); -
TfrmReminderTree.tvRemCollapsed procedure tvRemCollapsed(Sender: TObject; Node: TTreeNode); -
TfrmReminderTree.tvRemExpanded procedure tvRemExpanded(Sender: TObject; Node: TTreeNode); -


Source

238   procedure TfrmReminderTree.ResetlbItems(RootNode: TTreeNode);
239   var
240     Firsti, i: integer;
241     First, Node: TTreeNode;
242     sl: TStringList;
243     lvl: integer;
244     Add2LB: boolean;
245     Tmp, Data: string;
246   
247     function IsVis(Node: TTreeNode): boolean; // IsVisible doesn't work when updating
248     begin
249       Result := TRUE;
250       Node := Node.Parent;
251       while(Result and (assigned(Node))) do
252       begin
253         Result := Node.Expanded;
254         Node := Node.Parent;
255       end;
256     end;
257   
258   begin
259     if(not FSorting) then
260     begin
261       if(assigned(RootNode)) then
262       begin
263         Node := RootNode.GetFirstChild;
264         lvl := RootNode.Level;
265         Add2LB := RootNode.Expanded;
266         Firsti := lbRem.Items.IndexOfObject(RootNode)+1;
267       end
268       else
269       begin
270         Node := tvRem.Items.GetFirstNode;
271         lvl := -1;
272         Add2LB := TRUE;
273         Firsti := 0;
274       end;
275       First := Node;
276       if(assigned(Node)) then
277       begin
278         sl := TStringList.Create;
279         try
280           sl.Assign(lbRem.Items); // Must use regualr assign, FastAssign doesn't copy objects.
281           while(assigned(Node) and (Node.Level > lvl)) do
282           begin
283             i := sl.IndexOfObject(Node);
284             if(i >= 0) then
285               sl.Delete(i);
286             Node := Node.GetNext;
287           end;
288           if(Add2LB) then
289           begin
290             i := Firsti;
291             Node := First;
292             while(assigned(Node) and (Node.Level > lvl)) do
293             begin
294               if(IsVis(Node)) then
295               begin
296                 Tmp := TORTreeNode(Node).StringData;
297                 Data := Piece(Tmp,U,RemTreeDateIdx) + U + Piece(Tmp,U,RemTreeDateIdx+1) + U +
298                         RemPriorityText[StrToIntDef(Piece(Tmp, U, 5), 2)];
299                 sl.InsertObject(i, Data, Node);
300                 inc(i);
301               end;
302               Node := Node.GetNext;
303             end;
304           end;
305           lbRem.Items.Assign(sl);
306         finally
307           sl.Free;
308         end;
309       end;
310     end;
311   end;