This commit is contained in:
Kovid Goyal 2007-10-25 05:35:47 +00:00
parent 81c01f4561
commit 246c3520c1
2 changed files with 4 additions and 3 deletions

View File

@ -127,7 +127,7 @@ class BooksModel(QAbstractTableModel):
def save_to_disk(self, rows, path):
rows = [row.row() for row in rows]
self.db.export_to_dir(path, rows)
self.db.export_to_dir(path, rows, self.sorted_on[0] == 1)
def delete_books(self, indices):
ids = [ self.id(i) for i in indices ]

View File

@ -1060,7 +1060,7 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
self.conn.execute('DELETE FROM books WHERE id=?', (id,))
self.conn.commit()
def export_to_dir(self, dir, indices):
def export_to_dir(self, dir, indices, byauthor=False):
by_author = {}
for index in indices:
id = self.id(index)
@ -1086,7 +1086,8 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
os.mkdir(tpath)
for fmt in self.formats(idx).split(','):
data = self.format(idx, fmt)
f = open(os.path.join(tpath, title + ' - ' + au +'_'+id+'.'+fmt.lower()), 'wb')
name = au + ' - ' + title if byauthor else title + ' - ' + au
f = open(os.path.join(tpath, name +'_'+id+'.'+fmt.lower()), 'wb')
f.write(data)
if __name__ == '__main__':