--- oup/rewrite/DataAccess/Access_OUP_ADB.pas 2007/02/21 00:29:27 105 +++ oup/current/DataAccess/Access_OUP_ADB.pas 2007/02/22 00:37:39 112 @@ -17,6 +17,9 @@ type procedure UpdateListCache; + function GetLinksToFile(FileID: Integer): TLinks; + function GetLinksFromFile(FileID: Integer): TLinks; + function GetFileInfo(FileID: Integer): TFileInfo; override; function GetFilesList(Ext: String; Pattern: String; NoEmptyFiles: Boolean; SortType: TSortType): TStrings; override; @@ -168,6 +171,51 @@ begin end; + +function TAccess_OUP_ADB.GetLinksToFile(FileID: Integer): TLinks; +var + i: Integer; +begin + SetLength(Result.ByName, 0); + FQuery.SQL.Text := 'SELECT src_link_offset, src_id FROM linkmap WHERE target_id = ' + IntToStr(FileID) + ' ORDER BY src_id ASC;'; + FQuery.Open; + SetLength(Result.ByID, FQuery.RecordCount); + if FQuery.RecordCount > 0 then + begin + i := 0; + repeat + Result.ByID[i].SrcOffset := FQuery.FieldByName('src_link_offset').AsInteger; + Result.ByID[i].Destination := FQuery.FieldByName('src_id').AsInteger; + Inc(i); + FQuery.Next; + until FQuery.EOF; + end; + FQuery.Close; +end; + +function TAccess_OUP_ADB.GetLinksFromFile(FileID: Integer): TLinks; +var + i: Integer; +begin + SetLength(Result.ByName, 0); + FQuery.SQL.Text := 'SELECT src_link_offset, target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' ORDER BY target_id ASC;'; + FQuery.Open; + SetLength(Result.ByID, FQuery.RecordCount); + if FQuery.RecordCount > 0 then + begin + i := 0; + repeat + Result.ByID[i].SrcOffset := FQuery.FieldByName('src_link_offset').AsInteger; + Result.ByID[i].Destination := FQuery.FieldByName('target_id').AsInteger; + Inc(i); + FQuery.Next; + until FQuery.EOF; + end; + FQuery.Close; +end; + + + function TAccess_OUP_ADB.GetFileInfo(fileid: Integer): TFileInfo; begin if fileid = -1 then @@ -213,6 +261,12 @@ var name := fields.Strings[2]; extension := fields.Strings[0]; end; + if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then + begin + id := fields.Strings[2]; + name := fields.Strings[1]; + extension := fields.Strings[0]; + end; end; begin @@ -226,10 +280,7 @@ begin begin if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then begin - if AppSettings.FilenumbersAsHex then - id := IntToHex(Fdat_files[i].ID, 4) - else - id := FormatNumber(Fdat_files[i].ID, 5, '0'); + id := FormatNumber(Fdat_files[i].ID, 5, '0'); name := Fdat_files[i].Name; extension := Fdat_files[i].Extension; @@ -237,6 +288,7 @@ begin ST_IDAsc, ST_IDDesc: list.Add(id + ';' + name + ';' + extension); ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension); ST_ExtAsc, ST_ExtDesc: list.Add(extension + ';' + id + ';' + name); + ST_ExtNameAsc, ST_ExtNameDesc: list.Add(name + ';' + extension + ';' + id); end; end; end; @@ -245,7 +297,7 @@ begin if list.Count > 0 then begin fields := TStringList.Create; - if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc] then + if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then for i := 0 to list.Count - 1 do begin getfields;