Fix first book not being selected on calibre startup

This commit is contained in:
Kovid Goyal 2012-11-08 19:58:06 +05:30
parent 50c6ff97d4
commit ea37f4e8a7
2 changed files with 4 additions and 4 deletions

View File

@ -7,8 +7,8 @@ __docformat__ = 'restructuredtext en'
import functools
from PyQt4.Qt import Qt, QStackedWidget, QMenu, \
QSize, QSizePolicy, QStatusBar, QLabel, QFont
from PyQt4.Qt import (Qt, QStackedWidget, QMenu, QTimer,
QSize, QSizePolicy, QStatusBar, QLabel, QFont)
from calibre.utils.config import prefs
from calibre.constants import (isosx, __appname__, preferred_encoding,
@ -274,7 +274,7 @@ class LayoutMixin(object): # {{{
m = self.library_view.model()
if m.rowCount(None) > 0:
self.library_view.set_current_row(0)
QTimer.singleShot(0, self.library_view.set_current_row)
m.current_changed(self.library_view.currentIndex(),
self.library_view.currentIndex())
self.library_view.setFocus(Qt.OtherFocusReason)

View File

@ -777,7 +777,7 @@ class BooksView(QTableView): # {{{
self.scrollTo(self.model().index(row, i), self.PositionAtCenter)
break
def set_current_row(self, row, select=True):
def set_current_row(self, row=0, select=True):
if row > -1 and row < self.model().rowCount(QModelIndex()):
h = self.horizontalHeader()
logical_indices = list(range(h.count()))