This commit is contained in:
Kovid Goyal 2013-05-11 20:37:35 +05:30
parent fab6e1ce7f
commit 2b99afeda1

View File

@ -72,7 +72,8 @@ class PreserveViewState(object): # {{{
return {x:getattr(self, x) for x in ('selected_ids', 'current_id', return {x:getattr(self, x) for x in ('selected_ids', 'current_id',
'vscroll', 'hscroll')} 'vscroll', 'hscroll')}
def fset(self, state): def fset(self, state):
for k, v in state.iteritems(): setattr(self, k, v) for k, v in state.iteritems():
setattr(self, k, v)
self.__exit__() self.__exit__()
return property(fget=fget, fset=fset) return property(fget=fget, fset=fset)
@ -235,7 +236,7 @@ class BooksView(QTableView): # {{{
ac.setCheckable(True) ac.setCheckable(True)
ac.setChecked(True) ac.setChecked(True)
if col not in ('ondevice', 'inlibrary') and \ if col not in ('ondevice', 'inlibrary') and \
(not self.model().is_custom_column(col) or \ (not self.model().is_custom_column(col) or
self.model().custom_columns[col]['datatype'] not in ('bool', self.model().custom_columns[col]['datatype'] not in ('bool',
)): )):
m = self.column_header_context_menu.addMenu( m = self.column_header_context_menu.addMenu(
@ -277,7 +278,6 @@ class BooksView(QTableView): # {{{
partial(self.column_header_context_handler, partial(self.column_header_context_handler,
action='show', column=col)) action='show', column=col))
self.column_header_context_menu.addSeparator() self.column_header_context_menu.addSeparator()
self.column_header_context_menu.addAction( self.column_header_context_menu.addAction(
_('Shrink column if it is too wide to fit'), _('Shrink column if it is too wide to fit'),
@ -514,7 +514,6 @@ class BooksView(QTableView): # {{{
db.prefs[name] = ans db.prefs[name] = ans
return ans return ans
def restore_state(self): def restore_state(self):
old_state = self.get_old_state() old_state = self.get_old_state()
if old_state is None: if old_state is None:
@ -837,7 +836,8 @@ class BooksView(QTableView): # {{{
ids = frozenset(ids) ids = frozenset(ids)
m = self.model() m = self.model()
for row in xrange(m.rowCount(QModelIndex())): for row in xrange(m.rowCount(QModelIndex())):
if len(row_map) >= len(ids): break if len(row_map) >= len(ids):
break
c = m.id(row) c = m.id(row)
if c in ids: if c in ids:
row_map[c] = row row_map[c] = row
@ -897,7 +897,8 @@ class BooksView(QTableView): # {{{
pass pass
return None return None
def fset(self, val): def fset(self, val):
if val is None: return if val is None:
return
m = self.model() m = self.model()
for row in xrange(m.rowCount(QModelIndex())): for row in xrange(m.rowCount(QModelIndex())):
if m.id(row) == val: if m.id(row) == val:
@ -919,7 +920,8 @@ class BooksView(QTableView): # {{{
column = ci.column() column = ci.column()
for i in xrange(ci.row()+1, self.row_count()): for i in xrange(ci.row()+1, self.row_count()):
if i in selected_rows: continue if i in selected_rows:
continue
try: try:
return self.model().id(self.model().index(i, column)) return self.model().id(self.model().index(i, column))
except: except:
@ -927,7 +929,8 @@ class BooksView(QTableView): # {{{
# No unselected rows after the current row, look before # No unselected rows after the current row, look before
for i in xrange(ci.row()-1, -1, -1): for i in xrange(ci.row()-1, -1, -1):
if i in selected_rows: continue if i in selected_rows:
continue
try: try:
return self.model().id(self.model().index(i, column)) return self.model().id(self.model().index(i, column))
except: except: