Changeset 27
- Timestamp:
- Jun 7, 2016, 3:56:46 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AcronymDecoder.lpi
r25 r27 88 88 </Item4> 89 89 </RequiredPackages> 90 <Units Count="1 4">90 <Units Count="15"> 91 91 <Unit0> 92 92 <Filename Value="AcronymDecoder.lpr"/> … … 177 177 <ResourceBaseClass Value="Form"/> 178 178 </Unit13> 179 <Unit14> 180 <Filename Value="Forms\UFormImportPattern.pas"/> 181 <IsPartOfProject Value="True"/> 182 <ComponentName Value="FormImportPattern"/> 183 <ResourceBaseClass Value="Form"/> 184 </Unit14> 179 185 </Units> 180 186 </ProjectOptions> -
trunk/AcronymDecoder.lpr
r22 r27 11 11 CoolTranslator, UFormCategorySelect, UFormMain, UFormAcronym, UFormSettings, 12 12 UFormCategories, UFormAcronyms, UFormImportSource, UFormImportSources, 13 UFormAbout, UFormImportFormat, UFormImportFormats 13 UFormAbout, UFormImportFormat, UFormImportFormats, UFormImportPattern 14 14 { you can add units after this }; 15 15 … … 44 44 Application.CreateForm(TFormImportFormat, FormImportFormat); 45 45 Application.CreateForm(TFormImportFormats, FormImportFormats); 46 Application.CreateForm(TFormImportPattern, FormImportPattern); 46 47 Application.Run; 47 48 end. -
trunk/Forms/UFormAcronyms.lfm
r22 r27 11 11 object ListViewAcronyms: TListView 12 12 Left = 8 13 Height = 51013 Height = 480 14 14 Top = 40 15 15 Width = 725 … … 47 47 OnChange = ListViewFilter1Change 48 48 Anchors = [akTop, akLeft, akRight] 49 end 50 object StatusBar1: TStatusBar 51 Left = 0 52 Height = 28 53 Top = 530 54 Width = 740 55 Panels = < 56 item 57 Width = 100 58 end 59 item 60 Width = 100 61 end> 62 SimplePanel = False 49 63 end 50 64 object ListViewSort1: TListViewSort -
trunk/Forms/UFormAcronyms.pas
r22 r27 27 27 MenuItem7: TMenuItem; 28 28 PopupMenuAcronym: TPopupMenu; 29 StatusBar1: TStatusBar; 29 30 procedure AAddExecute(Sender: TObject); 30 31 procedure AModifyExecute(Sender: TObject); … … 41 42 procedure ListViewSort1Filter(ListViewSort: TListViewSort); 42 43 private 44 MeaningCount: Integer; 43 45 procedure FilterList(List: TListObject); 44 46 procedure UpdateAcronymsList; … … 211 213 FormMain.AcronymDb.Acronyms.Sort(AcronymComparer); 212 214 FormMain.AcronymDb.AssignToList(ListViewSort1.List); 215 MeaningCount := ListViewSort1.List.Count; 213 216 FilterList(ListViewSort1.List); 214 217 end; … … 247 250 ListViewSort1.Refresh; 248 251 UpdateInterface; 252 StatusBar1.Panels[0].Text := 'Total: ' + IntToStr(MeaningCount); 253 StatusBar1.Panels[1].Text := 'Filtered: ' + IntToStr(ListViewAcronyms.Items.Count); 249 254 end; 250 255 -
trunk/Forms/UFormImportFormat.lfm
r25 r27 7 7 ClientHeight = 433 8 8 ClientWidth = 664 9 LCLVersion = '1.7' 9 OnShow = FormShow 10 LCLVersion = '1.6.0.4' 10 11 object ButtonOk: TButton 11 12 Left = 560 … … 13 14 Top = 384 14 15 Width = 75 16 Anchors = [akRight, akBottom] 15 17 Caption = 'Ok' 16 18 ModalResult = 1 … … 22 24 Top = 384 23 25 Width = 75 26 Anchors = [akRight, akBottom] 24 27 Caption = 'Cancel' 25 28 ModalResult = 2 … … 28 31 object Label1: TLabel 29 32 Left = 20 30 Height = 2 233 Height = 20 31 34 Top = 16 32 Width = 4 935 Width = 43 33 36 Caption = 'Name:' 34 37 ParentColor = False … … 36 39 object EditName: TEdit 37 40 Left = 179 38 Height = 3241 Height = 28 39 42 Top = 11 40 43 Width = 461 … … 42 45 TabOrder = 2 43 46 end 44 object Label 2: TLabel47 object Label8: TLabel 45 48 Left = 20 46 Height = 22 47 Top = 133 48 Width = 112 49 Caption = 'Acronym start:' 50 ParentColor = False 51 end 52 object EditAcronymStart: TEdit 53 Left = 179 54 Height = 32 55 Top = 128 56 Width = 461 57 Anchors = [akTop, akLeft, akRight] 58 TabOrder = 3 59 end 60 object Label3: TLabel 61 Left = 20 62 Height = 22 63 Top = 173 64 Width = 105 65 Caption = 'Acronym end:' 66 ParentColor = False 67 end 68 object EditAcronymEnd: TEdit 69 Left = 179 70 Height = 32 71 Top = 168 72 Width = 461 73 Anchors = [akTop, akLeft, akRight] 74 TabOrder = 4 75 end 76 object Label4: TLabel 77 Left = 20 78 Height = 22 79 Top = 213 80 Width = 111 81 Caption = 'Meaning start:' 82 ParentColor = False 83 end 84 object EditMeaningStart: TEdit 85 Left = 179 86 Height = 32 87 Top = 208 88 Width = 461 89 Anchors = [akTop, akLeft, akRight] 90 TabOrder = 5 91 end 92 object Label5: TLabel 93 Left = 20 94 Height = 22 95 Top = 253 96 Width = 104 97 Caption = 'Meaning end:' 98 ParentColor = False 99 end 100 object EditMeaningEnd: TEdit 101 Left = 179 102 Height = 32 103 Top = 248 104 Width = 461 105 Anchors = [akTop, akLeft, akRight] 106 TabOrder = 6 107 end 108 object Label6: TLabel 109 Left = 20 110 Height = 22 111 Top = 293 112 Width = 132 113 Caption = 'Description start:' 114 ParentColor = False 115 end 116 object EditDescriptionStart: TEdit 117 Left = 179 118 Height = 32 119 Top = 288 120 Width = 461 121 Anchors = [akTop, akLeft, akRight] 122 TabOrder = 7 123 end 124 object Label7: TLabel 125 Left = 20 126 Height = 22 127 Top = 333 128 Width = 125 129 Caption = 'Description end:' 130 ParentColor = False 131 end 132 object EditDescriptionEnd: TEdit 133 Left = 179 134 Height = 32 135 Top = 328 136 Width = 461 137 Anchors = [akTop, akLeft, akRight] 138 TabOrder = 8 139 end 140 object Label8: TLabel 141 Left = 24 142 Height = 22 49 Height = 20 143 50 Top = 53 144 Width = 8551 Width = 72 145 52 Caption = 'Block start:' 146 53 ParentColor = False … … 148 55 object EditBlockStart: TEdit 149 56 Left = 179 150 Height = 3257 Height = 28 151 58 Top = 48 152 59 Width = 461 153 60 Anchors = [akTop, akLeft, akRight] 154 TabOrder = 961 TabOrder = 3 155 62 end 156 63 object Label9: TLabel 157 Left = 2 4158 Height = 2 264 Left = 20 65 Height = 20 159 66 Top = 93 160 Width = 7867 Width = 68 161 68 Caption = 'Block end:' 162 69 ParentColor = False … … 164 71 object EditBlockEnd: TEdit 165 72 Left = 179 166 Height = 3273 Height = 28 167 74 Top = 88 168 75 Width = 461 169 76 Anchors = [akTop, akLeft, akRight] 170 TabOrder = 10 77 TabOrder = 4 78 end 79 object ListViewItemRules: TListView 80 Left = 20 81 Height = 230 82 Top = 144 83 Width = 620 84 Anchors = [akTop, akLeft, akRight, akBottom] 85 Columns = < 86 item 87 Caption = 'Start string' 88 Width = 100 89 end 90 item 91 Caption = 'End string' 92 Width = 100 93 end 94 item 95 Caption = 'Action' 96 Width = 100 97 end 98 item 99 Caption = 'Variable' 100 Width = 100 101 end> 102 OwnerData = True 103 PopupMenu = PopupMenu1 104 ReadOnly = True 105 RowSelect = True 106 TabOrder = 5 107 ViewStyle = vsReport 108 OnData = ListViewItemRulesData 109 OnDblClick = AModifyExecute 110 end 111 object Label2: TLabel 112 Left = 20 113 Height = 20 114 Top = 120 115 Width = 68 116 Caption = 'Item rules:' 117 ParentColor = False 118 end 119 object PopupMenu1: TPopupMenu 120 Images = FormMain.ImageList1 121 left = 181 122 top = 240 123 object MenuItem1: TMenuItem 124 Action = AAdd 125 end 126 object MenuItem2: TMenuItem 127 Action = AModify 128 end 129 object MenuItem3: TMenuItem 130 Action = ARemove 131 end 132 object MenuItem4: TMenuItem 133 Action = AMoveUp 134 end 135 object MenuItem5: TMenuItem 136 Action = AMoveDown 137 end 138 end 139 object ActionList1: TActionList 140 Images = FormMain.ImageList1 141 left = 383 142 top = 245 143 object AAdd: TAction 144 Caption = 'Add' 145 OnExecute = AAddExecute 146 ShortCut = 45 147 end 148 object AModify: TAction 149 Caption = 'Modify' 150 OnExecute = AModifyExecute 151 ShortCut = 13 152 end 153 object ARemove: TAction 154 Caption = 'Remove' 155 OnExecute = ARemoveExecute 156 ShortCut = 46 157 end 158 object AMoveUp: TAction 159 Caption = 'Move up' 160 OnExecute = AMoveUpExecute 161 end 162 object AMoveDown: TAction 163 Caption = 'Move down' 164 OnExecute = AMoveDownExecute 165 end 171 166 end 172 167 end -
trunk/Forms/UFormImportFormat.lrt
r25 r27 3 3 TFORMIMPORTFORMAT.BUTTONCANCEL.CAPTION=Cancel 4 4 TFORMIMPORTFORMAT.LABEL1.CAPTION=Name: 5 TFORMIMPORTFORMAT.LABEL2.CAPTION=Acronym start:6 TFORMIMPORTFORMAT.LABEL3.CAPTION=Acronym end:7 TFORMIMPORTFORMAT.LABEL4.CAPTION=Meaning start:8 TFORMIMPORTFORMAT.LABEL5.CAPTION=Meaning end:9 TFORMIMPORTFORMAT.LABEL6.CAPTION=Description start:10 TFORMIMPORTFORMAT.LABEL7.CAPTION=Description end:11 5 TFORMIMPORTFORMAT.LABEL8.CAPTION=Block start: 12 6 TFORMIMPORTFORMAT.LABEL9.CAPTION=Block end: 7 TFORMIMPORTFORMAT.LISTVIEWITEMRULES.COLUMNS[0].CAPTION=Start string 8 TFORMIMPORTFORMAT.LISTVIEWITEMRULES.COLUMNS[1].CAPTION=End string 9 TFORMIMPORTFORMAT.LISTVIEWITEMRULES.COLUMNS[2].CAPTION=Action 10 TFORMIMPORTFORMAT.LISTVIEWITEMRULES.COLUMNS[3].CAPTION=Variable 11 TFORMIMPORTFORMAT.LABEL2.CAPTION=Item rules: 12 TFORMIMPORTFORMAT.AADD.CAPTION=Add 13 TFORMIMPORTFORMAT.AMODIFY.CAPTION=Modify 14 TFORMIMPORTFORMAT.AREMOVE.CAPTION=Remove 15 TFORMIMPORTFORMAT.AMOVEUP.CAPTION=Move up 16 TFORMIMPORTFORMAT.AMOVEDOWN.CAPTION=Move down -
trunk/Forms/UFormImportFormat.pas
r25 r27 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 UAcronym;9 ComCtrls, Menus, ActnList, UAcronym; 10 10 11 11 type … … 14 14 15 15 TFormImportFormat = class(TForm) 16 AAdd: TAction; 17 AMoveUp: TAction; 18 AMoveDown: TAction; 19 AModify: TAction; 20 ARemove: TAction; 21 ActionList1: TActionList; 16 22 ButtonOk: TButton; 17 23 ButtonCancel: TButton; … … 19 25 EditBlockStart: TEdit; 20 26 EditName: TEdit; 21 EditAcronymStart: TEdit;22 EditAcronymEnd: TEdit;23 EditMeaningStart: TEdit;24 EditMeaningEnd: TEdit;25 EditDescriptionStart: TEdit;26 EditDescriptionEnd: TEdit;27 27 Label1: TLabel; 28 28 Label2: TLabel; 29 Label3: TLabel;30 Label4: TLabel;31 Label5: TLabel;32 Label6: TLabel;33 Label7: TLabel;34 29 Label8: TLabel; 35 30 Label9: TLabel; 31 ListViewItemRules: TListView; 32 MenuItem1: TMenuItem; 33 MenuItem2: TMenuItem; 34 MenuItem3: TMenuItem; 35 MenuItem4: TMenuItem; 36 MenuItem5: TMenuItem; 37 PopupMenu1: TPopupMenu; 38 procedure AAddExecute(Sender: TObject); 39 procedure AModifyExecute(Sender: TObject); 40 procedure AMoveDownExecute(Sender: TObject); 41 procedure AMoveUpExecute(Sender: TObject); 42 procedure ARemoveExecute(Sender: TObject); 43 procedure FormShow(Sender: TObject); 44 procedure ListViewItemRulesData(Sender: TObject; Item: TListItem); 36 45 private 37 46 { private declarations } 38 47 public 48 ImportFormat: TImportFormat; 39 49 procedure Load(ImportFormat: TImportFormat); 40 50 procedure Save(ImportFormat: TImportFormat); 51 procedure ReloadList; 41 52 end; 42 53 … … 44 55 FormImportFormat: TFormImportFormat; 45 56 57 46 58 implementation 59 60 uses 61 UFormImportPattern; 47 62 48 63 {$R *.lfm} 49 64 65 resourcestring 66 SRemoveImportPattern = 'Remove import pattern'; 67 SRemoveImportPatternQuery = 'Do you really want to remove selected import patterns?'; 68 69 50 70 { TFormImportFormat } 71 72 procedure TFormImportFormat.AAddExecute(Sender: TObject); 73 var 74 NewImportPattern: TImportPattern; 75 begin 76 NewImportPattern := TImportPattern.Create; 77 FormImportPattern.Load(NewImportPattern); 78 if FormImportPattern.ShowModal = mrOk then begin 79 FormImportPattern.Save(NewImportPattern); 80 ImportFormat.ItemPatterns.Add(NewImportPattern); 81 NewImportPattern := nil; 82 ReloadList; 83 end; 84 if Assigned(NewImportPattern) then NewImportPattern.Free; 85 end; 86 87 procedure TFormImportFormat.AModifyExecute(Sender: TObject); 88 var 89 NewImportPattern: TImportPattern; 90 begin 91 if Assigned(ListViewItemRules.Selected) then begin 92 NewImportPattern := TImportPattern.Create; 93 NewImportPattern.Assign(ListViewItemRules.Selected.Data); 94 FormImportPattern.Load(NewImportPattern); 95 if FormImportPattern.ShowModal = mrOk then begin 96 FormImportPattern.Save(NewImportPattern); 97 TImportPattern(ListViewItemRules.Selected.Data).Assign(NewImportPattern); 98 ReloadList; 99 end; 100 if Assigned(NewImportPattern) then NewImportPattern.Free; 101 end; 102 end; 103 104 procedure TFormImportFormat.AMoveDownExecute(Sender: TObject); 105 begin 106 if ListViewItemRules.Selected.Index < (ImportFormat.ItemPatterns.Count - 1) then 107 with ImportFormat do 108 ItemPatterns.Exchange(ListViewItemRules.Selected.Index, 109 ListViewItemRules.Selected.Index + 1); 110 ReloadList; 111 end; 112 113 procedure TFormImportFormat.AMoveUpExecute(Sender: TObject); 114 begin 115 if ListViewItemRules.Selected.Index > 0 then 116 with ImportFormat do 117 ItemPatterns.Exchange(ListViewItemRules.Selected.Index, 118 ListViewItemRules.Selected.Index - 1); 119 ReloadList; 120 end; 121 122 procedure TFormImportFormat.ARemoveExecute(Sender: TObject); 123 var 124 I: Integer; 125 begin 126 if Assigned(ListViewItemRules.Selected) then begin 127 if MessageDlg(SRemoveImportPattern, SRemoveImportPatternQuery, 128 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin 129 for I := ListViewItemRules.Items.Count - 1 downto 0 do 130 if ListViewItemRules.Items[I].Selected then 131 ImportFormat.ItemPatterns.Remove(ListViewItemRules.Items[I].Data); 132 ReloadList; 133 end; 134 end; 135 end; 136 137 procedure TFormImportFormat.FormShow(Sender: TObject); 138 begin 139 ReloadList; 140 end; 141 142 procedure TFormImportFormat.ListViewItemRulesData(Sender: TObject; 143 Item: TListItem); 144 begin 145 if Item.Index < ImportFormat.ItemPatterns.Count then 146 with TImportPattern(ImportFormat.ItemPatterns[Item.Index]) do begin 147 Item.Caption := StartString; 148 Item.SubItems.Add(EndString); 149 Item.SubItems.Add(ImportPatternFlagString[Flag]); 150 Item.SubItems.Add(ImportVariableString[Variable]); 151 Item.Data := ImportFormat.ItemPatterns[Item.Index]; 152 end; 153 end; 51 154 52 155 procedure TFormImportFormat.Load(ImportFormat: TImportFormat); 53 156 begin 157 Self.ImportFormat := ImportFormat; 54 158 EditName.Text := ImportFormat.Name; 55 159 EditBlockStart.Text := ImportFormat.Block.StartString; 56 160 EditBlockEnd.Text := ImportFormat.Block.EndString; 57 EditAcronymStart.Text := ImportFormat.Acronym.StartString; 58 EditAcronymEnd.Text := ImportFormat.Acronym.EndString; 59 EditMeaningStart.Text := ImportFormat.Meaning.StartString; 60 EditMeaningEnd.Text := ImportFormat.Meaning.EndString; 61 EditDescriptionStart.Text := ImportFormat.Description.StartString; 62 EditDescriptionEnd.Text := ImportFormat.Description.EndString; 161 ReloadList; 63 162 end; 64 163 … … 68 167 ImportFormat.Block.StartString := EditBlockStart.Text; 69 168 ImportFormat.Block.EndString := EditBlockEnd.Text; 70 ImportFormat.Acronym.StartString := EditAcronymStart.Text;71 ImportFormat.Acronym.EndString := EditAcronymEnd.Text; 72 ImportFormat.Meaning.StartString := EditMeaningStart.Text;73 ImportFormat.Meaning.EndString := EditMeaningEnd.Text; 74 ImportFormat.Description.StartString := EditDescriptionStart.Text;75 ImportFormat.Description.EndString := EditDescriptionEnd.Text;169 end; 170 171 procedure TFormImportFormat.ReloadList; 172 begin 173 ListViewItemRules.Items.Count := ImportFormat.ItemPatterns.Count; 174 ListViewItemRules.Refresh; 76 175 end; 77 176 -
trunk/Forms/UFormMain.lfm
r22 r27 5 5 Width = 631 6 6 Caption = 'Acronym Decoder' 7 ClientHeight = 4 147 ClientHeight = 421 8 8 ClientWidth = 631 9 9 Menu = MainMenu1 … … 16 16 object ListViewAcronyms: TListView 17 17 Left = 8 18 Height = 3 3318 Height = 340 19 19 Top = 64 20 20 Width = 613 … … 51 51 object CheckBoxExactMath: TCheckBox 52 52 Left = 8 53 Height = 2 853 Height = 24 54 54 Top = 3 55 Width = 1 2955 Width = 104 56 56 Caption = 'Exact match' 57 57 OnChange = CheckBoxExactMathChange -
trunk/Forms/UFormMain.pas
r26 r27 274 274 begin 275 275 FormAcronyms.ShowModal; 276 UpdateInterface; 276 277 end; 277 278 -
trunk/Languages/AcronymDecoder.cs.po
r25 r27 186 186 msgstr "Formát dat:" 187 187 188 #: tformimportformat.aadd.caption 189 #, fuzzy 190 msgctxt "tformimportformat.aadd.caption" 191 msgid "Add" 192 msgstr "Přidat" 193 194 #: tformimportformat.amodify.caption 195 #, fuzzy 196 msgctxt "tformimportformat.amodify.caption" 197 msgid "Modify" 198 msgstr "Upravit" 199 200 #: tformimportformat.amovedown.caption 201 msgid "Move down" 202 msgstr "" 203 204 #: tformimportformat.amoveup.caption 205 msgid "Move up" 206 msgstr "" 207 208 #: tformimportformat.aremove.caption 209 #, fuzzy 210 msgctxt "tformimportformat.aremove.caption" 211 msgid "Remove" 212 msgstr "Odebrat" 213 188 214 #: tformimportformat.buttoncancel.caption 189 215 msgctxt "tformimportformat.buttoncancel.caption" … … 206 232 207 233 #: tformimportformat.label2.caption 208 msgid "Acronym start:" 234 #, fuzzy 235 #| msgid "Acronym start:" 236 msgid "Item rules:" 209 237 msgstr "Začátek zkratky:" 210 211 #: tformimportformat.label3.caption212 msgid "Acronym end:"213 msgstr "Konec zkratky:"214 215 #: tformimportformat.label4.caption216 msgid "Meaning start:"217 msgstr "Začátek významu:"218 219 #: tformimportformat.label5.caption220 msgid "Meaning end:"221 msgstr "Konec významu:"222 223 #: tformimportformat.label6.caption224 msgid "Description start:"225 msgstr "Začátek popisu:"226 227 #: tformimportformat.label7.caption228 msgid "Description end:"229 msgstr "Konec popisu:"230 238 231 239 #: tformimportformat.label8.caption … … 236 244 msgid "Block end:" 237 245 msgstr "Konec bloku:" 246 247 #: tformimportformat.listviewitemrules.columns[0].caption 248 msgid "Start string" 249 msgstr "" 250 251 #: tformimportformat.listviewitemrules.columns[1].caption 252 msgid "End string" 253 msgstr "" 254 255 #: tformimportformat.listviewitemrules.columns[2].caption 256 msgid "Action" 257 msgstr "" 258 259 #: tformimportformat.listviewitemrules.columns[3].caption 260 msgid "Variable" 261 msgstr "" 238 262 239 263 #: tformimportformats.aadd.caption … … 262 286 msgstr "Název" 263 287 288 #: tformimportpattern.buttoncancel.caption 289 #, fuzzy 290 msgctxt "tformimportpattern.buttoncancel.caption" 291 msgid "Cancel" 292 msgstr "Zrušit" 293 294 #: tformimportpattern.buttonok.caption 295 #, fuzzy 296 msgctxt "tformimportpattern.buttonok.caption" 297 msgid "Ok" 298 msgstr "Ok" 299 300 #: tformimportpattern.caption 301 msgid "Import pattern" 302 msgstr "" 303 304 #: tformimportpattern.label10.caption 305 msgid "Action:" 306 msgstr "" 307 308 #: tformimportpattern.label11.caption 309 msgid "Variable:" 310 msgstr "" 311 312 #: tformimportpattern.label8.caption 313 msgid "Start string:" 314 msgstr "" 315 316 #: tformimportpattern.label9.caption 317 msgid "End string:" 318 msgstr "" 319 264 320 #: tformimportsource.buttoncancel.caption 265 321 msgctxt "tformimportsource.buttoncancel.caption" … … 531 587 msgstr "Importováno %d nových zkratek." 532 588 589 #: uformimportformat.sremoveimportpattern 590 msgid "Remove import pattern" 591 msgstr "" 592 593 #: uformimportformat.sremoveimportpatternquery 594 msgid "Do you really want to remove selected import patterns?" 595 msgstr "" 596 533 597 #: uformimportformats.simportformatalreadyexists 534 598 msgid "Import format %s already exists!" … … 569 633 msgid "modified" 570 634 msgstr "upraveno" 635 -
trunk/Languages/AcronymDecoder.po
r25 r27 176 176 msgstr "" 177 177 178 #: tformimportformat.aadd.caption 179 msgctxt "TFORMIMPORTFORMAT.AADD.CAPTION" 180 msgid "Add" 181 msgstr "" 182 183 #: tformimportformat.amodify.caption 184 msgctxt "TFORMIMPORTFORMAT.AMODIFY.CAPTION" 185 msgid "Modify" 186 msgstr "" 187 188 #: tformimportformat.amovedown.caption 189 msgid "Move down" 190 msgstr "" 191 192 #: tformimportformat.amoveup.caption 193 msgid "Move up" 194 msgstr "" 195 196 #: tformimportformat.aremove.caption 197 msgctxt "TFORMIMPORTFORMAT.AREMOVE.CAPTION" 198 msgid "Remove" 199 msgstr "" 200 178 201 #: tformimportformat.buttoncancel.caption 179 202 msgctxt "TFORMIMPORTFORMAT.BUTTONCANCEL.CAPTION" … … 196 219 197 220 #: tformimportformat.label2.caption 198 msgid "Acronym start:" 199 msgstr "" 200 201 #: tformimportformat.label3.caption 202 msgid "Acronym end:" 203 msgstr "" 204 205 #: tformimportformat.label4.caption 206 msgid "Meaning start:" 207 msgstr "" 208 209 #: tformimportformat.label5.caption 210 msgid "Meaning end:" 211 msgstr "" 212 213 #: tformimportformat.label6.caption 214 msgid "Description start:" 215 msgstr "" 216 217 #: tformimportformat.label7.caption 218 msgid "Description end:" 221 msgid "Item rules:" 219 222 msgstr "" 220 223 … … 225 228 #: tformimportformat.label9.caption 226 229 msgid "Block end:" 230 msgstr "" 231 232 #: tformimportformat.listviewitemrules.columns[0].caption 233 msgid "Start string" 234 msgstr "" 235 236 #: tformimportformat.listviewitemrules.columns[1].caption 237 msgid "End string" 238 msgstr "" 239 240 #: tformimportformat.listviewitemrules.columns[2].caption 241 msgid "Action" 242 msgstr "" 243 244 #: tformimportformat.listviewitemrules.columns[3].caption 245 msgid "Variable" 227 246 msgstr "" 228 247 … … 252 271 msgstr "" 253 272 273 #: tformimportpattern.buttoncancel.caption 274 msgctxt "TFORMIMPORTPATTERN.BUTTONCANCEL.CAPTION" 275 msgid "Cancel" 276 msgstr "" 277 278 #: tformimportpattern.buttonok.caption 279 msgctxt "TFORMIMPORTPATTERN.BUTTONOK.CAPTION" 280 msgid "Ok" 281 msgstr "" 282 283 #: tformimportpattern.caption 284 msgid "Import pattern" 285 msgstr "" 286 287 #: tformimportpattern.label10.caption 288 msgid "Action:" 289 msgstr "" 290 291 #: tformimportpattern.label11.caption 292 msgid "Variable:" 293 msgstr "" 294 295 #: tformimportpattern.label8.caption 296 msgid "Start string:" 297 msgstr "" 298 299 #: tformimportpattern.label9.caption 300 msgid "End string:" 301 msgstr "" 302 254 303 #: tformimportsource.buttoncancel.caption 255 304 msgctxt "TFORMIMPORTSOURCE.BUTTONCANCEL.CAPTION" … … 521 570 msgstr "" 522 571 572 #: uformimportformat.sremoveimportpattern 573 msgid "Remove import pattern" 574 msgstr "" 575 576 #: uformimportformat.sremoveimportpatternquery 577 msgid "Do you really want to remove selected import patterns?" 578 msgstr "" 579 523 580 #: uformimportformats.simportformatalreadyexists 524 581 msgid "Import format %s already exists!" -
trunk/UAcronym.pas
r25 r27 109 109 end; 110 110 111 TImportPattern = record 111 TImportPatternFlag = (ipfNone, ipfNewItem, ipfSkip); 112 TImportVariable = (ivNone, ivAcronym, ivMeaning, ivDescription); 113 114 { TImportPattern } 115 116 TImportPattern = class 112 117 StartString: string; 113 118 EndString: string; 114 NewItem: Boolean; 119 Variable: TImportVariable; 120 Flag: TImportPatternFlag; 121 procedure Assign(Source: TImportPattern); 122 procedure SaveToNode(Node: TDOMNode); 123 procedure LoadFromNode(Node: TDOMNode); 124 end; 125 126 { TImportPatterns } 127 128 TImportPatterns = class(TObjectList) 129 procedure SaveToNode(Node: TDOMNode); 130 procedure LoadFromNode(Node: TDOMNode); 115 131 end; 116 132 … … 121 137 Name: string; 122 138 Block: TImportPattern; 123 Acronym: TImportPattern; 124 Meaning: TImportPattern; 125 Description: TImportPattern; 139 ItemPatterns: TImportPatterns; 126 140 Formats: TImportFormats; 127 141 procedure Assign(Source: TImportFormat); 128 142 procedure SaveToNode(Node: TDOMNode); 129 143 procedure LoadFromNode(Node: TDOMNode); 144 constructor Create; 145 destructor Destroy; override; 130 146 end; 131 147 … … 143 159 144 160 TImportSource = class 161 private 162 procedure DoPassword(Sender: TObject; var RepeatRequest : Boolean); 163 public 145 164 Name: string; 146 165 URL: string; … … 148 167 LastTime: TDateTime; 149 168 Sources: TImportSources; 169 function DownloadHTTP(URL: string; Stream: TStream): Boolean; 150 170 procedure Process; 151 171 procedure Assign(Source: TImportSource); … … 189 209 function AcronymComparer(Item1, Item2: Pointer): Integer; 190 210 211 const 212 ImportVariableString: array [TImportVariable] of string = ('None', 'Acronym', 213 'Meaning', 'Description'); 214 ImportPatternFlagString: array [TImportPatternFlag] of string = ('None', 'New item', 215 'Skip'); 216 191 217 192 218 implementation … … 195 221 SWrongFileFormat = 'Wrong file format'; 196 222 223 197 224 function AcronymComparer(Item1, Item2: Pointer): Integer; 198 225 begin … … 200 227 end; 201 228 202 function DownloadHTTP(URL: string; Stream: TStream): Boolean; 229 { TImportPatterns } 230 231 procedure TImportPatterns.SaveToNode(Node: TDOMNode); 232 var 233 I: Integer; 234 NewNode2: TDOMNode; 235 begin 236 for I := 0 to Count - 1 do 237 with TImportPattern(Items[I]) do begin 238 NewNode2 := Node.OwnerDocument.CreateElement('Pattern'); 239 Node.AppendChild(NewNode2); 240 SaveToNode(NewNode2); 241 end; 242 end; 243 244 procedure TImportPatterns.LoadFromNode(Node: TDOMNode); 245 var 246 Node2: TDOMNode; 247 NewItem: TImportPattern; 248 begin 249 Count := 0; 250 Node2 := Node.FirstChild; 251 while Assigned(Node2) and (Node2.NodeName = 'Pattern') do begin 252 NewItem := TImportPattern.Create; 253 NewItem.LoadFromNode(Node2); 254 Add(NewItem); 255 Node2 := Node2.NextSibling; 256 end; 257 end; 258 259 { TImportPattern } 260 261 procedure TImportPattern.Assign(Source: TImportPattern); 262 begin 263 StartString := Source.StartString; 264 EndString := Source.EndString; 265 Variable := Source.Variable; 266 Flag := Source.Flag; 267 end; 268 269 procedure TImportPattern.SaveToNode(Node: TDOMNode); 270 begin 271 WriteString(Node, 'StartString', StartString); 272 WriteString(Node, 'EndString', EndString); 273 WriteInteger(Node, 'Variable', Integer(Variable)); 274 WriteInteger(Node, 'Flag', Integer(Flag)); 275 end; 276 277 procedure TImportPattern.LoadFromNode(Node: TDOMNode); 278 begin 279 StartString := ReadString(Node, 'StartString', ''); 280 EndString := ReadString(Node, 'EndString', ''); 281 Variable := TImportVariable(ReadInteger(Node, 'Variable', 0)); 282 Flag := TImportPatternFlag(ReadInteger(Node, 'Flag', 0)); 283 end; 284 285 procedure TImportSource.DoPassword(Sender: TObject; var RepeatRequest: Boolean); 286 begin 287 if TFPHttpClient(Sender).Password = '' then begin 288 TFPHttpClient(Sender).UserName := 'test'; 289 TFPHttpClient(Sender).Password := 'test'; 290 RepeatRequest := True; 291 end else RepeatRequest := False; 292 end; 293 294 function TImportSource.DownloadHTTP(URL: string; Stream: TStream): Boolean; 203 295 var 204 296 HTTPClient: TFPHTTPClient; 205 297 begin 206 298 HTTPClient := TFPHttpClient.Create(nil); 299 HTTPClient.OnPassword := DoPassword; 207 300 HTTPClient.Get(URL, Stream); 208 301 HTTPClient.Free; … … 232 325 233 326 procedure TImportFormat.Assign(Source: TImportFormat); 327 var 328 I: Integer; 234 329 begin 235 330 Name := Source.Name; 236 331 Block.StartString := Source.Block.StartString; 237 332 Block.EndString := Source.Block.EndString; 238 Acronym.StartString := Source.Acronym.StartString; 239 Acronym.EndString := Source.Acronym.EndString; 240 Meaning.StartString := Source.Meaning.StartString; 241 Meaning.EndString := Source.Meaning.EndString; 242 Description.StartString := Source.Description.StartString; 243 Description.EndString := Source.Description.EndString; 333 while ItemPatterns.Count < Source.ItemPatterns.Count do 334 ItemPatterns.Add(TImportPattern.Create); 335 if ItemPatterns.Count > Source.ItemPatterns.Count then 336 ItemPatterns.Count := Source.ItemPatterns.Count; 337 for I := 0 to ItemPatterns.Count - 1 do begin 338 TImportPattern(ItemPatterns[I]).Assign(TImportPattern(Source.ItemPatterns[I])); 339 end; 244 340 end; 245 341 246 342 procedure TImportFormat.SaveToNode(Node: TDOMNode); 343 var 344 NewNode: TDOMNode; 247 345 begin 248 346 WriteInteger(Node, 'Id', Id); … … 250 348 WriteString(Node, 'BlockStartString', Block.StartString); 251 349 WriteString(Node, 'BlockEndString', Block.EndString); 252 WriteString(Node, 'AcronymStartString', Acronym.StartString); 253 WriteString(Node, 'AcronymEndString', Acronym.EndString); 254 WriteString(Node, 'MeaningStartString', Meaning.StartString); 255 WriteString(Node, 'MeaningEndString', Meaning.EndString); 256 WriteString(Node, 'DescriptionStartString', Description.StartString); 257 WriteString(Node, 'DescriptionEndString', Description.EndString); 350 351 NewNode := Node.OwnerDocument.CreateElement('Patterns'); 352 Node.AppendChild(NewNode); 353 ItemPatterns.SaveToNode(NewNode); 258 354 end; 259 355 260 356 procedure TImportFormat.LoadFromNode(Node: TDOMNode); 357 var 358 NewNode: TDOMNode; 261 359 begin 262 360 Id := ReadInteger(Node, 'Id', 0); … … 264 362 Block.StartString := ReadString(Node, 'BlockStartString', ''); 265 363 Block.EndString := ReadString(Node, 'BlockEndString', ''); 266 Acronym.StartString := ReadString(Node, 'AcronymStartString', ''); 267 Acronym.EndString := ReadString(Node, 'AcronymEndString', ''); 268 Meaning.StartString := ReadString(Node, 'MeaningStartString', ''); 269 Meaning.EndString := ReadString(Node, 'MeaningEndString', ''); 270 Description.StartString := ReadString(Node, 'DescriptionStartString', ''); 271 Description.EndString := ReadString(Node, 'DescriptionEndString', ''); 364 365 NewNode := Node.FindNode('Patterns'); 366 if Assigned(NewNode) then 367 ItemPatterns.LoadFromNode(NewNode); 368 end; 369 370 constructor TImportFormat.Create; 371 begin 372 Block := TImportPattern.Create; 373 ItemPatterns := TImportPatterns.Create; 374 end; 375 376 destructor TImportFormat.Destroy; 377 begin 378 Block.Free; 379 ItemPatterns.Free; 380 inherited Destroy; 272 381 end; 273 382 … … 390 499 Stream: TMemoryStream; 391 500 S: string; 501 SS: string; 392 502 NewAcronym: TAcronymEntry; 393 503 P: Integer; 394 NewName: string; 504 Q: Integer; 505 I: Integer; 506 T: string; 507 LastLength: Integer; 395 508 begin 396 509 Stream := TMemoryStream.Create; … … 401 514 SetLength(S, Stream.Size); 402 515 Stream.Read(S[1], Length(S)); 516 517 // Find main block 403 518 if Format.Block.StartString <> '' then begin 404 519 P := Pos(Format.Block.StartString, S); … … 412 527 end; 413 528 529 // Remove unneeded items 414 530 repeat 415 P := Pos(Format.Acronym.StartString, S); 416 if P > 0 then begin 417 // Acronym 418 Delete(S, 1, P + Length(Format.Acronym.StartString) - 1); 419 P := Pos(Format.Acronym.EndString, S); 420 NewName := Trim(StripHTML(Copy(S, 1, P - 1))); 421 if NewName <> '' then NewAcronym.Name := NewName; 422 Delete(S, 1, P + Length(Format.Acronym.EndString) - 1); 423 424 // Meaning 425 if Length(Format.Meaning.StartString) > 0 then begin 426 P := Pos(Format.Meaning.StartString, S); 427 Delete(S, 1, P + Length(Format.Meaning.StartString) - 1); 531 LastLength := Length(S); 532 for I := 0 to Format.ItemPatterns.Count - 1 do 533 with TImportPattern(Format.ItemPatterns[I]) do 534 if Flag = ipfSkip then begin 535 P := Pos(StartString, S); 536 if P > 0 then begin 537 SS := Copy(S, P + Length(StartString), Length(S)); 538 Q := Pos(EndString, SS); 539 if Q > 0 then begin 540 Delete(S, P, Q + Length(EndString) + Length(StartString) - 1); 541 end; 428 542 end; 429 P := Pos(Format.Meaning.EndString, S); 430 NewAcronym.Meaning := Trim(StripHTML(Copy(S, 1, P - 1))); 431 Delete(S, 1, P + Length(Format.Meaning.EndString) - 1); 432 Sources.AcronymDb.AddAcronym(NewAcronym.Name, NewAcronym.Meaning); 433 end else Break; 434 until False; 543 end; 544 until Length(S) = LastLength; 545 546 // Find items 547 repeat 548 LastLength := Length(S); 549 for I := 0 to Format.ItemPatterns.Count - 1 do 550 with TImportPattern(Format.ItemPatterns[I]) do 551 if Flag <> ipfSkip then begin 552 if Length(StartString) > 0 then begin 553 P := Pos(StartString, S); 554 if P > 0 then Delete(S, 1, P + Length(StartString) - 1); 555 end; 556 557 if ((Length(StartString) > 0) and (P > 0)) or (Length(StartString) = 0) then begin 558 P := Pos(EndString, S); 559 T := StripHTML(Copy(S, 1, P - 1)); 560 T := StringReplace(T, '"', '"', [rfReplaceAll]); 561 T := StringReplace(T, '™', 'TM', [rfReplaceAll]); 562 T := StringReplace(T, '&', '&', [rfReplaceAll]); 563 T := Trim(T); 564 case Variable of 565 ivAcronym: NewAcronym.Name := T; 566 ivMeaning: NewAcronym.Meaning := T; 567 end; 568 Delete(S, 1, P + Length(EndString) - 1); 569 570 if (Flag = ipfNewItem) and (Trim(NewAcronym.Name) <> '') and 571 (Trim(NewAcronym.Meaning) <> '') then 572 Sources.AcronymDb.AddAcronym(NewAcronym.Name, NewAcronym.Meaning); 573 end; 574 end; 575 until Length(S) = LastLength; 435 576 end; 436 577 finally
Note:
See TracChangeset
for help on using the changeset viewer.