- Timestamp:
- Jun 20, 2007, 12:57:51 PM (18 years ago)
- Location:
- oup/current
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/DataAccess/Access_OUP_ADB.pas
r173 r229 113 113 114 114 UpdateListCache; 115 116 inherited; 115 117 end; 116 118 -
oup/current/DataAccess/Access_OniArchive.pas
r209 r229 161 161 FConnectionID := ConnectionID; 162 162 FChangeRights := [CR_EditDat, CR_EditRaw, CR_AppendRaw]; 163 164 inherited; 163 165 end; 164 166 -
oup/current/DataAccess/DataAccess.pas
r227 r229 25 25 property MetaData: TMetaManager read FMeta; 26 26 27 constructor Create(FileName: String; ConnectionID: Integer; var Msg: TStatusMessages); virtual; abstract;27 constructor Create(FileName: String; ConnectionID: Integer; var Msg: TStatusMessages); virtual; 28 28 procedure Close; virtual; abstract; 29 29 … … 76 76 *) 77 77 78 constructor TDataAccess.Create(FileName: String; ConnectionID: Integer; 79 var Msg: TStatusMessages); 80 begin 81 FMeta := TMetaManager.Create(FConnectionID, Self); 82 end; 83 84 85 78 86 function TDataAccess.ExtractFileIDOfName(Name: String): Integer; 79 87 begin -
oup/current/FileClasses/_Extensions.pas
r228 r229 7 7 private 8 8 FConnectionID: Integer; 9 FExt: String; 9 10 FFiles: array of Integer; 10 11 function GetFile(ID: Integer): Integer; … … 13 14 constructor Create(ConnectionID: Integer; Ext: String); virtual; 14 15 procedure InitList; 16 property Ext: String read FExt; 15 17 property Files[ID: Integer]: Integer read GetFile; 16 18 property FileCount: Integer read GetFileCount; 17 19 end; 20 21 TExtensions = array of TExtension; 22 18 23 19 24 … … 26 31 27 32 constructor TExtension.Create(ConnectionID: Integer; Ext: String); 33 begin 34 FConnectionID := ConnectionID; 35 FExt := Ext; 36 end; 37 38 function TExtension.GetFile(ID: Integer): Integer; 39 begin 40 Result := FFiles[ID]; 41 end; 42 43 function TExtension.GetFileCount: Integer; 44 begin 45 Result := Length(FFiles); 46 end; 47 48 procedure TExtension.InitList; 28 49 var 29 50 files: TStrings; … … 50 71 end; 51 72 52 function TExtension.GetFile(ID: Integer): Integer;53 begin54 Result := FFiles[ID];55 end;56 57 function TExtension.GetFileCount: Integer;58 begin59 Result := Length(FFiles);60 end;61 62 procedure TExtension.InitList;63 begin64 Exit;65 end;66 67 73 end. -
oup/current/FileClasses/_MetaManager.pas
r228 r229 8 8 protected 9 9 FFiles: array of TFile; 10 FRoot: array of TExtension;10 FRoot: TExtensions; 11 11 FConnectionID: Integer; 12 FDataAccess: TObject; 12 13 function GetFileCount: Integer; 13 14 function GetFileById(Id: Integer): TFile; 15 function GetExt(Ext: String): TExtension; 16 procedure AddExt(Ext: String); 14 17 private 15 procedure Init RootFiles;18 procedure InitExts; 16 19 public 17 constructor Create(ConnectionID: Integer); 20 constructor Create(ConnectionID: Integer; DataAccess: TObject); 21 procedure InitExtFiles(Ext: String); 18 22 procedure InitFile(id: Integer); 19 23 procedure InitFileFields(id: Integer); 20 24 25 property Root: TExtensions read FRoot; 26 property RootExt[Ext: String]: TExtension read GetExt; 21 27 property FileCount: Integer read GetFileCount; 22 28 property FileById[Id: Integer]: TFile read GetFileById; 23 29 end; 24 30 25 var26 Meta: TMetaManager;27 28 31 implementation 29 32 30 33 uses 31 34 Classes, ConnectionManager, Access_OniArchive, TypeDefs, 32 Dialogs, SysUtils, StrUtils ;35 Dialogs, SysUtils, StrUtils, DataAccess; 33 36 34 37 { TFileManager } 35 38 36 constructor TMetaManager.Create(ConnectionID: Integer );39 constructor TMetaManager.Create(ConnectionID: Integer; DataAccess: TObject); 37 40 begin 38 41 FConnectionID := ConnectionID; 39 InitRootFiles; 42 FDataAccess := DataAccess; 43 SetLength(FFiles, TDataAccess(DataAccess).GetFileCount); 44 InitExts; 45 end; 46 47 function TMetaManager.GetExt(Ext: String): TExtension; 48 var 49 i: Integer; 50 begin 51 Result := nil; 52 if Length(FRoot) > 0 then 53 for i := 0 to High(FRoot) do 54 if FRoot[i].Ext = Ext then 55 begin 56 Result := FRoot[i]; 57 Break; 58 end; 59 end; 60 61 procedure TMetaManager.AddExt(Ext: String); 62 var 63 i: Integer; 64 begin 65 SetLength(FRoot, Length(FRoot) + 1); 66 for i := High(FRoot) downto 1 do 67 begin 68 if FRoot[i-1].Ext < Ext then 69 begin 70 FRoot[i] := TExtension.Create(FConnectionID, Ext); 71 Break; 72 end 73 else 74 FRoot[i] := FRoot[i-1]; 75 end; 76 if i = 0 then 77 FRoot[0] := TExtension.Create(FConnectionID, Ext); 40 78 end; 41 79 … … 92 130 end; 93 131 94 procedure TMetaManager.Init RootFiles;132 procedure TMetaManager.InitExtFiles(Ext: String); 95 133 var 96 134 files: TStrings; … … 136 174 end; 137 175 176 procedure TMetaManager.InitExts; 177 var 178 files: TStrings; 179 i: Integer; 180 fid: Integer; 181 finfo: TFileInfo; 182 begin 183 files := TStringList.Create; 184 files := TDataAccess(FDataAccess).GetFilesList('', '', False, ST_IDAsc); 185 SetLength(FRoot, 0); 186 if files.Count > 0 then 187 begin 188 for i := 0 to files.Count - 1 do 189 begin 190 fid := StrToInt(MidStr(files.Strings[i], 1, 5)); 191 finfo := TDataAccess(FDataAccess).GetFileInfo(fid); 192 if Length(finfo.Name) > 0 then 193 if not Assigned(GetExt(finfo.Extension)) then 194 AddExt(finfo.Extension); 195 end; 196 end; 197 files.Free; 198 end; 199 138 200 end. -
oup/current/FileClasses/_MetaTypes.pas
r228 r229 19 19 TFile_Empty = _EmptyFile.TFile_Empty; 20 20 TExtension = _Extensions.TExtension; 21 TExtensions = _Extensions.TExtensions; 21 22 22 23 TFileClass = class of TFile; -
oup/current/Tools/MetaEditor.dfm
r218 r229 4 4 PixelsPerInch = 96 5 5 TextHeight = 13 6 inherited panel_connection: TPanel7 ExplicitWidth = 5988 inherited combo_connection: TComboBox9 ExplicitWidth = 53210 end11 end12 6 inherited panel_basecontent: TPanel 13 7 ExplicitLeft = 0 -
oup/current/Tools/MetaEditor.pas
r218 r229 31 31 end; 32 32 33 var34 Form_Meta: TForm_Meta;35 33 36 34 implementation … … 64 62 node: PVirtualNode; 65 63 begin 64 { 66 65 if ID >= 0 then 67 66 begin … … 69 68 QueryPerformanceCounter(a); 70 69 if not Assigned(Meta) then 71 Meta := TMetaManager.Create(ID );70 Meta := TMetaManager.Create(ID, Self); 72 71 QueryPerformanceCounter(b); 73 72 ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's'); … … 87 86 VST.EndUpdate; 88 87 end; 88 } 89 89 end; 90 90 … … 99 99 id: Integer; 100 100 begin 101 { 101 102 data := VST.GetNodeData(node); 102 103 for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do … … 110 111 end; 111 112 ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount; 113 } 112 114 end; 113 115 … … 226 228 procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction); 227 229 begin 228 Meta.Free;230 // Meta.Free; 229 231 inherited; 230 232 end; -
oup/current/Tools/_TemplateFileList.dfm
r227 r229 33 33 Margins.Right = 1 34 34 Margins.Bottom = 0 35 ActivePage = tab_ files35 ActivePage = tab_meta 36 36 Align = alClient 37 37 TabOrder = 0 … … 284 284 Header.Options = [hoColumnResize, hoDrag] 285 285 TabOrder = 0 286 OnGetText = filelist_metaGetText 287 OnPaintText = filelist_metaPaintText 288 OnInitChildren = filelist_metaInitChildren 286 289 Columns = <> 287 290 end -
oup/current/Tools/_TemplateFileList.pas
r227 r229 55 55 procedure popup_linkshereClick(Sender: TObject); 56 56 procedure filepopupPopup(Sender: TObject); 57 procedure filelist_metaGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; 58 Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); 59 procedure filelist_metaInitChildren(Sender: TBaseVirtualTree; 60 Node: PVirtualNode; var ChildCount: Cardinal); 61 procedure filelist_metaPaintText(Sender: TBaseVirtualTree; 62 const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; 63 TextType: TVSTTextType); 57 64 private 58 65 FSortBy: TSortType; … … 73 80 {$R *.dfm} 74 81 uses ConnectionManager, Exporters, Functions, StrUtils, WhatLinksHere, Main, 75 _BaseTemplate; 82 _BaseTemplate, _MetaTypes, Data, _MetaManager, _FileTypes; 83 84 type 85 PNodeData = ^TNodeData; 86 87 TNodeData = record 88 Field: TObject; 89 end; 90 91 function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode; 92 ARecord: TNodeData): PVirtualNode; 93 var 94 Data: PNodeData; 95 begin 96 Result := AVST.AddChild(ANode); 97 Data := AVST.GetNodeData(Result); 98 AVST.ValidateNode(Result, False); 99 Data^ := ARecord; 100 end; 101 76 102 77 103 … … 108 134 pattern: String; 109 135 files: TStrings; 136 root: TExtensions; 137 i: Integer; 138 data: TNodeData; 139 node: PVirtualNode; 110 140 begin 111 141 if FConnectionID > -1 then … … 130 160 filelist.Items.AddStrings(files); 131 161 filelist.Visible := True; 162 163 //VST 164 filelist_meta.Clear; 165 filelist_meta.BeginUpdate; 166 root := ConManager.Connection[FConnectionID].MetaData.Root; 167 for i := 0 to High(root) do 168 begin 169 data.Field := root[i]; 170 node := AddVSTEntry(filelist_meta, nil, data); 171 filelist_meta.HasChildren[node] := True; 172 end; 173 filelist_meta.EndUpdate; 132 174 end; 133 175 end; … … 217 259 end; 218 260 261 219 262 procedure TForm_TemplateFileList.filepopupPopup(Sender: TObject); 220 263 var … … 338 381 begin 339 382 inherited; 383 filelist_meta.NodeDataSize := SizeOf(TNodeData); 384 filelist_meta.Font.Charset := AppSettings.CharSet; 385 filelist_meta.Clear; 386 340 387 FAllowedExts := ''; 341 388 FAllowMultiSelect := False; … … 356 403 357 404 405 406 procedure TForm_TemplateFileList.filelist_metaGetText(Sender: TBaseVirtualTree; 407 Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; 408 var CellText: WideString); 409 var 410 data: PNodeData; 411 begin 412 inherited; 413 data := Sender.GetNodeData(Node); 414 if data.Field is TExtension then 415 begin 416 CellText := TExtension(data.Field).Ext; 417 end; 418 if data.Field is TFile then 419 begin 420 if TFile(data.Field).FileName = '' then 421 CellText := TFile(data.Field).FileExt + ' (unnamed)' 422 else 423 CellText := TFile(data.Field).FileExt + ': ' + TFile(data.Field).FileName; 424 end; 425 end; 426 427 428 procedure TForm_TemplateFileList.filelist_metaInitChildren( 429 Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal); 430 var 431 data: PNodeData; 432 i: Integer; 433 newdata: TNodeData; 434 newnode: PVirtualNode; 435 id: Integer; 436 begin 437 inherited; 438 data := Sender.GetNodeData(Node); 439 if data.Field is TExtension then 440 begin 441 if TExtension(data.Field).FileCount = 0 then 442 TExtension(data.Field).InitList; 443 for i := 0 to TExtension(data.Field).FileCount - 1 do 444 begin 445 id := TExtension(data.Field).Files[i]; 446 ConManager.Connection[FConnectionID].MetaData.InitFile(id); 447 newdata.Field := ConManager.Connection[FConnectionID].MetaData.FileById[id]; 448 newnode := AddVSTEntry(filelist_meta, Node, newdata); 449 if ConManager.Connection[FConnectionID].MetaData.FileById[id].ChildCount > 0 then 450 filelist_meta.HasChildren[newnode] := True; 451 ChildCount := filelist_meta.ChildCount[node]; 452 end; 453 end; 454 if data.Field is TFile then 455 begin 456 for i := 0 to TFile(data.Field).ChildCount - 1 do 457 begin 458 id := TFile(data.Field).LinkByIndex[i].DestID; 459 ConManager.Connection[FConnectionID].MetaData.InitFile(id); 460 newdata.Field := ConManager.Connection[FConnectionID].MetaData.FileById[id]; 461 newnode := AddVSTEntry(filelist_meta, Node, newdata); 462 if ConManager.Connection[FConnectionID].MetaData.FileById[id].ChildCount > 0 then 463 filelist_meta.HasChildren[newnode] := True; 464 end; 465 ChildCount := filelist_meta.ChildCount[node]; 466 end; 467 end; 468 469 procedure TForm_TemplateFileList.filelist_metaPaintText( 470 Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; 471 Column: TColumnIndex; TextType: TVSTTextType); 472 var 473 Data: PNodeData; 474 begin 475 Data := Sender.GetNodeData(Node); 476 if Data.Field is TFile then 477 begin 478 if Length(TFile(Data.Field).FileName) = 0 then 479 TargetCanvas.Font.Color := $C06060; 480 if TFile(Data.Field).FileSize = 0 then 481 TargetCanvas.Font.Color := $2020A0; 482 end; 483 end; 484 358 485 end.
Note:
See TracChangeset
for help on using the changeset viewer.