當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。