Reverted recursive sort, opted for natsorted lib
Was having performance issue with very large directories. This does have the issue of order "File (1)" before "File", have raised an issue with natsorted.
This commit is contained in:
parent
df08b06d33
commit
6256c08bb4
@ -22,6 +22,7 @@ from image import ImageFlags
|
||||
from about import DialogAbout
|
||||
from options import DialogOptions
|
||||
from convert import DialogConvert
|
||||
from natsort import natsorted
|
||||
|
||||
|
||||
class Book(object):
|
||||
@ -352,13 +353,11 @@ class MainWindowBook(QtGui.QMainWindow):
|
||||
|
||||
|
||||
def addImageFiles(self, filenames):
|
||||
filenames.sort()
|
||||
|
||||
filenamesListed = []
|
||||
for i in xrange(0, self.listWidgetFiles.count()):
|
||||
filenamesListed.append(self.listWidgetFiles.item(i).text())
|
||||
|
||||
for filename in filenames:
|
||||
for filename in natsorted(filenames):
|
||||
if filename not in filenamesListed:
|
||||
filename = QtCore.QString(filename)
|
||||
self.listWidgetFiles.addItem(filename)
|
||||
@ -370,14 +369,11 @@ class MainWindowBook(QtGui.QMainWindow):
|
||||
filenames = []
|
||||
|
||||
for directory in directories:
|
||||
directory = unicode(directory)
|
||||
for item in sorted(os.listdir(directory), key=util.tokenize):
|
||||
item = unicode(item)
|
||||
path = os.path.join(directory, item)
|
||||
for root, subdirs, subfiles in os.walk(unicode(directory)):
|
||||
for filename in subfiles:
|
||||
path = os.path.join(root, filename)
|
||||
if self.isImageFile(path):
|
||||
filenames.append(path)
|
||||
elif os.path.isdir(path):
|
||||
self.addImageDirs([path])
|
||||
|
||||
self.addImageFiles(filenames)
|
||||
|
||||
|
@ -21,11 +21,3 @@ import re
|
||||
def buildResPath(relative):
|
||||
directory = os.path.dirname(__file__)
|
||||
return os.path.join(directory, relative)
|
||||
|
||||
|
||||
digits = re.compile(r'(\d+)')
|
||||
def tokenize(filename):
|
||||
return tuple(int(token) if match else token
|
||||
for token, match in
|
||||
((fragment, digits.search(fragment))
|
||||
for fragment in digits.split(filename)))
|
||||
|
Loading…
Reference in New Issue
Block a user