Python PyQt4.QtCore 模块,QVariant() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt4.QtCore.QVariant()

项目:nettools    作者:germandutchwindtunnels    | 项目源码 | 文件源码
def _submit_pressed(self, row_number):
        """ Qt slot for when a submit button was pressed """
        patchData = self._get_combobox_variantdata(row_number, 0)
        vlanData = self._get_combobox_variantdata(row_number, 2)

        username = self.username
        password = self.password
        switch_hostname = patchData['hostname']
        switchport = patchData['interface']
        old_vlanid = patchData['vlanid']
        vlanid = vlanData['vlanid']

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        portconfig.configure_patchid_raw(
            username, password, switch_hostname, switchport, vlanid, old_vlanid)
        QApplication.restoreOverrideCursor()

        patchData['vlanid'] = vlanid
        self._set_combobox_variantdata(row_number, 0, QVariant(str(patchData)))
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def data (self, index, role=QtCore.Qt.DisplayRole):
        """Return URL item data at given index for given role."""
        V = QtCore.QVariant
        if not index.isValid() or \
           not (0 <= index.row() < len(self.urls)):
            return EmptyQVariant
        urlitem = self.urls[index.row()]
        column = index.column()
        if role == QtCore.Qt.DisplayRole:
            return V(urlitem.display[column])
        elif role == QtCore.Qt.ToolTipRole:
            return V(urlitem.tooltips[column])
        elif role == QtCore.Qt.TextColorRole and column == 3:
            return QtGui.QColor(urlitem.result_color)
        else:
            return EmptyQVariant
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def AddCustomGCodeRowLayer(self, custom_gcode, parent_item, push_row=None):
        icon = QIcon()
        icon.addPixmap(QPixmap(":/images/custom.png"))
        item_col_0 = QStandardItem(icon, "")  # will only display a checkbox + an icon that will never be disabled
        item_col_0.setData(QtCore.QVariant(custom_gcode), CUSTOM_GCODE_OBJECT)  # store a ref to the custom gcode in our treeView element
        item_col_1 = QStandardItem(custom_gcode.name)
        item_col_2 = QStandardItem(str(custom_gcode.nr))
        item_col_3 = QStandardItem()
        if push_row:
            parent_item.insertRow(push_row, [item_col_0, item_col_1, item_col_2, item_col_3])
        else:
            parent_item.appendRow([item_col_0, item_col_1, item_col_2, item_col_3])

        # Deal with the checkboxes (shape enabled or disabled / send shape to TSP optimizer)
        item_col_0.setCheckState(QtCore.Qt.Unchecked if custom_gcode.isDisabled() else QtCore.Qt.Checked)

        flags = QtCore.Qt.ItemIsDragEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled
        item_col_0.setFlags(flags | QtCore.Qt.ItemIsUserCheckable)
        item_col_1.setFlags(flags)
        item_col_2.setFlags(flags)
        item_col_3.setFlags(flags)
项目:email_text_format    作者:juna89    | 项目源码 | 文件源码
def checkforintermidiatestate(self, index):
        parent = index.parent()
        parentlist = []
        while parent.isValid():
            parentlist.insert(0, parent)
            if unicode(self.filePath(parent)) in self.checks:
                break
            parent = parent.parent()

        if parent.isValid():
            self.checks.pop(unicode(self.filePath(parent)))
            parentlist.append(index)
            for i in range(len(parentlist)):
                if i < len(parentlist) - 1:
                    count = self.rowCount(parentlist[i])

                    for j in range(count):
                        childindex = parentlist[i].child(j, 0)
                        if (childindex != parentlist[i + 1]) and (childindex not in self.checks):
                            #self.checks[unicode(self.filePath(childindex))] = QtCore.QVariant(QtCore.Qt.Checked)
                            self.checks[unicode(self.filePath(childindex))] = QtCore.Qt.Checked
                            self.dataChanged.emit(childindex.child(0, 0), childindex.child(self.rowCount(childindex), 0))
                self.tView.collapse(parentlist[i])
                self.tView.expand(parentlist[i])
项目:P4VFX    作者:TomMinor    | 项目源码 | 文件源码
def from_qvariant(qobj=None, convfunc=None):
        """Convert QVariant object to Python object
        This is a transitional function from PyQt API #1 (QVariant exist)
        to PyQt API #2 and Pyside (QVariant does not exist)"""
        if PYQT_API_1:
            # PyQt API #1
            assert isinstance(convfunc, collections.Callable)
            if convfunc in TEXT_TYPES or convfunc is to_text_string:
                return convfunc(qobj.toString())
            elif convfunc is bool:
                return qobj.toBool()
            elif convfunc is int:
                return qobj.toInt()[0]
            elif convfunc is float:
                return qobj.toDouble()[0]
            else:
                return convfunc(qobj)
        else:
            # PyQt API #2
            return qobj
项目:sardana    作者:sardana-org    | 项目源码 | 文件源码
def setValue(self, value, undo=False):
        if not self._actualValue == value:
            if undo:
                self.emit(QtCore.SIGNAL("valueChanged"), copy.deepcopy(
                    self._actualValue), copy.deepcopy(value))
            self._actualValue = copy.deepcopy(value)

        rows = len(value)
        if (self._format == "2D") and (rows > 0):
            columns = len(value[0])
        else:
            columns = 1

        self._model = QtGui.QStandardItemModel(rows, columns)
        for row in range(rows):
            for column in range(columns):

                index = self._model.index(row, column, QtCore.QModelIndex())
                if (self._format == "1D"):
                    self._model.setData(index, QtCore.QVariant(value[row]))
                if (self._format == "2D"):
                    self._model.setData(
                        index, QtCore.QVariant(value[row][column]))
        self._tableView.setModel(self._model)
项目:nettools    作者:germandutchwindtunnels    | 项目源码 | 文件源码
def fillPatchports(self, comboBox):
        """ Fill the patchports into a ComboBox """
        comboBox.clear()
        # Fill out patchports
        self.load_patchports()
        for patchport in self.patchports:
            variantData = QVariant(str(patchport))
            label = patchport['patchid']
            comboBox.addItem(label, variantData)
项目:nettools    作者:germandutchwindtunnels    | 项目源码 | 文件源码
def fillVlans(self, comboBox):
        """ Fill the VLANs into a ComboBox """
        comboBox.clear()
        # Fill out vlans
        self.load_vlans()
        for vlan in self.vlans:
            variantData = QVariant(str(vlan))
            label = vlan['vlanid']  # vlan['vlanname'] + " (" + vlan['vlanid'] + ")"
            comboBox.addItem(label, variantData)
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def data(self, index, role=QtCore.Qt.DisplayRole):
        row = index.row()
        col = index.column()
        if role==QtCore.Qt.DisplayRole:
          if col==0:
            return unicode(self.downloadlist[row].filename)
          elif col==1:
            return self.formatFileSize(self.downloadlist[row].loadedsize)
          elif col==2:
            return self.formatFileSize(self.downloadlist[row].totalsize)
          elif col==3:
            return self.downloadlist[row].progress
        elif role==QtCore.Qt.TextAlignmentRole:
          if col!=0:
            return QtCore.Qt.AlignCenter
        return QtCore.QVariant()
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def headerData(self,index,orientation, role=QtCore.Qt.DisplayRole):
        if role == QtCore.Qt.DisplayRole and orientation==1:
          return QtCore.QVariant(self.headers[index])
        return QtCore.QVariant()
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def data (self, index, role=QtCore.Qt.DisplayRole):
        """Return data at given index for given role."""
        V = QtCore.QVariant
        if not index.isValid() or \
           not (0 <= index.row() < len(self.documents)) or \
           index.column() != 0:
            return EmptyQVariant
        if role == QtCore.Qt.DisplayRole:
            return V(self.documents[index.row()])
        return EmptyQVariant
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def loadResource (self, rtype, url):
        """Handle qthelp:// URLs, load content from help engine."""
        if url.scheme() == "qthelp":
            return QtCore.QVariant(self.engine.fileData(url))
        return QtGui.QTextBrowser.loadResource(self, rtype, url)
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def save_geometry (self, data):
        """Save size and position of main window."""
        size = save_size(data["size"])
        pos = save_point(data["pos"])
        self.settings.beginGroup('mainwindow')
        self.settings.setValue("size", QtCore.QVariant(size))
        self.settings.setValue("pos", QtCore.QVariant(pos))
        self.settings.endGroup()
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def save_treeviewcols (self, data):
        """Save widths of URL treeview columns."""
        self.settings.beginGroup('treeview')
        for key in ("col1", "col2", "col3"):
            self.settings.setValue(key, QtCore.QVariant(data[key]))
        self.settings.endGroup()
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def save_options (self, data):
        """Save GUI options."""
        self.settings.beginGroup('output')
        for key in ("debug", "verbose"):
            self.settings.setValue(key, QtCore.QVariant(data[key]))
        self.settings.endGroup()
        self.settings.beginGroup('checking')
        for key in ("recursionlevel", "warninglines", "ignorelines"):
            self.settings.setValue(key, QtCore.QVariant(data[key]))
        self.settings.endGroup()
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def save_misc(self, data):
        """Save misc options."""
        self.settings.beginGroup('misc')
        key = 'saveresultas'
        self.settings.setValue(key, QtCore.QVariant(data[key]))
        self.settings.endGroup()
项目:segyviewer    作者:Statoil    | 项目源码 | 文件源码
def _get_spec(self, index):
        user_data = self.itemData(index)
        """ :type: QVariant"""
        spec = user_data.toPyObject()
        return {str(key): value for key, value in spec.items()}
项目:py2cpp    作者:mugwort-rc    | 项目源码 | 文件源码
def data(self, index, role=Qt.DisplayRole):
        if not index.isValid() or role != Qt.DisplayRole:
            return QVariant()
        node = index.internalPointer()
        if index.column() == 0:
            return node.name
        elif index.column() == 1:
            return node.value
        return QVariant()
项目:py2cpp    作者:mugwort-rc    | 项目源码 | 文件源码
def headerData(self, section, orientation, role=Qt.DisplayRole):
        if orientation == Qt.Vertical or role != Qt.DisplayRole:
            return QVariant()
        elif orientation == Qt.Horizontal:
            return self.headers[section]
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def itemChange(self, change, value):
        if change == QtGui.QGraphicsItem.ItemPositionChange:
            for arrow in self.arrows:
                arrow.updatePosition()

        return QtCore.QVariant(value)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def createColorMenu(self, slot, defaultColor):
        colors = [QtCore.Qt.black, QtCore.Qt.white, QtCore.Qt.red, QtCore.Qt.blue, QtCore.Qt.yellow]
        names = ["black", "white", "red", "blue", "yellow"]

        colorMenu = QtGui.QMenu(self)
        for color, name in zip(colors, names):
            action = QtGui.QAction(name, self)
            action.setData(QtCore.QVariant(QtGui.QColor(color))) 
            action.setIcon(self.createColorIcon(color))
            action.triggered.connect(slot)
            colorMenu.addAction(action)
            if color == defaultColor:
                colorMenu.setDefaultAction(action)
        return colorMenu
项目:quantdigger    作者:andyzsf    | 项目源码 | 文件源码
def init_strategy_panel(self):
        strategy_files = sorted(glob.glob('%s/*.py' % strategy_path))
        for file in strategy_files:
            base = os.path.splitext(os.path.basename(file))[0]
            item = QtGui.QListWidgetItem(base, self.ui_controller.strategyListWidget)
            item.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
            self.ui_controller.strategyListWidget.addItem(item)
        self.ui_controller.strategyListWidget.customContextMenuRequested.connect(self.showMenu)
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def headerData(self, section, orientation, role=Qt.DisplayRole):
        if role != Qt.DisplayRole:
            return QVariant()

        if orientation == Qt.Horizontal:
            try:
                return self.df.columns.tolist()[section]
            except (IndexError, ):
                return QVariant()
        elif orientation == Qt.Vertical:
            try:
                # return self.df.index.tolist()
                return self.df.index.tolist()[section]
            except (IndexError, ):
                return QVariant()
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def data(self, index, role=Qt.DisplayRole):
        if role != Qt.DisplayRole:
            return QVariant()

        if not index.isValid():
            return QVariant()

        return QVariant(str(self.df.ix[index.row(), index.column()]))
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def setData(self, index, value, role):
        row = self.df.index[index.row()]
        col = self.df.columns[index.column()]
        if hasattr(value, 'toPyObject'):
            # PyQt4 gets a QVariant
            value = value.toPyObject()
        else:
            # PySide gets an unicode
            dtype = self.df[col].dtype
            if dtype != object:
                value = None if value == '' else dtype.type(value)
        self.df.set_value(row, col, value)
        return True
项目:ee-book    作者:ee-book    | 项目源码 | 文件源码
def data(self, column):
        if self.recipe is None:
            if column == 0:
                return QtCore.QVariant(self.header)
            if column == 1:
                return QtCore.QVariant("")
        else:
            if column == 0:
                return QtCore.QVariant(self.recipe.url)
            if column == 1:
                return QtCore.QVariant(self.recipe.recipe_info)
        return QtCore.QVariant()
项目:ee-book    作者:ee-book    | 项目源码 | 文件源码
def data(self, index, role):
        if not index.isValid():
            return QtCore.QVariant()

        item = index.internalPointer()
        if role == QtCore.Qt.DisplayRole:
            return item.data(index.column())
        if role == QtCore.Qt.UserRole:
            if item:
                return item.recipe

        return QtCore.QVariant()
项目:ee-book    作者:ee-book    | 项目源码 | 文件源码
def headerData(self, column, orientation, role):
        if (orientation == QtCore.Qt.Horizontal and
        role == QtCore.Qt.DisplayRole):
            try:
                return QtCore.QVariant(HORIZONTAL_HEADERS[column])
            except IndexError:
                pass

        return QtCore.QVariant()
项目:ee-book    作者:ee-book    | 项目源码 | 文件源码
def closeEvent(self, event):
        settings = QSettings()
        settings.setValue("MainWindow/Size", QVariant(self.size()))
        settings.setValue("MainWindow/Position", QVariant(self.pos()))
        settings.setValue("MainWindow/State", QVariant(self.saveState()))
项目:P4VFX    作者:TomMinor    | 项目源码 | 文件源码
def to_qvariant(pyobj=None):
        """Convert Python object to QVariant
        This is a transitional function from PyQt API #1 (QVariant exist)
        to PyQt API #2 and Pyside (QVariant does not exist)"""
        if PYQT_API_1:
            # PyQt API #1
            from PyQt4.QtCore import QVariant
            return QVariant(pyobj)
        else:
            # PyQt API #2
            return pyobj
项目:P4VFX    作者:TomMinor    | 项目源码 | 文件源码
def to_qvariant(obj=None):  # analysis:ignore
        """Convert Python object to QVariant
        This is a transitional function from PyQt API#1 (QVariant exist)
        to PyQt API#2 and Pyside (QVariant does not exist)"""
        return obj
项目:P4VFX    作者:TomMinor    | 项目源码 | 文件源码
def from_qvariant(qobj=None, pytype=None):  # analysis:ignore
        """Convert QVariant object to Python object
        This is a transitional function from PyQt API #1 (QVariant exist)
        to PyQt API #2 and Pyside (QVariant does not exist)"""
        return qobj


# =============================================================================
# Wrappers around QFileDialog static methods
# =============================================================================
项目:P4VFX    作者:TomMinor    | 项目源码 | 文件源码
def to_qvariant(pyobj=None):
        """Convert Python object to QVariant
        This is a transitional function from PyQt API #1 (QVariant exist)
        to PyQt API #2 and Pyside (QVariant does not exist)"""
        if PYQT_API_1:
            # PyQt API #1
            from PyQt4.QtCore import QVariant
            return QVariant(pyobj)
        else:
            # PyQt API #2
            return pyobj
项目:P4VFX    作者:TomMinor    | 项目源码 | 文件源码
def to_qvariant(obj=None):  # analysis:ignore
        """Convert Python object to QVariant
        This is a transitional function from PyQt API#1 (QVariant exist)
        to PyQt API#2 and Pyside (QVariant does not exist)"""
        return obj
项目:P4VFX    作者:TomMinor    | 项目源码 | 文件源码
def from_qvariant(qobj=None, pytype=None):  # analysis:ignore
        """Convert QVariant object to Python object
        This is a transitional function from PyQt API #1 (QVariant exist)
        to PyQt API #2 and Pyside (QVariant does not exist)"""
        return qobj


# =============================================================================
# Wrappers around QFileDialog static methods
# =============================================================================
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def library_changed(self):
        index_list = self.blofeld_model.match(self.blofeld_model.index(0, STATUS), EditedRole, QtCore.QVariant(STORED), hits=-1)
        if len(index_list) == self.blofeld_model.rowCount():
            return False
        return True
项目:SamuROI    作者:samuroi    | 项目源码 | 文件源码
def data(self, index, role):
        """Returns the data stored under the given role for the item referred to by the index."""
        if not index.isValid():
            return None
        if role != QtCore.Qt.DisplayRole and role != QtCore.Qt.EditRole:
            return None

        item = index.internalPointer()

        return QVariant(repr(item))
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def highlight(self):
            hi_selection = QtWidgets.QTextEdit.ExtraSelection()

            hi_selection.format.setBackground(self.palette().alternateBase())
            hi_selection.format.setProperty(QtGui.QTextFormat.FullWidthSelection, 1) #QtCore.QVariant(True)
            hi_selection.cursor = self.textCursor()
            hi_selection.cursor.clearSelection()

            self.setExtraSelections([hi_selection])
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def highlight(self):
            hi_selection = QtGui.QTextEdit.ExtraSelection()

            hi_selection.format.setBackground(self.palette().alternateBase())
            hi_selection.format.setProperty(QtGui.QTextFormat.FullWidthSelection, 1) #QtCore.QVariant(True)
            hi_selection.cursor = self.textCursor()
            hi_selection.cursor.clearSelection()

            self.setExtraSelections([hi_selection])
项目:PyTangoArchiving    作者:tango-controls    | 项目源码 | 文件源码
def initContexts(self, attrlist=[], sid=None):
        """
        This method overrides SnapDialog.initContexts()
        """
        #self.contextComboBox.blockSignals(True)
        #self.contextComboBox.clear()
        self._Form.setWindowTitle(QtGui.QApplication.translate("Form",'!'+str(os.getenv('TANGO_HOST')).split(':',1)[0]+' -> Snapshoting', None, QtGui.QApplication.UnicodeUTF8))
        try:
            if attrlist:
                if type(attrlist) is int and type(sid) is int:
                    contexts={attrlist: self.snapapi.get_context(attrlist)}
                    self._Form.setWindowTitle(QtGui.QApplication.translate("Form",str(os.getenv('TANGO_HOST')).split(':',1)[0]+' -> Snapshots for Context "'+str(self.snapapi.db.get_id_contexts(attrlist)[0]['name'])+'"', None, QtGui.QApplication.UnicodeUTF8))
                elif type(attrlist) is list:
                    contexts=dict((ID,self.snapapi.get_context(ID)) for ID in self.snapapi.db.find_context_for_attribute(attrlist))
                    self._Form.setWindowTitle(QtGui.QApplication.translate("Form",str(os.getenv('TANGO_HOST')).split(':',1)[0]+' -> Snapshots filtered by window content', None, QtGui.QApplication.UnicodeUTF8))
            else:
                contexts=self.snapapi.get_contexts()
        except:
            Qt.QMessageBox.critical(self,"Tango Archiving Problem",
                                    "Could not talk with SnapManager DS.<br>" + \
                                    "Please check if DS is running.")

        ctxs=sorted(contexts.values(), key=lambda s:s.name.lower())
        for context in ctxs:
            self.contextComboBox.addItem("%s [%d]" % (context.name, context.ID), Qt.QVariant(context.ID))
        #self.contextComboBox.model().sort(0, Qt.Qt.AscendingOrder)
        if sid>=0: self.listWidget.setCurrentRow(sid)
        #self.contextComboBox.blockSignals(False)
项目:PyTangoArchiving    作者:tango-controls    | 项目源码 | 文件源码
def onRefreshPressed(self):
        fkey = str(self.filterComboBox.currentText())
        fvalue = str(self.filterComboBox2.currentText())
        print 'onRefreshPressed(%s,%s)'%(fkey,fvalue)
        try:
            self.listWidget.blockSignals(True)
            self.listWidget.clear()
            self.listWidget.blockSignals(False)
            all_ctx = self.snapapi.get_contexts().values()
            if fkey!='Attributes':
                ctxs = [c for c in all_ctx if fandango.searchCl(fvalue, str(c.name) if fkey=='Name' else str(c.reason))]
            else:
                ctxs = [c for c in all_ctx if any(fandango.functional.searchCl(fvalue,a) \
                    for a in [c.name,c.reason,c.description]+[av['full_name'] for av in c.attributes.values()])] 
            if not len(ctxs):
                msg = QExceptionMessage(self,'Warning','No context in SnapDB is named like "%s"'%(fvalue))
                ctxs = all_ctx
            self.contextComboBox.blockSignals(True)
            self.contextComboBox.clear()
            current = self.getCurrentContext()
            if current in ctxs:
                ctxs.remove(current)
                ctxs.insert(0,current)
            for c in ctxs:
                self.contextComboBox.addItem("%s [%d]" % (c.name, c.ID), Qt.QVariant(c.ID))
            self.contextComboBox.blockSignals(False)
            if current is not None or len(ctxs)==1: self.onContextChanged()
        except: 
            msg = QExceptionMessage(self,"Error(%s,%s)"%(
                self.filterComboBox.currentText(),self.filterComboBox2.currentText()),traceback.format_exc())
项目:PyTangoArchiving    作者:tango-controls    | 项目源码 | 文件源码
def buildSnap2Box(self, sid):
        cid=self.getCurrentContext()
        self.comp._wi.diffComboBox.clear()
        try:
            snaps=self.snapapi.db.get_context_snapshots(cid)
        except:
            QtCore.QMessageBox.critical(self,"Tango Archiving Problem", "Could not talk with SnapManager DS.<br>Please check if DS is running.")
        self.comp._wi.diffComboBox.addItem("Actual values")
        for snapshot in snaps:
            if snapshot[0] != sid:
                self.comp._wi.diffComboBox.addItem("%s : \"%s\"" % (snapshot[1], snapshot[2].split('\n')[0]), QtCore.QVariant(snapshot[0]))
项目:MidiMemo    作者:MaurizioB    | 项目源码 | 文件源码
def headerData(self, section, orientation, role):
#        if orientation == QtCore.Qt.Vertical and role == QtCore.Qt.DisplayRole:
#            print section
#            return QtCore.QVariant('p')
        if orientation == QtCore.Qt.Vertical and role == QtCore.Qt.FontRole:
            font = QtGui.QFont(self.model.headerData(0, QtCore.Qt.Horizontal, role))
            if section == self.start_item:
                font.setBold(True)
            else:
                font.setBold(False)
            return font
        return QtGui.QStandardItemModel.headerData(self.model, section, orientation, role)
项目:MidiMemo    作者:MaurizioB    | 项目源码 | 文件源码
def event_enable(self, row_list, state):
        color = QtCore.QVariant(QtGui.QBrush(QtCore.Qt.black if state else QtCore.Qt.gray))
        for row in row_list:
            data = self.event_buffer[row]
            if isinstance(data.event, ConnectionEvent): continue
            data.enabled = state
            for c in range(self.model.columnCount()):
                self.model.item(row, c).setData(color, QtCore.Qt.ForegroundRole)
项目:sardana    作者:sardana-org    | 项目源码 | 文件源码
def setModelData(self, editor, model, index):
        self.emit(QtCore.SIGNAL("editorValueChanged"),
                  editor.getValue(), index.row(), index.column())
        value = editor.getValue()
        if index.column() == 0:  # name
            model.setData(index, QtCore.QVariant(value))
        if index.column() == 1:  # axis
            if editor.is_axis_free(int(value)):
                model.setData(index, QtCore.QVariant(value))
项目:sardana    作者:sardana-org    | 项目源码 | 文件源码
def setValue(self, value):
        rows = len(value)
        columns = 2
        self._model = QtGui.QStandardItemModel(rows, columns)
        for row in range(rows):
            for column in range(columns):
                index = self._model.index(row, column, QtCore.QModelIndex())
                self._model.setData(index, QtCore.QVariant(value[row][column]))
        self._model.setHeaderData(0, Qt.Qt.Horizontal, Qt.QVariant("Name"))
        self._model.setHeaderData(1, Qt.Qt.Horizontal, Qt.QVariant("Axis"))
        self._tableView.setModel(self._model)
        self._tableView.horizontalHeader().setVisible(True)
        self._tableView.horizontalHeader().setStretchLastSection(True)
项目:sardana    作者:sardana-org    | 项目源码 | 文件源码
def setModelData(self, editor, model, index):
        self.emit(QtCore.SIGNAL("editorValueChanged"),
                  editor.getValue(), index.row(), index.column())
        value = editor.getValue()
        model.setData(index, QtCore.QVariant(value))
项目:OnAirScreen    作者:saschaludwig    | 项目源码 | 文件源码
def value(self, name, default=None):
        try:
            return QVariant(self.config[self.currentgroup][name])
        except KeyError:
            return QVariant(default)
项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def data(self, index, role):
        if not index.isValid():
            return QtCore.QVariant()

        if role == QtCore.Qt.BackgroundRole:
            data = self.getrowdata(index.row())
            col = self.bgCol_c2sSent
            if data.direction == "s2c":
                col = self.bgCol_s2cSent

            if "status" in data.__dict__ and data.status == 'U':
                col = self.saturate(col)
            return QtCore.QVariant(col)


        # Sent are greyed out a bit
        if role == QtCore.Qt.ForegroundRole:
            data = self.getrowdata(index.row())
            col = self.fgCol_unsent
            if "status" in data.__dict__ and data.status == 'S':
                col = self.fgCol_sent
            return QtCore.QVariant(col)

        if role == QtCore.Qt.DisplayRole and index.isValid():
            data = self.getrowdata(index.row())

            if index.column() == 0:
                return data.cnt
            if index.column() == 1:
                return data.direction
            if index.column() == 2:
                return str(len(data.data))
            if index.column() == 3:
                return "%s:%s" % (data.source[0], data.source[1])
            if index.column() == 4:
                return "%s:%s" % (data.destination[0], data.destination[1])
            if index.column() == 5:
                if "status" in data.__dict__:
                    return data.status
                else:
                    return "U"                
            if index.column() == 5:
                return data.eventid
        else:
            return QtCore.QVariant()
项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def data(self, index, role):

        # Displaying Data
        if role == QtCore.Qt.DisplayRole:
            # Sanity check
            if index.row() < 0 or index.row() > self.if_cfg.num_ifs():
                return QtCore.QVariant()

            if index.column() == COLUMN_IFS:
                return self.if_cfg.get_if_for_idx(index.row())

            if index.column() == COLUMN_MITM:
                return QtCore.QVariant()

        # Editing Data (Not Needed)
        if role == QtCore.Qt.EditRole:
            if index.column() == COLUMN_MITM:
                pass

        # Align text   
        if role == QtCore.Qt.TextAlignmentRole:
            return QtCore.Qt.AlignCenter

        # Return internally managed checkbox state   
        if role == QtCore.Qt.CheckStateRole: 
            if_name = self.if_cfg.get_if_for_idx(index.row())

            if index.column() == COLUMN_MITM:
                if self.if_cfg.is_mitm(if_name):
                    return QtCore.Qt.Checked
                else:
                    return QtCore.Qt.Unchecked

            if index.column() == COLUMN_OUT:
                if self.if_cfg.is_outbound(if_name):
                    return QtCore.Qt.Checked
                else:
                    return QtCore.Qt.Unchecked


        return QtCore.QVariant()
    ## Required methods to subclass QAbstractTableModel

    ## Optional methods for subclass of QAbstractTableModel