Changeset 199 for trunk/Forms/UFormCheck.pas
- Timestamp:
- Aug 27, 2018, 8:33:25 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormCheck.pas
r198 r199 7 7 uses 8 8 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; 10 11 11 12 type … … 23 24 function AddNew(Message: string; Position: TPoint; 24 25 Kind: TReportType = rtNone): TReportItem; 26 procedure SaveToCsv(FileName: string); 25 27 end; 26 28 … … 28 30 29 31 TFormCheck = class(TForm) 32 AGoToLocation: TAction; 33 ASaveToCsv: TAction; 34 ActionList1: TActionList; 30 35 ButtonLoadFromFile: TButton; 31 36 ButtonAcronymsContent: TButton; … … 43 48 ListViewReport: TListView; 44 49 MemoDocument: TMemo; 50 MenuItem1: TMenuItem; 45 51 MenuItemGoTo: TMenuItem; 46 52 OpenDialog1: TOpenDialog; … … 49 55 Panel2: TPanel; 50 56 PopupMenuReport: TPopupMenu; 57 SaveDialog1: TSaveDialog; 51 58 Splitter1: TSplitter; 52 59 TabSheetSource: TTabSheet; 53 60 TabSheetReport: TTabSheet; 61 procedure AGoToLocationExecute(Sender: TObject); 62 procedure ASaveToCsvExecute(Sender: TObject); 54 63 procedure ButtonAcronymsSummaryClick(Sender: TObject); 55 64 procedure ButtonAcronymsContentClick(Sender: TObject); … … 119 128 SContentAcronyms = 'Content acronyms'; 120 129 SAcronymUsedBeforeDefined = 'Acronym %s used before it was defined.'; 130 SCSVFilter = 'CSV file (.csv)|*.csv|Any file|*.*'; 121 131 122 132 const … … 133 143 Result.Kind := Kind; 134 144 Add(Result); 145 end; 146 147 procedure TReportItems.SaveToCsv(FileName: string); 148 var 149 I: Integer; 150 F: TStringList; 151 Line: TStringList; 152 begin 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; 135 173 end; 136 174 … … 205 243 procedure TFormCheck.MenuItemGoToClick(Sender: TObject); 206 244 begin 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 213 246 end; 214 247 … … 238 271 finally 239 272 FreeAndNil(FormAcronyms); 273 end; 274 end; 275 276 procedure TFormCheck.ASaveToCsvExecute(Sender: TObject); 277 begin 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; 285 end; 286 287 procedure TFormCheck.AGoToLocationExecute(Sender: TObject); 288 begin 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; 240 294 end; 241 295 end; … … 389 443 if HasMeaning1 or HasMeaning2 then begin 390 444 // 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); 392 446 if Plural and (Length(Meaning) >= 1) and (Meaning[Length(Meaning)] = 's') then begin 393 447 Meaning := Copy(Meaning, 1, Length(Meaning) - 1);
Note:
See TracChangeset
for help on using the changeset viewer.