mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: include tag name in search result tab name on macOS
This commit is contained in:
parent
fbb7f756e0
commit
c199a7d36e
3 changed files with 53 additions and 14 deletions
|
|
@ -137,7 +137,7 @@ type
|
|||
procedure goToFolder( Sender: TObject );
|
||||
|
||||
procedure searchFinderTag( Sender: TObject );
|
||||
procedure onSearchFinderTagComplete( const files: TStringArray );
|
||||
procedure onSearchFinderTagComplete( const searchName: String; const files: TStringArray );
|
||||
end;
|
||||
|
||||
var
|
||||
|
|
@ -181,9 +181,10 @@ begin
|
|||
uDarwinFinderModelUtil.searchFilesForTagName( tagName, @self.onSearchFinderTagComplete );
|
||||
end;
|
||||
|
||||
procedure TToolBarMenuHandler.onSearchFinderTagComplete(const files: TStringArray);
|
||||
procedure TToolBarMenuHandler.onSearchFinderTagComplete(
|
||||
const searchName: String; const files: TStringArray);
|
||||
begin
|
||||
TSearchResultUtil.addResultPage( files );
|
||||
TSearchResultUtil.addResultPage( searchName, files );
|
||||
end;
|
||||
|
||||
function getMacOSDisplayNameFromPath(const path: String): String;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ type
|
|||
|
||||
TFinderTagNSColors = Array of NSColor;
|
||||
|
||||
TMacOSSearchResultHandler = procedure ( const files: TStringArray ) of object;
|
||||
TMacOSSearchResultHandler = procedure ( const searchName: String; const files: TStringArray ) of object;
|
||||
|
||||
{ uDarwinFinderModelUtil }
|
||||
|
||||
|
|
@ -169,9 +169,13 @@ end;
|
|||
type
|
||||
TMacOSQueryHandler = objcclass( NSObject )
|
||||
private
|
||||
_queryName: NSString;
|
||||
_query: NSMetadataQuery;
|
||||
_handler: TMacOSSearchResultHandler;
|
||||
procedure initalGatherComplete( sender: id ); message 'initalGatherComplete:';
|
||||
public
|
||||
function initWithName( name: NSString ): id; message 'doublecmd_initWithName:';
|
||||
procedure dealloc; override;
|
||||
end;
|
||||
|
||||
procedure TMacOSQueryHandler.initalGatherComplete(sender: id);
|
||||
|
|
@ -199,7 +203,19 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
_handler( files );
|
||||
_handler( _queryName.UTF8String, files );
|
||||
end;
|
||||
|
||||
function TMacOSQueryHandler.initWithName(name: NSString): id;
|
||||
begin
|
||||
_queryName:= name;
|
||||
_queryName.retain;
|
||||
Result:= self;
|
||||
end;
|
||||
|
||||
procedure TMacOSQueryHandler.dealloc;
|
||||
begin
|
||||
_queryName.release;
|
||||
end;
|
||||
|
||||
{ uDarwinFinderModelUtil }
|
||||
|
|
@ -255,11 +271,11 @@ var
|
|||
format: NSString;
|
||||
begin
|
||||
query:= NSMetadataQuery.new;
|
||||
queryHandler:= TMacOSQueryHandler.new;
|
||||
queryHandler:= TMacOSQueryHandler.alloc.initWithName( tagName );
|
||||
queryHandler._query:= query;
|
||||
queryHandler._handler:= handler;
|
||||
NSNotificationCenter.defaultCenter.addObserver_selector_name_object(
|
||||
QueryHandler,
|
||||
queryHandler,
|
||||
objcselector('initalGatherComplete:'),
|
||||
NSMetadataQueryDidFinishGatheringNotification,
|
||||
query );
|
||||
|
|
|
|||
|
|
@ -7,16 +7,41 @@ interface
|
|||
uses
|
||||
SysUtils, Classes,
|
||||
uSearchResultFileSource, uFile, uFileSystemFileSource, uFileSource,
|
||||
fMain, uFileViewNotebook;
|
||||
fMain, uFileViewNotebook, ulng;
|
||||
|
||||
type
|
||||
TSearchResultUtil = class
|
||||
class procedure addResultPage( const files: TStringArray);
|
||||
class procedure addResultPage( const searchName: String; const files: TStringArray);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
class procedure TSearchResultUtil.addResultPage( const files: TStringArray);
|
||||
type
|
||||
|
||||
{ TFinderTagSearchResultFileSource }
|
||||
|
||||
TFinderTagSearchResultFileSource = class( TSearchResultFileSource )
|
||||
private
|
||||
_tagName: String;
|
||||
public
|
||||
constructor Create( tagName: String );
|
||||
function GetRootDir(sPath: String): String; override;
|
||||
end;
|
||||
|
||||
{ TFinderTagSearchResultFileSource }
|
||||
|
||||
constructor TFinderTagSearchResultFileSource.Create(tagName: String);
|
||||
begin
|
||||
Inherited Create;
|
||||
_tagName:= tagName;
|
||||
end;
|
||||
|
||||
function TFinderTagSearchResultFileSource.GetRootDir(sPath: String): String;
|
||||
begin
|
||||
Result:= PathDelim + PathDelim + PathDelim + rsSearchResult + ': ' + _tagName + PathDelim;
|
||||
end;
|
||||
|
||||
class procedure TSearchResultUtil.addResultPage( const searchName: String; const files: TStringArray);
|
||||
var
|
||||
i: integer;
|
||||
count: Integer;
|
||||
|
|
@ -27,9 +52,6 @@ var
|
|||
Notebook: TFileViewNotebook;
|
||||
NewPage: TFileViewPage;
|
||||
begin
|
||||
if files = nil then
|
||||
Exit;
|
||||
|
||||
count:= Length(files);
|
||||
FileList := TFileTree.Create;
|
||||
for i:=0 to count-1 do begin
|
||||
|
|
@ -44,7 +66,7 @@ begin
|
|||
|
||||
// Create search result file source.
|
||||
// Currently only searching FileSystem is supported.
|
||||
SearchResultFS := TSearchResultFileSource.Create;
|
||||
SearchResultFS := TFinderTagSearchResultFileSource.Create( searchName );
|
||||
SearchResultFS.AddList(FileList, Notebook.ActiveView.FileSource);
|
||||
|
||||
NewPage.FileView.AddFileSource(SearchResultFS, SearchResultFS.GetRootDir);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue