示例#1
0
    def removeRows(self, position, rows=1, index=QtCore.QModelIndex()):
        """Remove waypoint; overrides the corresponding QAbstractTableModel
           method.
        """
        # beginRemoveRows emits rowsAboutToBeRemoved(index, first, last).
        self.beginRemoveRows(QtCore.QModelIndex(), position,
                             position + rows - 1)
        self.waypoints = self.waypoints[:position] + self.waypoints[position +
                                                                    rows:]
        if position < len(self.waypoints):
            self.update_distances(position,
                                  rows=min(rows,
                                           len(self.waypoints) - position))

        # endRemoveRows emits rowsRemoved(index, first, last).
        self.endRemoveRows()
        self.modified = True
        return True
示例#2
0
    def insertRows(self,
                   position,
                   rows=1,
                   index=QtCore.QModelIndex(),
                   waypoints=None):
        """Insert waypoint; overrides the corresponding QAbstractTableModel
           method.
        """
        if not waypoints:
            waypoints = [Waypoint(0, 0, 0)] * rows

        assert len(waypoints) == rows, (waypoints, rows)

        self.beginInsertRows(QtCore.QModelIndex(), position,
                             position + rows - 1)
        for row, wp in enumerate(waypoints):
            self.waypoints.insert(position + row, wp)

        self.update_distances(position, rows=rows)
        self.endInsertRows()
        self.modified = True
        return True
示例#3
0
 def columnCount(self, index=QtCore.QModelIndex()):
     return len(TABLE_FULL)
示例#4
0
 def rowCount(self, index=QtCore.QModelIndex()):
     """Number of waypoints in the model.
     """
     return len(self.waypoints)