Changeset 17 for trunk/Forms/UItemView.pas
- Timestamp:
- Jun 13, 2011, 2:35:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UItemView.pas
r16 r17 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ExtCtrls, ComCtrls, USqlDatabase, USystem ;9 ExtCtrls, ComCtrls, USqlDatabase, USystem, SpecializedList; 10 10 11 11 type … … 28 28 procedure FormCreate(Sender: TObject); 29 29 procedure FormDestroy(Sender: TObject); 30 procedure FormResize(Sender: TObject); 30 31 procedure FormShow(Sender: TObject); 32 procedure ListView1Data(Sender: TObject; Item: TListItem); 33 procedure ListView1Resize(Sender: TObject); 34 procedure TabControl1Change(Sender: TObject); 31 35 private 36 SubListObject: TChronisObject; 37 TabObjectList: TListInteger; 38 TabDataTypeList: TListObject; 39 procedure LoadSubList; 32 40 { private declarations } 33 41 public … … 56 64 procedure TItemViewForm.FormCreate(Sender: TObject); 57 65 begin 66 SubListObject := TChronisObject.Create; 67 SubListObject.Base := Core.System; 58 68 Report := TReport.Create; 59 69 Report.Base := Core.System; 70 TabObjectList := TListInteger.Create; 71 TabDataTypeList := TListObject.Create; 72 TabDataTypeList.OwnsObjects := False; 73 TabControl1.Tabs.Clear; 60 74 end; 61 75 62 76 procedure TItemViewForm.FormDestroy(Sender: TObject); 63 77 begin 78 SubListObject.Free; 64 79 Report.Free; 80 TabObjectList.Free; 81 TabDataTypeList.Free; 82 end; 83 84 procedure TItemViewForm.FormResize(Sender: TObject); 85 begin 86 ListView1Resize(Self); 65 87 end; 66 88 … … 85 107 MainForm.PersistentForm.Load(Self); 86 108 BuildControls; 109 LoadSubList; 110 end; 111 112 procedure TItemViewForm.ListView1Data(Sender: TObject; Item: TListItem); 113 var 114 I: Integer; 115 begin 116 if Item.Index < Report.Count then 117 with TReportLine(Report[Item.Index]) do begin 118 Item.Caption := Items[0]; 119 for I := 1 to Items.Count - 1 do 120 if not TReportColumn(Report.Columns[I]).VirtualItem then 121 Item.SubItems.Add(Items[I]); 122 end; 87 123 end; 88 124 … … 105 141 106 142 TabControl1.Tabs.Clear; 143 TabObjectList.Clear; 144 TabDataTypeList.Clear; 107 145 // Load column names 108 146 … … 110 148 for I := 0 to Report.Columns.Count - 1 do begin 111 149 DataType := TReportColumn(Report.Columns[I]).CustomType; 150 DataType.LoadDef(TReportColumn(Report.Columns[I]).CustomType.CustomType); 112 151 if DataType is TDataTypeRelationMany then begin 113 152 TabControl1.Tabs.Add(TReportColumn(Report.Columns[I]).Caption); 153 TabDataTypeList.Add(DataType); 154 TabObjectList.Add(MainForm.SelectedItem); 114 155 end else begin 115 156 NewControl := TLabel.Create(PanelControls); … … 132 173 end; 133 174 175 procedure TItemViewForm.LoadSubList; 176 var 177 NewColumn: TListColumn; 178 I: Integer; 179 begin 180 //SelectedObjectId := 0; 181 if (TabControl1.TabIndex >= 0) and (TabControl1.TabIndex < TabControl1.Tabs.Count) then 182 with ListView1 do 183 with TDataTypeRelationMany(TabDataTypeList[TabControl1.TabIndex]) do begin 184 Visible := True; 185 SubListObject.Load(ObjectId); 186 Report.Load(SubListObject, '`' + PropertyName + '`=' + IntToStr(TabObjectList[TabControl1.TabIndex])); 187 188 Columns.Clear; 189 for I := 0 to Report.Columns.Count - 1 do 190 if not TReportColumn(Report.Columns[I]).VirtualItem then begin 191 NewColumn := Columns.Add; 192 NewColumn.Caption := TReportColumn(Report.Columns[I]).Caption; 193 end; 194 Items.Count := Report.Count; 195 Refresh; 196 end; 197 ListView1Resize(Self); 198 end; 199 200 procedure TItemViewForm.ListView1Resize(Sender: TObject); 201 var 202 I: Integer; 203 begin 204 for I := 0 to ListView1.Columns.Count - 1 do 205 ListView1.Columns[I].Width := ListView1.Width div ListView1.Columns.Count; 206 end; 207 208 procedure TItemViewForm.TabControl1Change(Sender: TObject); 209 begin 210 LoadSubList; 211 end; 212 213 134 214 end. 135 215
Note:
See TracChangeset
for help on using the changeset viewer.