Changeset 199 for trunk


Ignore:
Timestamp:
Aug 27, 2018, 8:33:25 AM (6 years ago)
Author:
chronos
Message:
  • Added: Save to CSV action for document check report.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormCheck.lfm

    r198 r199  
    216216    DefaultExt = '.txt'
    217217    Filter = 'Text files (.txt)|*.txt|Any file|*.*'
    218     left = 116
    219     top = 493
     218    left = 544
     219    top = 288
    220220  end
    221221  object PopupMenuReport: TPopupMenu
    222     left = 378
     222    left = 376
    223223    top = 202
    224224    object MenuItemGoTo: TMenuItem
     225      Action = AGoToLocation
     226      OnClick = MenuItemGoToClick
     227    end
     228    object MenuItem1: TMenuItem
     229      Action = ASaveToCsv
     230    end
     231  end
     232  object ActionList1: TActionList
     233    left = 546
     234    top = 203
     235    object ASaveToCsv: TAction
     236      Caption = 'Save to CSV...'
     237      OnExecute = ASaveToCsvExecute
     238    end
     239    object AGoToLocation: TAction
    225240      Caption = 'Go to location'
    226       OnClick = MenuItemGoToClick
    227     end
     241      OnExecute = AGoToLocationExecute
     242    end
     243  end
     244  object SaveDialog1: TSaveDialog
     245    left = 378
     246    top = 288
    228247  end
    229248end
  • trunk/Forms/UFormCheck.pas

    r198 r199  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ExtCtrls, ComCtrls, Menus, UAcronym, URegistry, Registry, UCommon, fgl;
     9  ExtCtrls, ComCtrls, Menus, ActnList, UAcronym, URegistry, Registry, UCommon,
     10  fgl;
    1011
    1112type
     
    2324    function AddNew(Message: string; Position: TPoint;
    2425      Kind: TReportType = rtNone): TReportItem;
     26    procedure SaveToCsv(FileName: string);
    2527  end;
    2628
     
    2830
    2931  TFormCheck = class(TForm)
     32    AGoToLocation: TAction;
     33    ASaveToCsv: TAction;
     34    ActionList1: TActionList;
    3035    ButtonLoadFromFile: TButton;
    3136    ButtonAcronymsContent: TButton;
     
    4348    ListViewReport: TListView;
    4449    MemoDocument: TMemo;
     50    MenuItem1: TMenuItem;
    4551    MenuItemGoTo: TMenuItem;
    4652    OpenDialog1: TOpenDialog;
     
    4955    Panel2: TPanel;
    5056    PopupMenuReport: TPopupMenu;
     57    SaveDialog1: TSaveDialog;
    5158    Splitter1: TSplitter;
    5259    TabSheetSource: TTabSheet;
    5360    TabSheetReport: TTabSheet;
     61    procedure AGoToLocationExecute(Sender: TObject);
     62    procedure ASaveToCsvExecute(Sender: TObject);
    5463    procedure ButtonAcronymsSummaryClick(Sender: TObject);
    5564    procedure ButtonAcronymsContentClick(Sender: TObject);
     
    119128  SContentAcronyms = 'Content acronyms';
    120129  SAcronymUsedBeforeDefined = 'Acronym %s used before it was defined.';
     130  SCSVFilter = 'CSV file (.csv)|*.csv|Any file|*.*';
    121131
    122132const
     
    133143  Result.Kind := Kind;
    134144  Add(Result);
     145end;
     146
     147procedure TReportItems.SaveToCsv(FileName: string);
     148var
     149  I: Integer;
     150  F: TStringList;
     151  Line: TStringList;
     152begin
     153  F := TStringList.Create;
     154  Line := TStringList.Create;
     155  Line.StrictDelimiter := True;
     156  try
     157    Line.Clear;
     158    for I := 0 to Count - 1 do
     159    with TReportItem(Items[I]) do begin
     160      Line.Clear;
     161      if Position <> Point(0, 0) then
     162        Line.Add(IntToStr(Position.X) + ', ' + IntToStr(Position.Y))
     163        else Line.Add('');
     164      Line.Add(ReportTypeString[Kind]);
     165      Line.Add(Message);
     166      F.Add(Line.CommaText);
     167    end;
     168    F.SaveToFile(FileName);
     169  finally
     170    F.Free;
     171    Line.Free;
     172  end;
    135173end;
    136174
     
    205243procedure TFormCheck.MenuItemGoToClick(Sender: TObject);
    206244begin
    207   if Assigned(ListViewReport.Selected) then
    208   with TReportItem(ListViewReport.Selected.Data) do
    209   if Position <> Point(0, 0) then begin
    210     MemoDocument.CaretPos := Position;
    211     TabSheetSource.Show;
    212   end;
     245
    213246end;
    214247
     
    238271  finally
    239272    FreeAndNil(FormAcronyms);
     273  end;
     274end;
     275
     276procedure TFormCheck.ASaveToCsvExecute(Sender: TObject);
     277begin
     278  SaveDialog1.InitialDir := ExtractFileDir(LastDocumentFileName);
     279  SaveDialog1.DefaultExt := '.csv';
     280  SaveDialog1.FileName := ExtractFileNameWithoutExt(ExtractFileName(LastDocumentFileName)) + SaveDialog1.DefaultExt;
     281  SaveDialog1.Filter := SCSVFilter;
     282  if SaveDialog1.Execute then begin
     283    ReportItems.SaveToCsv(SaveDialog1.FileName);
     284  end;
     285end;
     286
     287procedure TFormCheck.AGoToLocationExecute(Sender: TObject);
     288begin
     289  if Assigned(ListViewReport.Selected) then
     290  with TReportItem(ListViewReport.Selected.Data) do
     291  if Position <> Point(0, 0) then begin
     292    MemoDocument.CaretPos := Position;
     293    TabSheetSource.Show;
    240294  end;
    241295end;
     
    389443          if HasMeaning1 or HasMeaning2 then begin
    390444            // If plural acronym then try to remove ending 's' character from the meaning
    391             if Plural then ReportItems.AddNew(Format(SPluralAcronym, [Acronym]), Point(0, 0));
     445            if Plural then ReportItems.AddNew(Format(SPluralAcronym, [Acronym]), Point(0, 0), rtNote);
    392446            if Plural and (Length(Meaning) >= 1) and (Meaning[Length(Meaning)] = 's') then begin
    393447              Meaning := Copy(Meaning, 1, Length(Meaning) - 1);
  • trunk/Languages/AcronymDecoder.cs.po

    r198 r199  
    190190msgstr "Vybrat kategories"
    191191
     192#: tformcheck.agotolocation.caption
     193msgctxt "tformcheck.agotolocation.caption"
     194msgid "Go to location"
     195msgstr "Jít na umístění"
     196
     197#: tformcheck.asavetocsv.caption
     198msgid "Save to CSV..."
     199msgstr "Uložit jako CSV..."
     200
    192201#: tformcheck.buttonacronymscontent.caption
    193202msgctxt "tformcheck.buttonacronymscontent.caption"
     
    259268msgstr "Zpráva"
    260269
    261 #: tformcheck.menuitemgoto.caption
    262 msgid "Go to location"
    263 msgstr "Jít na umístění"
    264 
    265270#: tformcheck.tabsheetreport.caption
    266271msgid "Report"
     
    973978msgstr "Zkratky těla dokumentu"
    974979
     980#: uformcheck.scsvfilter
     981msgid "CSV file (.csv)|*.csv|Any file|*.*"
     982msgstr "CSV soubor (.csv)|*.csv|Jakýkoliv soubor|*.*"
     983
    975984#: uformcheck.sduplicateacronymcontent
    976985msgid "Duplicate acronym %s with \"%s\" in document body."
  • trunk/Languages/AcronymDecoder.po

    r198 r199  
    180180msgstr ""
    181181
     182#: tformcheck.agotolocation.caption
     183msgctxt "tformcheck.agotolocation.caption"
     184msgid "Go to location"
     185msgstr ""
     186
     187#: tformcheck.asavetocsv.caption
     188msgid "Save to CSV..."
     189msgstr ""
     190
    182191#: tformcheck.buttonacronymscontent.caption
    183192msgctxt "tformcheck.buttonacronymscontent.caption"
     
    249258msgstr ""
    250259
    251 #: tformcheck.menuitemgoto.caption
    252 msgid "Go to location"
    253 msgstr ""
    254 
    255260#: tformcheck.tabsheetreport.caption
    256261msgid "Report"
     
    963968msgstr ""
    964969
     970#: uformcheck.scsvfilter
     971msgid "CSV file (.csv)|*.csv|Any file|*.*"
     972msgstr ""
     973
    965974#: uformcheck.sduplicateacronymcontent
    966975msgid "Duplicate acronym %s with \"%s\" in document body."
Note: See TracChangeset for help on using the changeset viewer.