Пример #1
0
    def data(self, index, role):
        """ return data to be displayed in a cell """
        if role == Qt.DisplayRole:
            logUICall.log("retrieving data %s %s" % (index.column(), index.row()), logUICall.DEBUG_L2)
            if index.column() == 0:
                # first column, show value
                value = self.values[index.row()]
                if value is not None:
                    return QString(value)
                else:
                    return ""
            else:
                # second column, show weight
                return QString("%.2f" % self.weights[index.row()])
        elif role == Qt.ToolTipRole:
            # construct data for display in tooltip
            if index.column() == 0:
                value = self.values[index.row()]
                if value is not None:
                    return build_attribute_tooltip(self.valid_codes, self.parser.parse(value))
            else:
                return QVariant("")

        else:
            return QVariant()
Пример #2
0
 def data(self, index, role):
     """ return data to be displayed in a cell """
     if role == Qt.DisplayRole:
         logUICall.log('retrieving data %s %s' % (index.column(), index.row()),
                          logUICall.DEBUG_L2)
         if (index.column() == 0):
             # first column, show value
             value = self.values[index.row()]
             if value is not None:
                 return QString(value)
             else:
                 return ""
         else:
             # second column, show weight
             return QString('%.2f'% self.weights[index.row()])
     elif role == Qt.ToolTipRole:
         # construct data for display in tooltip            
         if (index.column() == 0):
             value = self.values[index.row()]            
             if value is not None:
                 return build_attribute_tooltip(self.valid_codes, self.parser.parse(value))
         else:
             return QVariant("")            
     
     else:
         return QVariant()
Пример #3
0
 def data(self, index, role):
     """ data for cells """
     col, row = index.column(), index.row()
     logAPICall.log('data col %s row %s' % (row, col), logAPICall.DEBUG_L2)
     
     if role == Qt.DisplayRole:
         # construct data for display in table
         _mod = self.get_modifier(row)
         _idx = row - _mod[self.STR_INDEX]
         if (col < self.STR_INDEX):
             # for first 4 columns, only first row in new modifier
             # need to show the headings
             if (_idx == 0):
                 return QVariant(_mod[col])
             else:
                 return QVariant()
         else:
             # for last 2 columns, show modifier value and associated percentage
             for _key in sorted(_mod[self.MOD_INDEX].keys()):
                 if (_idx == 0):
                     if (col == self.STR_INDEX):
                         return QVariant(_key)
                     else:
                         return QVariant("%.2f" %_mod[self.MOD_INDEX].value(_key))
                 else:
                     _idx -=1
     elif role == Qt.ToolTipRole:
         # construct data for display in tooltip
         _mod = self.get_modifier(row)
         _idx = row - _mod[self.STR_INDEX]
         if col==1:
             if (_idx == 0):                    
                 return build_attribute_tooltip(self.valid_codes, self.ms.taxonomy.parse(_mod[col]))
             else:
                 return QVariant()
         elif col==2:
             _key = sorted(_mod[self.MOD_INDEX].keys())[_idx]
             if _key is not None:
                 return build_attribute_tooltip(self.valid_codes, self.ms.taxonomy.parse(_key))
         else:
             return QVariant("")
     else:
         return QVariant()
Пример #4
0
    def data(self, index, role):
        """
        (override function) retrieve appropriate data to show in UI given a index
        currently only DisplayRole is implemented
        """
        logUICall.log("data %s" % (index), logUICall.DEBUG_L2)

        if not index.isValid():  # invalid case, nothing to display
            return None

        if role == Qt.DisplayRole:
            # construct data to show in tree UI
            item = index.internalPointer()
            if item == self.rootNode:
                # root node
                logUICall.log("\tindex is root", logUICall.DEBUG_L2)
                return 'ROOT'
            elif isinstance(item, MappingSchemeZone):
                # zone node(first level under root node)
                # statistic in each zone should be 100%
                logUICall.log("\tindex is zone %s" % (item.name),
                              logUICall.DEBUG_L2)
                return '%s - %2.1f%%' % (item.name, 100.0)
            else:
                # statistic node
                # show weight for node
                logUICall.log(
                    "\tindex is node %s %s" % (item.value, item.weight),
                    logUICall.DEBUG_L2)
                if item.value is None:
                    return ' - %2.1f%%' % (item.weight)
                else:
                    return '%s - %2.1f%%' % (item.value, item.weight)
        elif role == Qt.ToolTipRole:
            # lookup data to show in tool tip
            item = index.internalPointer()
            if isinstance(item, MappingSchemeZone):
                return "Mapping Scheme Zone - %s" % item.name
            elif isinstance(item, StatisticNode):
                return build_attribute_tooltip(
                    self.valid_codes, self.ms.taxonomy.parse(item.value))
            else:
                return ""
        elif role == Qt.UserRole:
            return index.internalPointer()
        else:
            return None
Пример #5
0
 def data(self, index, role):
     """
     (override function) retrieve appropriate data to show in UI given a index
     currently only DisplayRole is implemented
     """
     logUICall.log("data %s" % (index), logUICall.DEBUG_L2)
     
     if not index.isValid():  # invalid case, nothing to display
         return None
     
     if role == Qt.DisplayRole:
         # construct data to show in tree UI
         item = index.internalPointer()
         if item == self.rootNode:
             # root node
             logUICall.log("\tindex is root", logUICall.DEBUG_L2)
             return 'ROOT'
         elif isinstance(item, MappingSchemeZone):
             # zone node(first level under root node)
             # statistic in each zone should be 100%
             logUICall.log("\tindex is zone %s" % (item.name), logUICall.DEBUG_L2)
             return '%s - %2.1f%%' % (item.name, 100.0)
         else:
             # statistic node 
             # show weight for node
             logUICall.log("\tindex is node %s %s" % (item.value, item.weight), logUICall.DEBUG_L2)
             if item.value is None:
                 return ' - %2.1f%%' % (item.weight)
             else:
                 return '%s - %2.1f%%' % (item.value, item.weight)
     elif role == Qt.ToolTipRole: 
         # lookup data to show in tool tip
         item = index.internalPointer()
         if isinstance(item, MappingSchemeZone):
             return "Mapping Scheme Zone - %s" % item.name
         elif isinstance(item, StatisticNode):                
             return build_attribute_tooltip(self.valid_codes, self.ms.taxonomy.parse(item.value))
         else:
             return "" 
     elif role == Qt.UserRole:            
         return index.internalPointer()
     else:
         return None
Пример #6
0
 def data(self, index, role):
     """ return data to be displayed in a cell """
     row, col = index.row(), index.column()                
     value = self.values[row][col]        
     if role == Qt.DisplayRole:
         if value is not None:
             return QString(self.formats[col] % value)
         else:
             return QVariant("")
     elif role == Qt.ToolTipRole:
         # construct data for display in tooltip            
         if (index.column() == 0):                            
             if value is not None:
                 return build_attribute_tooltip(self.valid_codes, self.parser.parse(value))
         else:
             return QVariant("")
     elif role == Qt.UserRole:            
         return index.internalPointer()
     else:
         return QVariant()
Пример #7
0
 def data(self, index, role):
     """ return data to be displayed in a cell """
     row, col = index.row(), index.column()
     value = self.values[row][col]
     if role == Qt.DisplayRole:
         if value is not None:
             return QString(self.formats[col] % value)
         else:
             return QVariant("")
     elif role == Qt.ToolTipRole:
         # construct data for display in tooltip
         if (index.column() == 0):
             if value is not None:
                 return build_attribute_tooltip(self.valid_codes,
                                                self.parser.parse(value))
         else:
             return QVariant("")
     elif role == Qt.UserRole:
         return index.internalPointer()
     else:
         return QVariant()