Changeset 145
- Timestamp:
- Jan 24, 2017, 1:55:43 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormCategories.lfm
r123 r145 1 1 object FormCategories: TFormCategories 2 Left = 5 922 Left = 516 3 3 Height = 429 4 Top = 4 904 Top = 439 5 5 Width = 784 6 6 Caption = 'Acronym categories' … … 11 11 OnShow = FormShow 12 12 Position = poScreenCenter 13 LCLVersion = '1.6. 0.4'13 LCLVersion = '1.6.2.0' 14 14 object ListViewCategories: TListView 15 15 Left = 4 … … 19 19 Align = alClient 20 20 BorderSpacing.Around = 4 21 Checkboxes = True 21 22 Columns = < 22 23 item … … 35 36 TabOrder = 0 36 37 ViewStyle = vsReport 38 OnChange = ListViewCategoriesChange 37 39 OnData = ListViewCategoriesData 38 40 OnDblClick = ListViewCategoriesDblClick … … 93 95 OnExecute = ASelectAllExecute 94 96 ShortCut = 16449 97 end 98 object AEnable: TAction 99 Caption = 'Enable' 100 OnExecute = AEnableExecute 101 end 102 object ADisable: TAction 103 Caption = 'Disable' 104 OnExecute = ADisableExecute 95 105 end 96 106 end … … 219 229 Action = ASelectAll 220 230 end 231 object MenuItem5: TMenuItem 232 Caption = '-' 233 end 234 object MenuItem6: TMenuItem 235 Action = AEnable 236 end 237 object MenuItem7: TMenuItem 238 Action = ADisable 239 end 240 end 241 object ListViewSort1: TListViewSort 242 ListView = ListViewCategories 243 OnCompareItem = ListViewSort1CompareItem 244 OnFilter = ListViewSort1Filter 245 Column = 0 246 Order = soNone 247 left = 536 248 top = 184 221 249 end 222 250 end -
trunk/Forms/UFormCategories.lrt
r123 r145 7 7 TFORMCATEGORIES.AMODIFY.CAPTION=Modify 8 8 TFORMCATEGORIES.ASELECTALL.CAPTION=Select all 9 TFORMCATEGORIES.AENABLE.CAPTION=Enable 10 TFORMCATEGORIES.ADISABLE.CAPTION=Disable 11 TFORMCATEGORIES.MENUITEM5.CAPTION=- -
trunk/Forms/UFormCategories.pas
r123 r145 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 ActnList, Menus, UAcronym ;9 ActnList, Menus, UAcronym, UListViewSort; 10 10 11 11 type … … 15 15 TFormCategories = class(TForm) 16 16 AAdd: TAction; 17 AEnable: TAction; 18 ADisable: TAction; 17 19 ASelectAll: TAction; 18 20 ARemove: TAction; … … 20 22 ActionList1: TActionList; 21 23 ListViewCategories: TListView; 24 ListViewSort1: TListViewSort; 22 25 MenuItem1: TMenuItem; 23 26 MenuItem2: TMenuItem; 24 27 MenuItem3: TMenuItem; 25 28 MenuItem4: TMenuItem; 29 MenuItem5: TMenuItem; 30 MenuItem6: TMenuItem; 31 MenuItem7: TMenuItem; 26 32 PopupMenuCategory: TPopupMenu; 27 33 ToolBar1: TToolBar; … … 30 36 ToolButton3: TToolButton; 31 37 procedure AAddExecute(Sender: TObject); 38 procedure ADisableExecute(Sender: TObject); 39 procedure AEnableExecute(Sender: TObject); 32 40 procedure AModifyExecute(Sender: TObject); 33 41 procedure ARemoveExecute(Sender: TObject); … … 36 44 procedure FormCreate(Sender: TObject); 37 45 procedure FormShow(Sender: TObject); 46 procedure ListViewCategoriesChange(Sender: TObject; Item: TListItem; 47 Change: TItemChange); 38 48 procedure ListViewCategoriesData(Sender: TObject; Item: TListItem); 39 49 procedure ListViewCategoriesDblClick(Sender: TObject); … … 41 51 procedure ListViewCategoriesSelectItem(Sender: TObject; Item: TListItem; 42 52 Selected: Boolean); 53 function ListViewSort1CompareItem(Item1, Item2: TObject): Integer; 54 procedure ListViewSort1Filter(ListViewSort: TListViewSort); 43 55 private 44 56 { private declarations } … … 73 85 UpdateList; 74 86 Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI); 87 end; 88 89 procedure TFormCategories.ListViewCategoriesChange(Sender: TObject; 90 Item: TListItem; Change: TItemChange); 91 begin 92 if Assigned(Item) and (Change = ctState) then begin 93 TAcronymCategory(Item.Data).Enabled := Item.Checked; 94 Core.AcronymDb.Modified := True; 95 end; 75 96 end; 76 97 … … 87 108 end else ShowMessage(Format(SCategoryAlreadyExists, [S])); 88 109 end; 110 end; 111 112 procedure TFormCategories.ADisableExecute(Sender: TObject); 113 var 114 I: Integer; 115 begin 116 for I := ListViewCategories.Items.Count - 1 downto 0 do 117 if ListViewCategories.Items[I].Selected then begin 118 TAcronymCategory(ListViewCategories.Items[I].Data).Enabled := False; 119 Core.AcronymDb.Modified := True; 120 end; 121 UpdateList; 122 end; 123 124 procedure TFormCategories.AEnableExecute(Sender: TObject); 125 var 126 I: Integer; 127 begin 128 for I := ListViewCategories.Items.Count - 1 downto 0 do 129 if ListViewCategories.Items[I].Selected then begin 130 TAcronymCategory(ListViewCategories.Items[I].Data).Enabled := True; 131 Core.AcronymDb.Modified := True; 132 end; 133 UpdateList; 89 134 end; 90 135 … … 145 190 procedure TFormCategories.ListViewCategoriesData(Sender: TObject; Item: TListItem); 146 191 begin 147 if Item.Index < Core.AcronymDb.Categories.Count then148 with TAcronymCategory( Core.AcronymDb.Categories[Item.Index]) do begin192 if Item.Index < ListViewSort1.List.Count then 193 with TAcronymCategory(ListViewSort1.List[Item.Index]) do begin 149 194 Item.Caption := Name; 150 Item.Data := Core.AcronymDb.Categories[Item.Index];195 Item.Data := ListViewSort1.List[Item.Index]; 151 196 Item.SubItems.Add(IntToStr(AcronymMeanings.Count)); 197 Item.Checked := Enabled; 152 198 end; 153 199 end; … … 170 216 end; 171 217 218 function TFormCategories.ListViewSort1CompareItem(Item1, Item2: TObject 219 ): Integer; 220 begin 221 Result := 0; 222 if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin 223 with ListViewSort1 do 224 case Column of 225 0: Result := CompareString(TAcronymCategory(Item1).Name, TAcronymCategory(Item2).Name); 226 1: Result := CompareInteger(TAcronymCategory(Item1).AcronymMeanings.Count, TAcronymCategory(Item2).AcronymMeanings.Count); 227 end; 228 if ListViewSort1.Order = soDown then Result := -Result; 229 end else Result := 0; 230 end; 231 232 procedure TFormCategories.ListViewSort1Filter(ListViewSort: TListViewSort); 233 begin 234 Core.AcronymDb.Categories.AssignToList(ListViewSort1.List); 235 end; 236 172 237 procedure TFormCategories.UpdateList; 173 238 begin 239 ListViewSort1.Refresh; 174 240 ListViewCategories.Items.Count := Core.AcronymDb.Categories.Count; 175 241 ListViewCategories.Refresh; -
trunk/Forms/UFormImportSources.lfm
r123 r145 11 11 OnShow = FormShow 12 12 Position = poScreenCenter 13 LCLVersion = '1.6. 0.4'13 LCLVersion = '1.6.2.0' 14 14 object ToolBar1: TToolBar 15 15 Left = 0 … … 296 296 } 297 297 end 298 object MenuItem7: TMenuItem 299 Caption = '-' 300 end 298 301 object MenuItem5: TMenuItem 299 302 Action = AEnable -
trunk/Forms/UFormImportSources.lrt
r123 r145 12 12 TFORMIMPORTSOURCES.AENABLE.CAPTION=Enable 13 13 TFORMIMPORTSOURCES.ADISABLE.CAPTION=Disable 14 TFORMIMPORTSOURCES.MENUITEM7.CAPTION=- -
trunk/Forms/UFormImportSources.pas
r123 r145 32 32 MenuItem5: TMenuItem; 33 33 MenuItem6: TMenuItem; 34 MenuItem7: TMenuItem; 34 35 PopupMenuImportSource: TPopupMenu; 35 36 ToolBar1: TToolBar; … … 182 183 if Assigned(Item) and (Change = ctState) then begin 183 184 TImportSource(Item.Data).Enabled := Item.Checked; 185 Core.AcronymDb.Modified := True; 184 186 end; 185 187 end; … … 226 228 begin 227 229 for I := ListView1.Items.Count - 1 downto 0 do 228 if ListView1.Items[I].Selected then 230 if ListView1.Items[I].Selected then begin 229 231 TImportSource(ListView1.Items[I].Data).Enabled := False; 232 Core.AcronymDb.Modified := True; 233 end; 230 234 UpdateList; 231 235 end; … … 236 240 begin 237 241 for I := ListView1.Items.Count - 1 downto 0 do 238 if ListView1.Items[I].Selected then 242 if ListView1.Items[I].Selected then begin 239 243 TImportSource(ListView1.Items[I].Data).Enabled := True; 244 Core.AcronymDb.Modified := True; 245 end; 240 246 UpdateList; 241 247 end; -
trunk/Forms/UFormMain.pas
r144 r145 499 499 procedure TFormMain.ListViewSort1Filter(ListViewSort: TListViewSort); 500 500 begin 501 Core.AcronymDb.AssignToList(ListViewSort1.List );501 Core.AcronymDb.AssignToList(ListViewSort1.List, True); 502 502 FilterList(ListViewSort1.List); 503 503 end; -
trunk/Languages/AcronymDecoder.cs.po
r139 r145 138 138 msgstr "Přidat" 139 139 140 #: tformcategories.adisable.caption 141 msgctxt "tformcategories.adisable.caption" 142 msgid "Disable" 143 msgstr "Zakázat" 144 145 #: tformcategories.aenable.caption 146 msgctxt "tformcategories.aenable.caption" 147 msgid "Enable" 148 msgstr "Povolit" 149 140 150 #: tformcategories.amodify.caption 141 151 msgctxt "tformcategories.amodify.caption" … … 167 177 msgstr "Počet použití" 168 178 179 #: tformcategories.menuitem5.caption 180 msgctxt "tformcategories.menuitem5.caption" 181 msgid "-" 182 msgstr "-" 183 169 184 #: tformcategories.toolbar1.caption 170 185 msgctxt "tformcategories.toolbar1.caption" … … 442 457 443 458 #: tformimportsources.adisable.caption 459 msgctxt "tformimportsources.adisable.caption" 444 460 msgid "Disable" 445 461 msgstr "Zakázat" 446 462 447 463 #: tformimportsources.aenable.caption 464 msgctxt "tformimportsources.aenable.caption" 448 465 msgid "Enable" 449 466 msgstr "Povolit" … … 492 509 msgstr "Datum" 493 510 511 #: tformimportsources.menuitem7.caption 512 msgctxt "tformimportsources.menuitem7.caption" 513 msgid "-" 514 msgstr "-" 515 494 516 #: tformimportsources.toolbar1.caption 495 517 msgctxt "tformimportsources.toolbar1.caption" … … 893 915 msgid "Process import sources" 894 916 msgstr "Zpracovat zdroje importu" 895 -
trunk/Languages/AcronymDecoder.po
r139 r145 128 128 msgstr "" 129 129 130 #: tformcategories.adisable.caption 131 msgctxt "TFORMCATEGORIES.ADISABLE.CAPTION" 132 msgid "Disable" 133 msgstr "" 134 135 #: tformcategories.aenable.caption 136 msgctxt "TFORMCATEGORIES.AENABLE.CAPTION" 137 msgid "Enable" 138 msgstr "" 139 130 140 #: tformcategories.amodify.caption 131 141 msgctxt "TFORMCATEGORIES.AMODIFY.CAPTION" … … 157 167 msgstr "" 158 168 169 #: tformcategories.menuitem5.caption 170 msgctxt "TFORMCATEGORIES.MENUITEM5.CAPTION" 171 msgid "-" 172 msgstr "" 173 159 174 #: tformcategories.toolbar1.caption 160 175 msgctxt "TFORMCATEGORIES.TOOLBAR1.CAPTION" … … 432 447 433 448 #: tformimportsources.adisable.caption 449 msgctxt "tformimportsources.adisable.caption" 434 450 msgid "Disable" 435 451 msgstr "" 436 452 437 453 #: tformimportsources.aenable.caption 454 msgctxt "tformimportsources.aenable.caption" 438 455 msgid "Enable" 439 456 msgstr "" … … 482 499 msgstr "" 483 500 501 #: tformimportsources.menuitem7.caption 502 msgctxt "TFORMIMPORTSOURCES.MENUITEM7.CAPTION" 503 msgid "-" 504 msgstr "" 505 484 506 #: tformimportsources.toolbar1.caption 485 507 msgctxt "TFORMIMPORTSOURCES.TOOLBAR1.CAPTION" -
trunk/UAcronym.pas
r113 r145 75 75 AcronymMeanings: TAcronymMeanings; 76 76 ImportSources: TImportSources; 77 Enabled: Boolean; 77 78 procedure SaveToNode(Node: TDOMNode); 78 79 procedure LoadFromNode(Node: TDOMNode); … … 96 97 procedure AssignFromStrings(Strings: TStrings); 97 98 procedure AddFromStrings(Strings: TStrings); 99 procedure AssignToList(List: TListObject); 98 100 function GetString: string; 99 101 procedure UpdateLinkImportSources(Item: TImportSource); 100 102 procedure UpdateLinkAcronymMeanings(Item: TAcronymMeaning); 103 function IsAnyEnabled: Boolean; 101 104 end; 102 105 … … 230 233 procedure RemoveMeaning(Meaning: TAcronymMeaning); 231 234 procedure RemoveAcronym(AcronymName, MeaningName: string); 232 procedure AssignToList(List: TListObject );235 procedure AssignToList(List: TListObject; EnabledCategoryOnly: Boolean = False); 233 236 end; 234 237 … … 1300 1303 end; 1301 1304 1305 procedure TAcronymCategories.AssignToList(List: TListObject); 1306 var 1307 I: Integer; 1308 begin 1309 List.Clear; 1310 for I := 0 to Count - 1 do 1311 List.Add(TAcronymCategory(Items[I])) 1312 end; 1313 1302 1314 function TAcronymCategories.GetString: string; 1303 1315 var … … 1328 1340 end; 1329 1341 1342 function TAcronymCategories.IsAnyEnabled: Boolean; 1343 var 1344 I: Integer; 1345 begin 1346 Result := False; 1347 for I := 0 to Count - 1 do 1348 if TAcronymCategory(Items[I]).Enabled then begin 1349 Result := True; 1350 Break; 1351 end; 1352 end; 1330 1353 1331 1354 { TAcronym } … … 1371 1394 WriteString(Node, 'Name', Name); 1372 1395 WriteInteger(Node, 'Id', Id); 1396 WriteBoolean(Node, 'Enabled', Enabled); 1373 1397 end; 1374 1398 … … 1377 1401 Name := ReadString(Node, 'Name', ''); 1378 1402 Id := ReadInteger(Node, 'Id', 0); 1403 Enabled := ReadBoolean(Node, 'Enabled', True); 1379 1404 end; 1380 1405 1381 1406 constructor TAcronymCategory.Create; 1382 1407 begin 1408 Id := 0; 1409 Name := ''; 1410 Enabled := True; 1383 1411 AcronymMeanings := TAcronymMeanings.Create(False); 1384 1412 ImportSources := TImportSources.Create(False); … … 1657 1685 end; 1658 1686 1659 procedure TAcronymDb.AssignToList(List: TListObject );1687 procedure TAcronymDb.AssignToList(List: TListObject; EnabledCategoryOnly: Boolean = False); 1660 1688 var 1661 1689 I: Integer; … … 1666 1694 with TAcronym(Acronyms[I]) do begin 1667 1695 for J := 0 to Meanings.Count - 1 do 1668 with TAcronymMeaning(Meanings[J]) do begin 1669 List.Add(TAcronymMeaning(Meanings[J])) 1696 with TAcronymMeaning(Meanings[J]) do 1697 if not EnabledCategoryOnly or (EnabledCategoryOnly and Categories.IsAnyEnabled) then begin 1698 List.Add(TAcronymMeaning(Meanings[J])); 1670 1699 end; 1671 1700 end;
Note:
See TracChangeset
for help on using the changeset viewer.