mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement workaround for incorrect initial horz scroll position of book list
This commit is contained in:
parent
ca1143f7ff
commit
6cfbfb0f51
@ -5,31 +5,35 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import itertools, operator
|
import itertools
|
||||||
from functools import partial
|
import operator
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from functools import partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QTableView, Qt, QAbstractItemView, QMenu, pyqtSignal, QFont, QModelIndex,
|
QAbstractItemView, QDialog, QDialogButtonBox, QDrag, QEvent, QFont, QFontMetrics,
|
||||||
QIcon, QItemSelection, QMimeData, QDrag, QStyle, QPoint, QUrl, QHeaderView, QEvent,
|
QGridLayout, QHeaderView, QIcon, QItemSelection, QItemSelectionModel, QLabel, QMenu,
|
||||||
QStyleOptionHeader, QItemSelectionModel, QSize, QFontMetrics,
|
QMimeData, QModelIndex, QPoint, QPushButton, QSize, QSpinBox, QStyle,
|
||||||
QDialog, QGridLayout, QPushButton, QDialogButtonBox, QLabel, QSpinBox)
|
QStyleOptionHeader, Qt, QTableView, QTimer, QUrl, pyqtSignal,
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.constants import islinux
|
from calibre import force_unicode
|
||||||
|
from calibre.constants import filesystem_encoding, islinux
|
||||||
|
from calibre.gui2 import FunctionDispatcher, error_dialog, gprefs
|
||||||
from calibre.gui2.dialogs.enum_values_edit import EnumValuesEdit
|
from calibre.gui2.dialogs.enum_values_edit import EnumValuesEdit
|
||||||
from calibre.gui2.library.delegates import (RatingDelegate, PubDateDelegate,
|
from calibre.gui2.gestures import GestureManager
|
||||||
TextDelegate, DateDelegate, CompleteDelegate, CcTextDelegate, CcLongTextDelegate,
|
from calibre.gui2.library import DEFAULT_SORT
|
||||||
CcBoolDelegate, CcCommentsDelegate, CcDateDelegate, CcTemplateDelegate,
|
from calibre.gui2.library.alternate_views import (
|
||||||
CcEnumDelegate, CcNumberDelegate, LanguagesDelegate, SeriesDelegate, CcSeriesDelegate)
|
AlternateViews, handle_enter_press, setup_dnd_interface,
|
||||||
|
)
|
||||||
|
from calibre.gui2.library.delegates import (
|
||||||
|
CcBoolDelegate, CcCommentsDelegate, CcDateDelegate, CcEnumDelegate,
|
||||||
|
CcLongTextDelegate, CcNumberDelegate, CcSeriesDelegate, CcTemplateDelegate,
|
||||||
|
CcTextDelegate, CompleteDelegate, DateDelegate, LanguagesDelegate, PubDateDelegate,
|
||||||
|
RatingDelegate, SeriesDelegate, TextDelegate,
|
||||||
|
)
|
||||||
from calibre.gui2.library.models import BooksModel, DeviceBooksModel
|
from calibre.gui2.library.models import BooksModel, DeviceBooksModel
|
||||||
from calibre.gui2.pin_columns import PinTableView
|
from calibre.gui2.pin_columns import PinTableView
|
||||||
from calibre.gui2.library.alternate_views import AlternateViews, setup_dnd_interface, handle_enter_press
|
from calibre.utils.config import prefs, tweaks
|
||||||
from calibre.gui2.gestures import GestureManager
|
|
||||||
from calibre.utils.config import tweaks, prefs
|
|
||||||
from calibre.gui2 import error_dialog, gprefs, FunctionDispatcher
|
|
||||||
from calibre.gui2.library import DEFAULT_SORT
|
|
||||||
from calibre.constants import filesystem_encoding
|
|
||||||
from calibre import force_unicode
|
|
||||||
from calibre.utils.icu import primary_sort_key
|
from calibre.utils.icu import primary_sort_key
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
@ -1055,6 +1059,13 @@ class BooksView(QTableView): # {{{
|
|||||||
self.series_delegate.set_auto_complete_function(db.all_series)
|
self.series_delegate.set_auto_complete_function(db.all_series)
|
||||||
self.publisher_delegate.set_auto_complete_function(db.all_publishers)
|
self.publisher_delegate.set_auto_complete_function(db.all_publishers)
|
||||||
self.alternate_views.set_database(db, stage=1)
|
self.alternate_views.set_database(db, stage=1)
|
||||||
|
# need to let a few event loop ticks pass for the bug to manifest
|
||||||
|
QTimer.singleShot(10, self.workaround_initial_horizontal_scroll_bug)
|
||||||
|
|
||||||
|
def workaround_initial_horizontal_scroll_bug(self):
|
||||||
|
h = self.horizontalScrollBar()
|
||||||
|
if h.value() == h.maximum():
|
||||||
|
h.setValue(0)
|
||||||
|
|
||||||
def marked_changed(self, old_marked, current_marked):
|
def marked_changed(self, old_marked, current_marked):
|
||||||
self.alternate_views.marked_changed(old_marked, current_marked)
|
self.alternate_views.marked_changed(old_marked, current_marked)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user