当前位置: 首页>>代码示例>>Python>>正文


Python QtCore.QModelIndex方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QModelIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QModelIndex方法的具体用法?Python QtCore.QModelIndex怎么用?Python QtCore.QModelIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore的用法示例。


在下文中一共展示了QtCore.QModelIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def update(self, header, data):
    self.header = header
    self.data = data

    numCols = len(self.header)
    self.setColumnCount(numCols)
    numRows = len(self.data)
    self.setRowCount(numRows)

    for col in range(numCols):
      self.setHeaderData(col, QtCore.Qt.Horizontal, self.header[col])

    for row in range(numRows):
      for col in range(numCols):
        value = self.data[row][col]
        self.setData(self.index(row, col, QtCore.QModelIndex()), value) 
开发者ID:htm-community,项目名称:nupic.studio,代码行数:18,代码来源:__init__.py

示例2: setFilter

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def setFilter(self, userFilter):
        if userFilter:
            userFilter = userFilter.strip().lower()
        if not userFilter:
            self.filteredGames = self.allGames[:]
        else:
            if not userFilter.startswith('*'):
                userFilter = '*' + userFilter
            if not userFilter.endswith('*'):
                userFilter += '*'
            self.filteredGames = []
            for d in self.allGames:
                if fnmatch.fnmatch(d[self.NAME].lower(), userFilter) or \
                        fnmatch.fnmatch(d[self.DESCRIPTION].lower(), userFilter):
                    self.filteredGames.append(d)
        self.sort(self.lastSort, self.lastSortDirection)
        rowcount = len(self.filteredGames)
        if rowcount > 0:
            idx1 = self.createIndex(0, 0)
            idx2 = self.createIndex(rowcount - 1, self.N_DISPLAY_COLUMNS - 1)
        else:
            idx1 = idx2 = QtCore.QModelIndex()
        self.dataChanged.emit(idx1, idx2) 
开发者ID:doctorguile,项目名称:pyqtggpo,代码行数:25,代码来源:savestatesdialog.py

示例3: ecuSel

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def ecuSel(self, index):
        if index.parent() == core.QModelIndex():
            return
        item = self.list.model().itemData(self.list.model().index(index.row(), 0, index.parent()))
        if qt5:
            selected = item[0]
        else:
            selected = utf8(item[0].toString())
        target = self.ecuscan.ecu_database.getTarget(selected)
        name = selected
        if target:
            self.ecuscan.addTarget(target)
            if target.addr in self.ecuscan.ecu_database.addr_group_mapping:
                group = self.ecuscan.ecu_database.addr_group_mapping[target.addr]
            else:
                group = "Unknown"
            print name, group
            name = "[ " + group + " ] " + name
        if selected:
            if name not in options.main_window.ecunamemap:
                options.main_window.ecunamemap[name] = selected
                self.treeview_ecu.addItem(name) 
开发者ID:cedricp,项目名称:ddt4all,代码行数:24,代码来源:ddt4all.py

示例4: set_active

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def set_active(self, name):
        """
        Selects object by name from the project list. This triggers the
        list_selection_changed event and call on_list_selection_changed.

        :param name: Name of the FlatCAM Object
        :return: None
        """
        obj = self.get_by_name(name)
        item = obj.item
        group = self.group_items[obj.kind]

        group_index = self.index(group.row(), 0, Qt.QModelIndex())
        item_index = self.index(item.row(), 0, group_index)

        self.view.selectionModel().select(item_index, QtGui.QItemSelectionModel.Select) 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:18,代码来源:ObjectCollection.py

示例5: rowCount

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def rowCount(self):
        """
        Tests self.model's implementation of QtCore.QAbstractItemModel::rowCount() and hasChildren()
        
        self.models that are dynamically populated are not as fully tested here.
        """
        # check top row
        topindex = self.model.index(0, 0, QtCore.QModelIndex())
        rows = self.model.rowCount(topindex)
        assert(rows >= 0)
        if rows > 0:
            assert(self.model.hasChildren(topindex) == True)

        secondlvl = self.model.index(0, 0, topindex)
        if secondlvl.isValid():
            # check a row count where parent is valid
            rows = self.model.rowCount(secondlvl)
            assert(rows >= 0)
            if rows > 0:
                assert(self.model.hasChildren(secondlvl) == True)
        
        # The self.models rowCount() is tested more extensively in checkChildren,
        # but this catches the big mistakes 
开发者ID:remig,项目名称:lic,代码行数:25,代码来源:modeltest.py

示例6: hasIndex

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def hasIndex(self):
        """
        Tests self.model's implementation of QtCore.QAbstractItemModel::hasIndex()
        """
        # Make sure that invalid values returns an invalid index
        assert(self.model.hasIndex(-2, -2) == False)
        assert(self.model.hasIndex(-2, 0) == False)
        assert(self.model.hasIndex(0, -2) == False)

        rows = self.model.rowCount(QtCore.QModelIndex())
        cols = self.model.columnCount(QtCore.QModelIndex())

        # check out of bounds
        assert(self.model.hasIndex(rows, cols) == False)
        assert(self.model.hasIndex(rows + 1, cols + 1) == False)

        if rows > 0:
            assert(self.model.hasIndex(0, 0) == True)

        # hasIndex() is tested more extensively in checkChildren()
        # but this catches the big mistakes 
开发者ID:remig,项目名称:lic,代码行数:23,代码来源:modeltest.py

示例7: rowsInserted

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def rowsInserted(self, parent, start, end):
        """
        Confirm that what was said was going to happen actually did
        """
        c = self.insert.pop()
        assert(c['parent'] == parent)
        assert(c['oldSize'] + (end - start + 1) == self.model.rowCount(parent))
        assert(c['last'] == self.model.data(self.model.index(start - 1, 0, c['parent'])))

        # if c['next'] != self.model.data(model.index(end+1, 0, c['parent'])):
        #   qDebug << start << end
        #   for i in range(0, self.model.rowCount(QtCore.QModelIndex())):
        #       qDebug << self.model.index(i, 0).data().toString()
        #   qDebug() << c['next'] << self.model.data(model.index(end+1, 0, c['parent']))

        assert(c['next'] == self.model.data(self.model.index(end + 1, 0, c['parent']))) 
开发者ID:remig,项目名称:lic,代码行数:18,代码来源:modeltest.py

示例8: rowCount

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def rowCount(self, index=QModelIndex()):
        return self.df.shape[0] 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:qtpandas.py

示例9: columnCount

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def columnCount(self, index=QModelIndex()):
        return self.df.shape[1] 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:qtpandas.py

示例10: index

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def index(self, row, column, parent=None, *args, **kwargs):
        if column == 0:
            if 0 <= row < self.rowCount():
                return self.createIndex(row, column)
        return QModelIndex() 
开发者ID:doctorguile,项目名称:pyqtggpo,代码行数:7,代码来源:completionlineedit.py

示例11: parent

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def parent(self, childIndex=None):
        return QModelIndex() 
开发者ID:doctorguile,项目名称:pyqtggpo,代码行数:4,代码来源:completionlineedit.py

示例12: index

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def index(self, row, column=0, parent=None, *args, **kwargs):
        if not self.hasIndex(row, column, parent):
            return QtCore.QModelIndex()

        if not parent.isValid():
            parent_item = self.root_item
        else:
            parent_item = parent.internalPointer()

        child_item = parent_item.child(row)

        if child_item:
            return self.createIndex(row, column, child_item)
        else:
            return QtCore.QModelIndex() 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:17,代码来源:ObjectCollection.py

示例13: parent

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def parent(self, index=None):
        if not index.isValid():
            return QtCore.QModelIndex()

        parent_item = index.internalPointer().parent_item

        if parent_item == self.root_item:
            return QtCore.QModelIndex()

        return self.createIndex(parent_item.row(), 0, parent_item) 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:12,代码来源:ObjectCollection.py

示例14: append

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def append(self, obj, active=False):
        FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + " --> OC.append()")

        name = obj.options["name"]

        # Check promises and clear if exists
        if name in self.promises:
            self.promises.remove(name)
            FlatCAMApp.App.log.debug("Promised object %s became available." % name)
            FlatCAMApp.App.log.debug("%d promised objects remaining." % len(self.promises))

        # Prevent same name
        while name in self.get_names():
            ## Create a new name
            # Ends with number?
            FlatCAMApp.App.log.debug("new_object(): Object name (%s) exists, changing." % name)
            match = re.search(r'(.*[^\d])?(\d+)$', name)
            if match:  # Yes: Increment the number!
                base = match.group(1) or ''
                num = int(match.group(2))
                name = base + str(num + 1)
            else:  # No: add a number!
                name += "_1"
        obj.options["name"] = name

        obj.set_ui(obj.ui_type())

        # Required before appending (Qt MVC)
        group = self.group_items[obj.kind]
        group_index = self.index(group.row(), 0, Qt.QModelIndex())
        self.beginInsertRows(group_index, group.child_count(), group.child_count())

        # Append new item
        obj.item = TreeItem(None, self.icons[obj.kind], obj, group)

        # Required after appending (Qt MVC)
        self.endInsertRows()

        # Expand group
        if group.child_count() is 1:
            self.view.setExpanded(group_index, True) 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:43,代码来源:ObjectCollection.py

示例15: delete_active

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QModelIndex [as 别名]
def delete_active(self):
        selections = self.view.selectedIndexes()
        if len(selections) == 0:
            return

        active = selections[0].internalPointer()
        group = active.parent_item

        self.beginRemoveRows(self.index(group.row(), 0, Qt.QModelIndex()), active.row(), active.row())

        group.remove_child(active)

        self.endRemoveRows() 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:15,代码来源:ObjectCollection.py


注:本文中的PyQt4.QtCore.QModelIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。