Changeset 434

User picture

Author: nrymanov@gmail.com

(2010/02/01 11:26) About 2 years ago

see #29 - Редизайн и унификация пользовательского интерфейса

Affected files

Updated trunk/Forms/frm_edit_author.dfm Download diff

433434
4
  HelpContext = 117
4
  HelpContext = 117
5
  BorderStyle = bsDialog
5
  BorderStyle = bsDialog
6
  Caption = #1048#1085#1092#1086#1088#1084#1072#1094#1080#1103' '#1086#1073' '#1072#1074#1090#1086#1088#1077
6
  Caption = #1048#1085#1092#1086#1088#1084#1072#1094#1080#1103' '#1086#1073' '#1072#1074#1090#1086#1088#1077
7
  ClientHeight = 216
7
  ClientHeight = 133
8
  ClientWidth = 358
8
  ClientWidth = 358
9
  Color = clBtnFace
9
  Color = clBtnFace
10
  Font.Charset = DEFAULT_CHARSET
10
  Font.Charset = DEFAULT_CHARSET
...
...
14
  Font.Style = []
14
  Font.Style = []
15
  OldCreateOrder = False
15
  OldCreateOrder = False
16
  Position = poOwnerFormCenter
16
  Position = poOwnerFormCenter
17
  OnShow = FormShow
18
  PixelsPerInch = 96
17
  PixelsPerInch = 96
19
  TextHeight = 13
18
  TextHeight = 13
20
  object gbInfo: TGroupBox
19
  object Label1: TLabel
21
    AlignWithMargins = True
20
    Left = 8
22
    Left = 3
21
    Top = 13
23
    Top = 3
22
    Width = 48
24
    Width = 352
23
    Height = 13
25
    Height = 102
24
    Caption = '&'#1060#1072#1084#1080#1083#1080#1103':'
26
    Align = alTop
25
    FocusControl = edLastName
27
    TabOrder = 0
28
    object Label1: TLabel
29
      Left = 9
30
      Top = 17
31
      Width = 48
32
      Height = 13
33
      Caption = '&'#1060#1072#1084#1080#1083#1080#1103':'
34
      FocusControl = edFamily
35
    end
36
    object Label2: TLabel
37
      Left = 9
38
      Top = 44
39
      Width = 23
40
      Height = 13
41
      Caption = '&'#1048#1084#1103':'
42
      FocusControl = edName
43
    end
44
    object Label3: TLabel
45
      Left = 9
46
      Top = 71
47
      Width = 53
48
      Height = 13
49
      Caption = #1054'&'#1090#1095#1077#1089#1090#1074#1086':'
50
      FocusControl = edMiddle
51
    end
52
    object edFamily: TEdit
53
      Left = 73
54
      Top = 14
55
      Width = 270
56
      Height = 21
57
      TabOrder = 0
58
    end
59
    object edName: TEdit
60
      Left = 73
61
      Top = 41
62
      Width = 270
63
      Height = 21
64
      TabOrder = 1
65
    end
66
    object edMiddle: TEdit
67
      Left = 73
68
      Top = 68
69
      Width = 270
70
      Height = 21
71
      TabOrder = 2
72
    end
73
  end
26
  end
74
  object gbAddNew: TGroupBox
27
  object Label2: TLabel
75
    AlignWithMargins = True
28
    Left = 8
76
    Left = 3
29
    Top = 40
77
    Top = 108
30
    Width = 23
78
    Width = 352
31
    Height = 13
79
    Height = 61
32
    Caption = '&'#1048#1084#1103':'
80
    Margins.Top = 0
33
    FocusControl = edFirstName
81
    Margins.Bottom = 0
82
    Align = alTop
83
    Caption = #1054'&'#1087#1094#1080#1080
84
    TabOrder = 1
85
    Visible = False
86
    object cbAddNew: TCheckBox
87
      Left = 17
88
      Top = 28
89
      Width = 85
90
      Height = 15
91
      Caption = '&'#1053#1086#1074#1099#1081' '#1072#1074#1090#1086#1088
92
      TabOrder = 0
93
    end
94
    object cbSaveLinks: TCheckBox
95
      Left = 158
96
      Top = 28
97
      Width = 108
98
      Height = 15
99
      Caption = #1057#1086'&'#1093#1088#1072#1085#1080#1090#1100'  '#1089#1074#1103#1079#1080
100
      TabOrder = 1
101
    end
102
  end
34
  end
35
  object Label3: TLabel
36
    Left = 8
37
    Top = 67
38
    Width = 53
39
    Height = 13
40
    Caption = #1054'&'#1090#1095#1077#1089#1090#1074#1086':'
41
    FocusControl = edMiddleName
42
  end
103
  object pnButtons: TPanel
43
  object pnButtons: TPanel
104
    Left = 0
44
    Left = 0
105
    Top = 175
45
    Top = 92
106
    Width = 358
46
    Width = 358
107
    Height = 41
47
    Height = 41
108
    Align = alBottom
48
    Align = alBottom
109
    BevelOuter = bvNone
49
    BevelOuter = bvNone
110
    Caption = 'pnButtons'
50
    Caption = 'pnButtons'
111
    ShowCaption = False
51
    ShowCaption = False
112
    TabOrder = 2
52
    TabOrder = 3
53
    ExplicitTop = 175
113
    DesignSize = (
54
    DesignSize = (
114
      358
55
      358
115
      41)
56
      41)
...
...
136
      TabOrder = 1
77
      TabOrder = 1
137
    end
78
    end
138
  end
79
  end
80
  object edFirstName: TEdit
81
    Left = 72
82
    Top = 37
83
    Width = 278
84
    Height = 21
85
    TabOrder = 1
86
  end
87
  object edLastName: TEdit
88
    Left = 72
89
    Top = 10
90
    Width = 278
91
    Height = 21
92
    TabOrder = 0
93
  end
94
  object edMiddleName: TEdit
95
    Left = 72
96
    Top = 64
97
    Width = 278
98
    Height = 21
99
    TabOrder = 2
100
  end
139
end
101
end

Updated trunk/Forms/frm_edit_author.pas Download diff

433434
6
  * 20.08.2008
6
  * 20.08.2008
7
  * Copyright (c) Aleksey Penkov  alex.penkov@gmail.com
7
  * Copyright (c) Aleksey Penkov  alex.penkov@gmail.com
8
  *               Nick Rymanov    nrymanov@gmail.com
8
  *               Nick Rymanov    nrymanov@gmail.com
9
  *
10
  * !!!      TfrmEditAuthorDataEx.
11
  *              ,    ,     .
12
  *
9
  ****************************************************************************** *)
13
  ****************************************************************************** *)
10
14
11
unit frm_edit_author;
15
unit frm_edit_author;
...
...
18
22
19
type
23
type
20
  TfrmEditAuthorData = class(TForm)
24
  TfrmEditAuthorData = class(TForm)
21
    gbInfo: TGroupBox;
22
    edFamily: TEdit;
23
    Label1: TLabel;
25
    Label1: TLabel;
24
    edName: TEdit;
25
    Label2: TLabel;
26
    Label2: TLabel;
26
    edMiddle: TEdit;
27
    Label3: TLabel;
27
    Label3: TLabel;
28
    gbAddNew: TGroupBox;
28
    edLastName: TEdit;
29
    cbAddNew: TCheckBox;
29
    edFirstName: TEdit;
30
    cbSaveLinks: TCheckBox;
30
    edMiddleName: TEdit;
31
    pnButtons: TPanel;
31
    pnButtons: TPanel;
32
    btnOk: TButton;
32
    btnOk: TButton;
33
    btnCancel: TButton;
33
    btnCancel: TButton;
34
    procedure FormShow(Sender: TObject);
34
35
  private
35
  private
36
    function GetAddNewState: boolean;
36
    function GetFirstName: string;
37
    function GetSaveLinks: boolean;
37
    function GetLastName: string;
38
    procedure SetShowCheckBoxes(const Value: boolean);
38
    function GetMidName: string;
39
    { Private declarations }
39
    procedure SetFirstName(const Value: string);
40
    procedure SetLastName(const Value: string);
41
    procedure SetMidName(const Value: string);
42
40
  public
43
  public
41
    { Public declarations }
44
    property LastName: string read GetLastName write SetLastName;
42
    property ShowCheckBoxes: boolean write SetShowCheckBoxes default False;
45
    property FirstName: string read GetFirstName write SetFirstName;
43
    property AddNew: boolean read GetAddNewState;
46
    property MidName: string read GetMidName write SetMidName;
44
    property SaveLinks: boolean read GetSaveLinks;
45
46
  end;
47
  end;
47
48
48
var
49
var
...
...
52
53
53
{$R *.dfm}
54
{$R *.dfm}
54
55
55
{ TfrmEditAuthor }
56
{ TfrmEditAuthorData }
56
57
57
procedure TfrmEditAuthorData.FormShow(Sender: TObject);
58
function TfrmEditAuthorData.GetFirstName: string;
58
begin
59
begin
59
  ActiveControl := edFamily;
60
  Result := Trim(edFirstName.Text);
60
end;
61
end;
61
62
62
function TfrmEditAuthorData.GetAddNewState: boolean;
63
function TfrmEditAuthorData.GetLastName: string;
63
begin
64
begin
64
  Result := cbAddNew.Checked;
65
  Result := Trim(edLastName.Text);
65
end;
66
end;
66
67
67
function TfrmEditAuthorData.GetSaveLinks: boolean;
68
function TfrmEditAuthorData.GetMidName: string;
68
begin
69
begin
69
  Result := cbSaveLinks.Checked;
70
  Result := Trim(edMiddleName.Text);
70
end;
71
end;
71
72
72
procedure TfrmEditAuthorData.SetShowCheckBoxes(const Value: boolean);
73
procedure TfrmEditAuthorData.SetFirstName(const Value: string);
73
begin
74
begin
74
  gbAddNew.Visible := Value;
75
  edFirstName.Text := Value;
75
end;
76
end;
76
77
78
procedure TfrmEditAuthorData.SetLastName(const Value: string);
79
begin
80
  edLastName.Text := Value;
81
end;
82
83
procedure TfrmEditAuthorData.SetMidName(const Value: string);
84
begin
85
  edMiddleName.Text := Value;
86
end;
87
77
end.
88
end.

Updated trunk/Forms/frm_edit_book_info.pas Download diff

433434
126
    if frmEditAuthor.ShowModal = mrOk then
126
    if frmEditAuthor.ShowModal = mrOk then
127
    begin
127
    begin
128
      Family := lvAuthors.Items.Add;
128
      Family := lvAuthors.Items.Add;
129
      Family.Caption := frmEditAuthor.edFamily.Text;
129
      Family.Caption := frmEditAuthor.LastName;
130
      Family.SubItems.Add(frmEditAuthor.edName.Text);
130
      Family.SubItems.Add(frmEditAuthor.FirstName);
131
      Family.SubItems.Add(frmEditAuthor.edMiddle.Text);
131
      Family.SubItems.Add(frmEditAuthor.MidName);
132
132
133
      FChanged := True;
133
      FChanged := True;
134
    end;
134
    end;
...
...
148
148
149
  frmEditAuthor := TfrmEditAuthorData.Create(Self);
149
  frmEditAuthor := TfrmEditAuthorData.Create(Self);
150
  try
150
  try
151
    frmEditAuthor.edFamily.Text := Family.Caption;
151
    frmEditAuthor.LastName := Family.Caption;
152
    frmEditAuthor.edName.Text := Family.SubItems[0];
152
    frmEditAuthor.FirstName := Family.SubItems[0];
153
    frmEditAuthor.edMiddle.Text := Family.SubItems[1];
153
    frmEditAuthor.MidName := Family.SubItems[1];
154
154
155
    if frmEditAuthor.ShowModal = mrOk then
155
    if frmEditAuthor.ShowModal = mrOk then
156
    begin
156
    begin
157
      Family.Caption := frmEditAuthor.edFamily.Text;
157
      Family.Caption := frmEditAuthor.LastName;
158
      Family.SubItems[0] := frmEditAuthor.edName.Text;
158
      Family.SubItems[0] := frmEditAuthor.FirstName;
159
      Family.SubItems[1] := frmEditAuthor.edMiddle.Text;
159
      Family.SubItems[1] := frmEditAuthor.MidName;
160
160
161
      FChanged := True;
161
      FChanged := True;
162
    end;
162
    end;

Updated trunk/Forms/frm_main.pas Download diff

433434
820
  unit_SearchUtils,
820
  unit_SearchUtils,
821
  frm_search,
821
  frm_search,
822
  unit_WriteFb2Info,
822
  unit_WriteFb2Info,
823
  frm_ConverToFBD;
823
  frm_ConverToFBD,
824
  frmEditAuthorEx;
824
825
825
resourcestring
826
resourcestring
826
  rstrFileNotFoundMsg = ' %s  !'#13'  !';
827
  rstrFileNotFoundMsg = ' %s  !'#13'  !';
...
...
4550
  old_AiD: integer;
4551
  old_AiD: integer;
4551
  new_AiD: integer;
4552
  new_AiD: integer;
4552
4553
4554
  frmEditAuthor: TfrmEditAuthorDataEx;
4553
begin
4555
begin
4554
  if ActiveView = FavoritesView then
4556
  if ActiveView = FavoritesView then
4555
  begin
4557
  begin
...
...
4571
  dmCollection.tblAuthors.Locate('A_ID', dmCollection.tblAuthor_List['AL_AuthID'], []);
4573
  dmCollection.tblAuthors.Locate('A_ID', dmCollection.tblAuthor_List['AL_AuthID'], []);
4572
  old_AiD := dmCollection.tblAuthor_List['AL_AuthID'];
4574
  old_AiD := dmCollection.tblAuthor_List['AL_AuthID'];
4573
4575
4574
  frmEditAuthorData.edFamily.Text := dmCollection.tblAuthors.FieldByName('A_Family').AsString;
4576
  frmEditAuthor := TfrmEditAuthorDataEx.Create(Self);
4575
  frmEditAuthorData.edName.Text := dmCollection.tblAuthors.FieldByName('A_Name').AsString;
4577
  try
4576
  frmEditAuthorData.edMiddle.Text := dmCollection.tblAuthors.FieldByName('A_Middle').AsString;
4578
    frmEditAuthor.LastName := dmCollection.tblAuthors.FieldByName('A_Family').AsString;
4579
    frmEditAuthor.FirstName := dmCollection.tblAuthors.FieldByName('A_Name').AsString;
4580
    frmEditAuthor.MidName := dmCollection.tblAuthors.FieldByName('A_Middle').AsString;
4577
4581
4578
  frmEditAuthorData.ShowCheckBoxes := True;
4582
    if frmEditAuthor.ShowModal = mrOk then
4583
    begin
4584
      S := Trim(AnsiUpperCase(frmEditAuthor.LastName + ' ' +
4585
                                   frmEditAuthor.FirstName + ' ' +
4586
                                   frmEditAuthor.MidName));
4579
4587
4580
  if frmEditAuthorData.ShowModal = mrOk then
4588
      if (not frmEditAuthor.AddNew) and (not frmEditAuthor.SaveLinks) then
4581
  begin
4589
      begin
4590
        //     ,     
        if dmCollection.tblAuthors.Locate(
4591
          'A_Family;A_Name;A_Middle',
4592
          VarArrayOf([frmEditAuthor.LastName, frmEditAuthor.FirstName, frmEditAuthor.MidName]),
4593
          [loCaseInsensitive]
4594
          )
4595
        then
4596
        begin
4597
          //     ,      ()
4598
          new_AiD := dmCollection.tblAuthorsID.Value;
4599
          repeat
4600
            //   Id  
            { TODO -oNickR -cRefactoring :     UPDATE }
4601
            dmCollection.tblAuthor_List.MasterSource := nil;
4582
4602
4583
    S := trim(AnsiUpperCase(frmEditAuthorData.edFamily.Text + ' ' +
4603
            Res := dmCollection.tblAuthor_List.Locate('AL_AuthID',old_Aid,[]);
4584
                                 frmEditAuthorData.edName.Text + ' ' +
4604
            if Res then
4585
                                 frmEditAuthorData.edMiddle.Text));
4605
            begin
4606
              dmCollection.tblAuthor_List.Edit;
4607
              dmCollection.tblAuthor_ListAL_AuthID.Value := new_AiD;
4608
              dmCollection.tblAuthor_List.Post;
4609
            end;
4610
          until not Res;
4586
4611
4587
    if (not frmEditAuthorData.AddNew) and (not frmEditAuthorData.SaveLinks) then
4612
          repeat
4588
    begin    //     ,     
4613
            Res := dmCollection.tblBooks.Locate('FullName', AnsiUpperCase(Data.FullName), [loCaseInsensitive]);
4589
      if dmCollection.tblAuthors.Locate('A_Family;A_Name;A_Middle',
4614
            if Res then
4590
                            VarArrayOf([frmEditAuthorData.edFamily.Text,
4615
            begin
4591
                                        frmEditAuthorData.edName.Text,
4616
              dmCollection.tblBooks.Edit;
4592
                                        frmEditAuthorData.edMiddle.Text]),
4617
              dmCollection.tblBooksFullName.Value := S;
4593
                                        [loCaseInsensitive]) then
4618
              dmCollection.tblBooks.Post;
4594
      begin  //     ,      ()
4619
            end;
4595
        new_AiD := dmCollection.tblAuthorsID.Value;
4620
          until not Res;
4596
        repeat
4597
          //   Id  
          //   
          { TODO -oNickR -cRefactoring :     UPDATE }
4598
          dmCollection.tblAuthor_List.MasterSource := nil;
4599
4621
4600
          Res := dmCollection.tblAuthor_List.Locate('AL_AuthID',old_Aid,[]);
4622
          //   
4601
          if Res then
4623
          if dmCollection.tblAuthors.Locate('A_ID', old_Aid,[]) then
4602
          begin
4624
             dmCollection.tblAuthors.Delete;
4603
            dmCollection.tblAuthor_List.Edit;
4604
            dmCollection.tblAuthor_ListAL_AuthID.Value := new_AiD;
4605
            dmCollection.tblAuthor_List.Post;
4606
          end;
4607
        until not Res;
4608
4625
4609
        //   
        { TODO -oNickR -cRefactoring :     UPDATE }
4626
          dmCollection.tblAuthor_List.MasterSource := dmCollection.dsAuthors;
4627
        end // if Locate
4628
        else  //   -   
4629
        begin
4630
          dmCollection.tblAuthors.Edit;
4631
          dmCollection.tblAuthorsFamily.Value := frmEditAuthor.LastName;
4632
          dmCollection.tblAuthorsName.Value := frmEditAuthor.FirstName;
4633
          dmCollection.tblAuthorsMiddle.Value := frmEditAuthor.MidName;
4634
          dmCollection.tblAuthors.Post;
4635
        end;
4636
4610
        repeat
4637
        repeat
4638
          { TODO -oNickR -cRefactoring :     UPDATE }
4611
          Res := dmCollection.tblBooks.Locate('FullName', AnsiUpperCase(Data.FullName), [loCaseInsensitive]);
4639
          Res := dmCollection.tblBooks.Locate('FullName', AnsiUpperCase(Data.FullName), [loCaseInsensitive]);
4612
          if Res then
4640
          if Res then
4613
          begin
4641
          begin
...
...
4619
            dmCollection.tblBooks.Post;
4648
            dmCollection.tblBooks.Post;
4620
          end;
4649
          end;
4621
        until not Res;
4650
        until not Res;
4622
4623
        if dmCollection.tblAuthors.Locate('A_ID', old_Aid,[]) then
4624
           dmCollection.tblAuthors.Delete;   //   
4625
        dmCollection.tblAuthor_List.MasterSource := dmCollection.dsAuthors;
4626
      end // if Locate
4627
      else  //   -   
4628
      begin
4629
        dmCollection.tblAuthors.Edit;
4630
        dmCollection.tblAuthorsFamily.Value := frmEditAuthorData.edFamily.Text;
4631
        dmCollection.tblAuthorsName.Value := frmEditAuthorData.edName.Text;
4632
        dmCollection.tblAuthorsMiddle.Value := frmEditAuthorData.edMiddle.Text;
4633
        dmCollection.tblAuthors.Post;
4634
      end;
4651
      end;
4635
4652
4636
      repeat
4653
      if (frmEditAuthor.AddNew) then
4637
        { TODO -oNickR -cRefactoring :     UPDATE }
4654
      begin    //    
4638
        Res := dmCollection.tblBooks.Locate('FullName', AnsiUpperCase(Data.FullName), [loCaseInsensitive]);
4655
        //   
4639
        if Res then
4656
        if not dmCollection.tblAuthors.Locate(
4657
          'A_Family;A_Name;A_Middle',
4658
          VarArrayOf([frmEditAuthor.LastName, frmEditAuthor.FirstName, frmEditAuthor.MidName]),
4659
          [loCaseInsensitive]
4660
          )
4661
        then
4640
        begin
4662
        begin
4641
          dmCollection.tblBooks.Edit;
4663
          dmCollection.tblAuthors.Insert;
4642
          dmCollection.tblBooksFullName.Value := S;
4664
          dmCollection.tblAuthorsFamily.Value := frmEditAuthor.LastName;
4643
          dmCollection.tblBooks.Post;
4665
          dmCollection.tblAuthorsName.Value := frmEditAuthor.FirstName;
4666
          dmCollection.tblAuthorsMiddle.Value := frmEditAuthor.MidName;
4667
          dmCollection.tblAuthors.Post;
4644
        end;
4668
        end;
4645
      until not Res;
4646
    end;
4647
4669
4648
    if (frmEditAuthorData.AddNew) then
4670
        //  
4649
    begin    //    
4671
        dmCollection.tblAuthor_List.MasterSource := nil;
4650
4672
4651
      //   
4673
        Node := Tree.GetFirst;
4652
      if not dmCollection.tblAuthors.Locate('A_Family;A_Name;A_Middle',
4674
        while Node <> Nil do
4653
                            VarArrayOf([frmEditAuthorData.edFamily.Text,
4654
                                        frmEditAuthorData.edName.Text,
4655
                                        frmEditAuthorData.edMiddle.Text]),
4656
                                        [loCaseInsensitive]) then
4657
      begin
4658
        dmCollection.tblAuthors.Insert;
4659
        dmCollection.tblAuthorsFamily.Value := frmEditAuthorData.edFamily.Text;
4660
        dmCollection.tblAuthorsName.Value := frmEditAuthorData.edName.Text;
4661
        dmCollection.tblAuthorsMiddle.Value := frmEditAuthorData.edMiddle.Text;
4662
        dmCollection.tblAuthors.Post;
4663
      end;
4664
4665
      //  
4666
      dmCollection.tblAuthor_List.MasterSource := nil;
4667
4668
      Node := Tree.GetFirst;
4669
      while Node <> Nil do
4670
      begin
4671
        Data := Tree.GetNodeData(Node);
4672
        if (Data.nodeType = ntBookInfo) and
4673
            ((Tree.CheckState[Node] = csCheckedNormal) or
4674
            (Tree.Selected[Node])) then
4675
        begin
4675
        begin
4676
          if not frmEditAuthorData.SaveLinks then   //  
4676
          Data := Tree.GetNodeData(Node);
4677
          if (Data.nodeType = ntBookInfo) and
4678
              ((Tree.CheckState[Node] = csCheckedNormal) or
4679
              (Tree.Selected[Node])) then
4677
          begin
4680
          begin
4678
            if dmCollection.tblAuthor_List.Locate('AL_BookID',Data.ID,[]) then
4681
            if not frmEditAuthor.SaveLinks then   //  
4679
            begin
4682
            begin
4680
              dmCollection.tblAuthor_List.Edit;
4683
              if dmCollection.tblAuthor_List.Locate('AL_BookID',Data.ID,[]) then
4684
              begin
4685
                dmCollection.tblAuthor_List.Edit;
4686
                dmCollection.tblAuthor_ListAL_AuthID.Value := dmCollection.tblAuthorsID.Value;
4687
                dmCollection.tblAuthor_List.Post;
4688
              end
4689
            end
4690
            else
4691
            begin //   
4692
              dmCollection.tblAuthor_List.Insert;
4681
              dmCollection.tblAuthor_ListAL_AuthID.Value := dmCollection.tblAuthorsID.Value;
4693
              dmCollection.tblAuthor_ListAL_AuthID.Value := dmCollection.tblAuthorsID.Value;
4682
              dmCollection.tblAuthor_List.Post;
4694
              dmCollection.tblAuthor_ListAL_BookID.Value := Data.ID;
4683
            end
4684
          end
4685
          else
4686
          begin //   
4687
            dmCollection.tblAuthor_List.Insert;
4688
            dmCollection.tblAuthor_ListAL_AuthID.Value := dmCollection.tblAuthorsID.Value;
4689
            dmCollection.tblAuthor_ListAL_BookID.Value := Data.ID;
4690
4695
4691
            dmCollection.tblAuthor_ListAL_Series.Value := Copy(Data.Series, 1, IndexSize);
4696
              dmCollection.tblAuthor_ListAL_Series.Value := Copy(Data.Series, 1, IndexSize);
4692
            dmCollection.tblAuthor_ListAL_Title.Value := Copy(Data.Title, 1, IndexSize);
4697
              dmCollection.tblAuthor_ListAL_Title.Value := Copy(Data.Title, 1, IndexSize);
4693
4698
4694
            dmCollection.tblAuthor_List.Post;
4699
              dmCollection.tblAuthor_List.Post;
4700
            end;
4701
            dmCollection.tblBooks.Locate('ID', Data.ID, []);
4702
            dmCollection.tblBooks.Edit;
4703
            dmCollection.tblBooksFullName.Value:= S;
4704
            dmCollection.tblBooks.Post;
4695
          end;
4705
          end;
4696
          dmCollection.tblBooks.Locate('ID', Data.ID, []);
4706
          Node := Tree.GetNext(Node,False);
4697
          dmCollection.tblBooks.Edit;
4698
          dmCollection.tblBooksFullName.Value:= S;
4699
          dmCollection.tblBooks.Post;
4700
        end;
4707
        end;
4701
        Node := Tree.GetNext(Node,False);
4708
        dmCollection.tblAuthor_List.MasterSource := dmCollection.dsAuthors;
4702
      end;
4709
      end;
4703
      dmCollection.tblAuthor_List.MasterSource := dmCollection.dsAuthors;
4710
      InitCollection(True);
4704
    end;
4711
    end;
4705
    InitCollection(True);
4712
  finally
4713
    frmEditAuthor.Free;
4706
  end;
4714
  end;
4707
end;
4715
end;
4708
4716

Updated trunk/Forms/frm_settings.pas Download diff

433434
542
  frmCreateMask: TfrmCreateMask;
542
  frmCreateMask: TfrmCreateMask;
543
  TypeMask: TFMask;
543
  TypeMask: TFMask;
544
begin
544
begin
545
  frmCreateMask:= TfrmCreateMask.Create(Self);
545
  try
546
  try
546
    frmCreateMask:= TfrmCreateMask.Create(self);
547
    // TODO -oNickR -cCode quality :       -   .      
    if (Sender as TRzButtonEdit).Tag = 785 then
547
548
    if (sender as TRzButtonEdit).Tag = 785 then
549
      frmCreateMask.FoderMask:= MFolder
548
      frmCreateMask.FoderMask:= MFolder
550
    else
549
    else
551
      frmCreateMask.FoderMask:= MFile;
550
      frmCreateMask.FoderMask:= MFile;
552
551
553
    frmCreateMask.edTemplate.Text:= (Sender as TRzButtonEdit).Text;
552
    frmCreateMask.edTemplate.Text:= (Sender as TRzButtonEdit).Text;
554
553
555
    frmCreateMask.ShowModal;
554
    if frmCreateMask.ShowModal = mrOk then
556
    if frmCreateMask.ModalResult = mrOk then
555
      (Sender as TRzButtonEdit).Text := frmCreateMask.edTemplate.Text;
557
      (Sender as TRzButtonEdit).text := frmCreateMask.edTemplate.Text;
558
  finally
556
  finally
559
    frmCreateMask.Free
557
    frmCreateMask.Free
560
  end;
558
  end;

Added trunk/Forms/frmEditAuthorEx.dfm

Show contents

Added trunk/Forms/frmEditAuthorEx.pas

Show contents

Updated trunk/MyhomeLib.dpr Download diff

433434
111
  frm_create_mask in 'Forms\frm_create_mask.pas' {frmCreateMask},
111
  frm_create_mask in 'Forms\frm_create_mask.pas' {frmCreateMask},
112
  unit_Downloader in 'DwnldImpl\unit_Downloader.pas',
112
  unit_Downloader in 'DwnldImpl\unit_Downloader.pas',
113
  frame_NCWDownload in 'Wizards\NewCollection\frame_NCWDownload.pas' {frameNCWDownload: TFrame},
113
  frame_NCWDownload in 'Wizards\NewCollection\frame_NCWDownload.pas' {frameNCWDownload: TFrame},
114
  unit_Templater in 'Units\unit_Templater.pas';
114
  unit_Templater in 'Units\unit_Templater.pas',
115
  frmEditAuthorEx in 'Forms\frmEditAuthorEx.pas' {frmEditAuthorDataEx};
115
116
116
{$R *.res}
117
{$R *.res}
117
118
...
...
131
    frmSplash.Update; // Update the splash screen to ensure it gets drawn
132
    frmSplash.Update; // Update the splash screen to ensure it gets drawn
132
133
133
    // !      
    //   -  !
    Application.CreateForm(TDMUser, DMUser);
134
    // !      
    //   -  !
    Application.CreateForm(TDMUser, DMUser);
134
  Application.CreateForm(TDMCollection, DMCollection);
135
    Application.CreateForm(TfrmMain, frmMain);
135
  Application.CreateForm(TfrmMain, frmMain);
136
  //   -  !
    Application.CreateForm(TDMCollection, DMCollection);
137
    Application.CreateForm(TfrmEditor, frmEditor);
136
    Application.CreateForm(TfrmEditor, frmEditor);
138
    Application.CreateForm(TfrmEditBookInfo, frmEditBookInfo);
137
    Application.CreateForm(TfrmEditBookInfo, frmEditBookInfo);
139
    Application.CreateForm(TfrmGenreTree, frmGenreTree);
138
    Application.CreateForm(TfrmGenreTree, frmGenreTree);
140
    Application.CreateForm(TfrmAddnonfb2, frmAddnonfb2);
139
    Application.CreateForm(TfrmAddnonfb2, frmAddnonfb2);
141
    Application.CreateForm(TfrmEditAuthorData, frmEditAuthorData);
142
    Application.CreateForm(TfrmConvertToFBD, frmConvertToFBD);
140
    Application.CreateForm(TfrmConvertToFBD, frmConvertToFBD);
143
    Application.CreateForm(TfrmAuthorList, frmAuthorList);
141
    Application.CreateForm(TfrmAuthorList, frmAuthorList);
144
    frmSplash.Hide;  // Hide the splash screen
142
    frmSplash.Hide;  // Hide the splash screen

Updated trunk/MyhomeLib.dproj Download diff

433434
247
				<DesignClass>TFrame</DesignClass>
247
				<DesignClass>TFrame</DesignClass>
248
			</DCCReference>
248
			</DCCReference>
249
			<DCCReference Include="Units\unit_Templater.pas"/>
249
			<DCCReference Include="Units\unit_Templater.pas"/>
250
			<DCCReference Include="Forms\frmEditAuthorEx.pas">
251
				<Form>frmEditAuthorDataEx</Form>
252
			</DCCReference>
250
			<RcItem Include="Resources\Images\16x16\star_small.png">
253
			<RcItem Include="Resources\Images\16x16\star_small.png">
251
				<ResourceType>RCData</ResourceType>
254
				<ResourceType>RCData</ResourceType>
252
				<ResourceId>smallStar</ResourceId>
255
				<ResourceId>smallStar</ResourceId>

Updated trunk/Units/unit_Templater.pas Download diff

433434
1
{ ****************************************************************************** }
1
(* *****************************************************************************
2
{ }
2
  *
3
{ MyHomeLib }
3
  * MyHomeLib
4
{ }
4
  *
5
{ Version 1 }
5
  *    
  *
6
{ 31.01.2010 }
6
  * Version 1.0
7
{ Copyright (c) Matvienko Sergei  matv84@mail.ru }
7
  * 31.01.2010
8
{ }
8
  * Copyright (c) Aleksey Penkov  alex.penkov@gmail.com
9
{     }
9
  * Author        Matvienko Sergei  matv84@mail.ru
10
{ ****************************************************************************** }
10
  *
11
  ****************************************************************************** *)
11
12
12
unit unit_Templater;
13
unit unit_Templater;
13
14
...
...
25
27
26
  TTemplater = class
28
  TTemplater = class
27
  private
29
  private
28
    Template: string;
30
    FTemplate: string;
29
    ParsedString: string;
31
    FParsedString: string;
30
    BlocksMap: array of TElement;
32
    FBlocksMap: array of TElement;
31
  public
33
  public
32
    constructor Create;
34
    constructor Create;
33
    function ValidateTemplate(Template: string): TErrorType;
35
    function ValidateTemplate(Template: string): TErrorType;
34
    function SetTemplate(Template: String): TErrorType;
36
    function SetTemplate(Template: string): TErrorType;
35
    procedure ParseTemplate(ACollection: TDMCollection);
37
    procedure ParseTemplate(ACollection: TDMCollection);
36
    function GetParsedString: string;
38
    function GetParsedString: string;
37
  end;
39
  end;
38
40
39
implementation
41
implementation
40
42
41
uses SysUtils, unit_Globals, unit_Consts;
43
uses
44
  SysUtils, unit_Globals, unit_Consts;
42
45
43
constructor TTemplater.Create;
46
constructor TTemplater.Create;
44
begin
47
begin
45
  inherited;
48
  inherited;
46
  ParsedString := '';
49
  FParsedString := '';
47
  Template := '';
50
  FTemplate := '';
48
end;
51
end;
49
52
50
function TTemplater.ValidateTemplate(Template: string): TErrorType;
53
function TTemplater.ValidateTemplate(Template: string): TErrorType;
51
const
54
const
52
  mask_elements: array [1 .. 8] of string = ('f', 't', 's', 'n', 'id', 'g',
55
  mask_elements: array [1 .. 8] of string = ('f', 't', 's', 'n', 'id', 'g', 'fl', 'rg');
53
    'fl', 'rg');
54
var
56
var
55
  stack: array of TElement;
57
  stack: array of TElement;
56
  h, k, i, j, StackPos, ElementPos, ColElements, last_char,
58
  h, k, i, j, StackPos, ElementPos, ColElements, last_char, last_col_elements: integer;
57
    last_col_elements: integer;
58
  bol, TemplEnd: boolean;
59
  bol, TemplEnd: boolean;
59
  TemplatePart: string;
60
  TemplatePart: string;
60
begin
61
begin
61
  //           (   )
62
  //           (   )
62
  last_col_elements := 0;
63
  last_col_elements := 0;
63
  last_char := 0;
64
  last_char := 0;
65
64
  //     
66
  //     
65
  ColElements := 0;
67
  ColElements := 0;
66
  for i := 1 to Length(Template) do
68
  for i := 1 to Length(Template) do
67
    if Template[i] = '%' then
69
    if Template[i] = '%' then
68
      inc(ColElements);
70
      Inc(ColElements);
71
69
  //      
  SetLength(stack, ColElements);
72
  //      
  SetLength(stack, ColElements);
70
  SetLength(BlocksMap, ColElements);
73
  SetLength(FBlocksMap, ColElements);
71
  for i := 0 to ColElements - 1 do
74
  for i := 0 to ColElements - 1 do
72
  begin
75
  begin
73
    stack[i].name := '';
76
    stack[i].name := '';
74
    BlocksMap[i].name := '';
77
    FBlocksMap[i].name := '';
75
  end;
78
  end;
79
76
  TemplEnd := false;
80
  TemplEnd := false;
77
  k := 1;
81
  k := 1;
78
  while not(TemplEnd) do
82
  while not(TemplEnd) do
...
...
85
    while (not(Template[k] in ['/', '\'])) and (k <= Length(Template)) do
89
    while (not(Template[k] in ['/', '\'])) and (k <= Length(Template)) do
86
    begin
90
    begin
87
      TemplatePart := TemplatePart + Template[k];
91
      TemplatePart := TemplatePart + Template[k];
88
      inc(k);
92
      Inc(k);
89
    end;
93
    end;
90
    inc(k);
94
    Inc(k);
91
    //     ,   
95
    //     ,   
92
    if k > Length(Template) then
96
    if k > Length(Template) then
93
      TemplEnd := true;
97
      TemplEnd := true;
...
...
100
      //     
      if TemplatePart[i] = '[' then
104
      //     
      if TemplatePart[i] = '[' then
101
      begin
105
      begin
102
        inc(StackPos);
106
        Inc(StackPos);
103
        stack[StackPos].BegBlock := i;
107
        stack[StackPos].BegBlock := i;
104
        stack[StackPos].name := '';
108
        stack[StackPos].name := '';
105
      end;
109
      end;
...
...
112
        if (stack[StackPos].name <> '') and (StackPos > 0) then
116
        if (stack[StackPos].name <> '') and (StackPos > 0) then
113
        begin
117
        begin
114
          Result := ErTemplate; //        
          exit;
118
          Result := ErTemplate; //        
          exit;
119
          Exit;
115
        end;
120
        end;
116
121
117
        //   
        inc(i);
122
        //   
        inc(i);
123
        Inc(i);
118
        stack[StackPos].name := '';
124
        stack[StackPos].name := '';
119
        while CharInSet(TemplatePart[i], ['a' .. 'z', 'A' .. 'Z']) do
125
        while CharInSet(TemplatePart[i], ['a' .. 'z', 'A' .. 'Z']) do
120
        begin
126
        begin
121
          stack[StackPos].name := stack[StackPos].name + TemplatePart[i];
127
          stack[StackPos].name := stack[StackPos].name + TemplatePart[i];
122
          inc(i);
128
          Inc(i);
123
        end;
129
        end;
124
        dec(i);
130
        Dec(i);
125
131
126
        //      
132
        //      
127
        if StackPos = 0 then
133
        if StackPos = 0 then
128
        begin
134
        begin
129
          BlocksMap[ElementPos + last_col_elements].name := stack[StackPos]
135
          FBlocksMap[ElementPos + last_col_elements].name := stack[StackPos].name;
130
            .name;
136
          FBlocksMap[ElementPos + last_col_elements].BegBlock := 0;
131
          BlocksMap[ElementPos + last_col_elements].BegBlock := 0;
137
          FBlocksMap[ElementPos + last_col_elements].EndBlock := 0;
132
          BlocksMap[ElementPos + last_col_elements].EndBlock := 0;
138
          Inc(ElementPos);
133
          inc(ElementPos);
134
        end;
139
        end;
135
136
      end;
140
      end;
137
141
138
      //    
142
      //    
...
...
145
        if (stack[StackPos].name = '') or (StackPos <= 0) then
147
        if (stack[StackPos].name = '') or (StackPos <= 0) then
146
        begin
148
        begin
147
          Result := ErBlocks; //        
149
          Result := ErBlocks; //        
148
          exit;
150
          Exit;
149
        end;
151
        end;
150
        stack[StackPos].EndBlock := i;
152
        stack[StackPos].EndBlock := i;
151
153
152
        //      
154
        //      
153
        BlocksMap[ElementPos + last_col_elements].name := stack[StackPos].name;
155
        FBlocksMap[ElementPos + last_col_elements].name := stack[StackPos].name;
154
        BlocksMap[ElementPos + last_col_elements].BegBlock := stack[StackPos]
156
        FBlocksMap[ElementPos + last_col_elements].BegBlock := stack[StackPos].BegBlock + last_char;
155
          .BegBlock + last_char;
157
        FBlocksMap[ElementPos + last_col_elements].EndBlock := stack[StackPos].EndBlock + last_char;
156
        BlocksMap[ElementPos + last_col_elements].EndBlock := stack[StackPos]
158
        Inc(ElementPos);
157
          .EndBlock + last_char;
158
        inc(ElementPos);
159
159
160
        dec(StackPos);
160
        Dec(StackPos);
161
      end;
161
      end;
162
162
163
      //      
163
      //      
164
      inc(i);
164
      Inc(i);
165
    end;
165
    end;
166
166
167
    //    
168
    if StackPos > 0 then
169
    begin
170
      Result := ErBlocks; //        
171
      Exit;
172
    end;
173
167
    //      
174
    //      
168
    for h := Low(BlocksMap) to High(BlocksMap) do
175
    for h := Low(FBlocksMap) to High(FBlocksMap) do
169
    begin
176
    begin
170
      if BlocksMap[h].name <> '' then
177
      if FBlocksMap[h].name <> '' then
171
      begin
178
      begin
172
        bol := false;
179
        bol := False;
173
        for j := 1 to High(mask_elements) do
180
        for j := 1 to High(mask_elements) do
174
          if BlocksMap[h].name = mask_elements[j] then
181
          if FBlocksMap[h].name = mask_elements[j] then
175
            bol := true;
182
          begin
183
            bol := True;
184
            Break;
185
          end;
176
186
177
        if not(bol) then
187
        if not(bol) then
178
          break;
188
          Break;
179
      end;
189
      end;
180
    end;
190
    end;
181
191
182
    //    
183
    if StackPos > 0 then
184
    begin
185
      Result := ErBlocks; //        
186
      exit;
187
    end;
188
    //    
192
    //    
189
    if not(bol) then
193
    if not(bol) then
190
    begin
194
    begin
191
      Result := ErElements; //   
195
      Result := ErElements; //   
192
      exit;
196
      Exit;
193
    end;
197
    end;
194
198
195
    inc(last_col_elements, ElementPos);
199
    Inc(last_col_elements, ElementPos);
196
200
197
    //         
    //     (   )
201
    //         
    //     (   )
198
    last_char := last_char + k - 1;
202
    last_char := last_char + k - 1;
199
203
200
    //              
    inc(i);
204
    //              
    inc(i);
205
    Inc(i);
201
  end;
206
  end;
202
207
203
  //   ,   
208
  //   ,   
...
...
210
begin
214
begin
211
  Result := ValidateTemplate(Template);
215
  Result := ValidateTemplate(Template);
212
  if Result = ErFine then
216
  if Result = ErFine then
213
    Self.Template := Template;
217
    FTemplate := Template;
214
end;
218
end;
215
219
216
procedure TTemplater.ParseTemplate(ACollection: TDMCollection);
220
procedure TTemplater.ParseTemplate(ACollection: TDMCollection);
...
...
226
  i, j: integer;
230
  i, j: integer;
227
  R: TBookRecord;
231
  R: TBookRecord;
228
begin
232
begin
229
  ParsedString := Self.Template;
233
  FParsedString := FTemplate;
230
234
231
  //   
  ACollection.GetCurrentBook(R);
235
  //   
  ACollection.GetCurrentBook(R);
...
...
249
253
250
  MaskElements[4].templ := 'f';
254
  MaskElements[4].templ := 'f';
251
  AuthorName := '';
255
  AuthorName := '';
252
  for i := low(R.Authors) to high(R.Authors) do
256
  for i := Low(R.Authors) to High(R.Authors) do
253
  begin
257
  begin
254
    LastName := R.Authors[i].FLastName;
258
    LastName := R.Authors[i].FLastName;
255
    if R.Authors[i].FFirstName <> '' then
259
    if R.Authors[i].FFirstName <> '' then
...
...
257
    if R.Authors[i].FMiddleName <> '' then
261
    if R.Authors[i].FMiddleName <> '' then
258
      MiddleName := ' ' + R.Authors[i].FMiddleName[1] + '.';
262
      MiddleName := ' ' + R.Authors[i].FMiddleName[1] + '.';
259
    AuthorName := AuthorName + LastName + FirstName + MiddleName;
263
    AuthorName := AuthorName + LastName + FirstName + MiddleName;
260
    if i < high(R.Authors) then
264
    if i < High(R.Authors) then
261
      AuthorName := AuthorName + ', ';
265
      AuthorName := AuthorName + ', ';
262
  end;
266
  end;
263
  MaskElements[4].value := AuthorName;
267
  MaskElements[4].value := AuthorName;
...
...
274
  end;
278
  end;
275
279
276
  MaskElements[7].templ := 'fl';
280
  MaskElements[7].templ := 'fl';
277
  MaskElements[7].value := R.Authors[ low(R.Authors)].FLastName[1];
281
  MaskElements[7].value := R.Authors[Low(R.Authors)].FLastName[1];
278
282
279
  MaskElements[8].templ := 'rg';
283
  MaskElements[8].templ := 'rg';
280
  MaskElements[8].value := ACollection.GetRootGenre(R.LibID);
284
  MaskElements[8].value := ACollection.GetRootGenre(R.LibID);
281
285
282
  //   "" 
286
  //   "" 
283
  for i := Low(MaskElements) to High(MaskElements) do
287
  for i := Low(MaskElements) to High(MaskElements) do
284
    for j := Low(BlocksMap) to High(BlocksMap) do
288
    for j := Low(FBlocksMap) to High(FBlocksMap) do
285
      if (MaskElements[i].templ = BlocksMap[j].name) and
289
      if (MaskElements[i].templ = FBlocksMap[j].name) and (MaskElements[i].value = '') then
286
        (MaskElements[i].value = '') then
290
        if (FBlocksMap[j].BegBlock <> 0) and (FBlocksMap[j].EndBlock <> 0) then
287
        if (BlocksMap[j].BegBlock <> 0) and (BlocksMap[j].EndBlock <> 0) then
288
        begin
291
        begin
289
          Delete(ParsedString, BlocksMap[j].BegBlock,
292
          Delete(FParsedString, FBlocksMap[j].BegBlock, FBlocksMap[j].EndBlock - FBlocksMap[j].BegBlock + 1);
290
            BlocksMap[j].EndBlock - BlocksMap[j].BegBlock + 1);
291
          //           
293
          //           
292
          ValidateTemplate(ParsedString);
294
          ValidateTemplate(FParsedString);
293
        end;
295
        end;
294
296
295
  //    
297
  //    
296
  for i := Length(ParsedString) downto 1 do
298
  for i := Length(FParsedString) downto 1 do
297
    if CharInSet(ParsedString[i], ['[', ']']) then
299
    if CharInSet(FParsedString[i], ['[', ']']) then
298
      Delete(ParsedString, i, 1);
300
      Delete(FParsedString, i, 1);
299
301
300
  //      
302
  //      
301
  for i := 1 to mask_elements do
303
  for i := 1 to mask_elements do
302
    StrReplace('%' + MaskElements[i].templ, MaskElements[i].value,
304
    StrReplace('%' + MaskElements[i].templ, MaskElements[i].value, FParsedString);
303
      ParsedString);
304
end;
305
end;
305
306
306
function TTemplater.GetParsedString: string;
307
function TTemplater.GetParsedString: string;
307
begin
308
begin
308
  Result := ParsedString;
309
  Result := FParsedString;
309
end;
310
end;
310
311
311
end.
312
end.