-
Notifications
You must be signed in to change notification settings - Fork 24
/
ImportList.pas
690 lines (642 loc) · 23.5 KB
/
ImportList.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
{
Copyright (C) 2006-2010 Matteo Salvi of SalvadorSoftware
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
}
unit ImportList;
interface
uses
Windows, SysUtils, Graphics, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls,
VirtualTrees, AppConfig, DOM, XMLRead, ulEnumerations, ulDatabase, DateUtils,
Classes;
type
TImportListToTree = function(Tree: TVirtualStringTree;Node: TDOMNode;Parent: PVirtualNode): PVirtualNode of object;
{ TfrmImportList }
TfrmImportList = class(TForm)
bvl1: TBevel;
bvl2: TBevel;
nbImport: TNotebook;
pgLaunchers: TPage;
pgSettings: TPage;
pgItems: TPage;
pgProgress: TPage;
rgrpLauncher: TRadioGroup;
gbElements: TGroupBox;
cbImportList: TCheckBox;
cbImportSettings: TCheckBox;
gbFile: TGroupBox;
lblFile: TLabel;
btnBrowse: TButton;
edtPathList: TEdit;
vstListImp: TVirtualStringTree;
btnSelectAll: TButton;
btnDeselectAll: TButton;
btnBack: TButton;
btnNext: TButton;
btnCancel: TButton;
pnlHeader: TPanel;
lblTitle: TLabel;
OpenDialog1: TOpenDialog;
pbImport: TProgressBar;
lblItems: TLabel;
imgList: TImage;
lblList: TLabel;
lblLauncher: TLabel;
imgSettings: TImage;
lblSettings: TLabel;
procedure btnDeselectAllClick(Sender: TObject);
procedure btnSelectAllClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure pgItemsBeforeShow(ASender: TObject; ANewPage: TPage;
ANewIndex: Integer);
procedure pgLaunchersBeforeShow(ASender: TObject; ANewPage: TPage;
ANewIndex: Integer);
procedure pgProgressBeforeShow(ASender: TObject; ANewPage: TPage;
ANewIndex: Integer);
procedure pgSettingsBeforeShow(ASender: TObject; ANewPage: TPage;
ANewIndex: Integer);
procedure vstListImpFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure vstListImpGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
procedure FormCreate(Sender: TObject);
procedure btnBrowseClick(Sender: TObject);
procedure vstListImpGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer);
procedure vstListImpExpanding(Sender: TBaseVirtualTree; Node: PVirtualNode;
var Allowed: Boolean);
procedure btnBackClick(Sender: TObject);
procedure btnNextClick(Sender: TObject);
procedure edtPathListEnter(Sender: TObject);
procedure cbImportListClick(Sender: TObject);
private
{ Private declarations }
procedure ImportSettingsInASuite;
procedure ImportListInASuite;
procedure SelectNextPage(Notebook: TNotebook);
procedure SelectPrevPage(Notebook: TNotebook);
function TreeImp2Tree(TreeImp, Tree: TVirtualStringTree): Boolean;
function GetNumberNodeImp(Sender: TBaseVirtualTree): Integer;
procedure PopulateTree(Tree: TVirtualStringTree;FilePath: String);
function ASuite1NodeToTree(Tree: TVirtualStringTree;XMLNode: TDOMNode;
Parent: PVirtualNode): PVirtualNode;
function wppLauncherNodeToTree(Tree: TVirtualStringTree;XMLNode: TDOMNode;
Parent: PVirtualNode): PVirtualNode;
procedure XMLToTree(Tree: TVirtualStringTree;CallBack: TImportListToTree;
XMLDoc: TXMLDocument);
procedure CheckAllItems(State: TCheckState);
function InternalImportOptions: Boolean;
public
{ Public declarations }
end;
var
frmImportList : TfrmImportList;
ConfigCache : Boolean;
implementation
{$R *.lfm}
uses
Main, ulNodeDataTypes, ulCommonUtils, ulTreeView, udImages, ulAppConfig;
procedure TfrmImportList.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure TfrmImportList.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
//Restore cache option
Config.Cache := ConfigCache;
end;
procedure TfrmImportList.pgItemsBeforeShow(ASender: TObject; ANewPage: TPage;
ANewIndex: Integer);
begin
//If cbImportList is checked, import selected list in VirtualTree
if (cbImportList.Checked) then
begin
lblTitle.Caption := msgImportTitle3;
btnNext.Caption := msgImport;
//Import list in temporary vst
PopulateTree(vstListImp, edtPathList.Text);
end
else //Else next page
SelectNextPage(nbImport);
end;
procedure TfrmImportList.pgLaunchersBeforeShow(ASender: TObject;
ANewPage: TPage; ANewIndex: Integer);
begin
lblTitle.Caption := msgImportTitle1;
btnNext.Caption := msgNext;
btnNext.Enabled := True;
end;
procedure TfrmImportList.pgProgressBeforeShow(ASender: TObject;
ANewPage: TPage; ANewIndex: Integer);
begin
btnBack.Enabled := False;
btnNext.Enabled := False;
try
lblTitle.Caption := msgImportProgress;
//Which launcher?
case rgrpLauncher.ItemIndex of
0,1: lblLauncher.Caption := Format(lblLauncher.Caption,['ASuite']);
2: lblLauncher.Caption := Format(lblLauncher.Caption,['winPenPack Launcher']);
end;
//Set some label and progress bar visibile
lblList.Enabled := cbImportList.Checked;
lblItems.Visible := cbImportList.Checked;
pbImport.Visible := cbImportList.Checked;
lblSettings.Enabled := cbImportSettings.Checked;
//Import list
ImportListInASuite;
ImportSettingsInASuite;
finally
btnNext.Enabled := True;
btnNext.Caption := msgClose;
Self.Show;
end;
end;
procedure TfrmImportList.pgSettingsBeforeShow(ASender: TObject;
ANewPage: TPage; ANewIndex: Integer);
begin
lblTitle.Caption := msgImportTitle2;
btnNext.Enabled := (edtPathList.Text <> '') and FileExists(edtPathList.Text);
btnNext.Caption := msgNext;
//Change opendialog's filter depending on chosen launcher
case rgrpLauncher.ItemIndex of
0: OpenDialog1.Filter:= Format('ASuite 2.x List (*%s, *%s)|*%s;*%s', [EXT_SQL,EXT_SQLBCK,EXT_SQL,EXT_SQLBCK]);
1: OpenDialog1.Filter:= Format('ASuite 1.x List (*%s, *%s)|*%s;*%s', [EXT_XML,EXT_XMLBCK,EXT_XML,EXT_XMLBCK]);
2: OpenDialog1.Filter:= Format('winPenPack 1.x List (*%s, *%s)|*%s;*%s',[EXT_XML,EXT_XMLBCK,EXT_XML,EXT_XMLBCK]);
end;
end;
procedure TfrmImportList.vstListImpFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
NodeData : PBaseData;
begin
//FreeAndNil not imported NodeData
NodeData := Sender.GetNodeData(Node);
if Not((Node.CheckState = csCheckedNormal) or (Node.CheckState = csMixedNormal)) then
FreeAndNil(NodeData.Data);
end;
function TfrmImportList.ASuite1NodeToTree(Tree: TVirtualStringTree;XMLNode: TDOMNode;
Parent: PVirtualNode): PVirtualNode;
var
NodeData : PBaseData;
BaseNodeData : TvBaseNodeData;
begin
Result := nil;
if ((XMLNode.HasAttributes) or (XMLNode.NodeName = 'Separator')) and
((XMLNode.NodeName = 'Software') or (XMLNode.NodeName = 'Category') or
(XMLNode.NodeName = 'Separator')) then
begin
//Create a new XMLNode
//Get item type
if (XMLNode.NodeName = 'Category') then
Result := Tree.AddChild(Parent, TvCategoryNodeData.Create)
else
if (XMLNode.NodeName = 'Software') then
Result := Tree.AddChild(Parent, TvFileNodeData.Create(vtdtFile))
else
if XMLNode.NodeName = 'Separator' then
Result := Tree.AddChild(Parent, TvSeparatorNodeData.Create);
//Add checkbox
Tree.CheckType[Result] := ctTriStateCheckBox;
NodeData := Tree.GetNodeData(Result);
NodeData.pNode := Result;
BaseNodeData := TvBaseNodeData(NodeData.Data);
//Get base properties
if (BaseNodeData.DataType <> vtdtSeparator) then
begin
BaseNodeData.Name := XMLNode.Attributes.Item[0].NodeValue;
BaseNodeData.PathIcon := GetStrPropertyXML(XMLNode, 'PathIcon', '');
BaseNodeData.HideFromMenu := GetBoolPropertyXML(XMLNode, 'HideSoftwareMenu', false);
//Check if it is a software, so get software properties
if (BaseNodeData.DataType = vtdtFile) then
begin
with TvFileNodeData(BaseNodeData) do
begin
NoMRU := GetBoolPropertyXML(XMLNode, 'DontInsertMRU',false);
PathExe := GetStrPropertyXML (XMLNode, 'PathExe', '');
Parameters := GetStrPropertyXML (XMLNode, 'Parameters', '');
WorkingDir := GetStrPropertyXML (XMLNode, 'WorkingDir', '');
WindowState := GetIntPropertyXML (XMLNode, 'WindowState',0);
ShortcutDesktop := GetBoolPropertyXML(XMLNode, 'ShortcutDesktop',false);
ActionOnExe := TActionOnExecution(GetIntPropertyXML(XMLNode, 'ActionOnExe',0));
Autorun := TAutorunType(GetIntPropertyXML(XMLNode, 'Autorun',0));
AutorunPos := GetIntPropertyXML (XMLNode, 'AutorunPosition',0);
end;
end;
end;
end;
end;
procedure TfrmImportList.btnBackClick(Sender: TObject);
begin
SelectPrevPage(nbImport);
btnBack.Enabled := nbImport.PageIndex <> 0;
end;
procedure TfrmImportList.btnBrowseClick(Sender: TObject);
begin
vstListImp.Clear;
OpenDialog1.InitialDir := ExtractFileDir(edtPathList.text);
if (OpenDialog1.Execute) then
begin
edtPathList.text := OpenDialog1.FileName;
btnNext.Enabled := True;
end;
SetCurrentDir(SUITE_WORKING_PATH);
end;
procedure TfrmImportList.btnSelectAllClick(Sender: TObject);
begin
CheckAllItems(csCheckedNormal);
end;
procedure TfrmImportList.cbImportListClick(Sender: TObject);
begin
btnNext.Enabled := ((cbImportList.Checked) or (cbImportSettings.Checked)) and
((edtPathList.Text <> '') and FileExists(edtPathList.Text));
end;
procedure TfrmImportList.ImportSettingsInASuite;
begin
//Import settings
if (cbImportSettings.Checked) then
begin
if InternalImportOptions then
ImagesDM.IcoImages.GetBitmap(IMG_Accept, imgSettings.Picture.Bitmap);
end;
end;
procedure TfrmImportList.ImportListInASuite;
begin
if (cbImportList.Checked) then
begin
//Set progressbar's max
pbImport.Max := GetNumberNodeImp(vstListImp);
try
TreeImp2Tree(vstListImp,frmMain.vstList);
ImagesDM.IcoImages.GetBitmap(IMG_Accept,imgList.Picture.Bitmap);
lblItems.Caption := Format(msgItemsImported,[pbImport.Max]);
except
on E : Exception do
begin
ShowMessageFmt(msgErrGeneric,[E.ClassName,E.Message]);
lblItems.Caption := msgImportFailed;
end;
end;
end;
end;
procedure TfrmImportList.SelectNextPage(Notebook: TNotebook);
begin
Notebook.PageIndex := Notebook.PageIndex + 1;
end;
procedure TfrmImportList.SelectPrevPage(Notebook: TNotebook);
begin
Notebook.PageIndex := Notebook.PageIndex - 1;
end;
procedure TfrmImportList.PopulateTree(Tree: TVirtualStringTree;FilePath: String);
var
DBImp : TDBManager;
XMLDoc : TXMLDocument;
FileName : String;
FileExt : String;
begin
vstListImp.BeginUpdate;
FileName := LowerCase(ExtractFileName(FilePath));
FileExt := ExtractFileExt(FileName);
//ASuite or wppLauncher
if (FileExt = EXT_XML) or (FileExt = EXT_XMLBCK) then
begin
ReadXMLFile(XMLDoc,FilePath);
try
//Identify launcher xml from first node
//ASuite 1.x
if (XMLDoc.FirstChild.NodeName = 'ASuite') then
XMLToTree(vstListImp,ASuite1NodeToTree,XMLDoc)
else //winPenPack Launcher 1.x
if ChangeFileExt(FileName,'') = 'winpenpack' then
XMLToTree(vstListImp,wppLauncherNodeToTree,XMLDoc);
finally
XMLDoc.Free;
end;
end
else //ASuite 2.x
if (FileExt = EXT_SQL) or (FileExt = EXT_SQLBCK) then
begin
DBImp := TDBManager.Create(FilePath);
DBImp.LoadData(Tree, True);
DBImp.Destroy;
end;
vstListImp.EndUpdate;
GetChildNodesIcons(Tree, Tree.RootNode);
end;
function TfrmImportList.wppLauncherNodeToTree(Tree: TVirtualStringTree;XMLNode: TDomNode;
Parent: PVirtualNode): PVirtualNode;
var
NodeData : PBaseData;
BaseNodeData : TvBaseNodeData;
begin
Result := nil;
if ((XMLNode.HasAttributes) or (XMLNode.NodeName = 'separator')) and
((XMLNode.NodeName = 'file') or (XMLNode.NodeName = 'files') or
(XMLNode.NodeName = 'separator')) then
begin
//Create a new XMLNode
//Get item type
if (XMLNode.NodeName = 'files') then
Result := tree.AddChild(Parent, CreateNodeData(vtdtCategory))
else
if (XMLNode.NodeName = 'file') then
Result := tree.AddChild(Parent, CreateNodeData(vtdtFile))
else
if XMLNode.NodeName = 'separator' then
Result := Tree.AddChild(Parent, CreateNodeData(vtdtSeparator));
//Add checkbox
Tree.CheckType[Result] := ctTriStateCheckBox;
NodeData := Tree.GetNodeData(Result);
NodeData.pNode := Result;
BaseNodeData := TvBaseNodeData(NodeData.Data);
//Get base properties
if BaseNodeData.DataType <> vtdtSeparator then
begin
BaseNodeData.Name := XMLNode.Attributes.Item[0].NodeValue;
BaseNodeData.PathIcon := GetStrPropertyXML(XMLNode,'icon','');
BaseNodeData.HideFromMenu := GetBoolPropertyXML(XMLNode, 'HideSoftwareMenu', false);
//Check if it is a software, so get software properties
if (BaseNodeData.DataType = vtdtFile) then
begin
with TvFileNodeData(BaseNodeData) do
begin
NoMRU := GetBoolPropertyXML(XMLNode, 'DontInsertMRU',false);
PathExe := GetStrPropertyXML (XMLNode, 'path','');
Parameters := GetStrPropertyXML (XMLNode, 'parameters','');
WorkingDir := GetStrPropertyXML (XMLNode, 'WorkingDir','');
WindowState := GetIntPropertyXML (XMLNode, 'WindowState',0);
ShortcutDesktop := GetBoolPropertyXML(XMLNode, 'ShortcutDesktop',false);
ActionOnExe := TActionOnExecution(GetIntPropertyXML(XMLNode, 'ActionOnExe',0));
Autorun := TAutorunType(GetIntPropertyXML(XMLNode, 'Autorun',0));
AutorunPos := GetIntPropertyXML(XMLNode, 'AutorunPosition',0);
end;
end;
end;
end;
end;
procedure TfrmImportList.btnDeselectAllClick(Sender: TObject);
begin
CheckAllItems(csUncheckedNormal);
end;
procedure TfrmImportList.btnNextClick(Sender: TObject);
begin
//If PageIndex is not last page, show next page
if nbImport.PageIndex <> (nbImport.PageCount - 1) then
begin
SelectNextPage(nbImport);
btnBack.Enabled := nbImport.PageIndex <> 0;
end
else //Else close import form
Close;
end;
procedure TfrmImportList.FormCreate(Sender: TObject);
begin
vstListImp.NodeDataSize := SizeOf(rBaseData);
vstListImp.Images := ImagesDM.IcoImages;
nbImport.PageIndex := 0;
//Disable cache, so ASuite can't create useless cache icon
ConfigCache := Config.Cache;
Config.Cache := False;
//Set imgList and imgSettings's icon
ImagesDM.IcoImages.GetBitmap(IMG_Cancel,imgList.Picture.Bitmap);
ImagesDM.IcoImages.GetBitmap(IMG_Cancel,imgSettings.Picture.Bitmap);
end;
procedure TfrmImportList.vstListImpExpanding(Sender: TBaseVirtualTree;
Node: PVirtualNode; var Allowed: Boolean);
begin
GetChildNodesIcons(Sender, Node);
end;
procedure TfrmImportList.vstListImpGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer);
var
NodeData : PvBaseNodeData;
begin
NodeData := Sender.GetNodeData(Node);
ImageIndex := NodeData.ImageIndex;
if Column = 1 then
ImageIndex := -1;
end;
procedure TfrmImportList.vstListImpGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
var
NodeData : PBaseData;
I : Byte;
str : string;
begin
NodeData := Sender.GetNodeData(Node);
if NodeData.Data.DataType = vtdtSeparator then
begin
I := 40 - (Length(NodeData.Data.Name));
str := '----------------------';
if I >= 10 then
SetLength(str, I div 2)
else
SetLength(str, 5);
CellText := str + ' ' + NodeData.Data.Name + ' ' + str;
end
else
CellText := StringReplace(NodeData.Data.Name, '&&', '&', [rfIgnoreCase,rfReplaceAll]);
end;
procedure TfrmImportList.XMLToTree(Tree: TVirtualStringTree;CallBack: TImportListToTree;
XMLDoc: TXMLDocument);
var
cXMLNode : TDOMNode;
procedure ProcessNode(XMLNode : TDOMNode;TreeNode : PVirtualNode);
var
cNode : TDOMNode;
begin
if XMLNode = nil then Exit;
//Import xml node in vstListImp
TreeNode := CallBack(vstListImp, XMLNode, TreeNode);
//Next nodes
cNode := XMLNode.FirstChild;
while Assigned(cNode) do
begin
ProcessNode(cNode,TreeNode);
cNode := cNode.NextSibling;
end;
end;
begin
Tree.Clear;
Tree.BeginUpdate;
cXMLNode := XMLDoc.DocumentElement.FirstChild;
while Assigned(cXMLNode) do
begin
ProcessNode(cXMLNode,nil);
cXMLNode := cXMLNode.NextSibling;
end;
Tree.EndUpdate;
end;
procedure TfrmImportList.CheckAllItems(State: TCheckState);
var
tnImp: PVirtualNode;
begin
tnImp := vstListImp.GetFirst;
while Assigned(tnImp) do
begin
vstListImp.CheckState[tnImp] := State;
tnImp := tnImp.NextSibling;
end;
end;
procedure TfrmImportList.edtPathListEnter(Sender: TObject);
begin
btnNext.Enabled := ((Sender as TEdit).Text <> '') and FileExists((Sender as TEdit).Text);
end;
function TfrmImportList.TreeImp2Tree(TreeImp, Tree: TVirtualStringTree): Boolean;
var
tnImp : PVirtualNode;
procedure ProcessTreeItem(tn, tnImp: PVirtualNode);
var
NodeData, NodeDataImp : PBaseData;
begin
if (tnImp = nil) then Exit;
NodeDataImp := TreeImp.GetNodeData(tnImp);
if (tnImp.CheckState = csCheckedNormal) or (tnImp.CheckState = csMixedNormal) then
begin
pbImport.Position := pbImport.Position + 1;
lblItems.Caption := Format(msgProcessingItems, [((pbImport.Position / pbImport.Max) * 100), pbImport.Max]);
Self.Update;
tn := Tree.AddChild(tn);
NodeData := Tree.GetNodeData(tn);
NodeData^ := NodeDataImp^;
with NodeData.Data do
begin
ID := -1;
ParentID := -1;
Position := tn.Index;
UnixAddDate := DateTimeToUnix(Now);
UnixEditDate := NodeData.Data.UnixAddDate;
end;
NodeData.pNode := tn;
end;
tnImp := tnImp.FirstChild;
while Assigned(tnImp) do
begin
ProcessTreeItem(tn, tnImp);
tnImp := tnImp.NextSibling;
end;
end;
begin
Tree.BeginUpdate;
Result := True;
try
tnImp := TreeImp.GetFirst;
while Assigned(tnImp) do
begin
ProcessTreeItem(nil, tnImp);
tnImp := tnImp.NextSibling;
end;
except
Result := False;
end;
Tree.EndUpdate;
end;
function TfrmImportList.GetNumberNodeImp(Sender: TBaseVirtualTree): Integer;
var
NumberNode : Integer;
begin
NumberNode := 0;
Sender.IterateSubtree(nil, IterateSubTreeProcs.IncNumberNode, @NumberNode, [], True);
Result := NumberNode;
end;
function TfrmImportList.InternalImportOptions: Boolean;
var
XMLDoc : TXMLDocument;
DBImp : TDBManager;
Node, tvFontStyle : TDOMNode;
ImportFileExt : String;
begin
Result := False;
try
ImportFileExt := LowerCase(ExtractFileExt(edtPathList.Text));
if (ImportFileExt = EXT_XML) or (ImportFileExt = EXT_XMLBCK) then
begin
ReadXMLFile(XMLDoc, edtPathList.Text);
//ASuite 1.x - wppLauncher
Node := XMLDoc.DocumentElement.FindNode('Option');
//General
Config.StartWithWindows := GetBoolPropertyXML(Node, 'StartOnWindowsStartup', false);
Config.ShowPanelAtStartUp := GetBoolPropertyXML(Node, 'StartUpShowPanel', true);
Config.ShowMenuAtStartUp := GetBoolPropertyXML(Node, 'StartUpShowMenu', false);
//Main Form
Config.CustomTitleString := GetStrPropertyXML(Node, 'CustomTitleString', APP_TITLE);
Config.UseCustomTitle := GetBoolPropertyXML(Node, 'CustomTitle', false);
Config.HideTabSearch := GetBoolPropertyXML(Node, 'HideSearch', false);
//Main Form - Position and size
Config.HoldSize := GetBoolPropertyXML(Node, 'HoldSize', false);
Config.AlwaysOnTop := GetBoolPropertyXML(Node, 'MainOnTop', false);
//frmMain's size
frmMain.Width := GetIntPropertyXML(Node,'ListFormWidth',frmMainWidth);
frmMain.Height := GetIntPropertyXML(Node,'ListFormHeight',frmMainHeight);
//frmMain position
SetFormPosition(frmMain, GetIntPropertyXML(Node,'ListFormLeft',frmMain.Left),
GetIntPropertyXML(Node,'ListFormTop',frmMain.Top));
frmMain.Position := poDesigned;
//Main Form - Treevew
Config.TVBackgroundPath := GetStrPropertyXML(Node, 'BackgroundPath','');
Config.TVBackground := GetBoolPropertyXML(Node, 'Background',False);
Config.TVAutoOpClCats := GetBoolPropertyXML(Node, 'AutoOpClCategories',False);
//Treeview Font
Config.TVFont.Name := GetStrPropertyXML(Node, 'TreeViewFontName','MS Sans Serif');
tvFontStyle := Node.FindNode('TreeViewFontStyle');
if Assigned(tvFontStyle) then
begin
if GetBoolPropertyXML(tvFontStyle,'fsBold',false) then
Config.TVFont.Style := Config.TVFont.Style + [fsBold];
if GetBoolPropertyXML(tvFontStyle,'fsItalic',false) then
Config.TVFont.Style := Config.TVFont.Style + [fsItalic];
if GetBoolPropertyXML(tvFontStyle,'fsUnderline',false) then
Config.TVFont.Style := Config.TVFont.Style + [fsUnderline];
if GetBoolPropertyXML(tvFontStyle,'fsStrikeOut',false) then
Config.TVFont.Style := Config.TVFont.Style + [fsStrikeOut];
end;
Config.TVFont.Size := GetIntPropertyXML(Node,'TreeViewFontSize',8);
Config.TVFont.Color := GetIntPropertyXML(Node,'TreeViewFontColor',clWindowText);
//MRU
Config.MRU := GetBoolPropertyXML(Node, 'ActiveMRU',true);
Config.SubMenuMRU := GetBoolPropertyXML(Node, 'ActiveSubMenuMRU',false);
Config.MRUNumber := GetIntPropertyXML(Node, 'MRUNumber',5);
//Backup
Config.Backup := GetBoolPropertyXML(Node, 'ActiveBackup',true);
Config.BackupNumber := GetIntPropertyXML(Node, 'BackupNumber',5);
//Other functions
Config.Autorun := GetBoolPropertyXML(Node, 'ActiveAutorun',true);
ConfigCache := GetBoolPropertyXML(Node, 'ActiveCache',true);
//Execution
Config.ActionOnExe := TActionOnExecution(GetIntPropertyXML(Node, 'ActionOnExe',0));
Config.RunSingleClick := GetBoolPropertyXML(Node, 'RunSingleClick',false);
//Trayicon
Config.TrayIcon := GetBoolPropertyXML(Node, 'ActiveTrayIcon',true);
Config.TrayCustomIconPath := GetStrPropertyXML(Node, 'TrayIconPath','');
Config.ActionClickLeft := GetIntPropertyXML(Node, 'ActionClickLeft',0);
Config.ActionClickRight := GetIntPropertyXML(Node, 'ActionClickRight',2);
XMLDoc.Free;
end
else
if (ImportFileExt = EXT_SQL) or (ImportFileExt = EXT_SQLBCK)then
begin
//ASuite 2.x
DBImp := TDBManager.Create(edtPathList.Text);
DBImp.LoadOptions;
DBImp.Destroy;
end;
finally
Result := True;
//Config changed and focus vstList (so it repaint)
Config.Changed := True;
frmMain.FocusControl(frmMain.vstList);
end;
end;
end.