Changeset 14


Ignore:
Timestamp:
Mar 19, 2013, 8:38:28 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Možnost nastavit si formát jména výstupního souboru.
  • Opraveno: Omezení nastavení časového intervalu na povolené hodnoty.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/FioInfo.lpr

    r12 r14  
    1313{$R *.res}
    1414
     15{$IFDEF DEBUG}
     16const
     17  HeapTraceLog = 'heaptrclog.trc';
     18{$ENDIF}
     19
    1520begin
     21  {$IFDEF DEBUG}
     22  // Heap trace
     23  DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     24  SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     25  {$ENDIF}
     26
    1627  RequireDerivedFormResource := True;
    1728  Application.Initialize;
  • trunk/Forms/UFormAccounts.pas

    r12 r14  
    3131      Selected: Boolean);
    3232  private
    33     { private declarations }
     33    DisableEditUpdate: Boolean;
    3434  public
    3535    Accounts: TListObject;
     
    6666  Selected: Boolean);
    6767begin
     68  if Assigned(ListView1.Selected) then begin
     69    DisableEditUpdate := True;
     70    LabeledEditToken.Text := TAccount(ListView1.Selected.Data).Token;
     71    LabeledEditName.Text := TAccount(ListView1.Selected.Data).Name;
     72    DisableEditUpdate := False;
     73  end;
    6874  UpdateInterface;
    6975end;
     
    7783procedure TFormAccounts.LabeledEditTokenChange(Sender: TObject);
    7884begin
    79   if Assigned(ListView1.Selected) then begin
    80     TAccount(ListView1.Selected.Data).Token := LabeledEditToken.Text;
    81     TAccount(ListView1.Selected.Data).Name := LabeledEditName.Text;
     85  if not DisableEditUpdate then begin
     86    if Assigned(ListView1.Selected) then begin
     87      TAccount(ListView1.Selected.Data).Token := LabeledEditToken.Text;
     88      TAccount(ListView1.Selected.Data).Name := LabeledEditName.Text;
     89    end;
     90    Reload;
    8291  end;
    83   Reload;
    8492end;
    8593
     
    111119  ListView1.Items.Count := Accounts.Count;
    112120  ListView1.Refresh;
     121  UpdateInterface;
    113122end;
    114123
     
    116125begin
    117126  ButtonRemove.Enabled := Assigned(ListView1.Selected);
    118   if Assigned(ListView1.Selected) then begin
    119     LabeledEditToken.Text := TAccount(ListView1.Selected.Data).Token;
    120     LabeledEditName.Text := TAccount(ListView1.Selected.Data).Name;
    121   end;
     127  LabeledEditToken.Enabled := Assigned(ListView1.Selected);
     128  LabeledEditName.Enabled := Assigned(ListView1.Selected);
    122129end;
    123130
  • trunk/Forms/UFormMain.lfm

    r12 r14  
    6666      Width = 80
    6767      CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames]
     68      OnAcceptDate = DateEditStartAcceptDate
    6869      OKCaption = 'OK'
    6970      CancelCaption = 'Cancel'
     
    8182      Width = 80
    8283      CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames]
     84      OnAcceptDate = DateEditToAcceptDate
    8385      OKCaption = 'OK'
    8486      CancelCaption = 'Cancel'
  • trunk/Forms/UFormMain.pas

    r13 r14  
    4343    procedure ButtonNewClick(Sender: TObject);
    4444    procedure ComboBoxAccountsChange(Sender: TObject);
     45    procedure DateEditStartAcceptDate(Sender: TObject; var ADate: TDateTime;
     46      var AcceptDate: Boolean);
     47    procedure DateEditToAcceptDate(Sender: TObject; var ADate: TDateTime;
     48      var AcceptDate: Boolean);
    4549    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4650    procedure FormCreate(Sender: TObject);
     
    8286    else Core.CurrentAccount := nil;
    8387  LoadInterface;
     88  Core.SelectedAccountIndex := ComboBoxAccounts.ItemIndex;
     89end;
     90
     91procedure TFormMain.DateEditStartAcceptDate(Sender: TObject;
     92  var ADate: TDateTime; var AcceptDate: Boolean);
     93begin
     94  AcceptDate := (ADate <= Now) and (ADate <= DateEditTo.Date);
     95end;
     96
     97procedure TFormMain.DateEditToAcceptDate(Sender: TObject; var ADate: TDateTime;
     98  var AcceptDate: Boolean);
     99begin
     100  AcceptDate := (ADate <= Now) and (ADate >= DateEditStart.Date);
    84101end;
    85102
     
    115132begin
    116133  Core.Accounts.LoadToStrings(ComboBoxAccounts.Items);
     134  if (Core.SelectedAccountIndex >= 0) and
     135    (Core.SelectedAccountIndex < ComboBoxAccounts.Items.Count) then
     136    ComboBoxAccounts.ItemIndex := Core.SelectedAccountIndex;
    117137  DateEditStart.Date := Core.ReportTimeFrom;
    118138  DateEditTo.Date := Core.ReportTimeTo;
    119139  SpinEditYear.Value := Core.ReportYear;
     140  SpinEditYear.MaxValue := YearOf(Now);
    120141  SpinEditId.Value := Core.ReportId;
    121142  ButtonInterval.Enabled := Assigned(Core.CurrentAccount);
    122143  ButtonMonthly.Enabled := Assigned(Core.CurrentAccount);
    123144  ButtonNew.Enabled := Assigned(Core.CurrentAccount);
     145  Core.ADownloadInterval.Enabled := Assigned(Core.CurrentAccount);
     146  Core.ADownloadMonthly.Enabled := Assigned(Core.CurrentAccount);
     147  Core.ADownloadNew.Enabled := Assigned(Core.CurrentAccount);
    124148  if ComboBoxAccounts.ItemIndex <> -1 then begin
    125149    LabelBalance.Caption := FloatToStr(TAccount(ComboBoxAccounts.Items.Objects[
  • trunk/Forms/UFormSettings.lfm

    r12 r14  
    11object FormSettings: TFormSettings
    22  Left = 420
    3   Height = 273
     3  Height = 281
    44  Top = 127
    5   Width = 550
     5  Width = 558
    66  Caption = 'Settings'
    7   ClientHeight = 273
    8   ClientWidth = 550
     7  ClientHeight = 281
     8  ClientWidth = 558
    99  OnCreate = FormCreate
    1010  Position = poScreenCenter
    1111  LCLVersion = '1.1'
    1212  object ButtonCancel: TButton
    13     Left = 376
     13    Left = 384
    1414    Height = 25
    15     Top = 242
     15    Top = 250
    1616    Width = 75
    1717    Anchors = [akRight, akBottom]
     
    2121  end
    2222  object ButtonOk: TButton
    23     Left = 464
     23    Left = 472
    2424    Height = 25
    25     Top = 242
     25    Top = 249
    2626    Width = 75
    2727    Anchors = [akRight]
     
    5252    Height = 27
    5353    Top = 88
    54     Width = 440
     54    Width = 448
    5555    Anchors = [akTop, akLeft, akRight]
    5656    EditLabel.AnchorSideLeft.Control = LabeledEditFolder
     
    6161    EditLabel.Height = 17
    6262    EditLabel.Top = 68
    63     EditLabel.Width = 440
     63    EditLabel.Width = 448
    6464    EditLabel.Caption = 'Destination folder:'
    6565    EditLabel.ParentColor = False
     
    6767  end
    6868  object Button1: TButton
    69     Left = 464
     69    Left = 472
    7070    Height = 25
    7171    Top = 88
     
    7676    TabOrder = 4
    7777  end
     78  object LabeledEditFileNameFormat: TLabeledEdit
     79    Left = 11
     80    Height = 27
     81    Top = 144
     82    Width = 448
     83    Anchors = [akTop, akLeft, akRight]
     84    EditLabel.AnchorSideLeft.Control = LabeledEditFileNameFormat
     85    EditLabel.AnchorSideRight.Control = LabeledEditFileNameFormat
     86    EditLabel.AnchorSideRight.Side = asrBottom
     87    EditLabel.AnchorSideBottom.Control = LabeledEditFileNameFormat
     88    EditLabel.Left = 11
     89    EditLabel.Height = 17
     90    EditLabel.Top = 124
     91    EditLabel.Width = 448
     92    EditLabel.Caption = 'Output file name format:'
     93    EditLabel.ParentColor = False
     94    TabOrder = 5
     95  end
     96  object Label2: TLabel
     97    Left = 11
     98    Height = 38
     99    Top = 176
     100    Width = 532
     101    Anchors = [akTop, akLeft, akRight]
     102    Caption = '%f - data format, %d - date, %t - time, %a - account number, %n - account name, %% - percent symbol'
     103    ParentColor = False
     104    WordWrap = True
     105  end
    78106end
  • trunk/Forms/UFormSettings.lrt

    r12 r14  
    55TFORMSETTINGS.LABELEDEDITFOLDER.EDITLABEL.CAPTION=Destination folder:
    66TFORMSETTINGS.BUTTON1.CAPTION=Select
     7TFORMSETTINGS.LABELEDEDITFILENAMEFORMAT.EDITLABEL.CAPTION=Output file name format:
     8TFORMSETTINGS.LABEL2.CAPTION=%f - data format, %d - date, %t - time, %a - account number, %n - account name, %% - percent symbol
  • trunk/Forms/UFormSettings.pas

    r12 r14  
    1919    ComboBox1: TComboBox;
    2020    Label1: TLabel;
     21    Label2: TLabel;
    2122    LabeledEditFolder: TLabeledEdit;
     23    LabeledEditFileNameFormat: TLabeledEdit;
    2224    procedure Button1Click(Sender: TObject);
    2325    procedure FormCreate(Sender: TObject);
     
    6668procedure TFormSettings.Load;
    6769begin
     70  LabeledEditFileNameFormat.Text := Core.OutputFormat;
    6871  ComboBox1.ItemIndex := Integer(Core.DataFormat);
    6972  LabeledEditFolder.Text := Core.TargetDirectory;
     
    7275procedure TFormSettings.Save;
    7376begin
     77  Core.OutputFormat := LabeledEditFileNameFormat.Text;
    7478  Core.DataFormat := TFioDataFormat(ComboBox1.ItemIndex);
    7579  Core.TargetDirectory := LabeledEditFolder.Text;
  • trunk/Languages/FioInfo.cs.po

    r12 r14  
    231231msgstr "Formát dat:"
    232232
     233#: tformsettings.label2.caption
     234msgid "%f - data format, %d - date, %t - time, %a - account number, %n - account name, %% - percent symbol"
     235msgstr "%f - formát dat, %d - datum, %t - čas, %a - číslo účtu, %n - jméno účtu, %% - znak procent"
     236
     237#: tformsettings.labelededitfilenameformat.editlabel.caption
     238msgid "Output file name format:"
     239msgstr "Formát jména vÃœstupního souboru:"
     240
    233241#: tformsettings.labelededitfolder.editlabel.caption
    234242msgid "Destination folder:"
     
    240248msgstr "Staşení selhalo"
    241249
     250#: ucore.sdumpformat
     251msgid "Dump %d %t.%f"
     252msgstr "VÃœpis %d %t.%f"
     253
    242254#: ucore.sreport
    243255msgid "Dump %s"
  • trunk/Languages/FioInfo.po

    r12 r14  
    221221msgstr ""
    222222
     223#: tformsettings.label2.caption
     224msgid "%f - data format, %d - date, %t - time, %a - account number, %n - account name, %% - percent symbol"
     225msgstr ""
     226
     227#: tformsettings.labelededitfilenameformat.editlabel.caption
     228msgid "Output file name format:"
     229msgstr ""
     230
    223231#: tformsettings.labelededitfolder.editlabel.caption
    224232msgid "Destination folder:"
     
    230238msgstr ""
    231239
     240#: ucore.sdumpformat
     241msgid "Dump %d %t.%f"
     242msgstr ""
     243
    232244#: ucore.sreport
    233245msgid "Dump %s"
  • trunk/UCore.lfm

    r12 r14  
    380380      Default = True
    381381    end
     382    object MenuItem9: TMenuItem
     383      Action = AAccounts
     384    end
    382385    object MenuItem7: TMenuItem
    383386      Action = ASettings
     
    402405    EmailContact = 'robie@centrum.cz'
    403406    AppName = 'FioInfo'
    404     ReleaseDate = 41348
     407    ReleaseDate = 41352
    405408    RegistryKey = '\Software\Chronosoft\FioInfo'
    406409    RegistryRoot = rrKeyCurrentUser
  • trunk/UCore.pas

    r13 r14  
    5757    MenuItem7: TMenuItem;
    5858    MenuItem8: TMenuItem;
     59    MenuItem9: TMenuItem;
    5960    PopupMenuTray: TPopupMenu;
    6061    TrayIcon1: TTrayIcon;
     
    7071    procedure DataModuleDestroy(Sender: TObject);
    7172  private
    72     { private declarations }
     73    function GetFileName: string;
    7374  public
    7475    RegistryContext: TRegistryContext;
     
    8182    ReportTimeFrom: TDateTime;
    8283    ReportTimeTo: TDateTime;
     84    OutputFormat: string;
     85    SelectedAccountIndex: Integer;
    8386    procedure LoadAccount(Account: TAccount);
    8487    procedure LoadAccounts;
     
    101104  SReport = 'Dump %s';
    102105  SSavedToFile = 'Dump saved to file %s';
     106  SDumpFormat = 'Dump %d %t.%f';
    103107
    104108{ TAccount }
     
    121125    Name := UTF8Encode(ReadStringWithDefault('Name', UTF8Decode('Učet')));
    122126    Time := ReadDateTimeWithDefault('Time', 0);
    123     Token :=UTF8Encode( ReadStringWithDefault('Token', ''));
     127    Token := UTF8Encode(ReadStringWithDefault('Token', ''));
    124128    Balance := ReadFloatWithDefault('Balance', 0);
    125129    Number := UTF8Encode(ReadStringWithDefault('Number', ''));
     
    227231  SaveToRegistry(RegistryContext);
    228232  FreeAndNil(Accounts);
     233end;
     234
     235function TCore.GetFileName: string;
     236begin
     237  Result := OutputFormat;
     238  Result := StringReplace(Result, '%f', DataFormatURL[DataFormat], [rfReplaceAll]);
     239  Result := StringReplace(Result, '%d', DateToStr(Now), [rfReplaceAll]);
     240  Result := StringReplace(Result, '%t', TimeToStr(Now), [rfReplaceAll]);
     241  Result := StringReplace(Result, '%a', CurrentAccount.Number, [rfReplaceAll]);
     242  Result := StringReplace(Result, '%n', CurrentAccount.Name, [rfReplaceAll]);
     243  Result := StringReplace(Result, '%%', '%', [rfReplaceAll]);
    229244end;
    230245
     
    302317    WriteInteger('ReportId', ReportId);
    303318    WriteString('Language', CoolTranslator1.Language.Code);
     319    WriteString('FileNameFormat', OutputFormat);
     320    WriteInteger('SelectedAccountIndex', SelectedAccountIndex);
    304321  finally
    305322    Free;
     
    321338    ReportId := ReadIntegerWithDefault('ReportId', MonthOf(Now));
    322339    CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('Language', 'cs'));
     340    OutputFormat := UTF8Encode(ReadStringWithDefault('FileNameFormat', UTF8Decode(SDumpFormat)));
     341    SelectedAccountIndex := ReadIntegerWithDefault('SelectedAccountIndex', 0);
    323342  finally
    324343    Free;
     
    353372    FioAPI.Token := CurrentAccount.Token;
    354373    if FioAPI.DownloadLast(List) then begin
    355       FileName := TargetDirectory + DirectorySeparator + Format(SReport, [FormatDateTime('yyyy-mm-dd hh-nn-ss', Now) +
    356         ExtensionSeparator + DataFormatURL[FioAPI.Format]]);
     374      FileName := TargetDirectory + DirectorySeparator + GetFileName;
    357375      List.SaveToFile(UTF8Decode(FileName));
    358376      ShowMessage(Format(SSavedToFile, [FileName]));
     
    376394    FioAPI.Token := CurrentAccount.Token;
    377395    if FioAPI.DownloadMonthly(ReportYear, ReportId, List) then begin
    378       FileName := TargetDirectory + DirectorySeparator + Format(SReport, [IntToStr(ReportYear) +
    379         '-' + IntToStr(ReportId) +
    380         ExtensionSeparator + DataFormatURL[FioAPI.Format]]);
     396      FileName := TargetDirectory + DirectorySeparator + GetFileName;
    381397      List.SaveToFile(UTF8Decode(FileName));
    382398      ShowMessage(Format(SSavedToFile, [FileName]));
     
    400416    FioAPI.Token := CurrentAccount.Token;
    401417    if FioAPI.DownloadInterval(ReportTimeFrom, ReportTimeTo, List) then begin
    402       FileName := TargetDirectory + DirectorySeparator + Format(SReport, [FormatDateTime('yyyy-mm-dd', ReportTimeFrom) +
    403         ' ' + FormatDateTime('yyyy-mm-dd', ReportTimeTo) +
    404         ExtensionSeparator + DataFormatURL[FioAPI.Format]]);
     418      FileName := TargetDirectory + DirectorySeparator + GetFileName;
    405419      List.SaveToFile(UTF8Decode(FileName));
    406420      ShowMessage(Format(SSavedToFile, [FileName]));
Note: See TracChangeset for help on using the changeset viewer.