Changeset 159 for oup/current/DataAccess/Access_OUP_ADB.pas
- Timestamp:
- Apr 2, 2007, 2:29:55 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/DataAccess/Access_OUP_ADB.pas
r157 r159 214 214 215 215 216 function CompareItems(List: TStringList; I1, I2: Integer): Integer; 217 var 218 s1, s2: String; 219 begin 220 s1 := MidStr(List[I1], 1, PosEx(';', List[I1], 6) - 1); 221 s2 := MidStr(List[I2], 1, PosEx(';', List[I2], 6) - 1); 222 Result := CompareStr(s1, s2); 223 end; 224 216 225 function TAccess_OUP_ADB.GetFilesList(ext: String; pattern: String; 217 226 NoEmptyFiles: Boolean; SortType: TSortType): TStrings; … … 252 261 253 262 begin 254 if not (SortType in [ST_ExtNameAsc, ST_ExtNameDesc]) then 255 begin 256 list := TStringList.Create; 263 list := TStringList.Create; 264 if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then 265 list.Sorted := False 266 else 257 267 list.Sorted := True; 258 for i := 0 to GetFileCount - 1 do 259 begin 260 if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and 261 ((Length(pattern) = 0) or 262 (Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then 268 for i := 0 to GetFileCount - 1 do 269 begin 270 if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and 271 ((Length(pattern) = 0) or 272 (Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then 273 begin 274 if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then 263 275 begin 264 if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then 265 begin 266 id := FormatNumber(Fdat_files[i].ID, 5, '0'); 267 name := Fdat_files[i].Name; 268 extension := Fdat_files[i].Extension; 269 270 case SortType of 271 ST_IDAsc, ST_IDDesc: list.Add(id + ';' + name + ';' + extension); 272 ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension); 273 ST_ExtAsc, ST_ExtDesc: list.Add(extension + ';' + id + ';' + name); 274 ST_ExtNameAsc, ST_ExtNameDesc: list.Add(extension + ';' + name + ';' + id); 275 end; 276 id := FormatNumber(Fdat_files[i].ID, 5, '0'); 277 name := Fdat_files[i].Name; 278 extension := Fdat_files[i].Extension; 279 280 case SortType of 281 ST_IDAsc, ST_IDDesc: list.Add(id + ';' + name + ';' + extension); 282 ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension); 283 ST_ExtAsc, ST_ExtDesc: list.Add(extension + ';' + id + ';' + name); 284 ST_ExtNameAsc, ST_ExtNameDesc: list.Add(extension + ';' + name + ';' + id); 276 285 end; 277 286 end; 278 287 end; 279 if not Assigned(Result) then 280 Result := TStringList.Create; 281 if list.Count > 0 then 282 begin 283 fields := TStringList.Create; 284 if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then 285 for i := 0 to list.Count - 1 do 286 begin 287 getfields; 288 Result.Add(id + '-' + name + '.' + extension); 289 end 290 else 291 for i := list.Count - 1 downto 0 do 292 begin 293 getfields; 294 Result.Add(id + '-' + name + '.' + extension); 295 end; 296 fields.Free; 297 end; 298 list.Free; 299 end 300 else 301 begin 302 FQuery.SQL.Text := 'SELECT id, name, extension FROM datfiles ' + 303 'WHERE Length(name) > 0 ORDER BY extension ASC, name ASC;'; 304 FQuery.Open; 305 if not Assigned(Result) then 306 Result := TStringList.Create; 307 if FQuery.RecordCount > 0 then 308 begin 309 FQuery.First; 310 repeat 311 name := FormatNumber(FQuery.FieldByName('id').AsInteger, 5, '0') + 312 '-' + FQuery.FieldByName('name').AsString + '.' + 313 FQuery.FieldByName('extension').AsString; 314 if SortType = ST_ExtNameAsc then 315 Result.Add(name) 316 else 317 Result.Insert(0, name); 318 FQuery.Next; 319 until FQuery.EOF; 320 end; 321 FQuery.Close; 322 end; 288 end; 289 if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then 290 list.CustomSort(CompareItems); 291 if not Assigned(Result) then 292 Result := TStringList.Create; 293 if list.Count > 0 then 294 begin 295 fields := TStringList.Create; 296 if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then 297 for i := 0 to list.Count - 1 do 298 begin 299 getfields; 300 Result.Add(id + '-' + name + '.' + extension); 301 end 302 else 303 for i := list.Count - 1 downto 0 do 304 begin 305 getfields; 306 Result.Add(id + '-' + name + '.' + extension); 307 end; 308 fields.Free; 309 end; 310 list.Free; 323 311 end; 324 312
Note:
See TracChangeset
for help on using the changeset viewer.