|
@@ -3,7 +3,7 @@
|
|
-------------------------------------------------------------------------
|
|
-------------------------------------------------------------------------
|
|
Load/Save search templates
|
|
Load/Save search templates
|
|
|
|
|
|
- Copyright (C) 2009 Koblov Alexander ([email protected])
|
|
|
|
|
|
+ Copyright (C) 2009-2010 Koblov Alexander ([email protected])
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
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
|
|
it under the terms of the GNU General Public License as published by
|
|
@@ -57,19 +57,31 @@ type
|
|
TSearchTemplateList = class(TList)
|
|
TSearchTemplateList = class(TList)
|
|
private
|
|
private
|
|
function GetTemplate(Index: Integer): TSearchTemplate;
|
|
function GetTemplate(Index: Integer): TSearchTemplate;
|
|
|
|
+ function GetTemplate(const AName: UTF8String): TSearchTemplate;
|
|
public
|
|
public
|
|
function Add(SearchTemplate: TSearchTemplate): Integer;
|
|
function Add(SearchTemplate: TSearchTemplate): Integer;
|
|
procedure DeleteTemplate(Index: Integer);
|
|
procedure DeleteTemplate(Index: Integer);
|
|
procedure LoadToStringList(StringList: TStrings);
|
|
procedure LoadToStringList(StringList: TStrings);
|
|
procedure LoadFromIni(IniFile: TIniFileEx);
|
|
procedure LoadFromIni(IniFile: TIniFileEx);
|
|
procedure SaveToIni(IniFile: TIniFileEx);
|
|
procedure SaveToIni(IniFile: TIniFileEx);
|
|
|
|
+ property TemplateByName[const AName: UTF8String]: TSearchTemplate read GetTemplate;
|
|
property Templates[Index: Integer]: TSearchTemplate read GetTemplate;
|
|
property Templates[Index: Integer]: TSearchTemplate read GetTemplate;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+const
|
|
|
|
+ cTemplateSign = '>';
|
|
|
|
+
|
|
|
|
+function IsMaskSearchTemplate(const sMask: UTF8String): Boolean; inline;
|
|
|
|
+
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
- DateUtils, uFileProperty;
|
|
|
|
|
|
+ DateUtils, Masks, uFileProperty;
|
|
|
|
+
|
|
|
|
+function IsMaskSearchTemplate(const sMask: UTF8String): Boolean; inline;
|
|
|
|
+begin
|
|
|
|
+ Result:= (Length(sMask) > 0) and (sMask[1] = cTemplateSign);
|
|
|
|
+end;
|
|
|
|
|
|
{ TSearchTemplate }
|
|
{ TSearchTemplate }
|
|
|
|
|
|
@@ -171,6 +183,9 @@ begin
|
|
Result:= True;
|
|
Result:= True;
|
|
with SearchRecord do
|
|
with SearchRecord do
|
|
begin
|
|
begin
|
|
|
|
+ if (fpName in AFile.GetSupportedProperties) then
|
|
|
|
+ Result:= MatchesMaskList(AFile.Name, SearchRecord.rFileMask);
|
|
|
|
+
|
|
if (fpModificationTime in AFile.GetSupportedProperties) then
|
|
if (fpModificationTime in AFile.GetSupportedProperties) then
|
|
if (rIsDateFrom or rIsDateTo or rIsTimeFrom or rIsTimeTo or FIsNotOlderThan) then
|
|
if (rIsDateFrom or rIsDateTo or rIsTimeFrom or rIsTimeTo or FIsNotOlderThan) then
|
|
Result:= CheckFileDate((AFile.Properties[fpModificationTime] as TFileDateTimeProperty).Value);
|
|
Result:= CheckFileDate((AFile.Properties[fpModificationTime] as TFileDateTimeProperty).Value);
|
|
@@ -188,6 +203,26 @@ begin
|
|
Result:= TSearchTemplate(Items[Index]);
|
|
Result:= TSearchTemplate(Items[Index]);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TSearchTemplateList.GetTemplate(const AName: UTF8String): TSearchTemplate;
|
|
|
|
+var
|
|
|
|
+ I: Integer;
|
|
|
|
+ sName: UTF8String;
|
|
|
|
+begin
|
|
|
|
+ Result:= nil;
|
|
|
|
+
|
|
|
|
+ if IsMaskSearchTemplate(AName) then
|
|
|
|
+ sName:= PChar(AName) + 1 // skip template sign
|
|
|
|
+ else
|
|
|
|
+ sName:= AName;
|
|
|
|
+
|
|
|
|
+ for I:= 0 to Count - 1 do
|
|
|
|
+ if SameText(TSearchTemplate(Items[I]).TemplateName, sName) then
|
|
|
|
+ begin
|
|
|
|
+ Result:= TSearchTemplate(Items[I]);
|
|
|
|
+ Exit;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TSearchTemplateList.Add(SearchTemplate: TSearchTemplate): Integer;
|
|
function TSearchTemplateList.Add(SearchTemplate: TSearchTemplate): Integer;
|
|
begin
|
|
begin
|
|
Result:= inherited Add(SearchTemplate);
|
|
Result:= inherited Add(SearchTemplate);
|