Changeset 229 for oup


Ignore:
Timestamp:
Jun 20, 2007, 12:57:51 PM (17 years ago)
Author:
alloc
Message:
 
Location:
oup/current
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • oup/current/DataAccess/Access_OUP_ADB.pas

    r173 r229  
    113113
    114114  UpdateListCache;
     115
     116  inherited;
    115117end;
    116118
  • oup/current/DataAccess/Access_OniArchive.pas

    r209 r229  
    161161  FConnectionID := ConnectionID;
    162162  FChangeRights := [CR_EditDat, CR_EditRaw, CR_AppendRaw];
     163
     164  inherited;
    163165end;
    164166
  • oup/current/DataAccess/DataAccess.pas

    r227 r229  
    2525    property MetaData:     TMetaManager read FMeta;
    2626
    27     constructor Create(FileName: String; ConnectionID: Integer; var Msg: TStatusMessages); virtual; abstract;
     27    constructor Create(FileName: String; ConnectionID: Integer; var Msg: TStatusMessages); virtual;
    2828    procedure Close; virtual; abstract;
    2929
     
    7676*)
    7777
     78constructor TDataAccess.Create(FileName: String; ConnectionID: Integer;
     79  var Msg: TStatusMessages);
     80begin
     81  FMeta := TMetaManager.Create(FConnectionID, Self);
     82end;
     83
     84
     85
    7886function TDataAccess.ExtractFileIDOfName(Name: String): Integer;
    7987begin
  • oup/current/FileClasses/_Extensions.pas

    r228 r229  
    77    private
    88      FConnectionID: Integer;
     9      FExt: String;
    910      FFiles: array of Integer;
    1011      function GetFile(ID: Integer): Integer;
     
    1314      constructor Create(ConnectionID: Integer; Ext: String); virtual;
    1415      procedure InitList;
     16      property Ext: String read FExt;
    1517      property Files[ID: Integer]: Integer read GetFile;
    1618      property FileCount: Integer read GetFileCount;
    1719  end;
     20
     21  TExtensions = array of TExtension;
     22                     
    1823
    1924
     
    2631
    2732constructor TExtension.Create(ConnectionID: Integer; Ext: String);
     33begin
     34  FConnectionID := ConnectionID;
     35  FExt := Ext;
     36end;
     37
     38function TExtension.GetFile(ID: Integer): Integer;
     39begin
     40  Result := FFiles[ID];
     41end;
     42
     43function TExtension.GetFileCount: Integer;
     44begin
     45  Result := Length(FFiles);
     46end;
     47
     48procedure TExtension.InitList;
    2849var
    2950  files: TStrings;
     
    5071end;
    5172
    52 function TExtension.GetFile(ID: Integer): Integer;
    53 begin
    54   Result := FFiles[ID];
    55 end;
    56 
    57 function TExtension.GetFileCount: Integer;
    58 begin
    59   Result := Length(FFiles);
    60 end;
    61 
    62 procedure TExtension.InitList;
    63 begin
    64 Exit;
    65 end;
    66 
    6773end.
  • oup/current/FileClasses/_MetaManager.pas

    r228 r229  
    88    protected
    99      FFiles: array of TFile;
    10       FRoot: array of TExtension;
     10      FRoot: TExtensions;
    1111      FConnectionID: Integer;
     12      FDataAccess: TObject;
    1213      function GetFileCount: Integer;
    1314      function GetFileById(Id: Integer): TFile;
     15      function GetExt(Ext: String): TExtension;
     16      procedure AddExt(Ext: String);
    1417    private
    15       procedure InitRootFiles;
     18      procedure InitExts;
    1619    public
    17       constructor Create(ConnectionID: Integer);
     20      constructor Create(ConnectionID: Integer; DataAccess: TObject);
     21      procedure InitExtFiles(Ext: String);
    1822      procedure InitFile(id: Integer);
    1923      procedure InitFileFields(id: Integer);
    2024
     25      property Root: TExtensions read FRoot;
     26      property RootExt[Ext: String]: TExtension read GetExt;
    2127      property FileCount: Integer read GetFileCount;
    2228      property FileById[Id: Integer]: TFile read GetFileById;
    2329  end;
    2430
    25 var
    26   Meta: TMetaManager;
    27 
    2831implementation
    2932
    3033uses
    3134  Classes, ConnectionManager, Access_OniArchive, TypeDefs,
    32   Dialogs, SysUtils, StrUtils;
     35  Dialogs, SysUtils, StrUtils, DataAccess;
    3336
    3437{ TFileManager }
    3538
    36 constructor TMetaManager.Create(ConnectionID: Integer);
     39constructor TMetaManager.Create(ConnectionID: Integer; DataAccess: TObject);
    3740begin
    3841  FConnectionID := ConnectionID;
    39   InitRootFiles;
     42  FDataAccess := DataAccess;
     43  SetLength(FFiles, TDataAccess(DataAccess).GetFileCount);
     44  InitExts;
     45end;
     46
     47function TMetaManager.GetExt(Ext: String): TExtension;
     48var
     49  i: Integer;
     50begin
     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;
     59end;
     60
     61procedure TMetaManager.AddExt(Ext: String);
     62var
     63  i: Integer;
     64begin
     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);
    4078end;
    4179
     
    92130end;
    93131
    94 procedure TMetaManager.InitRootFiles;
     132procedure TMetaManager.InitExtFiles(Ext: String);
    95133var
    96134  files: TStrings;
     
    136174end;
    137175
     176procedure TMetaManager.InitExts;
     177var
     178  files: TStrings;
     179  i: Integer;
     180  fid: Integer;
     181  finfo: TFileInfo;
     182begin
     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;
     198end;
     199
    138200end.
  • oup/current/FileClasses/_MetaTypes.pas

    r228 r229  
    1919  TFile_Empty = _EmptyFile.TFile_Empty;
    2020  TExtension = _Extensions.TExtension;
     21  TExtensions = _Extensions.TExtensions;
    2122
    2223  TFileClass = class of TFile;
  • oup/current/Tools/MetaEditor.dfm

    r218 r229  
    44  PixelsPerInch = 96
    55  TextHeight = 13
    6   inherited panel_connection: TPanel
    7     ExplicitWidth = 598
    8     inherited combo_connection: TComboBox
    9       ExplicitWidth = 532
    10     end
    11   end
    126  inherited panel_basecontent: TPanel
    137    ExplicitLeft = 0
  • oup/current/Tools/MetaEditor.pas

    r218 r229  
    3131  end;
    3232
    33 var
    34   Form_Meta: TForm_Meta;
    3533
    3634implementation
     
    6462  node: PVirtualNode;
    6563begin
     64{
    6665  if ID >= 0 then
    6766  begin
     
    6968    QueryPerformanceCounter(a);
    7069    if not Assigned(Meta) then
    71       Meta := TMetaManager.Create(ID);
     70      Meta := TMetaManager.Create(ID, Self);
    7271    QueryPerformanceCounter(b);
    7372    ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's');
     
    8786    VST.EndUpdate;
    8887  end;
     88}
    8989end;
    9090
     
    9999  id: Integer;
    100100begin
     101{
    101102  data := VST.GetNodeData(node);
    102103  for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do
     
    110111  end;
    111112  ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount;
     113}
    112114end;
    113115
     
    226228procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction);
    227229begin
    228   Meta.Free;
     230//  Meta.Free;
    229231  inherited;
    230232end;
  • oup/current/Tools/_TemplateFileList.dfm

    r227 r229  
    3333        Margins.Right = 1
    3434        Margins.Bottom = 0
    35         ActivePage = tab_files
     35        ActivePage = tab_meta
    3636        Align = alClient
    3737        TabOrder = 0
     
    284284            Header.Options = [hoColumnResize, hoDrag]
    285285            TabOrder = 0
     286            OnGetText = filelist_metaGetText
     287            OnPaintText = filelist_metaPaintText
     288            OnInitChildren = filelist_metaInitChildren
    286289            Columns = <>
    287290          end
  • oup/current/Tools/_TemplateFileList.pas

    r227 r229  
    5555    procedure popup_linkshereClick(Sender: TObject);
    5656    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);
    5764  private
    5865    FSortBy: TSortType;
     
    7380{$R *.dfm}
    7481uses ConnectionManager, Exporters, Functions, StrUtils, WhatLinksHere, Main,
    75   _BaseTemplate;
     82  _BaseTemplate, _MetaTypes, Data, _MetaManager, _FileTypes;
     83
     84type
     85  PNodeData = ^TNodeData;
     86
     87  TNodeData = record
     88    Field: TObject;
     89  end;
     90
     91function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode;
     92  ARecord: TNodeData): PVirtualNode;
     93var
     94  Data: PNodeData;
     95begin
     96  Result := AVST.AddChild(ANode);
     97  Data   := AVST.GetNodeData(Result);
     98  AVST.ValidateNode(Result, False);
     99  Data^ := ARecord;
     100end;
     101
    76102
    77103
     
    108134  pattern: String;
    109135  files: TStrings;
     136  root: TExtensions;
     137  i: Integer;
     138  data: TNodeData;
     139  node: PVirtualNode;
    110140begin
    111141  if FConnectionID > -1 then
     
    130160      filelist.Items.AddStrings(files);
    131161    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;
    132174  end;
    133175end;
     
    217259end;
    218260
     261
    219262procedure TForm_TemplateFileList.filepopupPopup(Sender: TObject);
    220263var
     
    338381begin
    339382  inherited;
     383  filelist_meta.NodeDataSize := SizeOf(TNodeData);
     384  filelist_meta.Font.Charset := AppSettings.CharSet;
     385  filelist_meta.Clear;
     386
    340387  FAllowedExts := '';
    341388  FAllowMultiSelect := False;
     
    356403
    357404
     405
     406procedure TForm_TemplateFileList.filelist_metaGetText(Sender: TBaseVirtualTree;
     407  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
     408  var CellText: WideString);
     409var
     410  data: PNodeData;
     411begin
     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;
     425end;
     426
     427
     428procedure TForm_TemplateFileList.filelist_metaInitChildren(
     429  Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal);
     430var
     431  data: PNodeData;
     432  i: Integer;
     433  newdata: TNodeData;
     434  newnode: PVirtualNode;
     435  id: Integer;
     436begin
     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;
     467end;
     468
     469procedure TForm_TemplateFileList.filelist_metaPaintText(
     470  Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode;
     471  Column: TColumnIndex; TextType: TVSTTextType);
     472var
     473  Data: PNodeData;
     474begin
     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;
     483end;
     484
    358485end.
Note: See TracChangeset for help on using the changeset viewer.