mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix editing of narrow yes/no columns in the book list not very convenient
Fixes #1272089 [Making True/False columns narrow displaces the drop down list](https://bugs.launchpad.net/calibre/+bug/1272089)
This commit is contained in:
parent
706ecd5fe9
commit
715cfb23d2
@ -7,8 +7,8 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt4.Qt import (Qt, QApplication, QStyle, QIcon, QDoubleSpinBox,
|
from PyQt4.Qt import (Qt, QApplication, QStyle, QIcon, QDoubleSpinBox, QStyleOptionViewItemV4,
|
||||||
QVariant, QSpinBox, QStyledItemDelegate, QComboBox, QTextDocument,
|
QVariant, QSpinBox, QStyledItemDelegate, QComboBox, QTextDocument, QSize,
|
||||||
QAbstractTextDocumentLayout, QFont, QFontInfo, QDate, QDateTimeEdit, QDateTime)
|
QAbstractTextDocumentLayout, QFont, QFontInfo, QDate, QDateTimeEdit, QDateTime)
|
||||||
|
|
||||||
from calibre.gui2 import UNDEFINED_QDATETIME, error_dialog, rating_font
|
from calibre.gui2 import UNDEFINED_QDATETIME, error_dialog, rating_font
|
||||||
@ -450,6 +450,21 @@ class CcBoolDelegate(QStyledItemDelegate): # {{{
|
|||||||
val = 2 if val is None else 1 if not val else 0
|
val = 2 if val is None else 1 if not val else 0
|
||||||
editor.setCurrentIndex(val)
|
editor.setCurrentIndex(val)
|
||||||
|
|
||||||
|
def updateEditorGeometry(self, editor, option, index):
|
||||||
|
if editor is None:
|
||||||
|
return
|
||||||
|
opt = QStyleOptionViewItemV4(option)
|
||||||
|
self.initStyleOption(opt, index)
|
||||||
|
opt.showDecorationSelected = True
|
||||||
|
opt.decorationSize = QSize(0, 0) # We want the editor to cover the decoration
|
||||||
|
style = QApplication.style()
|
||||||
|
geom = style.subElementRect(style.SE_ItemViewItemText, opt, None)
|
||||||
|
|
||||||
|
if editor.layoutDirection() == Qt.RightToLeft:
|
||||||
|
delta = editor.sizeHint().width() - geom.width()
|
||||||
|
if delta > 0:
|
||||||
|
geom.adjust(-delta, 0, 0, 0)
|
||||||
|
editor.setGeometry(geom)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class CcTemplateDelegate(QStyledItemDelegate): # {{{
|
class CcTemplateDelegate(QStyledItemDelegate): # {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user