fixed path sort to album sort + title sort
This commit is contained in:
parent
eadf5bc76d
commit
9667e2b9b6
1 changed files with 15 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:collection';
|
||||||
|
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/model/image_file_service.dart';
|
import 'package:aves/model/image_file_service.dart';
|
||||||
import 'package:aves/model/image_metadata.dart';
|
import 'package:aves/model/image_metadata.dart';
|
||||||
|
@ -64,7 +66,14 @@ class ImageCollection with ChangeNotifier {
|
||||||
]));
|
]));
|
||||||
break;
|
break;
|
||||||
case SortFactor.name:
|
case SortFactor.name:
|
||||||
sections = Map.unmodifiable(groupBy(_rawEntries, (entry) => entry.directory));
|
final byAlbum = groupBy(_rawEntries, (ImageEntry entry) => entry.directory);
|
||||||
|
final albums = byAlbum.keys.toSet();
|
||||||
|
final compare = (a, b) {
|
||||||
|
final ua = getUniqueAlbumName(a, albums);
|
||||||
|
final ub = getUniqueAlbumName(b, albums);
|
||||||
|
return compareAsciiUpperCase(ua, ub);
|
||||||
|
};
|
||||||
|
sections = Map.unmodifiable(SplayTreeMap.from(byAlbum, compare));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -79,7 +88,7 @@ class ImageCollection with ChangeNotifier {
|
||||||
_rawEntries.sort((a, b) => b.sizeBytes.compareTo(a.sizeBytes));
|
_rawEntries.sort((a, b) => b.sizeBytes.compareTo(a.sizeBytes));
|
||||||
break;
|
break;
|
||||||
case SortFactor.name:
|
case SortFactor.name:
|
||||||
_rawEntries.sort((a, b) => a.path.compareTo(b.path));
|
_rawEntries.sort((a, b) => compareAsciiUpperCase(a.title, b.title));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,8 +105,8 @@ class ImageCollection with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateAlbums() {
|
void updateAlbums() {
|
||||||
Set<String> albums = _rawEntries.map((entry) => entry.directory).toSet();
|
final albums = _rawEntries.map((entry) => entry.directory).toSet();
|
||||||
List<String> sorted = albums.toList()
|
final sorted = albums.toList()
|
||||||
..sort((a, b) {
|
..sort((a, b) {
|
||||||
final ua = getUniqueAlbumName(a, albums);
|
final ua = getUniqueAlbumName(a, albums);
|
||||||
final ub = getUniqueAlbumName(b, albums);
|
final ub = getUniqueAlbumName(b, albums);
|
||||||
|
@ -107,8 +116,8 @@ class ImageCollection with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTags() {
|
void updateTags() {
|
||||||
Set<String> tags = _rawEntries.expand((entry) => entry.xmpSubjects).toSet();
|
final tags = _rawEntries.expand((entry) => entry.xmpSubjects).toSet();
|
||||||
List<String> sorted = tags.toList()..sort(compareAsciiUpperCase);
|
final sorted = tags.toList()..sort(compareAsciiUpperCase);
|
||||||
sortedTags = List.unmodifiable(sorted);
|
sortedTags = List.unmodifiable(sorted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue