def __init__(self, schid, cid, password, parent=None, *, readonly=False): super(QAbstractItemModel, self).__init__(parent) self.schid = schid self.cid = cid self.password = password self.readonly = readonly self.pathChanged = Signal() self.error = Signal() self._path = None self.newpath = None self.files = [] self.newfiles = [] self.retcode = None self.renretcode = None self.renfile = () self.titles = [ self._tr("Name"), self._tr("Size"), self._tr("Type"), self._tr("Last Changed") ] PluginHost.registerCallbackProxy(self)
def __init__(self, schid, cid, password, rootdir): """ Instantiates a new object. @param schid: the id of the serverconnection handler @type schid: int @param cid: the id of the channel @type cid: int @param password: the password of the channel @type password: str @param rootdir: the root download directory @type rootdir: str """ super().__init__() self.schid = schid self.cid = cid self.password = password self.rootdir = rootdir self.collectionFinished = Signal() self.collectionError = Signal() self.queue = {} self.files = {} PluginHost.registerCallbackProxy(self)
def __init__(self, schid, cid, password, parent=None, *, readonly=False): super(QAbstractItemModel, self).__init__(parent) self.schid = schid self.cid = cid self.password = password self.readonly = readonly self.pathChanged = Signal() self.error = Signal() self._path = None self.newpath = None self.files = [] self.newfiles = [] self.retcode = None self.renretcode = None self.renfile = () self.titles = [self._tr("Name"), self._tr("Size"), self._tr("Type"), self._tr("Last Changed")] PluginHost.registerCallbackProxy(self)
def __init__(self, schid, cid, password, parent=None): super().__init__(parent) self.schid = schid self.cid = cid self.password = password self.titles = [self._tr("Description"), self._tr("Progress")] self.transfers = OrderedDict() self.downcounter = 0 self.timer = None PluginHost.registerCallbackProxy(self)
def __init__(self, schid, cid, password='', path='/', parent=None, *, staticpath=False, readonly=False, downloaddir=None, iconpack=None): """ Instantiates a new object. @param schid: the id of the serverconnection handler @type schid: int @param cid: the id of the channel @type cid: int @param password: password to the channel, defaults to an empty string @type password: str @param path: path to display, defaults to the root path @type path: str @param parent: parent of the dialog; optional keyword arg; defaults to None @type parent: QWidget @param staticpath: if set to True, the initial path can't be changed by the user; optional keyword arg; defaults to False @type staticpath: bool @param readonly: if set to True, the user can't download, upload or delete files, or create new directories; optional keyword arg; defaults to False @type readonly: bool @param downloaddir: directory to download files to; optional keyword arg; defaults to None; if set to None, the TS3 client's download directory is used @type downloaddir: str @param iconpack: iconpack to load icons from; optional keyword arg; defaults to None; if set to None, the current iconpack is used @type iconpack: ts3client.IconPack """ super(QDialog, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) iconpackopened = False if not iconpack: try: iconpack = ts3client.IconPack.current() iconpack.open() iconpackopened = True except Exception as e: self.delete() raise e try: setupUi(self, pytson.getPluginPath("ressources", "filebrowser.ui"), iconpack=iconpack) self.statusbar = SmartStatusBar(self) self.layout().addWidget(self.statusbar) self.statusbar.hide() except Exception as e: self.delete() raise e err, cname = ts3lib.getChannelVariableAsString( schid, cid, ChannelProperties.CHANNEL_NAME) if err == ERROR_ok: self.setWindowTitle( self._tr("File Browser - {cname}").format(cname=cname)) else: self.setWindowTitle(self._tr("File Browser")) self.schid = schid self.cid = cid self.password = password self.path = None self.staticpath = staticpath self.readonly = readonly self.createretcode = None self.delretcode = None if not self.readonly and not downloaddir: cfg = ts3client.Config() q = cfg.query("SELECT value FROM filetransfer " "WHERE key='DownloadDir'") del cfg if q.next(): self.downloaddir = q.value("value") else: self.delete() raise Exception("Error getting DownloadDir from config") else: self.downloaddir = downloaddir if not self.readonly: menu = self.menu = QMenu(self) self.openAction = menu.addAction(QIcon(iconpack.icon("FILE_UP")), self._tr("Open")) self.openAction.connect("triggered()", self.on_openAction_triggered) self.downAction = menu.addAction(QIcon(iconpack.icon("DOWN")), self._tr("Download")) self.downAction.connect("triggered()", self.downloadFiles) self.renameAction = menu.addAction(QIcon(iconpack.icon("EDIT")), self._tr("Rename")) self.renameAction.connect("triggered()", self.on_renameAction_triggered) self.copyAction = menu.addAction(QIcon(iconpack.icon("COPY")), self._tr("Copy URL")) self.copyAction.connect("triggered()", self.on_copyAction_triggered) self.delAction = menu.addAction(QIcon(iconpack.icon("DELETE")), self._tr("Delete")) self.delAction.connect("triggered()", self.deleteFiles) self.upAction = menu.addAction(QIcon(iconpack.icon("UP")), self._tr("Upload files")) self.upAction.connect("triggered()", self.uploadFiles) self.createAction = menu.addAction(QIcon.fromTheme("folder"), self._tr("Create Folder")) self.createAction.connect("triggered()", self.createFolder) self.refreshAction = menu.addAction( QIcon(iconpack.icon("FILE_REFRESH")), self._tr("Refresh")) self.refreshAction.connect("triggered()", self.refresh) self.allactions = [ self.openAction, self.downAction, self.renameAction, self.copyAction, self.delAction, self.upAction, self.createAction, self.refreshAction ] self.collector = FileCollector(schid, cid, password, self.downloaddir) self.collector.collectionFinished.connect(self._startDownload) self.collector.collectionError.connect(self.showError) self.fileDoubleClicked = Signal() self.contextMenuRequested = Signal() self.transdlg = None self.listmodel = FileListModel(schid, cid, password, self, readonly=readonly) self.listmodel.pathChanged.connect(self.onPathChanged) self.listmodel.error.connect(self.showError) self.proxy = QSortFilterProxyModel(self) self.proxy.setSortRole(Qt.UserRole) self.proxy.setSortCaseSensitivity(Qt.CaseInsensitive) self.proxy.setFilterCaseSensitivity(Qt.CaseInsensitive) self.proxy.setSourceModel(self.listmodel) self.listmodel.path = path self._adjustUi() if iconpackopened: iconpack.close() PluginHost.registerCallbackProxy(self)
def __init__(self, schid, cid, password='', path='/', parent=None, *, staticpath=False, readonly=False, downloaddir=None, iconpack=None): """ Instantiates a new object. @param schid: the id of the serverconnection handler @type schid: int @param cid: the id of the channel @type cid: int @param password: password to the channel, defaults to an empty string @type password: str @param path: path to display, defaults to the root path @type path: str @param parent: parent of the dialog; optional keyword arg; defaults to None @type parent: QWidget @param staticpath: if set to True, the initial path can't be changed by the user; optional keyword arg; defaults to False @type staticpath: bool @param readonly: if set to True, the user can't download, upload or delete files, or create new directories; optional keyword arg; defaults to False @type readonly: bool @param downloaddir: directory to download files to; optional keyword arg; defaults to None; if set to None, the TS3 client's download directory is used @type downloaddir: str @param iconpack: iconpack to load icons from; optional keyword arg; defaults to None; if set to None, the current iconpack is used @type iconpack: ts3client.IconPack """ super(QDialog, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) iconpackopened = False if not iconpack: try: iconpack = ts3client.IconPack.current() iconpack.open() iconpackopened = True except Exception as e: self.delete() raise e try: setupUi(self, pytson.getPluginPath("ressources", "filebrowser.ui"), iconpack=iconpack) self.statusbar = SmartStatusBar(self) self.layout().addWidget(self.statusbar) self.statusbar.hide() except Exception as e: self.delete() raise e err, cname = ts3lib.getChannelVariableAsString(schid, cid, ChannelProperties. CHANNEL_NAME) if err == ERROR_ok: self.setWindowTitle(self._tr("File Browser - {cname}").format( cname=cname)) else: self.setWindowTitle(self._tr("File Browser")) self.schid = schid self.cid = cid self.password = password self.path = None self.staticpath = staticpath self.readonly = readonly self.createretcode = None self.delretcode = None if not self.readonly and not downloaddir: cfg = ts3client.Config() q = cfg.query("SELECT value FROM filetransfer " "WHERE key='DownloadDir'") del cfg if q.next(): self.downloaddir = q.value("value") else: self.delete() raise Exception("Error getting DownloadDir from config") else: self.downloaddir = downloaddir if not self.readonly: menu = self.menu = QMenu(self) self.openAction = menu.addAction(QIcon(iconpack.icon("FILE_UP")), self._tr("Open")) self.openAction.connect("triggered()", self.on_openAction_triggered) self.downAction = menu.addAction(QIcon(iconpack.icon("DOWN")), self._tr("Download")) self.downAction.connect("triggered()", self.downloadFiles) self.renameAction = menu.addAction(QIcon(iconpack.icon("EDIT")), self._tr("Rename")) self.renameAction.connect("triggered()", self.on_renameAction_triggered) self.copyAction = menu.addAction(QIcon(iconpack.icon("COPY")), self._tr("Copy URL")) self.copyAction.connect("triggered()", self.on_copyAction_triggered) self.delAction = menu.addAction(QIcon(iconpack.icon("DELETE")), self._tr("Delete")) self.delAction.connect("triggered()", self.deleteFiles) self.upAction = menu.addAction(QIcon(iconpack.icon("UP")), self._tr("Upload files")) self.upAction.connect("triggered()", self.uploadFiles) self.createAction = menu.addAction(QIcon.fromTheme("folder"), self._tr("Create Folder")) self.createAction.connect("triggered()", self.createFolder) self.refreshAction = menu.addAction(QIcon(iconpack.icon( "FILE_REFRESH")), self._tr("Refresh")) self.refreshAction.connect("triggered()", self.refresh) self.allactions = [self.openAction, self.downAction, self.renameAction, self.copyAction, self.delAction, self.upAction, self.createAction, self.refreshAction] self.collector = FileCollector(schid, cid, password, self.downloaddir) self.collector.collectionFinished.connect(self._startDownload) self.collector.collectionError.connect(self.showError) self.fileDoubleClicked = Signal() self.contextMenuRequested = Signal() self.transdlg = None self.listmodel = FileListModel(schid, cid, password, self, readonly=readonly) self.listmodel.pathChanged.connect(self.onPathChanged) self.listmodel.error.connect(self.showError) self.proxy = QSortFilterProxyModel(self) self.proxy.setSortRole(Qt.UserRole) self.proxy.setSortCaseSensitivity(Qt.CaseInsensitive) self.proxy.setFilterCaseSensitivity(Qt.CaseInsensitive) self.proxy.setSourceModel(self.listmodel) self.listmodel.path = path self._adjustUi() if iconpackopened: iconpack.close() PluginHost.registerCallbackProxy(self)