Пример #1
0
    def __init__(self, data, parent=None, *args):
        QAbstractListModel.__init__(self, parent, *args)

        self._data = data
        self._roles = {}
        self._file = None
        self._just_created = False
Пример #2
0
 def __init__(self, query, display_column):
     QAbstractListModel.__init__(self)
     self._query = query
     self._query.add_sort(display_column, True)
     self._column_name = display_column
     self._data = None
     self._count = None
Пример #3
0
	def __init__(self, conn):
		QAbstractListModel.__init__(self)
		self._conn = conn
		self._data = [('', '', 0)]
		self._rolesindex = {
			Qt.DisplayRole: 0, 
			Qt.UserRole: 1,
			Qt.UserRole+1: 2}
Пример #4
0
    def __init__(self, logs):
        QAbstractListModel.__init__(self)

        # late init
        self.window = None

        self.__logs_obj = logs
        self.__logs = []
Пример #5
0
 def __init__(self, general_text_visible=True, general_text=None):
     QAbstractListModel.__init__(self)
     self._state = None
     self._filter_enable = True
     self._general_visible = general_text_visible
     self._callback = ProviderStateModelCallback(self)
     if general_text is None:
         general_text = 'GENERAL_TEXT'
     self._general_text = general_text
Пример #6
0
    def removeData(self, row):
        if row < 0 | row > len(self._m_data):
            return

        data = self._m_data[row]

        QAbstractListModel.beginRemoveRows(self, QModelIndex(), row, row)
        self._m_data.remove(data)
        QAbstractListModel.endRemoveRows(self)
Пример #7
0
    def duplicateData(self, row):
        if row < 0 | row > len(self._m_data):
            return

        data = self._m_data[row]
        rowOfInsert = row + 1

        QAbstractListModel.beginInsertRows(self, QModelIndex(), rowOfInsert,
                                           rowOfInsert)
        self._m_data.insert(rowOfInsert, data)
        QAbstractListModel.endInsertRows(self)
Пример #8
0
    def __init__(self, torrent_client, logs, on_peer_limit):
        QAbstractListModel.__init__(self)

        self.__logs = logs
        self.__torrent_client = torrent_client
        self.__filter_status = None
        self.__on_peer_limit = on_peer_limit

        self.__torrents = self._fetch_torrents()

        self.REFETCH_SIGNAL.connect(self.on_refetch)
        self.__stop_interval = set_interval(lambda: self.REFETCH_SIGNAL.emit(),
                                            1)
Пример #9
0
    def growPopulation(self):
        growthFactor = 0.01 / self.RAND_MAX

        count = len(self._m_data)
        for i in range(0, count):
            self._m_data[
                i].population += self._m_data[i].population * random.randint(
                    1, self.RAND_MAX) * growthFactor

        startIndex = QAbstractListModel.index(self, 0, 0)
        endIndex = QAbstractListModel.index(self, count - 1, 0)

        self.dataChanged.emit(startIndex, endIndex,
                              [self.Roles.PopulationRole])
Пример #10
0
    def __init__(self, me, preview_dler, gameset=None):
        QAbstractListModel.__init__(self)
        self._me = me
        self._preview_dler = preview_dler

        self._gameitems = {}
        self._itemlist = []  # For queries

        self._gameset = gameset
        if self._gameset is not None:
            self._gameset.newGame.connect(self.add_game)
            self._gameset.newClosedGame.connect(self.remove_game)

            for game in self._gameset.values():
                self.add_game(game)
Пример #11
0
    def __init__(self, parent=None):
        QAbstractListModel.__init__(self, parent)
        self._layerStack = []
        self.selectionModel = QItemSelectionModel(self)
        self.selectionModel.selectionChanged.connect(self.updateGUI)
        self.selectionModel.selectionChanged.connect(self._onSelectionChanged)
        self._movingRows = False
        QTimer.singleShot(0, self.updateGUI)

        def _handleRemovedLayer(layer):
            # Layerstacks *own* the layers they hold, and thus are
            #  responsible for cleaning them up when they are removed:
            layer.clean_up()

        self.layerRemoved.connect(_handleRemovedLayer)
Пример #12
0
 def __init__(self, model, parent=None):
     QAbstractListModel.__init__(self, parent=parent)
     self.spectra_model = model
     self.combinations = []
     self.selected_xtal_family = None
     self.ignore_family_constrain = False
     if len(self.spectra_model.collection) > 0:
         self.combinations = sorted(set.union(*[
             i.spect_xtal_unique_combinations
             for i in self.spectra_model.collection
         ]),
                                    key=lambda x: x.combi_string)
     self.spectra_model.rowsInserted.connect(self.scan_and_add_entries)
     for stuff in self.combinations:
         stuff.q_checked_state = Qt.Unchecked
Пример #13
0
    def __init__(self, parent=None):
        QAbstractListModel.__init__(self, parent)
        self._layerStack = []
        self.selectionModel = QItemSelectionModel(self)
        self.selectionModel.selectionChanged.connect(self.updateGUI)
        self.selectionModel.selectionChanged.connect(self._onSelectionChanged)
        self._movingRows = False
        QTimer.singleShot(0, self.updateGUI)

        def _handleRemovedLayer(layer):
            # Layerstacks *own* the layers they hold, and thus are
            #  responsible for cleaning them up when they are removed:
            layer.clean_up()

        self.layerRemoved.connect(_handleRemovedLayer)
Пример #14
0
 def __init__(self):
     QAbstractListModel.__init__(self)
     self.list_mes = [
         "Enero",
         "Febrero",
         "Marzo",
         "Abril",
         "Mayo",
         "Junio",
         "Julio",
         "Agosto",
         "Septiembre",
         "Octubre",
         "Noviembre",
         "Diciembre",
     ]
Пример #15
0
 def itemData(self, index):
     mapping = QAbstractListModel.itemData(self, index)
     if self._is_index_valid_for(index, self._other_data):
         items = list(self._other_data[index.row()].items())
     else:
         items = []
     for key, value in items:
         mapping[key] = value
     return mapping
Пример #16
0
 def itemData(self, index):
     mapping = QAbstractListModel.itemData(self, index)
     if self._is_index_valid_for(index, self._other_data):
         items = list(self._other_data[index.row()].items())
     else:
         items = []
     for key, value in items:
         mapping[key] = value
     return mapping
Пример #17
0
    def mimeData(self, indexlist):
        if len(indexlist) <= 0:
            return None

        items = [self[i.row()] for i in indexlist]
        mime = QAbstractListModel.mimeData(self, indexlist)
        data = pickle.dumps(vars)
        mime.set_data(self.MIME_TYPE, QByteArray(data))
        mime._items = items
        return mime
Пример #18
0
    def mimeData(self, indexlist):
        if len(indexlist) <= 0:
            return None

        items = [self[i.row()] for i in indexlist]
        mime = QAbstractListModel.mimeData(self, indexlist)
        data = pickle.dumps(vars)
        mime.set_data(self.MIME_TYPE, QByteArray(data))
        mime._items = items
        return mime
Пример #19
0
    def dropMimeData(self, mime, action, row, column, parent):
        if action == Qt.IgnoreAction:
            return True

        if not mime.hasFormat(self.MIME_TYPE):
            return False

        if hasattr(mime, "_vars"):
            vars_ = mime._vars
        else:
            desc = str(mime.data(self.MIME_TYPE))
            vars_ = pickle.loads(desc)

        return QAbstractListModel.dropMimeData(
            self, mime, action, row, column, parent)
Пример #20
0
    def dropMimeData(self, mime, action, row, column, parent):
        if action == Qt.IgnoreAction:
            return True

        if not mime.hasFormat(self.MIME_TYPE):
            return False

        if hasattr(mime, "_vars"):
            vars_ = mime._vars
        else:
            desc = str(mime.data(self.MIME_TYPE))
            vars_ = pickle.loads(desc)

        return QAbstractListModel.dropMimeData(self, mime, action, row, column,
                                               parent)
Пример #21
0
    def setData(self, index, value, role=Qt.EditRole):
        if index.isValid():
            marker = self._markers[index.row()]

            if role == MarkerModel.PositionRole:
                return marker.setPosition(value)
            elif role == MarkerModel.NameRole:
                return marker.setName(value)
            elif role == MarkerModel.ColorRole:
                return marker.setColor(value)

            self.dataChanged.emit(index, index)
            return True

        return QAbstractListModel.setData(self, index, value, role)
Пример #22
0
    def setData(self, index, value, role=Qt.EditRole):
        if index.isValid():
            marker = self._markers[index.row()]

            if role == MarkerModel.position_role:
                return marker.setPosition(value)
            elif role == MarkerModel.color_role:
                return marker.setColor(value)
            elif role == MarkerModel.event_id_role:
                return marker.setEventId(value)
            elif role == MarkerModel.highlight_role:
                return marker.setHighlight(value)

            self.dataChanged.emit(index, index)

        return QAbstractListModel.setData(self, index, value, role)
Пример #23
0
 def flags(self, index):
     """
     Public method to get flags for an item.
     
     @param index index of the node cell (QModelIndex)
     @return flags (Qt.ItemFlags)
     """
     if index.row() < 0 or index.row() >= self.rowCount(index.parent()):
         return Qt.NoItemFlags
     
     defaultFlags = QAbstractListModel.flags(self, index)
     
     itm = self.__manager.downloads()[index.row()]
     if itm.downloadedSuccessfully():
         return defaultFlags | Qt.ItemIsDragEnabled
     
     return defaultFlags
Пример #24
0
    def flags(self, index):
        """
        Public method to get flags for an item.
        
        @param index index of the node cell (QModelIndex)
        @return flags (Qt.ItemFlags)
        """
        if index.row() < 0 or index.row() >= self.rowCount(index.parent()):
            return Qt.NoItemFlags

        defaultFlags = QAbstractListModel.flags(self, index)

        itm = self.__manager.downloads()[index.row()]
        if itm.downloadedSuccessfully():
            return defaultFlags | Qt.ItemIsDragEnabled

        return defaultFlags
Пример #25
0
 def flags(self, index):
     if index.column() == 0:
         return QAbstractListModel.flags(self, index) | Qt.ItemIsEditable
     return QAbstractListModel.flags(self, index)
Пример #26
0
 def __init__(self):
     QAbstractListModel.__init__(self)
     self.list_division = ["A", "B", "C", "D", "E"]
Пример #27
0
 def __init__(self):
     QAbstractListModel.__init__(self)
     self.list_turno = ["Mañana", "Tarde"]
Пример #28
0
 def __init__(self):
     QAbstractListModel.__init__(self)
     self.list_grado = [1, 2, 3, 4, 5, 6, 7]
Пример #29
0
 def __init__(self, datain, parent=None, *args):
     """ datain: a list where each item is a row
     """
     QAbstractListModel.__init__(self, parent, *args)
     self.listdata = datain
Пример #30
0
 def __init__(self,
              department_list: [Department],
              check_state=Qt.Unchecked):
     QAbstractListModel.__init__(self)
     self.department_list = [[dep, check_state] for dep in department_list]
Пример #31
0
 def __init__( self ):
     QAbstractListModel.__init__( self )
     self._data_model = []
 def __init__(self, parent=None, *args):
     """ datain: a list where each item is a row
     """
     QAbstractListModel.__init__(self, parent, *args)
Пример #33
0
 def __init__(self):
     QAbstractListModel.__init__(self)
     self.shortcuts = []
Пример #34
0
 def index(self, row, column=0, parent=QModelIndex()):
     if self._is_index_valid_for(row, self) and column == 0:
         return QAbstractListModel.createIndex(self, row, column, parent)
     else:
         return QModelIndex()
Пример #35
0
 def flags(self, index):
     if index.isValid():
         return QAbstractListModel.flags(self, index) | Qt.ItemIsUserCheckable
     return QAbstractListModel.flags(self, index)
Пример #36
0
 def __init__(self):
     QAbstractListModel.__init__(self)
     self.widgets = []
Пример #37
0
 def mimeTypes(self):
     return self.MIME_TYPES + list(QAbstractListModel.mimeTypes(self))
Пример #38
0
 def __init__(self, databaseFile):
     QAbstractListModel.__init__(self)
     self.db = ShortcutDatabase(databaseFile)
     self.shortcuts = self.db.selectShortcut("")
Пример #39
0
 def __init__(self, parent, *args, **kwargs):
     QAbstractListModel.__init__(self, parent, *args, **kwargs)
     self._parent = parent
     self._xpath = "//grouping"
Пример #40
0
 def index(self, row, column=0, parent=QModelIndex()):
     if self._is_index_valid_for(row, self) and column == 0:
         return QAbstractListModel.createIndex(self, row, column, parent)
     else:
         return QModelIndex()
Пример #41
0
 def __init__(self, itemcls, data, parent=None):
     QAbstractListModel.__init__(self, parent)
     AbstractQtModel.__init__(self, itemcls, data)
Пример #42
0
 def __init__(self, parent=None, *args):
     """ datain: a list where each item is a row
     """
     QAbstractListModel.__init__(self, parent, *args)
     self.es_themes = []
     self.selected_theme_index = 0
Пример #43
0
 def __init__(self, session):
     QAbstractListModel.__init__(self)
     self.session = session
     self._cards = []
Пример #44
0
 def __init__(self, tree, xpath, parent=None):
     QAbstractListModel.__init__(self, parent=parent)
     self._tree=tree
     self._xpath=xpath
Пример #45
0
 def __init__(self,  parent=None):
     QAbstractListModel.__init__(self)
     self._list = []
 def __init__(self, data=None, parent=None):
     QAbstractListModel.__init__(self, parent)
     self._data = data
Пример #47
0
 def mimeTypes(self):
     return self.MIME_TYPES + list(QAbstractListModel.mimeTypes(self))