mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 04:34:27 +02:00
Fix #1158066 ({Enhance] Indicate Custom Columns in column lists)
This commit is contained in:
parent
fcf3d082be
commit
503719a1fe
3 changed files with 7 additions and 2 deletions
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import copy, sys
|
||||
|
||||
from PyQt4.Qt import Qt, QVariant, QListWidgetItem
|
||||
from PyQt4.Qt import Qt, QVariant, QListWidgetItem, QIcon
|
||||
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||
from calibre.gui2.preferences.columns_ui import Ui_Form
|
||||
|
|
@ -67,6 +67,8 @@ def init_columns(self, defaults=False):
|
|||
for col in colmap:
|
||||
item = QListWidgetItem(model.headers[col], self.opt_columns)
|
||||
item.setData(Qt.UserRole, QVariant(col))
|
||||
if col.startswith('#'):
|
||||
item.setData(Qt.DecorationRole, QVariant(QIcon(I('column.png'))))
|
||||
flags = Qt.ItemIsEnabled|Qt.ItemIsSelectable
|
||||
if col != 'ondevice':
|
||||
flags |= Qt.ItemIsUserCheckable
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
import re
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import QDialog, Qt, QListWidgetItem, QVariant, QColor
|
||||
from PyQt4.Qt import QDialog, Qt, QListWidgetItem, QVariant, QColor, QIcon
|
||||
|
||||
from calibre.gui2.preferences.create_custom_column_ui import Ui_QCreateCustomColumn
|
||||
from calibre.gui2 import error_dialog
|
||||
|
|
@ -323,6 +323,7 @@ def accept(self):
|
|||
}
|
||||
item = QListWidgetItem(col_heading, self.parent.opt_columns)
|
||||
item.setData(Qt.UserRole, QVariant(key))
|
||||
item.setData(Qt.DecorationRole, QVariant(QIcon(I('column.png'))))
|
||||
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
|
||||
item.setCheckState(Qt.Checked)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ def data(self, index, role):
|
|||
return name
|
||||
if role == Qt.CheckStateRole:
|
||||
return Qt.Checked if visible else Qt.Unchecked
|
||||
if role == Qt.DecorationRole and field.startswith('#'):
|
||||
return QIcon(I('column.png'))
|
||||
return NONE
|
||||
|
||||
def flags(self, index):
|
||||
|
|
|
|||
Loading…
Reference in a new issue