コード例 #1
0
    def parent(self, index):
        if not index.isValid():
            return QModelIndex()

        if index.internalId() == 0:
            return QModelIndex()
        else:
            return self.createIndex(index.internalId() - 1, 0, 0)
コード例 #2
0
 def index(self, row, column, parent):
     if not parent.isValid():
         if len(QApplication.topLevelWidgets()) <= row:
             return QModelIndex()
         else:
             return self.createIndex(row, column, QApplication.topLevelWidgets()[row])
     else:
         if len(parent.internalPointer().children()) <= row:
             return QModelIndex()
         else:
             return self.createIndex(row, column, parent.internalPointer().children()[row])
コード例 #3
0
 def parent(self, index):
     if not index.isValid():
         return QModelIndex()
        
     obj = index.internalPointer()
     tlw = QApplication.topLevelWidgets()
     
     if obj in tlw:
         return QModelIndex()
     else:
         if obj.parent() in tlw:
             return self.createIndex(tlw.index(obj.parent()), 0, obj.parent())
         else:
             return self.createIndex(obj.parent().children().index(obj), 0, obj.parent()) 
コード例 #4
0
    def callback(self, name, *args):
        if self._paused:
            self.pevents.append((name, args))
            return

        if self._maxevents != 0 and len(self.events) >= self._maxevents:
            self.beginRemoveRows(QModelIndex(), 0,
                                 len(self.events) - self._maxevents)
            self.events = self.events[len(self.events) - self._maxevents + 1:]
            self.endRemoveRows()

        idx = len(self.events)
        self.beginInsertRows(QModelIndex(), idx, idx)
        self.events.append((name, args))
        self.endInsertRows()
コード例 #5
0
ファイル: filetransfer.py プロジェクト: exp111/pyTSon-Scripts
    def addUpload(self, path, localfile, overwrite, resume):
        """
        Requests an upload to the server.
        @param path: path to upload the file to
        @type path: str
        @param localfile: path to the file to upload
        @type localfile: str
        @param overwrite: set to True to overwrite an existing file
        @type overwrite: bool
        @param resume: set to True to resume a previous upload
        @type resume: bool
        @return: the filetransfer id
        @rtype: int
        """
        retcode = ts3lib.createReturnCode()
        err, ftid = ts3lib.sendFile(
            self.schid, self.cid, self.password,
            joinpath(path,
                     os.path.split(localfile)[-1]), overwrite, resume,
            os.path.dirname(localfile), retcode)

        self.beginInsertRows(QModelIndex(), len(self.transfers),
                             len(self.transfers))
        self.transfers[ftid] = Upload(err, retcode, localfile)
        self.endInsertRows()

        return ftid
コード例 #6
0
ファイル: filetransfer.py プロジェクト: exp111/pyTSon-Scripts
    def addDownload(self, thefile, downloaddir, overwrite, resume):
        """
        Requests a download from the server and monitors its progress
        @param thefile: remote file to download
        @type thefile: File
        @param downloaddir: path to the download directory
        @type downloaddir: str
        @param overwrite: set to True to overwrite an existing file
        @type overwrite: bool
        @param resume: set to True to resume a previous download
        @type resume: bool
        @return: the filetransfer id
        @rtype: int
        """
        retcode = ts3lib.createReturnCode()
        err, ftid = ts3lib.requestFile(self.schid, self.cid, self.password,
                                       thefile.fullpath, overwrite, resume,
                                       downloaddir, retcode)

        self.beginInsertRows(QModelIndex(), len(self.transfers),
                             len(self.transfers))
        self.transfers[ftid] = Download(err, retcode, thefile, downloaddir)
        self.endInsertRows()

        self.downcounter += 1
        if self.downcounter == 1:
            self.timer = self.startTimer(500)

        return ftid
コード例 #7
0
ファイル: serverview.py プロジェクト: TheKilledDead/pyTSon
    def parent(self, index):
        obj = self._indexObject(index)

        if obj == self.root:
            return QModelIndex()
        else:
            parent = obj.parentNode
            return self._createIndex(parent.rowOf(), 0, parent)
コード例 #8
0
ファイル: filetransfer.py プロジェクト: exp111/pyTSon-Scripts
 def cleanup(self):
     """
     Cleanup finished and broken downloads
     """
     for i, ftid in enumerate(list(self.transfers)):
         trans = self.transfers[ftid]
         if trans.progress == 100 or trans.hasError:
             self.beginRemoveRows(QModelIndex(), i, i)
             del self.transfers[ftid]
             self.endRemoveRows()
コード例 #9
0
    def maximumEvents(self, val):
        if val < 0:
            val = 0

        self._maxevents = val

        if val != 0 and len(self.events) > val:
            idx = len(self.events) - val
            self.beginRemoveRows(QModelIndex(), 0, idx)
            self.events = self.events[idx:]
            self.endRemoveRows()
コード例 #10
0
    def highestIndex(self, indexes, node=None):
        if len(indexes) == 0:
            return -1

        if not node:
            node = self.index(0, 0, QModelIndex())

        for i in range(len(indexes)):
            if node == indexes[i]:
                return i

        for k in range(self.rowCount(node)):
            for i in range(len(indexes)):
                kidx = self.index(k, 0, node)
                if indexes[i] == kidx:
                    return i

                recursive = self.highestIndex(indexes, kidx)
                if recursive != -1:
                    return recursive

        return -1
コード例 #11
0
 def parent(self, index):
     return QModelIndex()
コード例 #12
0
ファイル: filetransfer.py プロジェクト: exp111/pyTSon-Scripts
 def columnCount(self, parent=QModelIndex()):
     return len(self.titles)
コード例 #13
0
ファイル: filetransfer.py プロジェクト: exp111/pyTSon-Scripts
    def rowCount(self, parent=QModelIndex()):
        if parent.isValid():
            return 0

        return len(self.files)
コード例 #14
0
ファイル: filetransfer.py プロジェクト: exp111/pyTSon-Scripts
    def index(self, row, column, parent=QModelIndex()):
        if parent.isValid():
            return QModelIndex()

        return self.createIndex(row, column)
コード例 #15
0
ファイル: filetransfer.py プロジェクト: exp111/pyTSon-Scripts
 def columnCount(self, parent=QModelIndex()):
     return 2