def render_result(self): query = self.query_edit.text() if not query: return self.feed = FeedBooks() response = self.feed.search(str(query)) if not response: QMessageBox.critical(self, 'Error', 'Could not get any result') return self.table.clear() self.table.setHorizontalHeaderLabels(['Select', 'Title', 'URL']) self.table.setRowCount(len(response[1])) for i, name in enumerate(zip(response[1], response[3])): item = QTableWidgetItem(1) item.data(Qt.CheckStateRole) item.setCheckState(Qt.Checked) self.table.setItem(i, 0, item) for j in range(2): item = QTableWidgetItem(name[j]) item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.table.setItem(i, j+1, item) self.table.resizeColumnsToContents()
def data(self,role): if role == Qt.DisplayRole : if self.value.isValid(): return self.value.toString() else: return "####" elif (role == Qt.TextAlignmentRole): if (self.value.type() == QVariant.String): return int(Qt.AlignLeft | Qt.AlignVCenter) else: return int(Qt.AlignRight | Qt.AlignVCenter) else: return QTableWidgetItem.data(role)
def data(self, role): if role == Qt.DisplayRole: if self.value.isValid(): return self.value.toString() else: return "####" elif (role == Qt.TextAlignmentRole): if (self.value.type() == QVariant.String): return int(Qt.AlignLeft | Qt.AlignVCenter) else: return int(Qt.AlignRight | Qt.AlignVCenter) else: return QTableWidgetItem.data(role)
def addNodeInIndexList(self, index): """ Add the node wich pointer is index.data(QT.UserRole + 1) in the indexedItems list. """ # get the node from the index node_ptr = self.selectIndexItems.model().data(index, Qt.UserRole + 1) if not node_ptr.isValid(): return added_node = VFS.Get().getNodeFromPointer(node_ptr.toULongLong()[0]) # add the node.this into the selected items list new_item = QTableWidgetItem(QIcon(":/folder.png"), added_node.name()) new_item.setData(Qt.UserRole + 1, QVariant(long(added_node.this))) self.tmp_indexed_items[long(added_node.this)] = False new_checkbox = QTableWidgetItem(1); new_checkbox.data(Qt.CheckStateRole); new_checkbox.setCheckState(Qt.Unchecked); self.indexedItems.insertRow(0) self.indexedItems.setItem(0, 0, new_item) self.indexedItems.setItem(0, 1, new_checkbox)
def __initializeUi(self): """ Initializes the Widget ui. """ umbra.ui.common.setWindowDefaultIcon(self) LOGGER.debug("> Initializing '{0}' ui.".format( self.__class__.__name__)) if Constants.applicationName not in self.__releases: self.sIBL_GUI_frame.hide() self.Get_sIBL_GUI_pushButton.hide() else: self.Logo_label.setPixmap( QPixmap( os.path.join(self.__uiResourcesDirectory, self.__uiLogoImage))) self.Your_Version_label.setText( self.__releases[Constants.applicationName].localVersion) self.Latest_Version_label.setText( self.__releases[Constants.applicationName].repositoryVersion) self.Change_Log_webView.load( QUrl.fromEncoded(QByteArray(self.__applicationChangesUrl))) templatesReleases = dict(self.__releases) if Constants.applicationName in self.__releases: templatesReleases.pop(Constants.applicationName) if not templatesReleases: self.Templates_frame.hide() self.Get_Latest_Templates_pushButton.hide() else: self.Templates_label.setPixmap( QPixmap( os.path.join(self.__uiResourcesDirectory, self.__uiTemplatesImage))) self.Templates_tableWidget.setParent(None) self.Templates_tableWidget = TemplatesReleases_QTableWidget( self, message="No Releases to view!") self.Templates_tableWidget.setObjectName("Templates_tableWidget") self.Templates_frame_gridLayout.addWidget( self.Templates_tableWidget, 1, 0) self.__view = self.Templates_tableWidget self.__view.clear() self.__view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.__view.setRowCount(len(templatesReleases)) self.__view.setColumnCount(len(self.__headers)) self.__view.setHorizontalHeaderLabels(self.__headers) self.__view.hideColumn(0) self.__view.horizontalHeader().setStretchLastSection(True) palette = QPalette() palette.setColor(QPalette.Base, Qt.transparent) self.__view.setPalette(palette) verticalHeaderLabels = [] for row, release in enumerate(sorted(templatesReleases)): verticalHeaderLabels.append(release) tableWidgetItem = QTableWidgetItem() tableWidgetItem.data = templatesReleases[release] self.__view.setItem(row, 0, tableWidgetItem) tableWidgetItem = Variable_QPushButton( self, True, (self.__uiLightGrayColor, self.__uiDarkGrayColor), ("Yes", "No")) tableWidgetItem.setObjectName("Spread_Sheet_pushButton") self.__view.setCellWidget(row, 1, tableWidgetItem) tableWidgetItem = QTableWidgetItem( templatesReleases[release].localVersion or Constants.nullObject) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 2, tableWidgetItem) tableWidgetItem = QTableWidgetItem( templatesReleases[release].repositoryVersion) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 3, tableWidgetItem) tableWidgetItem = QTableWidgetItem( templatesReleases[release].type) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 4, tableWidgetItem) tableWidgetItem = QTableWidgetItem( templatesReleases[release].comment) self.__view.setItem(row, 5, tableWidgetItem) self.__view.setVerticalHeaderLabels(verticalHeaderLabels) self.__view.resizeColumnsToContents() # Signals / Slots. self.Get_sIBL_GUI_pushButton.clicked.connect( self.__Get_sIBL_GUI_pushButton__clicked) self.Get_Latest_Templates_pushButton.clicked.connect( self.__Get_Latest_Templates_pushButton__clicked) self.Open_Repository_pushButton.clicked.connect( self.__Open_Repository_pushButton__clicked) self.Close_pushButton.clicked.connect(self.__Close_pushButton__clicked)
def __initializeUi(self): """ Initializes the Widget ui. """ umbra.ui.common.setWindowDefaultIcon(self) LOGGER.debug("> Initializing '{0}' ui.".format(self.__class__.__name__)) if Constants.applicationName not in self.__releases: self.sIBL_GUI_frame.hide() self.Get_sIBL_GUI_pushButton.hide() else: self.Logo_label.setPixmap(QPixmap(os.path.join(self.__uiResourcesDirectory, self.__uiLogoImage))) self.Your_Version_label.setText(self.__releases[Constants.applicationName].localVersion) self.Latest_Version_label.setText(self.__releases[Constants.applicationName].repositoryVersion) self.Change_Log_webView.load(QUrl.fromEncoded(QByteArray(self.__applicationChangesUrl))) templatesReleases = dict(self.__releases) if Constants.applicationName in self.__releases: templatesReleases.pop(Constants.applicationName) if not templatesReleases: self.Templates_frame.hide() self.Get_Latest_Templates_pushButton.hide() else: self.Templates_label.setPixmap(QPixmap(os.path.join(self.__uiResourcesDirectory, self.__uiTemplatesImage))) self.Templates_tableWidget.setParent(None) self.Templates_tableWidget = TemplatesReleases_QTableWidget(self, message="No Releases to view!") self.Templates_tableWidget.setObjectName("Templates_tableWidget") self.Templates_frame_gridLayout.addWidget(self.Templates_tableWidget, 1, 0) self.__view = self.Templates_tableWidget self.__view.clear() self.__view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.__view.setRowCount(len(templatesReleases)) self.__view.setColumnCount(len(self.__headers)) self.__view.setHorizontalHeaderLabels(self.__headers) self.__view.hideColumn(0) self.__view.horizontalHeader().setStretchLastSection(True) palette = QPalette() palette.setColor(QPalette.Base, Qt.transparent) self.__view.setPalette(palette) verticalHeaderLabels = [] for row, release in enumerate(sorted(templatesReleases)): verticalHeaderLabels.append(release) tableWidgetItem = QTableWidgetItem() tableWidgetItem.data = templatesReleases[release] self.__view.setItem(row, 0, tableWidgetItem) tableWidgetItem = Variable_QPushButton(self, True, (self.__uiLightGrayColor, self.__uiDarkGrayColor), ("Yes", "No")) tableWidgetItem.setObjectName("Spread_Sheet_pushButton") self.__view.setCellWidget(row, 1, tableWidgetItem) tableWidgetItem = QTableWidgetItem(templatesReleases[release].localVersion or Constants.nullObject) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 2, tableWidgetItem) tableWidgetItem = QTableWidgetItem(templatesReleases[release].repositoryVersion) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 3, tableWidgetItem) tableWidgetItem = QTableWidgetItem(templatesReleases[release].type) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 4, tableWidgetItem) tableWidgetItem = QTableWidgetItem(templatesReleases[release].comment) self.__view.setItem(row, 5, tableWidgetItem) self.__view.setVerticalHeaderLabels(verticalHeaderLabels) self.__view.resizeColumnsToContents() # Signals / Slots. self.Get_sIBL_GUI_pushButton.clicked.connect(self.__Get_sIBL_GUI_pushButton__clicked) self.Get_Latest_Templates_pushButton.clicked.connect(self.__Get_Latest_Templates_pushButton__clicked) self.Open_Repository_pushButton.clicked.connect(self.__Open_Repository_pushButton__clicked) self.Close_pushButton.clicked.connect(self.__Close_pushButton__clicked)