mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
now date sorting (dialog) falls back to file sequence and then file name when the earlier is equal + added cmp chaining...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f64d93ad1e
commit
1adf3d60b3
@ -2,7 +2,7 @@
|
|||||||
#=======================================================================
|
#=======================================================================
|
||||||
|
|
||||||
__version__ = '''0.0.01'''
|
__version__ = '''0.0.01'''
|
||||||
__sub_version__ = '''20140102083502'''
|
__sub_version__ = '''20140112165326'''
|
||||||
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
||||||
|
|
||||||
|
|
||||||
@ -527,6 +527,7 @@ def build_images(path, config=CONFIG, gid_generator=hash_gid, dry_run=False, ver
|
|||||||
if orientation not in range(0, 9):
|
if orientation not in range(0, 9):
|
||||||
orientation = 0
|
orientation = 0
|
||||||
|
|
||||||
|
p = pathjoin(path, name)
|
||||||
img = {
|
img = {
|
||||||
'id': gid_generator(source_path),
|
'id': gid_generator(source_path),
|
||||||
'name': name,
|
'name': name,
|
||||||
@ -556,7 +557,10 @@ def build_images(path, config=CONFIG, gid_generator=hash_gid, dry_run=False, ver
|
|||||||
8: None,
|
8: None,
|
||||||
}[orientation],
|
}[orientation],
|
||||||
'path': getpath(path, source_path, absolute_path),
|
'path': getpath(path, source_path, absolute_path),
|
||||||
'ctime': os.path.getctime(pathjoin(path, name)),
|
'ctime': min(
|
||||||
|
# to compensate for touch updating mtime by default...
|
||||||
|
os.path.getmtime(p),
|
||||||
|
os.path.getctime(p)),
|
||||||
'preview': {},
|
'preview': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
ui/sort.js
28
ui/sort.js
@ -159,6 +159,26 @@ function imageXPStyleFileNameCmp(a, b, get, data){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function chainCmp(a, b, cmp_chain, get, data){
|
||||||
|
var res
|
||||||
|
for(var i=0; i < cmp_chain.length; i++){
|
||||||
|
res = cmp_chain[i](a, b, get, data)
|
||||||
|
if(res != 0){
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function imageDateOrSeqOrNameCmp(a, b, get, data){
|
||||||
|
return chainCmp(a, b, [
|
||||||
|
imageDateCmp,
|
||||||
|
imageSeqOrNameCmp
|
||||||
|
], get, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get list of gids sorted by proximity to current gid
|
// Get list of gids sorted by proximity to current gid
|
||||||
//
|
//
|
||||||
// NOTE: the distance used is the actual 2D distance...
|
// NOTE: the distance used is the actual 2D distance...
|
||||||
@ -207,6 +227,9 @@ function sortImages(cmp, reverse){
|
|||||||
function sortImagesByDate(reverse){
|
function sortImagesByDate(reverse){
|
||||||
return sortImages(imageDateCmp, reverse)
|
return sortImages(imageDateCmp, reverse)
|
||||||
}
|
}
|
||||||
|
function sortImagesByDateOrSeqOrName(reverse){
|
||||||
|
return sortImages(imageDateOrSeqOrNameCmp, reverse)
|
||||||
|
}
|
||||||
function sortImagesByFileName(reverse){
|
function sortImagesByFileName(reverse){
|
||||||
return sortImages(imageNameCmp, reverse)
|
return sortImages(imageNameCmp, reverse)
|
||||||
}
|
}
|
||||||
@ -390,7 +413,7 @@ function sortImagesDialog(){
|
|||||||
|
|
||||||
cfg = {}
|
cfg = {}
|
||||||
cfg[alg] = [
|
cfg[alg] = [
|
||||||
'Date',
|
'Date | this will fall back to file sequence and file name.',
|
||||||
'Sequence number',
|
'Sequence number',
|
||||||
'Sequence number with overflow',
|
'Sequence number with overflow',
|
||||||
'File name'
|
'File name'
|
||||||
@ -406,7 +429,8 @@ function sortImagesDialog(){
|
|||||||
res = res[alg]
|
res = res[alg]
|
||||||
|
|
||||||
if(/Date/i.test(res)){
|
if(/Date/i.test(res)){
|
||||||
var method = sortImagesByDate
|
//var method = sortImagesByDate
|
||||||
|
var method = sortImagesByDateOrSeqOrName
|
||||||
|
|
||||||
} else if(/File name/i.test(res)){
|
} else if(/File name/i.test(res)){
|
||||||
var method = sortImagesByFileNameXPStyle
|
var method = sortImagesByFileNameXPStyle
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user