Returns the index in a combo box where itemData == value

    Raises a ValueError if data is not found
554070
def _find_combo_data(widget, value):
    
    # Here we check that the result is True, because some classes may overload
    # == and return other kinds of objects whether true or false.
    for idx in range(widget.count()):
        if widget.itemData(idx) is value or (widget.itemData(idx) == value) is True:
            return idx
    else:
        raise ValueError("%s not found in combo box" % (value,))
984923
def get_item_key(self, item):
        """"""
        try:
            ret = item[item['key']]
        except KeyError:
            logger.error("No 'key' available in {}".format(item))
        if isinstance(ret, list):
            return ret[0]
        else:
            return ret
826183
def data_item(self) -> DataItem:
        
        display_panel = self.__display_panel
        if not display_panel:
            return None
        data_item = display_panel.data_item
        return DataItem(data_item) if data_item else None
407525
def __get_value_from_data(self, key, data):
        
        if key.isdigit():
            return data[int(key)]

        if key not in data:
            raise KeyError("Key not exists")

        return data.get(key)
371901
def setComboValue(combo, value):
    
    dataType = unwrapVariant(combo.property('dataType'))
    
    if dataType == 'string':
        return combo.setCurrentIndex(combo.findText(value))
    elif dataType == 'data':
        for i in range(combo.count()):
            if unwrapVariant(combo.itemData(i)) == value:
                return combo.setCurrentIndex(i)
        return combo.setCurrentIndex(-1)
    return combo.setCurrentIndex(value)
1365692
def getitem(source, index):
    
    if isinstance(index, builtins.slice):
        return slice.raw(source, index.start, index.stop, index.step)
    if isinstance(index, int):
        return item.raw(source, index)
    raise TypeError("Not a valid index (int or slice)")
981320
def setData(self, index, value, role=Qt.EditRole):
        """"""
        if not index.isValid() or self.readonly:
            return False
        i = index.row()
        j = index.column()
        value = from_qvariant(value, str)
        dtype = self._data.dtype.name
        if dtype == "bool":
            try:
                val = bool(float(value))
            except ValueError:
                val = value.lower() == "true"
        elif dtype.startswith("string") or dtype.startswith("bytes"):
            val = to_binary_string(value, 'utf8')
        elif dtype.startswith("unicode") or dtype.startswith("str"):
            val = to_text_string(value)
        else:
            if value.lower().startswith('e') or value.lower().endswith('e'):
                return False
            try:
                val = complex(value)
                if not val.imag:
                    val = val.real
            except ValueError as e:
                QMessageBox.critical(self.dialog, "Error",
                                     "Value error: %s" % str(e))
                return False
        try:
            self.test_array[0] = val  # will raise an Exception eventually
        except OverflowError as e:
            print("OverflowError: " + str(e))  # spyder: test-skip
            QMessageBox.critical(self.dialog, "Error",
                                 "Overflow error: %s" % str(e))
            return False

        # Add change to self.changes
        self.changes[(i, j)] = val
        self.dataChanged.emit(index, index)
        if not is_string(val):
            if val > self.vmax:
                self.vmax = val
            if val < self.vmin:
                self.vmin = val
        return True
1007549
def pickdata(self, data):
        
        """
        attrs = data.get(self.__options['attrkey']) or {}
        values = data.get(self.__options['valuekey']) or ''
        return (attrs, values)
631935
def index(self, item):
        
        for i, x in enumerate(self.iter()):
            if x == item:
                return i
        return None
1044479
def getfieldindex(data, commdct, objkey, fname):
    """"""
    objindex = data.dtls.index(objkey)
    objcomm = commdct[objindex]
    for i_index, item in enumerate(objcomm):
        try:
            if item['field'] == [fname]:
                break
        except KeyError as err:
            pass
    return i_index
185360
def get_value(self, index):
        """"""
        if index.column() == 0:
            return self.keys[ index.row() ]
        elif index.column() == 1:
            return self.types[ index.row() ]
        elif index.column() == 2:
            return self.sizes[ index.row() ]
        else:
            return self._data[ self.keys[index.row()] ]
1234541
def get_value(self, column=0, row=0):
        
        x = self._widget.item(row, column)

        if x==None: return x
        else:       return str(self._widget.item(row,column).text())
1127865
def currentValue(self):
        
        enum  = self.enum()
        if ( self.isCheckable() ):
            value = 0
            for i in self.checkedIndexes():
                value |= enum[nativestring(self.itemText(i))]
            return value
        else:
            try:
                return enum[nativestring(self.itemText(self.currentIndex()))]
            except KeyError:
                return 0
437351
def indexFromItem(self, regItem, col=0):
        
        if col < 0:
            col = len(self.attrNames) - col
        try:
            row = self.registry.items.index(regItem)
        except ValueError:
            return QtCore.QModelIndex()
        else:
            return self.index(row, col)
33927
def setData(self, index, value, role=Qt.EditRole):
        
        item = self.itemAt(index)
        if not item:
            return False
        d = item.declaration
        if role == Qt.CheckStateRole:
            checked = value == Qt.Checked
            if checked != d.checked:
                d.checked = checked
                d.toggled(checked)
            return True
        elif role == Qt.EditRole:
            if value != d.text:
                d.text = value
            return True
        return super(QAbstractAtomItemModel, self).setData(index, value, role)
799909
function indexOf(items, item) {
    var len = items.length, i;
    for (i = 0; i < len; i++) {
      if (items[i] === item) {
        return i;
      }
    }
    return -1;
  }
790700
function findItemInDataForExpansion (label) {
    for (let i = 0; i < data.length; i++) {
        if (data[i].label === label) {
            let item = data[i];
            let offset = data.filter(d => d.parent === item.parent).findIndex(d => d.id === item.id);

            return {
                parent: item.parent,
                id: item.id,
                children: item.children,
                offset: offset
            };
        }
    }
}