eric6/CondaInterface/CondaPackageDetailsWidget.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

# -*- coding: utf-8 -*-

# Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a widget and a dialog to show package details.
"""

from PyQt5.QtCore import Qt, QDateTime
from PyQt5.QtWidgets import QWidget, QDialog, QVBoxLayout, QDialogButtonBox

from .Ui_CondaPackageDetailsWidget import Ui_CondaPackageDetailsWidget

from Globals import dataString


class CondaPackageDetailsWidget(QWidget, Ui_CondaPackageDetailsWidget):
    """
    Class implementing a widget to show package details.
    """
    def __init__(self, details, parent=None):
        """
        Constructor
        
        @param details dictionary containing the package details
        @type dict
        @param parent reference to the parent widget
        @type QWidget
        """
        super(CondaPackageDetailsWidget, self).__init__(parent)
        self.setupUi(self)
        
        self.headerLabel.setText(self.tr("<b>{0} / {1} / {2}</b>").format(
            details["name"], details["version"], details["build"]))
        if "fn" in details:
            self.filenameLabel.setText(details["fn"])
        if "size" in details:
            self.sizeLabel.setText(dataString(details["size"]))
        if "channel" in details:
            self.channelLabel.setText(details["channel"])
        if "url" in details:
            self.urlLabel.setText(details["url"])
        if "md5" in details:
            self.md5Label.setText(details["md5"])
        if "license" in details:
            self.licenseLabel.setText(details["license"])
        if "subdir" in details:
            self.platformLabel.setText(details["subdir"])
        elif "platform" in details:
            self.platformLabel.setText(details["platform"])
        else:
            self.platformLabel.setText(self.tr("unknown"))
        if "depends" in details:
            self.dependenciesEdit.setPlainText("\n".join(details["depends"]))
        
        if "timestamp" in details:
            dt = QDateTime.fromMSecsSinceEpoch(details["timestamp"], Qt.UTC)
            self.timestampLabel.setText(dt.toString("yyyy-MM-dd hh:mm:ss t"))
        
        self.resize(600, 450)


class CondaPackageDetailsDialog(QDialog):
    """
    Class implementing a dialog to show package details.
    """
    def __init__(self, details, parent=None):
        """
        Constructor
        
        @param details dictionary containing the package details
        @type dict
        @param parent reference to the parent widget
        @type QWidget
        """
        super(CondaPackageDetailsDialog, self).__init__(parent)
        self.setSizeGripEnabled(True)
        
        self.__layout = QVBoxLayout(self)
        self.setLayout(self.__layout)
        
        self.__cw = CondaPackageDetailsWidget(details, self)
        size = self.__cw.size()
        self.__layout.addWidget(self.__cw)
        self.__buttonBox = QDialogButtonBox(self)
        self.__buttonBox.setStandardButtons(QDialogButtonBox.Close)
        self.__layout.addWidget(self.__buttonBox)
        
        self.resize(size)
        self.setWindowTitle(self.tr("Package Details"))
        
        self.__buttonBox.accepted.connect(self.accept)
        self.__buttonBox.rejected.connect(self.reject)

eric ide

mercurial