Пример #1
0
    def add_file(self, filename):
        if filename not in self.filenames:
            # make filenames unicode-safe for Qt (#141)
            filename = filename.encode('utf-8').decode('utf-8', 'replace')

            self.filenames.append(filename)

            fileinfo = QtCore.QFileInfo(filename)
            basename = os.path.basename(filename.rstrip('/'))
            ip = QtGui.QFileIconProvider()
            icon = ip.icon(fileinfo)

            if os.path.isfile(filename):
                size = helpers.human_readable_filesize(fileinfo.size())
            else:
                size = helpers.human_readable_filesize(
                    helpers.dir_size(filename))
            item_name = unicode('{0:s} ({1:s})'.format(basename, size))
            item = QtGui.QListWidgetItem(item_name)
            item.setToolTip(QtCore.QString(size))

            item.setIcon(icon)
            self.addItem(item)

            self.files_updated.emit()
Пример #2
0
    def add_file(self, filename):
        """
        Add a file or directory to this widget.
        """
        if filename not in self.filenames:
            self.filenames.append(filename)

            fileinfo = QtCore.QFileInfo(filename)
            basename = os.path.basename(filename.rstrip('/'))
            ip = QtWidgets.QFileIconProvider()
            icon = ip.icon(fileinfo)

            if os.path.isfile(filename):
                size = helpers.human_readable_filesize(fileinfo.size())
            else:
                size = helpers.human_readable_filesize(
                    helpers.dir_size(filename))
            item_name = '{0:s} ({1:s})'.format(basename, size)
            item = QtWidgets.QListWidgetItem(item_name)
            item.setToolTip(size)

            item.setIcon(icon)
            self.addItem(item)

            self.files_updated.emit()
Пример #3
0
    def add_file(self, filename):
        """
        Add a file or directory to this widget.
        """
        if filename not in self.filenames:
            # make filenames unicode-safe for Qt (#141)
            filename = filename.encode('utf-8').decode('utf-8', 'replace')

            self.filenames.append(filename)

            fileinfo = QtCore.QFileInfo(filename)
            basename = os.path.basename(filename.rstrip('/'))
            ip = QtGui.QFileIconProvider()
            icon = ip.icon(fileinfo)

            if os.path.isfile(filename):
                size = helpers.human_readable_filesize(fileinfo.size())
            else:
                size = helpers.human_readable_filesize(helpers.dir_size(filename))
            item_name = unicode('{0:s} ({1:s})'.format(basename, size))
            item = QtGui.QListWidgetItem(item_name)
            item.setToolTip(QtCore.QString(size))

            item.setIcon(icon)
            self.addItem(item)

            self.files_updated.emit()
Пример #4
0
 def _compute_total_size(filenames):
     total_size = 0
     for filename in filenames:
         if os.path.isfile(filename):
             total_size += os.path.getsize(filename)
         if os.path.isdir(filename):
             total_size += helpers.dir_size(filename)
     return total_size
Пример #5
0
 def _compute_total_size(filenames):
     total_size = 0
     for filename in filenames:
         if os.path.isfile(filename):
             total_size += os.path.getsize(filename)
         if os.path.isdir(filename):
             total_size += helpers.dir_size(filename)
     return total_size
Пример #6
0
    def add_file(self, filename):
        if filename not in self.filenames:
            self.filenames.append(filename)

            basename = os.path.basename(filename)
            fileinfo = QtCore.QFileInfo(filename)
            ip = QtGui.QFileIconProvider()
            icon = ip.icon(fileinfo)

            if os.path.isfile(filename):
                size = self.human_readable_filesize(fileinfo.size())
            else:
                size = self.human_readable_filesize(helpers.dir_size(filename))
            item = QtGui.QListWidgetItem('{0} ({1})'.format(basename, size))
            item.setToolTip(QtCore.QString(size))
            
            item.setIcon(icon)
            self.addItem(item)

            self.files_updated.emit()
Пример #7
0
    def add_file(self, filename):
        """
        Add a file or directory to this widget.
        """
        if filename not in self.filenames:
            self.filenames.append(filename)

            fileinfo = QtCore.QFileInfo(filename)
            basename = os.path.basename(filename.rstrip('/'))
            ip = QtWidgets.QFileIconProvider()
            icon = ip.icon(fileinfo)

            if os.path.isfile(filename):
                size = helpers.human_readable_filesize(fileinfo.size())
            else:
                size = helpers.human_readable_filesize(helpers.dir_size(filename))
            item_name = '{0:s} ({1:s})'.format(basename, size)
            item = QtWidgets.QListWidgetItem(item_name)
            item.setToolTip(size)

            item.setIcon(icon)
            self.addItem(item)

            self.files_updated.emit()