Exemple #1
0
    def populateTableWidget(self, selectedLog=None):
        logger.debug(">>populateTableWidget()")
        selected = None
        self.logsTableWidget.clear()
        self.logsTableWidget.setSortingEnabled(False)
        self.logsTableWidget.setRowCount(len(self._logTableModel.logs))
        self.logsTableWidget.setColumnCount(len(self._logTableModel.HEADERS))
        self.logsTableWidget.setHorizontalHeaderLabels(
            self._logTableModel.HEADERS)
        for row, log in enumerate(self._logTableModel.logs):
            item = QTableWidgetItem(log.name)
            item.setData(Qt.UserRole, str(id(log)))
            localLogType = LogType.findLogTypeFromMnemonic(log.fileMnemonic)
            if selectedLog is not None and selectedLog == id(log):
                selected = item
            chkBoxItem = QtGui.QTableWidgetItem()
            chkBoxItem.setFlags(QtCore.Qt.ItemIsUserCheckable
                                | QtCore.Qt.ItemIsEnabled)
            chkBoxItem.setCheckState(QtCore.Qt.Unchecked)
            #is this needed?
            chkBoxItem.setData(Qt.UserRole, str(id(log)))

            self.logsTableWidget.setItem(row, logtablemodel.IMPORT, chkBoxItem)
            self.logsTableWidget.setItem(row, logtablemodel.NAME, item)
            self.logsTableWidget.setCellWidget(
                row, logtablemodel.TYPE,
                self.getPreparedTypesCombo(log.fileMnemonic))
            self.logsTableWidget.setCellWidget(
                row, logtablemodel.UNIT,
                self.populateUnitsCombo(localLogType, log.fileUnit))
            self.logsTableWidget.setItem(row, logtablemodel.FILE_MNEMONIC,
                                         QTableWidgetItem(log.fileMnemonic))
            self.logsTableWidget.setItem(row, logtablemodel.FILE_UNIT,
                                         QTableWidgetItem(log.fileUnit))
            self.logsTableWidget.setItem(row, logtablemodel.FILE_DESCRIPTION,
                                         QTableWidgetItem(log.fileDescription))
        self.logsTableWidget.setSortingEnabled(True)
        self.logsTableWidget.resizeColumnsToContents()

        if selected is not None:
            selected.setSelected(True)
            self.logsTableWidget.setCurrentItem(selected)
Exemple #2
0
    def getPreparedTypesCombo(self, logMnemonic):
        typesComboBox = self.generateTypesCombo()
        localLogType = LogType.findLogTypeFromMnemonic(logMnemonic)

        if typesComboBox.findData(localLogType.name):
            index = typesComboBox.findText(localLogType.name)
            logger.debug(
                "--getPreparedTypesCombo() matched name in combo - index: " +
                str(index) + " name: " + str(localLogType.name) + " mnem: " +
                str(logMnemonic))
            typesComboBox.setCurrentIndex(index)
        else:
            type = LogType
            logType = type.UNKNOWN
            index = typesComboBox.findText(logType.name)
            logger.debug("--getPreparedTypesCombo() not matched - index: " +
                         str(index) + " name: " + str(logType.name) +
                         " mnem: " + str(logMnemonic))
            typesComboBox.setCurrentIndex(index)
        return typesComboBox
Exemple #3
0
 def test_getIndex(self):
     logger.debug(">>test_getIndex")
     logType = LogType.findLogTypeFromMnemonic("Time")
     index = logType.getIndex()
     self.assertTrue(5 == index)
Exemple #4
0
 def test_findFromMnemonic1(self):
     logger.debug(">>test_findFromMnemonic1")
     logType = LogType.findLogTypeFromMnemonic("VQtz")
     self.assertTrue("Volume fraction" == logType.name)
Exemple #5
0
 def test_findFromMnemonic0(self):
     """ generated source for method getLogTypeFromString0_Test """
     log = "RHOB"
     logType = LogType.findLogTypeFromMnemonic(log)
     self.assertTrue(
         logType.RHO.__str__().lower() == logType.__str__().lower())
Exemple #6
0
 def convertType(self, fileMnemonic):
     type_ = LogType.findLogTypeFromMnemonic(fileMnemonic).__str__()
     return type_