Ejemplo n.º 1
0
    def dropMimeData(self, data, action, row, column, parent):
        if data.hasFormat('application/target.tableitem.creepy'):
            encodedData = data.data('application/target.tableitem.creepy')
            stream = QDataStream(encodedData, QIODevice.ReadOnly)
            columnsList = []
            qVariant = QVariant()
            while not stream.atEnd():
                stream >> qVariant
                columnsList.append(qVariant.toPyObject())
            draggedRows = [
                columnsList[x:x + 5] for x in range(0, len(columnsList), 5)
            ]
            droppedRows = []
            for row in draggedRows:
                # Ensure we are not putting duplicates in the target list
                existed = False
                for target in self.targets:
                    if row[2] == target['targetUsername'] and row[0] == target[
                            'pluginName']:
                        existed = True
                if not existed:
                    droppedRows.append({
                        'targetUsername': row[2],
                        'targetFullname': row[3],
                        'targetPicture': row[1],
                        'targetUserid': row[4],
                        'pluginName': row[0]
                    })
            self.insertRows(droppedRows, len(droppedRows), parent)

        return True
Ejemplo n.º 2
0
    def _restoreState(self, state):
        '''
        @param: state QByteArray
        '''
        stream = QDataStream(state)
        if stream.atEnd():
            return

        version = -1
        historyIndex = -1
        databases = False
        localStorage = False
        cache = False
        cookies = False

        version = stream.readInt()
        if version != self._s_stateDataVersoin:
            return

        historyIndex = stream.readInt()
        databases = stream.readBool()
        localStorage = stream.readBool()
        cache = stream.readBool()
        cookies = stream.readBool()

        if historyIndex != -1:
            self._ui.history.setChecked(True)
            self._ui.historyLength.setEnabled(True)
            self._ui.historyLength.setCurrentIndex(historyIndex)

        self._ui.databases.setChecked(databases)
        self._ui.localStorage.setChecked(localStorage)
        self._ui.cache.setChecked(cache)
        self._ui.cookies.setChecked(cookies)