本文整理汇总了Python中PyQt5.Qt.QTableView.model方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.model方法的具体用法?Python QTableView.model怎么用?Python QTableView.model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTableView
的用法示例。
在下文中一共展示了QTableView.model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginUpdaterDialog
# 需要导入模块: from PyQt5.Qt import QTableView [as 别名]
# 或者: from PyQt5.Qt.QTableView import model [as 别名]
class PluginUpdaterDialog(SizePersistedDialog):
initial_extra_size = QSize(350, 100)
forum_label_text = _('Plugin homepage')
def __init__(self, gui, initial_filter=FILTER_UPDATE_AVAILABLE):
SizePersistedDialog.__init__(self, gui, 'Plugin Updater plugin:plugin updater dialog')
self.gui = gui
self.forum_link = None
self.zip_url = None
self.model = None
self.do_restart = False
self._initialize_controls()
self._create_context_menu()
try:
display_plugins = read_available_plugins(raise_error=True)
except Exception:
display_plugins = []
import traceback
error_dialog(self.gui, _('Update Check Failed'),
_('Unable to reach the plugin index page.'),
det_msg=traceback.format_exc(), show=True)
if display_plugins:
self.model = DisplayPluginModel(display_plugins)
self.proxy_model = DisplayPluginSortFilterModel(self)
self.proxy_model.setSourceModel(self.model)
self.plugin_view.setModel(self.proxy_model)
self.plugin_view.resizeColumnsToContents()
self.plugin_view.selectionModel().currentRowChanged.connect(self._plugin_current_changed)
self.plugin_view.doubleClicked.connect(self.install_button.click)
self.filter_combo.setCurrentIndex(initial_filter)
self._select_and_focus_view()
else:
self.filter_combo.setEnabled(False)
# Cause our dialog size to be restored from prefs or created on first usage
self.resize_dialog()
def _initialize_controls(self):
self.setWindowTitle(_('User plugins'))
self.setWindowIcon(QIcon(I('plugins/plugin_updater.png')))
layout = QVBoxLayout(self)
self.setLayout(layout)
title_layout = ImageTitleLayout(self, 'plugins/plugin_updater.png',
_('User plugins'))
layout.addLayout(title_layout)
header_layout = QHBoxLayout()
layout.addLayout(header_layout)
self.filter_combo = PluginFilterComboBox(self)
self.filter_combo.setMinimumContentsLength(20)
self.filter_combo.currentIndexChanged[int].connect(self._filter_combo_changed)
la = QLabel(_('Filter list of &plugins')+':', self)
la.setBuddy(self.filter_combo)
header_layout.addWidget(la)
header_layout.addWidget(self.filter_combo)
header_layout.addStretch(10)
# filter plugins by name
la = QLabel(_('Filter by &name')+':', self)
header_layout.addWidget(la)
self.filter_by_name_lineedit = QLineEdit(self)
la.setBuddy(self.filter_by_name_lineedit)
self.filter_by_name_lineedit.setText("")
self.filter_by_name_lineedit.textChanged.connect(self._filter_name_lineedit_changed)
header_layout.addWidget(self.filter_by_name_lineedit)
self.plugin_view = QTableView(self)
self.plugin_view.horizontalHeader().setStretchLastSection(True)
self.plugin_view.setSelectionBehavior(QAbstractItemView.SelectRows)
self.plugin_view.setSelectionMode(QAbstractItemView.SingleSelection)
self.plugin_view.setAlternatingRowColors(True)
self.plugin_view.setSortingEnabled(True)
self.plugin_view.setIconSize(QSize(28, 28))
layout.addWidget(self.plugin_view)
details_layout = QHBoxLayout()
layout.addLayout(details_layout)
forum_label = self.forum_label = QLabel('')
forum_label.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard)
forum_label.linkActivated.connect(self._forum_label_activated)
details_layout.addWidget(QLabel(_('Description')+':', self), 0, Qt.AlignLeft)
details_layout.addWidget(forum_label, 1, Qt.AlignRight)
self.description = QLabel(self)
self.description.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.description.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.description.setMinimumHeight(40)
self.description.setWordWrap(True)
layout.addWidget(self.description)
self.button_box = QDialogButtonBox(QDialogButtonBox.Close)
self.button_box.rejected.connect(self.reject)
self.finished.connect(self._finished)
self.install_button = self.button_box.addButton(_('&Install'), QDialogButtonBox.AcceptRole)
self.install_button.setToolTip(_('Install the selected plugin'))
self.install_button.clicked.connect(self._install_clicked)
self.install_button.setEnabled(False)
#.........这里部分代码省略.........
示例2: OpdsDialog
# 需要导入模块: from PyQt5.Qt import QTableView [as 别名]
# 或者: from PyQt5.Qt.QTableView import model [as 别名]
class OpdsDialog(QDialog):
def __init__(self, gui, icon, do_user_config):
QDialog.__init__(self, gui)
self.gui = gui
self.do_user_config = do_user_config
self.db = gui.current_db.new_api
# The model for the book list
self.model = OpdsBooksModel(None, self.dummy_books(), self.db)
self.searchproxymodel = QSortFilterProxyModel(self)
self.searchproxymodel.setFilterCaseSensitivity(Qt.CaseInsensitive)
self.searchproxymodel.setFilterKeyColumn(-1)
self.searchproxymodel.setSourceModel(self.model)
self.layout = QGridLayout()
self.setLayout(self.layout)
self.setWindowTitle('OPDS Client')
self.setWindowIcon(icon)
labelColumnWidths = []
self.opdsUrlLabel = QLabel('OPDS URL: ')
self.layout.addWidget(self.opdsUrlLabel, 0, 0)
labelColumnWidths.append(self.layout.itemAtPosition(0, 0).sizeHint().width())
config.convertSingleStringOpdsUrlPreferenceToListOfStringsPreference()
self.opdsUrlEditor = QComboBox(self)
self.opdsUrlEditor.activated.connect(self.opdsUrlEditorActivated)
self.opdsUrlEditor.addItems(prefs['opds_url'])
self.opdsUrlEditor.setEditable(True)
self.opdsUrlEditor.setInsertPolicy(QComboBox.InsertAtTop)
self.layout.addWidget(self.opdsUrlEditor, 0, 1, 1, 3)
self.opdsUrlLabel.setBuddy(self.opdsUrlEditor)
buttonColumnNumber = 7
buttonColumnWidths = []
self.about_button = QPushButton('About', self)
self.about_button.setAutoDefault(False)
self.about_button.clicked.connect(self.about)
self.layout.addWidget(self.about_button, 0, buttonColumnNumber)
buttonColumnWidths.append(self.layout.itemAtPosition(0, buttonColumnNumber).sizeHint().width())
# Initially download the catalogs found in the root catalog of the URL
# selected at startup. Fail quietly on failing to open the URL
catalogsTuple = self.model.downloadOpdsRootCatalog(self.gui, self.opdsUrlEditor.currentText(), False)
print catalogsTuple
firstCatalogTitle = catalogsTuple[0]
self.currentOpdsCatalogs = catalogsTuple[1] # A dictionary of title->feedURL
self.opdsCatalogSelectorLabel = QLabel('OPDS Catalog:')
self.layout.addWidget(self.opdsCatalogSelectorLabel, 1, 0)
labelColumnWidths.append(self.layout.itemAtPosition(1, 0).sizeHint().width())
self.opdsCatalogSelector = QComboBox(self)
self.opdsCatalogSelector.setEditable(False)
self.opdsCatalogSelectorModel = QStringListModel(self.currentOpdsCatalogs.keys())
self.opdsCatalogSelector.setModel(self.opdsCatalogSelectorModel)
self.opdsCatalogSelector.setCurrentText(firstCatalogTitle)
self.layout.addWidget(self.opdsCatalogSelector, 1, 1, 1, 3)
self.download_opds_button = QPushButton('Download OPDS', self)
self.download_opds_button.setAutoDefault(False)
self.download_opds_button.clicked.connect(self.download_opds)
self.layout.addWidget(self.download_opds_button, 1, buttonColumnNumber)
buttonColumnWidths.append(self.layout.itemAtPosition(1, buttonColumnNumber).sizeHint().width())
# Search GUI
self.searchEditor = QLineEdit(self)
self.searchEditor.returnPressed.connect(self.searchBookList)
self.layout.addWidget(self.searchEditor, 2, buttonColumnNumber - 2, 1, 2)
self.searchButton = QPushButton('Search', self)
self.searchButton.setAutoDefault(False)
self.searchButton.clicked.connect(self.searchBookList)
self.layout.addWidget(self.searchButton, 2, buttonColumnNumber)
buttonColumnWidths.append(self.layout.itemAtPosition(2, buttonColumnNumber).sizeHint().width())
# The main book list
self.library_view = QTableView(self)
self.library_view.setAlternatingRowColors(True)
self.library_view.setModel(self.searchproxymodel)
self.library_view.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
self.library_view.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
self.library_view.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)
self.library_view.setSelectionBehavior(QAbstractItemView.SelectRows)
self.resizeAllLibraryViewLinesToHeaderHeight()
self.library_view.resizeColumnsToContents()
self.layout.addWidget(self.library_view, 3, 0, 3, buttonColumnNumber + 1)
self.hideNewsCheckbox = QCheckBox('Hide Newspapers', self)
self.hideNewsCheckbox.clicked.connect(self.setHideNewspapers)
self.hideNewsCheckbox.setChecked(prefs['hideNewspapers'])
self.layout.addWidget(self.hideNewsCheckbox, 6, 0, 1, 3)
self.hideBooksAlreadyInLibraryCheckbox = QCheckBox('Hide books already in library', self)
self.hideBooksAlreadyInLibraryCheckbox.clicked.connect(self.setHideBooksAlreadyInLibrary)
self.hideBooksAlreadyInLibraryCheckbox.setChecked(prefs['hideBooksAlreadyInLibrary'])
#.........这里部分代码省略.........