예제 #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
파일: sqlistmodel.py 프로젝트: hazzl/chirpy
	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))