Changeset 298 for trunk/Forms/UFormList.pas
- Timestamp:
- Jul 10, 2019, 5:35:15 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormList.pas
r290 r298 51 51 procedure UpdateListViewColumns; 52 52 public 53 MinItemCount: Integer; 54 MaxItemCount: Integer; 53 55 procedure UpdateInterface; 54 56 procedure UpdateList; … … 70 72 SRemoveItems = 'Remove items'; 71 73 SRemoveItemsQuery = 'Do you want to remove selected items?'; 72 SNew Item = 'New item';74 SNew = 'New'; 73 75 74 76 { TFormList } … … 83 85 for I := ListView1.Items.Count - 1 downto 0 do 84 86 if ListView1.Items[I].Selected then begin 87 if List.Count <= MinItemCount then Break; 85 88 ListView1.Items[I].Selected := False; 86 89 List.Remove(TItem(ListView1.Items[I].Data)); … … 99 102 if Assigned(ListView1.Selected) then 100 103 with TItem(ListView1.Selected.Data) do begin 101 TempEntry := List. GetItemClass.Create;104 TempEntry := List.CreateItem; 102 105 TempEntry.Assign(TItem(ListView1.Selected.Data)); 103 106 FormItem := TFormItem.Create(Self); … … 121 124 FormItem: TFormItem; 122 125 begin 123 TempEntry := List.GetItemClass.Create; 126 if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit; 127 128 TempEntry := List.CreateItem; 124 129 FormItem := TFormItem.Create(Self); 125 130 try 126 TempEntry.Name := SNew Item;131 TempEntry.Name := SNew + ' ' + LowerCase(List.GetItemClass.GetClassName); 127 132 FormItem.Item := TempEntry; 128 133 if FormItem.ShowModal = mrOk then begin … … 143 148 FormItem: TFormItem; 144 149 begin 145 TempEntry := List.GetItemClass.Create; 150 if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit; 151 152 TempEntry := List.CreateItem; 146 153 TempEntry.Assign(TItem(ListView1.Selected.Data)); 147 154 FormItem := TFormItem.Create(Self); … … 183 190 for I := 0 to ToolBar1.ButtonCount - 1 do 184 191 ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption; 192 MinItemCount := 0; 193 MaxItemCount := -1; 185 194 end; 186 195 … … 197 206 var DefaultDraw: Boolean); 198 207 var 208 ItemFields: TItemFields; 199 209 ItemField: TItemField; 200 210 begin 201 ItemField := TItem(Item.Data).GetField(SubItem); 202 if ItemField.DataType = dtColor then 203 with ListView1.Canvas do begin 204 Brush.Color := TItem(Item.Data).GetValueColor(ItemField.Index); 205 Brush.Style := bsSolid; 206 FillRect(Item.DisplayRectSubItem(1, drBounds)); 207 end; 208 ItemField.Free; 211 ItemFields := TItem(Item.Data).GetFields; 212 try 213 ItemField := ItemFields[SubItem]; 214 if ItemField.DataType = dtColor then 215 with ListView1.Canvas do begin 216 Brush.Color := TItem(Item.Data).GetValueColor(ItemField.Index); 217 Brush.Style := bsSolid; 218 FillRect(Item.DisplayRectSubItem(SubItem, drBounds)); 219 end; 220 finally 221 ItemFields.Free; 222 end; 209 223 end; 210 224 … … 272 286 procedure TFormList.UpdateInterface; 273 287 begin 274 ARemove.Enabled := Assigned(FList) and Assigned(ListView1.Selected) ;288 ARemove.Enabled := Assigned(FList) and Assigned(ListView1.Selected) and (List.Count > MinItemCount); 275 289 AModify.Enabled := Assigned(FList) and Assigned(ListView1.Selected); 276 AAdd.Enabled := Assigned(FList); 290 AAdd.Enabled := Assigned(FList) and ((MaxItemCount = -1) or ((MaxItemCount <> -1) and (List.Count < MaxItemCount))); 291 AClone.Enabled := Assigned(FList) and ((MaxItemCount = -1) or ((MaxItemCount <> -1) and (List.Count < MaxItemCount))); 277 292 ASelectAll.Enabled := ListView1.Items.Count > 0; 278 293 end;
Note:
See TracChangeset
for help on using the changeset viewer.