Changeset 17 for trunk/Forms


Ignore:
Timestamp:
Jun 13, 2011, 2:35:01 PM (13 years ago)
Author:
george
Message:
  • Fixed: Loading content of RelationMany sublist in item view.
Location:
trunk/Forms
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UItemView.lfm

    r12 r17  
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
     12  OnResize = FormResize
    1213  OnShow = FormShow
    1314  LCLVersion = '0.9.31'
     
    5556      object TabControl1: TTabControl
    5657        Left = 0
    57         Height = 32
     58        Height = 24
    5859        Top = 0
    5960        Width = 626
    6061        Align = alTop
     62        OnChange = TabControl1Change
    6163        TabIndex = 0
    6264        TabOrder = 0
     
    7072      object ListView1: TListView
    7173        Left = 0
    72         Height = 168
    73         Top = 32
     74        Height = 176
     75        Top = 24
    7476        Width = 626
    7577        Align = alClient
    7678        Columns = <>
     79        OwnerData = True
     80        ReadOnly = True
     81        RowSelect = True
    7782        TabOrder = 1
     83        ViewStyle = vsReport
     84        OnData = ListView1Data
    7885      end
    7986    end
  • trunk/Forms/UItemView.pas

    r16 r17  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ExtCtrls, ComCtrls, USqlDatabase, USystem;
     9  ExtCtrls, ComCtrls, USqlDatabase, USystem, SpecializedList;
    1010
    1111type
     
    2828    procedure FormCreate(Sender: TObject);
    2929    procedure FormDestroy(Sender: TObject);
     30    procedure FormResize(Sender: TObject);
    3031    procedure FormShow(Sender: TObject);
     32    procedure ListView1Data(Sender: TObject; Item: TListItem);
     33    procedure ListView1Resize(Sender: TObject);
     34    procedure TabControl1Change(Sender: TObject);
    3135  private
     36    SubListObject: TChronisObject;
     37    TabObjectList: TListInteger;
     38    TabDataTypeList: TListObject;
     39    procedure LoadSubList;
    3240    { private declarations }
    3341  public
     
    5664procedure TItemViewForm.FormCreate(Sender: TObject);
    5765begin
     66  SubListObject := TChronisObject.Create;
     67  SubListObject.Base := Core.System;
    5868  Report := TReport.Create;
    5969  Report.Base := Core.System;
     70  TabObjectList := TListInteger.Create;
     71  TabDataTypeList := TListObject.Create;
     72  TabDataTypeList.OwnsObjects := False;
     73  TabControl1.Tabs.Clear;
    6074end;
    6175
    6276procedure TItemViewForm.FormDestroy(Sender: TObject);
    6377begin
     78  SubListObject.Free;
    6479  Report.Free;
     80  TabObjectList.Free;
     81  TabDataTypeList.Free;
     82end;
     83
     84procedure TItemViewForm.FormResize(Sender: TObject);
     85begin
     86  ListView1Resize(Self);
    6587end;
    6688
     
    85107  MainForm.PersistentForm.Load(Self);
    86108  BuildControls;
     109  LoadSubList;
     110end;
     111
     112procedure TItemViewForm.ListView1Data(Sender: TObject; Item: TListItem);
     113var
     114  I: Integer;
     115begin
     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;
    87123end;
    88124
     
    105141
    106142  TabControl1.Tabs.Clear;
     143  TabObjectList.Clear;
     144  TabDataTypeList.Clear;
    107145  // Load column names
    108146
     
    110148  for I := 0 to Report.Columns.Count - 1 do begin
    111149    DataType := TReportColumn(Report.Columns[I]).CustomType;
     150    DataType.LoadDef(TReportColumn(Report.Columns[I]).CustomType.CustomType);
    112151  if DataType is TDataTypeRelationMany then begin
    113152    TabControl1.Tabs.Add(TReportColumn(Report.Columns[I]).Caption);
     153    TabDataTypeList.Add(DataType);
     154    TabObjectList.Add(MainForm.SelectedItem);
    114155  end else begin
    115156    NewControl := TLabel.Create(PanelControls);
     
    132173end;
    133174
     175procedure TItemViewForm.LoadSubList;
     176var
     177  NewColumn: TListColumn;
     178  I: Integer;
     179begin
     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);
     198end;
     199
     200procedure TItemViewForm.ListView1Resize(Sender: TObject);
     201var
     202  I: Integer;
     203begin
     204  for I := 0 to ListView1.Columns.Count - 1 do
     205    ListView1.Columns[I].Width := ListView1.Width div ListView1.Columns.Count;
     206end;
     207
     208procedure TItemViewForm.TabControl1Change(Sender: TObject);
     209begin
     210  LoadSubList;
     211end;
     212
     213
    134214end.
    135215
  • trunk/Forms/UMainForm.pas

    r16 r17  
    440440  ObjectPropertyId := AddObject('Properties', 'Property', Core.System.Database.Database, GroupId);
    441441    AddPropertyString(ObjectPropertyId, 'Name', 'Name');
    442     PropertyObjectId := AddPropertyRelationOne(ObjectPropertyId, 'Object', 'Object', ObjectId);
     442    PropertyParentId := AddPropertyRelationOne(ObjectPropertyId, 'Object', 'Object', ObjectId);
    443443    ObjectPropertyIdGroup := AddPropertyRelationOne(ObjectPropertyId, 'Property group', 'PropertyGroup', ObjectPropertyGroupId);
    444444    AddPropertyNumber(ObjectPropertyId, 'Custom type', 'CustomType');
     
    597597  with TReportLine(Report[Item.Index]) do begin
    598598    Item.Caption := Items[0];
    599     for I := 1 to Items.Count - 1 do
    600     if not TReportColumn(Report.Columns[I]).VirtualItem then
     599    for I := 1 to Report.Columns.Count - 1 do
     600    if not TReportColumn(Report.Columns[I]).VirtualItem then begin
    601601      Item.SubItems.Add(Items[I]);
     602    end;
    602603  end;
    603604end;
Note: See TracChangeset for help on using the changeset viewer.