Changeset 229 for oup/current/Tools


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

Legend:

Unmodified
Added
Removed
  • 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.