Metadata dialog: When you change/add the series name, the series number will automatically increment to the next number in the series. Fixes #4285 (2 suggestions - could be pilot error on my end but I did search help files.)

This commit is contained in:
Kovid Goyal 2009-12-24 11:22:04 -07:00
parent f7f4432d6b
commit fb4acd3221
2 changed files with 24 additions and 1 deletions

View File

@ -382,6 +382,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
self.series_index.setValue(1.0)
QObject.connect(self.series, SIGNAL('currentIndexChanged(int)'), self.enable_series_index)
QObject.connect(self.series, SIGNAL('editTextChanged(QString)'), self.enable_series_index)
self.series.lineEdit().editingFinished.connect(self.increment_series_index)
self.show()
height_of_rest = self.frameGeometry().height() - self.cover.height()
@ -597,6 +598,16 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
def enable_series_index(self, *args):
self.series_index.setEnabled(True)
def increment_series_index(self):
if self.db is not None:
try:
series = unicode(self.series.text())
if series:
ns = self.db.get_next_series_num_for(series)
self.series_index.setValue(ns)
except:
traceback.print_exc()
def remove_unused_series(self):
self.db.remove_unused_series()
idx = qstring_to_unicode(self.series.currentText())

View File

@ -10,6 +10,7 @@ import os, re, sys, shutil, cStringIO, glob, collections, textwrap, \
itertools, functools, traceback
from itertools import repeat
from datetime import datetime
from math import floor
from PyQt4.QtCore import QThread, QReadWriteLock
try:
@ -1080,7 +1081,18 @@ class LibraryDatabase2(LibraryDatabase):
if tags and tag in tags.lower():
yield r[FIELD_MAP['id']]
def get_next_series_num_for(self, series):
series_id = self.conn.get('SELECT id from series WHERE name=?',
(series,), all=False)
if series_id is None:
return 1.0
series_num = self.conn.get(
('SELECT MAX(series_index) FROM books WHERE id IN '
'(SELECT book FROM books_series_link where series=?)'),
(series_id,), all=False)
if series_num is None:
return 1.0
return floor(series_num+1)
def set(self, row, column, val):
'''