def paint(self, painter, option, index): r = option.rect if option.state & QStyle.State_Selected: painter.fillRect(r, self.parent().palette().highlight()) fontPen = QPen(self.parent().palette().highlightedText(), 1, Qt.SolidLine) else: painter.fillRect(r, self.parent().palette().base()) fontPen = QPen(self.parent().palette().text(), 1, Qt.SolidLine) painter.setPen(fontPen) name = index.data(Qt.DisplayRole) path = index.data(Qt.UserRole) imageSpace = 10 # notebook name r = option.rect.adjusted(imageSpace, 0, -10, -20) name_font = QFont(self.parent().font()) name_font.setPointSize(10) name_font.setBold(True) if index.flags() == Qt.NoItemFlags: name_font.setStrikeOut(True) painter.setFont(name_font) painter.drawText(r.left(), r.top(), r.width(), r.height(), Qt.AlignBottom|Qt.AlignLeft, name) # notebook path path_font = QFont(self.parent().font()) path_font.setPointSize(8) if index.flags() == Qt.NoItemFlags: path_font.setStrikeOut(True) r = option.rect.adjusted(imageSpace, 20, -10, 0) painter.setFont(path_font) painter.drawText(r.left(), r.top(), r.width(), r.height(), Qt.AlignLeft, path)
def data(self, index, role): if not index.isValid(): return None item = index.internalPointer() node = item.node() attributes = [] attributeMap = node.attributes() if role == Qt.DisplayRole: if index.column() == 0: return attributeMap.namedItem("subject").nodeValue() elif index.column() == 1: return attributeMap.namedItem( "percentageComplete").nodeValue().toInt()[0] return None elif role == Qt.CheckStateRole: if index.column() == 0: if attributeMap.namedItem( "percentageComplete").nodeValue() == "100": return Qt.Checked else: return Qt.Unchecked elif role == Qt.FontRole: if index.column() == 0: font = QFont() if attributeMap.namedItem( "percentageComplete").nodeValue() == "100": font.setStrikeOut(True) else: font.setStrikeOut(False) return font elif role == Qt.ForegroundRole: if index.column() == 0: if attributeMap.namedItem( "percentageComplete").nodeValue() == "100": brush = QBrush() brush.setColor(QColor("grey")) return brush return None
def setHeader(self, data=None): if data is None: self.model.clear() nameHeader = 'Select Raster Layer(Palette)' font = QFont() font.setStrikeOut(False) headerModel = QStandardItem(nameHeader) headerModel.setData(font, Qt.FontRole) tip = "Raster with Palette(Single Band)" headerModel.setData(tip, Qt.ToolTipRole) self.model.setHorizontalHeaderItem(0, headerModel) else: headerModel = self.model.horizontalHeaderItem(0) label = "%s" % data['name'] formatMgs = "Layer: %s\nSource: %s\nNumber Class: %d\nWidth: %d\nHeight: %d\nRes.X: %f\nRes.Y: %f\n\n* Double click copy to Clipboard" dataMsg = (data['name'], data['source'], data['num_class'], data['width'], data['height'], data['resX'], data['resY']) tip = formatMgs % dataMsg headerModel.setData(data, Qt.UserRole) headerModel.setData(label, Qt.DisplayRole) headerModel.setData(tip, Qt.ToolTipRole)
def paint(self, painter, option, index): r = option.rect if option.state & QStyle.State_Selected: painter.fillRect(r, self.parent().palette().highlight()) fontPen = QPen(self.parent().palette().highlightedText(), 1, Qt.SolidLine) else: painter.fillRect(r, self.parent().palette().base()) fontPen = QPen(self.parent().palette().text(), 1, Qt.SolidLine) painter.setPen(fontPen) name = index.data(Qt.DisplayRole) path = index.data(Qt.UserRole) imageSpace = 10 # notebook name r = option.rect.adjusted(imageSpace, 0, -10, -20) name_font = QFont(self.parent().font()) name_font.setPointSize(10) name_font.setBold(True) if index.flags() == Qt.NoItemFlags: name_font.setStrikeOut(True) painter.setFont(name_font) painter.drawText(r.left(), r.top(), r.width(), r.height(), Qt.AlignBottom | Qt.AlignLeft, name) # notebook path path_font = QFont(self.parent().font()) path_font.setPointSize(8) if index.flags() == Qt.NoItemFlags: path_font.setStrikeOut(True) r = option.rect.adjusted(imageSpace, 20, -10, 0) painter.setFont(path_font) painter.drawText(r.left(), r.top(), r.width(), r.height(), Qt.AlignLeft, path)
# Copyright (C) 2010 Julien Miotte <*****@*****.**> # # This module is part of gitbuster and is released under the GPLv3 # License: http://www.gnu.org/licenses/gpl-3.0.txt # from PyQt4.QtCore import QAbstractTableModel, QDataStream, QIODevice, \ QModelIndex, QString, QStringList, QVariant, Qt, SIGNAL from PyQt4.QtGui import QColor, QFont from gfbi_core import NOT_EDITABLE_FIELDS, TIME_FIELDS from gfbi_core.editable_git_model import EditableGitModel from gitbuster.q_git_model import QGitModel DELETED_FONT = QFont("Sans Serif", italic=True) DELETED_FONT.setStrikeOut(True) class QEditableGitModel(QGitModel): def __init__(self, models_dict, directory=".", fake_branch_name="", from_model_row=None, parent=None): """ Initializes the git model with the repository root directory. :param directory: Root directory of the git repository. Non editable QGitModel can be initialized with a GitModel(to limit the number of GitModels). """
class ClinInfo(QWidget): """ classdocs """ def __init__(self, parent=None): """ Constructor """ QWidget.__init__(self, parent) self.ui = Ui_ClinInfoWidget() self.ui.setupUi(self) self._textClear = 'N/A' self._fontChecked = QFont() self._fontChecked.setStrikeOut(False) self._fontNotChecked = QFont() self._fontNotChecked.setStrikeOut(True) self.clear_all() def clear_all(self): self.ui.label_apgar1.setText(self._textClear) self.ui.label_apgar5.setText(self._textClear) self.ui.label_bdecf.setText(self._textClear) self.ui.label_be.setText(self._textClear) self.ui.label_gravidity.setText(self._textClear) self.ui.label_IIstage.setText(self._textClear) self.ui.label_Istage.setText(self._textClear) self.ui.label_maternal_age.setText(self._textClear) self.ui.label_parity.setText(self._textClear) self.ui.label_pco2.setText(self._textClear) self.ui.label_ph.setText(self._textClear) self.ui.label_presentation.setText(self._textClear) self.ui.label_sex.setText(self._textClear) self.ui.label_sig2birth.setText(self._textClear) self.ui.label_week_gestation.setText(self._textClear) self.ui.label_weigth.setText(self._textClear) self.ui.label_annot.setText(self._textClear) # risk factors self.__set_label_not_present(self.ui.label_diabetes) self.__set_label_not_present(self.ui.label_fever) self.__set_label_not_present(self.ui.label_hypertension) self.__set_label_not_present(self.ui.label_libpreacox) self.__set_label_not_present(self.ui.label_meconium) self.__set_label_not_present(self.ui.label_preeclampsia) def set_all(self, dict_clin_info): self.clear_all() # print dictClinInfo.keys() self.__set_label(dict_clin_info, 'Apgar1', self.ui.label_apgar1) self.__set_label(dict_clin_info, 'Apgar5', self.ui.label_apgar5) self.__set_label(dict_clin_info, 'BDecf', self.ui.label_bdecf) self.__set_label(dict_clin_info, 'BE', self.ui.label_be) self.__set_label(dict_clin_info, 'Gravidity', self.ui.label_gravidity) self.__set_label(dict_clin_info, 'IIstage', self.ui.label_IIstage) self.__set_label(dict_clin_info, 'Istage', self.ui.label_Istage) self.__set_label(dict_clin_info, 'Age', self.ui.label_maternal_age) self.__set_label(dict_clin_info, 'Parity', self.ui.label_parity) self.__set_label(dict_clin_info, 'pCO2', self.ui.label_pco2) self.__set_label(dict_clin_info, 'pH', self.ui.label_ph) self.__set_label(dict_clin_info, 'Presentation', self.ui.label_presentation) self.__set_label(dict_clin_info, 'Sex', self.ui.label_sex) self.__set_label(dict_clin_info, 'Sig2Birth', self.ui.label_sig2birth) self.__set_label(dict_clin_info, 'Gest_weeks', self.ui.label_week_gestation) self.__set_label(dict_clin_info, 'Weight_g', self.ui.label_weigth) self.__set_label(dict_clin_info, 'ClinAnnotation', self.ui.label_annot) self.__set_risk_factors(dict_clin_info, 'Diabetes', self.ui.label_diabetes) self.__set_risk_factors(dict_clin_info, '', self.ui.label_fever) self.__set_risk_factors(dict_clin_info, 'Hypertension', self.ui.label_hypertension) self.__set_risk_factors(dict_clin_info, 'Liq_praecox', self.ui.label_libpreacox) self.__set_risk_factors(dict_clin_info, 'Meconium', self.ui.label_meconium) self.__set_risk_factors(dict_clin_info, 'Preeclampsia', self.ui.label_preeclampsia) def __set_label_not_present(self, label): label.setFont(self._fontNotChecked) label.setEnabled(False) def __set_label(self, dict_ci, key, label): if key in dict_ci: label.setText(str(dict_ci[key])) def __set_risk_factors(self, dict_ci, key, label): if key in dict_ci: if dict_ci[key] > 0: label.setFont(self._fontChecked) label.setEnabled(True)