예제 #1
0
    def set_data(self, _file):
        ff = QFileInfo(_file)
        self.short_title(ff.fileName())
        self.ui.lsize.setText(naturalsize(ff.size(), format="%.1f "))

        if ff.isDir():
            self.ui.litems.show()
            self.ui.label_3.show()
            self.ui.litems.setText(str(len(glob(_file + "/*"))))
        else:
            self.ui.label_3.hide()
            self.ui.litems.hide()

        self.ui.lcreated.setText(ff.created().toString())
        self.ui.lmodified.setText(ff.lastModified().toString())
        self.ui.laccessed.setText(ff.lastRead().toString())
        self.ui.luser.setText(ff.owner())
        self.ui.luid.setText(str(ff.ownerId()))
        self.ui.lgroup.setText(str(ff.group()))
        self.ui.lgid.setText(str(ff.groupId()))
        self.ui.lpath.setText(ff.path())
예제 #2
0
    def updateDetails(self, path):
        """
        Updates the elements in the right menu based on arguments
        :param path: path of the file
        :return: nothing
        """
        info = QFileInfo(path)

        bullet = html.unescape("•")

        value: str = bullet + " File not saved!"
        # Get the file info and update all the respective fields
        if info is not None and path is not None:
            value = ""
            i_s = "<i>"
            i_e = "</i>"
            br = "<br>"

            size = info.size()
            units = ['Bytes', 'KB', 'MB', 'GB']
            unit = 0
            while len(str(round(size, 0))) > 3:
                size /= 1000
                unit += 1

            value += bullet + " Name: " + i_s + info.fileName() + i_e + br
            value += bullet + " Path: " + i_s + info.path() + i_e + br
            value += bullet + " Size: " + i_s + str(size) + " " + units[unit] + i_e + br
            value += bullet + " Owner: " + i_s + (str(info.owner())) + i_e + br
            value += bullet + " Viewed: " + i_s + \
                     (info.lastRead().toString(self.format_time)) + i_e + br
            value += bullet + " Modified: " + i_s + \
                     (info.lastModified().toString(self.format_time)) + i_e

        self.col_metadata_contents.setText(value)
        # Update the summary from file
        self.updateSummary()