Changeset 2


Ignore:
Timestamp:
May 30, 2010, 6:09:55 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Uchování polohy a velikosti oken.
  • Přidáno: Čtení stromu skupin a objektů. Zobrazení seznamů objektů.
Location:
trunk
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        11lib
         2Config.xml
         3chronis
  • trunk/UMainForm.lfm

    r1 r2  
    11object MainForm: TMainForm
    2   Left = 326
     2  Left = 359
    33  Height = 445
    4   Top = 164
     4  Top = 124
    55  Width = 649
    66  ActiveControl = ListView1
     
    88  ClientHeight = 445
    99  ClientWidth = 649
     10  OnClose = FormClose
    1011  OnCreate = FormCreate
     12  OnShow = FormShow
    1113  LCLVersion = '0.9.29'
    1214  object TreeView1: TTreeView
     
    1618    Width = 171
    1719    Anchors = [akTop, akLeft, akBottom]
    18     DefaultItemHeight = 19
     20    DefaultItemHeight = 15
     21    ReadOnly = True
    1922    TabOrder = 0
     23    OnChange = TreeView1Change
     24    Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
    2025  end
    2126  object ListView1: TListView
    22     Left = 187
     27    Left = 184
    2328    Height = 417
    24     Top = 19
     29    Top = 16
    2530    Width = 453
    2631    Anchors = [akTop, akLeft, akRight, akBottom]
    2732    Columns = <>
    2833    ItemIndex = -1
     34    ReadOnly = True
     35    RowSelect = True
    2936    TabOrder = 1
    3037    ViewStyle = vsReport
     
    3239  object Label1: TLabel
    3340    Left = 7
    34     Height = 18
     41    Height = 14
    3542    Top = 4
    36     Width = 57
     43    Width = 47
    3744    Caption = 'Skupiny:'
    3845    ParentColor = False
     
    4047  object Label2: TLabel
    4148    Left = 187
    42     Height = 18
     49    Height = 14
    4350    Top = 4
    44     Width = 49
     51    Width = 38
    4552    Caption = 'Výpisy:'
    4653    ParentColor = False
  • trunk/UMainForm.pas

    r1 r2  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   StdCtrls, USqlDatabase;
     9  StdCtrls, USqlDatabase, DOM, XMLRead, XMLWrite, UPersistentForm;
     10
     11const
     12  ConfigFileName = 'Config.xml';
    1013
    1114type
     
    1821    ListView1: TListView;
    1922    TreeView1: TTreeView;
     23    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2024    procedure FormCreate(Sender: TObject);
     25    procedure FormShow(Sender: TObject);
     26    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
    2127  private
    22     { private declarations }
     28    procedure LoadConfiguration;
    2329  public
     30    PersistentForm: TPersistentForm;
    2431    Database: TSQLDatabase;
    2532    procedure LoadTree;
     
    3542{ TMainForm }
    3643
     44procedure TMainForm.LoadConfiguration;
     45var
     46  Config: TXMLDocument;
     47  I1: Integer;
     48  I2: Integer;
     49  I3: Integer;
     50begin
     51  if FileExists(ConfigFileName) then begin
     52    ReadXMLFile(Config, ConfigFileName);
     53    for I1 := 0 to Config.ChildNodes.Count - 1 do
     54    with Config.ChildNodes[I1] do begin
     55      if NodeName = 'configuration' then
     56      for I2 := 0 to ChildNodes.Count - 1 do
     57      with ChildNodes[I2] do begin
     58        if NodeName = 'database' then
     59        for I3 := 0 to ChildNodes.Count - 1 do
     60        with ChildNodes[I3] do begin
     61          if NodeName = 'hostname' then
     62            Database.HostName := TextContent;
     63          if NodeName = 'schema' then
     64            Database.Schema := TextContent;
     65          if NodeName = 'username' then
     66            Database.UserName := TextContent;
     67          if NodeName = 'password' then
     68            Database.Password := TextContent;
     69        end;
     70      end;
     71    end;
     72    Config.Destroy;
     73  end;
     74end;
     75
    3776procedure TMainForm.FormCreate(Sender: TObject);
    3877begin
    3978  Database := TSqlDatabase.Create;
    40   with Database do begin
    41     Hostname := 'localhost';
    42     Schema := 'chronis_system';
    43     UserName := 'root';
     79  LoadConfiguration;
     80  Database.Connect;
     81  PersistentForm := TPersistentForm.Create;
     82end;
    4483
     84procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     85begin
     86  PersistentForm.Save(Self);
     87end;
     88
     89procedure TMainForm.FormShow(Sender: TObject);
     90begin
     91  PersistentForm.Load(Self);
     92  LoadTree;
     93end;
     94
     95procedure TMainForm.TreeView1Change(Sender: TObject; Node: TTreeNode);
     96var
     97  DbRows: TDbRows;
     98  Properties: TDbRows;
     99  Values: TDbRows;
     100  I: Integer;
     101  C: Integer;
     102  NewItem: TListItem;
     103  NewColumn: TListColumn;
     104begin
     105  if Assigned(TreeView1.Selected) then
     106  with ListView1, Items do begin
     107    Clear;
     108    DbRows := Database.Query('SELECT * FROM `Object` WHERE `Id`=' + IntToStr(TreeView1.Selected.ImageIndex));
     109    if DbRows.Count = 1 then begin
     110      // Load column names
     111      Properties := Database.Query('SELECT * FROM `Property` WHERE `Object`=' +
     112        DbRows[0].Values['Id']);
     113      Columns.Clear;
     114      NewColumn := Columns.Add;
     115      NewColumn.Caption := 'Id';
     116      for I := 0 to Properties.Count - 1 do begin
     117        NewColumn := Columns.Add;
     118        NewColumn.Caption := DbRows[I].Values['Name'];
     119      end;
     120
     121      // Load items
     122      Values := Database.Query('SELECT * FROM `' + DbRows[0].Values['Schema'] + '`.`' +
     123        DbRows[0].Values['Table'] + '`');
     124      for I := 0 to Values.Count - 1 do begin
     125        NewItem := Items.Add;
     126        NewItem.Caption := Values[I].Values['Id'];
     127        for C := 0 to Properties.Count - 1 do begin
     128          NewItem.SubItems.Add(Values[I].Values[Properties[C].Values['ColumnName']]);
     129        end;
     130      end;
     131      Values.Destroy;
     132      Properties.Destroy;
     133    end;
     134    DbRows.Destroy;
    45135  end;
    46136end;
    47137
    48138procedure TMainForm.LoadTree;
     139var
     140  DbRows: TDbRows;
     141  ObjectDbRows: TDbRows;
     142  I: Integer;
     143  O: Integer;
     144  NewNode: TTreeNode;
     145  NewObjectNode: TTreeNode;
    49146begin
    50 
     147  with TreeView1, Items do begin
     148    Clear;
     149    AddChild(nil, 'Skupiny');
     150    DbRows := Database.Query('SELECT * FROM `MenuGroup`');
     151    for I := 0 to DbRows.Count - 1 do begin
     152      NewNode := AddChild(TopItem, DbRows[I].Values['Name']);
     153      ObjectDbRows := Database.Query('SELECT * FROM `Object` WHERE `MenuGroup`=' + DbRows[I].Values['Id']);
     154      for O := 0 to ObjectDbRows.Count - 1 do begin
     155        NewObjectNode := AddChild(NewNode, ObjectDbRows[O].Values['Name']);
     156        NewObjectNode.ImageIndex := StrToInt(ObjectDbRows[O].Values['Id']);
     157      end;
     158      ObjectDbRows.Destroy;
     159    end;
     160    TopItem.Expand(True);
     161    DbRows.Destroy;
     162  end;
    51163end;
    52164
  • trunk/chronis.lpi

    r1 r2  
    3737      </Item1>
    3838    </RequiredPackages>
    39     <Units Count="6">
     39    <Units Count="15">
    4040      <Unit0>
    4141        <Filename Value="chronis.lpr"/>
    4242        <IsPartOfProject Value="True"/>
    4343        <UnitName Value="chronis"/>
    44         <EditorIndex Value="0"/>
    45         <WindowIndex Value="0"/>
    46         <TopLine Value="1"/>
    47         <CursorPos X="18" Y="15"/>
    48         <UsageCount Value="27"/>
     44        <EditorIndex Value="3"/>
     45        <WindowIndex Value="0"/>
     46        <TopLine Value="1"/>
     47        <CursorPos X="59" Y="20"/>
     48        <UsageCount Value="30"/>
    4949        <Loaded Value="True"/>
    5050      </Unit0>
     
    7171      <Unit3>
    7272        <Filename Value="USqlDatabase.pas"/>
    73         <IsPartOfProject Value="True"/>
    7473        <UnitName Value="USqlDatabase"/>
    75         <EditorIndex Value="1"/>
    76         <WindowIndex Value="0"/>
    77         <TopLine Value="37"/>
    78         <CursorPos X="16" Y="4"/>
    79         <UsageCount Value="23"/>
     74        <EditorIndex Value="4"/>
     75        <WindowIndex Value="0"/>
     76        <TopLine Value="330"/>
     77        <CursorPos X="1" Y="347"/>
     78        <UsageCount Value="26"/>
    8079        <Loaded Value="True"/>
    8180      </Unit3>
     
    8887        <UnitName Value="UMainForm"/>
    8988        <IsVisibleTab Value="True"/>
    90         <EditorIndex Value="3"/>
    91         <WindowIndex Value="0"/>
    92         <TopLine Value="19"/>
    93         <CursorPos X="5" Y="44"/>
    94         <UsageCount Value="20"/>
     89        <EditorIndex Value="0"/>
     90        <WindowIndex Value="0"/>
     91        <TopLine Value="84"/>
     92        <CursorPos X="51" Y="100"/>
     93        <UsageCount Value="23"/>
    9594        <Loaded Value="True"/>
    9695      </Unit4>
     
    102101        <ResourceBaseClass Value="Form"/>
    103102        <UnitName Value="ULoginForm"/>
     103        <WindowIndex Value="0"/>
     104        <TopLine Value="1"/>
     105        <CursorPos X="24" Y="14"/>
     106        <UsageCount Value="23"/>
     107      </Unit5>
     108      <Unit6>
     109        <Filename Value="../../../lazarus/trunk/lcl/comctrls.pp"/>
     110        <UnitName Value="ComCtrls"/>
     111        <WindowIndex Value="0"/>
     112        <TopLine Value="2651"/>
     113        <CursorPos X="3" Y="2669"/>
     114        <SyntaxHighlighter Value="FreePascal"/>
     115        <UsageCount Value="10"/>
     116        <DefaultSyntaxHighlighter Value="Text"/>
     117      </Unit6>
     118      <Unit7>
     119        <Filename Value="../../../lazarus/trunk/lcl/include/customform.inc"/>
     120        <WindowIndex Value="0"/>
     121        <TopLine Value="819"/>
     122        <CursorPos X="1" Y="838"/>
     123        <SyntaxHighlighter Value="FreePascal"/>
     124        <UsageCount Value="11"/>
     125        <DefaultSyntaxHighlighter Value="Text"/>
     126      </Unit7>
     127      <Unit8>
     128        <Filename Value="Common/UPersistentForm.pas"/>
     129        <IsPartOfProject Value="True"/>
     130        <UnitName Value="UPersistentForm"/>
     131        <EditorIndex Value="1"/>
     132        <WindowIndex Value="0"/>
     133        <TopLine Value="1"/>
     134        <CursorPos X="36" Y="19"/>
     135        <SyntaxHighlighter Value="FreePascal"/>
     136        <UsageCount Value="21"/>
     137        <Loaded Value="True"/>
     138        <DefaultSyntaxHighlighter Value="Text"/>
     139      </Unit8>
     140      <Unit9>
     141        <Filename Value="Common/USqlDatabase.pas"/>
     142        <IsPartOfProject Value="True"/>
     143        <UnitName Value="USqlDatabase"/>
     144        <UsageCount Value="21"/>
     145        <DefaultSyntaxHighlighter Value="Text"/>
     146      </Unit9>
     147      <Unit10>
     148        <Filename Value="../../../lazarus/trunk/lcl/forms.pp"/>
     149        <UnitName Value="Forms"/>
     150        <WindowIndex Value="0"/>
     151        <TopLine Value="579"/>
     152        <CursorPos X="15" Y="596"/>
     153        <SyntaxHighlighter Value="FreePascal"/>
     154        <UsageCount Value="10"/>
     155        <DefaultSyntaxHighlighter Value="Text"/>
     156      </Unit10>
     157      <Unit11>
     158        <Filename Value="Common/URegistry.pas"/>
     159        <IsPartOfProject Value="True"/>
     160        <UnitName Value="URegistry"/>
    104161        <EditorIndex Value="2"/>
    105162        <WindowIndex Value="0"/>
    106         <TopLine Value="1"/>
    107         <CursorPos X="24" Y="14"/>
     163        <TopLine Value="32"/>
     164        <CursorPos X="21" Y="13"/>
     165        <SyntaxHighlighter Value="FreePascal"/>
    108166        <UsageCount Value="20"/>
    109167        <Loaded Value="True"/>
    110       </Unit5>
     168        <DefaultSyntaxHighlighter Value="Text"/>
     169      </Unit11>
     170      <Unit12>
     171        <Filename Value="/usr/share/fpcsrc/packages/fcl-registry/src/registry.pp"/>
     172        <UnitName Value="registry"/>
     173        <WindowIndex Value="0"/>
     174        <TopLine Value="1"/>
     175        <CursorPos X="5" Y="14"/>
     176        <SyntaxHighlighter Value="FreePascal"/>
     177        <UsageCount Value="10"/>
     178        <DefaultSyntaxHighlighter Value="Text"/>
     179      </Unit12>
     180      <Unit13>
     181        <Filename Value="/usr/share/fpcsrc/packages/fcl-registry/src/regdef.inc"/>
     182        <WindowIndex Value="0"/>
     183        <TopLine Value="4"/>
     184        <CursorPos X="17" Y="21"/>
     185        <SyntaxHighlighter Value="FreePascal"/>
     186        <UsageCount Value="10"/>
     187        <DefaultSyntaxHighlighter Value="Text"/>
     188      </Unit13>
     189      <Unit14>
     190        <Filename Value="/usr/share/fpcsrc/rtl/objpas/sysutils/sysutilh.inc"/>
     191        <WindowIndex Value="0"/>
     192        <TopLine Value="17"/>
     193        <CursorPos X="4" Y="34"/>
     194        <SyntaxHighlighter Value="FreePascal"/>
     195        <UsageCount Value="10"/>
     196        <DefaultSyntaxHighlighter Value="Text"/>
     197      </Unit14>
    111198    </Units>
    112     <JumpHistory Count="8" HistoryIndex="7">
     199    <JumpHistory Count="26" HistoryIndex="25">
    113200      <Position1>
    114         <Filename Value="chronis.lpr"/>
    115         <Caret Line="1" Column="16" TopLine="1"/>
     201        <Filename Value="UMainForm.pas"/>
     202        <Caret Line="110" Column="3" TopLine="100"/>
    116203      </Position1>
    117204      <Position2>
    118         <Filename Value="chronis.lpr"/>
    119         <Caret Line="11" Column="39" TopLine="1"/>
     205        <Filename Value="UMainForm.pas"/>
     206        <Caret Line="115" Column="1" TopLine="100"/>
    120207      </Position2>
    121208      <Position3>
    122         <Filename Value="USqlDatabase.pas"/>
    123         <Caret Line="12" Column="35" TopLine="1"/>
     209        <Filename Value="UMainForm.pas"/>
     210        <Caret Line="116" Column="1" TopLine="100"/>
    124211      </Position3>
    125212      <Position4>
    126213        <Filename Value="UMainForm.pas"/>
    127         <Caret Line="23" Column="24" TopLine="1"/>
     214        <Caret Line="114" Column="29" TopLine="100"/>
    128215      </Position4>
    129216      <Position5>
    130217        <Filename Value="USqlDatabase.pas"/>
    131         <Caret Line="3" Column="44" TopLine="1"/>
     218        <Caret Line="182" Column="11" TopLine="168"/>
    132219      </Position5>
    133220      <Position6>
    134         <Filename Value="UMainForm.pas"/>
    135         <Caret Line="23" Column="28" TopLine="12"/>
     221        <Filename Value="USqlDatabase.pas"/>
     222        <Caret Line="392" Column="26" TopLine="370"/>
    136223      </Position6>
    137224      <Position7>
    138225        <Filename Value="UMainForm.pas"/>
    139         <Caret Line="9" Column="17" TopLine="1"/>
     226        <Caret Line="120" Column="49" TopLine="100"/>
    140227      </Position7>
    141228      <Position8>
    142         <Filename Value="USqlDatabase.pas"/>
    143         <Caret Line="83" Column="54" TopLine="68"/>
     229        <Filename Value="UMainForm.pas"/>
     230        <Caret Line="45" Column="41" TopLine="17"/>
    144231      </Position8>
     232      <Position9>
     233        <Filename Value="UMainForm.pas"/>
     234        <Caret Line="80" Column="18" TopLine="75"/>
     235      </Position9>
     236      <Position10>
     237        <Filename Value="Common/UPersistentForm.pas"/>
     238        <Caret Line="8" Column="47" TopLine="1"/>
     239      </Position10>
     240      <Position11>
     241        <Filename Value="Common/UPersistentForm.pas"/>
     242        <Caret Line="29" Column="24" TopLine="12"/>
     243      </Position11>
     244      <Position12>
     245        <Filename Value="UMainForm.pas"/>
     246        <Caret Line="77" Column="15" TopLine="75"/>
     247      </Position12>
     248      <Position13>
     249        <Filename Value="Common/UPersistentForm.pas"/>
     250        <Caret Line="37" Column="12" TopLine="12"/>
     251      </Position13>
     252      <Position14>
     253        <Filename Value="Common/UPersistentForm.pas"/>
     254        <Caret Line="44" Column="15" TopLine="21"/>
     255      </Position14>
     256      <Position15>
     257        <Filename Value="Common/UPersistentForm.pas"/>
     258        <Caret Line="46" Column="21" TopLine="29"/>
     259      </Position15>
     260      <Position16>
     261        <Filename Value="Common/UPersistentForm.pas"/>
     262        <Caret Line="29" Column="69" TopLine="25"/>
     263      </Position16>
     264      <Position17>
     265        <Filename Value="Common/UPersistentForm.pas"/>
     266        <Caret Line="51" Column="71" TopLine="33"/>
     267      </Position17>
     268      <Position18>
     269        <Filename Value="Common/UPersistentForm.pas"/>
     270        <Caret Line="52" Column="23" TopLine="37"/>
     271      </Position18>
     272      <Position19>
     273        <Filename Value="Common/UPersistentForm.pas"/>
     274        <Caret Line="54" Column="98" TopLine="37"/>
     275      </Position19>
     276      <Position20>
     277        <Filename Value="Common/UPersistentForm.pas"/>
     278        <Caret Line="74" Column="53" TopLine="46"/>
     279      </Position20>
     280      <Position21>
     281        <Filename Value="Common/UPersistentForm.pas"/>
     282        <Caret Line="75" Column="19" TopLine="54"/>
     283      </Position21>
     284      <Position22>
     285        <Filename Value="Common/URegistry.pas"/>
     286        <Caret Line="8" Column="9" TopLine="1"/>
     287      </Position22>
     288      <Position23>
     289        <Filename Value="Common/UPersistentForm.pas"/>
     290        <Caret Line="8" Column="49" TopLine="1"/>
     291      </Position23>
     292      <Position24>
     293        <Filename Value="Common/UPersistentForm.pas"/>
     294        <Caret Line="84" Column="28" TopLine="54"/>
     295      </Position24>
     296      <Position25>
     297        <Filename Value="Common/UPersistentForm.pas"/>
     298        <Caret Line="84" Column="10" TopLine="54"/>
     299      </Position25>
     300      <Position26>
     301        <Filename Value="UMainForm.pas"/>
     302        <Caret Line="25" Column="15" TopLine="7"/>
     303      </Position26>
    145304    </JumpHistory>
    146305  </ProjectOptions>
     
    153312      <IncludeFiles Value="$(ProjOutDir)/"/>
    154313      <Libraries Value="/usr/lib/mysql/;/usr/lib64/mysql/"/>
     314      <OtherUnitFiles Value="Common/"/>
    155315      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
    156316    </SearchPaths>
     
    160320      </SyntaxOptions>
    161321    </Parsing>
     322    <CodeGeneration>
     323      <Checks>
     324        <IOChecks Value="True"/>
     325        <RangeChecks Value="True"/>
     326        <OverflowChecks Value="True"/>
     327        <StackChecks Value="True"/>
     328      </Checks>
     329    </CodeGeneration>
    162330    <Linking>
     331      <Debugging>
     332        <GenerateDebugInfo Value="True"/>
     333      </Debugging>
    163334      <Options>
    164335        <Win32>
  • trunk/chronis.lpr

    r1 r2  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, USqlDatabase, UMainForm, ULoginForm
     10  Forms, UMainForm, ULoginForm, UPersistentForm, URegistry, USqlDatabase
    1111  { you can add units after this };
    1212
     
    1515begin
    1616  Application.Initialize;
     17  Application.CreateForm(TMainForm, MainForm);
    1718  Application.Run;
    1819end.
Note: See TracChangeset for help on using the changeset viewer.