Пример #1
0
 def emitCurrentRecordChanged(self):
     """
     Emits the current record changed signal for this combobox, provided \
     the signals aren't blocked.
     """
     record = unwrapVariant(self.itemData(self.currentIndex(), Qt.UserRole))
     if not Table.recordcheck(record):
         record = None
     
     self._currentRecord = record
     if not self.signalsBlocked():
         self._changedRecord = record
         self.currentRecordChanged.emit(record)
Пример #2
0
    def emitCurrentRecordChanged(self):
        """
        Emits the current record changed signal for this combobox, provided \
        the signals aren't blocked.
        """
        record = unwrapVariant(self.itemData(self.currentIndex(), Qt.UserRole))
        if not Table.recordcheck(record):
            record = None

        self._currentRecord = record
        if not self.signalsBlocked():
            self._changedRecord = record
            self.currentRecordChanged.emit(record)
Пример #3
0
 def setCurrentRecord(self, record, autoAdd=False):
     """
     Sets the index for this combobox to the inputed record instance.
     
     :param      record      <orb.Table>
     
     :return     <bool> success
     """
     if record is not None and not Table.recordcheck(record):
         return False
     
     # don't reassign the current record
     # clear the record
     if record is None:
         self._currentRecord = None
         blocked = self.signalsBlocked()
         self.blockSignals(True)
         self.setCurrentIndex(-1)
         self.blockSignals(blocked)
         
         if not blocked:
             self.currentRecordChanged.emit(None)
         
         return True
     
     elif record == self.currentRecord():
         return False
     
     self._currentRecord = record
     found = False
     
     blocked = self.signalsBlocked()
     self.blockSignals(True)
     for i in range(self.count()):
         stored = unwrapVariant(self.itemData(i, Qt.UserRole))
         if stored == record:
             self.setCurrentIndex(i)
             found = True
             break
     
     if not found and autoAdd:
         self.addRecord(record)
         self.setCurrentIndex(self.count() - 1)
     
     self.blockSignals(blocked)
     
     if not blocked:
         self.currentRecordChanged.emit(record)
     return False
Пример #4
0
    def setCurrentRecord(self, record, autoAdd=False):
        """
        Sets the index for this combobox to the inputed record instance.
        
        :param      record      <orb.Table>
        
        :return     <bool> success
        """
        if record is not None and not Table.recordcheck(record):
            return False

        # don't reassign the current record
        # clear the record
        if record is None:
            self._currentRecord = None
            blocked = self.signalsBlocked()
            self.blockSignals(True)
            self.setCurrentIndex(-1)
            self.blockSignals(blocked)

            if not blocked:
                self.currentRecordChanged.emit(None)

            return True

        elif record == self.currentRecord():
            return False

        self._currentRecord = record
        found = False

        blocked = self.signalsBlocked()
        self.blockSignals(True)
        for i in range(self.count()):
            stored = unwrapVariant(self.itemData(i, Qt.UserRole))
            if stored == record:
                self.setCurrentIndex(i)
                found = True
                break

        if not found and autoAdd:
            self.addRecord(record)
            self.setCurrentIndex(self.count() - 1)

        self.blockSignals(blocked)

        if not blocked:
            self.currentRecordChanged.emit(record)
        return False