mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1158066 ({Enhance] Indicate Custom Columns in column lists)
This commit is contained in:
parent
fcf3d082be
commit
503719a1fe
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import copy, sys
|
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 import ConfigWidgetBase, test_widget
|
||||||
from calibre.gui2.preferences.columns_ui import Ui_Form
|
from calibre.gui2.preferences.columns_ui import Ui_Form
|
||||||
@ -67,6 +67,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
for col in colmap:
|
for col in colmap:
|
||||||
item = QListWidgetItem(model.headers[col], self.opt_columns)
|
item = QListWidgetItem(model.headers[col], self.opt_columns)
|
||||||
item.setData(Qt.UserRole, QVariant(col))
|
item.setData(Qt.UserRole, QVariant(col))
|
||||||
|
if col.startswith('#'):
|
||||||
|
item.setData(Qt.DecorationRole, QVariant(QIcon(I('column.png'))))
|
||||||
flags = Qt.ItemIsEnabled|Qt.ItemIsSelectable
|
flags = Qt.ItemIsEnabled|Qt.ItemIsSelectable
|
||||||
if col != 'ondevice':
|
if col != 'ondevice':
|
||||||
flags |= Qt.ItemIsUserCheckable
|
flags |= Qt.ItemIsUserCheckable
|
||||||
|
@ -6,7 +6,7 @@ __copyright__ = '2010, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import re
|
import re
|
||||||
from functools import partial
|
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.preferences.create_custom_column_ui import Ui_QCreateCustomColumn
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
@ -323,6 +323,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
}
|
}
|
||||||
item = QListWidgetItem(col_heading, self.parent.opt_columns)
|
item = QListWidgetItem(col_heading, self.parent.opt_columns)
|
||||||
item.setData(Qt.UserRole, QVariant(key))
|
item.setData(Qt.UserRole, QVariant(key))
|
||||||
|
item.setData(Qt.DecorationRole, QVariant(QIcon(I('column.png'))))
|
||||||
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
|
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
|
||||||
item.setCheckState(Qt.Checked)
|
item.setCheckState(Qt.Checked)
|
||||||
else:
|
else:
|
||||||
|
@ -53,6 +53,8 @@ class DisplayedFields(QAbstractListModel): # {{{
|
|||||||
return name
|
return name
|
||||||
if role == Qt.CheckStateRole:
|
if role == Qt.CheckStateRole:
|
||||||
return Qt.Checked if visible else Qt.Unchecked
|
return Qt.Checked if visible else Qt.Unchecked
|
||||||
|
if role == Qt.DecorationRole and field.startswith('#'):
|
||||||
|
return QIcon(I('column.png'))
|
||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
def flags(self, index):
|
def flags(self, index):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user