CondaInterface/CondaPackageDetailsWidget.py

branch
maintenance
changeset 6826
c6dda2cbe081
parent 6728
ba077788a882
equal deleted inserted replaced
6764:d14ddbfbbd36 6826:c6dda2cbe081
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a widget and a dialog to show package details.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import Qt, QDateTime
13 from PyQt5.QtWidgets import QWidget, QDialog, QVBoxLayout, QDialogButtonBox
14
15 from .Ui_CondaPackageDetailsWidget import Ui_CondaPackageDetailsWidget
16
17 from Globals import dataString
18
19
20 class CondaPackageDetailsWidget(QWidget, Ui_CondaPackageDetailsWidget):
21 """
22 Class implementing a widget to show package details.
23 """
24 def __init__(self, details, parent=None):
25 """
26 Constructor
27
28 @param details dictionary containing the package details
29 @type dict
30 @param parent reference to the parent widget
31 @type QWidget
32 """
33 super(CondaPackageDetailsWidget, self).__init__(parent)
34 self.setupUi(self)
35
36 self.headerLabel.setText(self.tr("<b>{0} / {1} / {2}</b>").format(
37 details["name"], details["version"], details["build"]))
38 if "fn" in details:
39 self.filenameLabel.setText(details["fn"])
40 if "size" in details:
41 self.sizeLabel.setText(dataString(details["size"]))
42 if "channel" in details:
43 self.channelLabel.setText(details["channel"])
44 if "url" in details:
45 self.urlLabel.setText(details["url"])
46 if "md5" in details:
47 self.md5Label.setText(details["md5"])
48 if "license" in details:
49 self.licenseLabel.setText(details["license"])
50 if "subdir" in details:
51 self.platformLabel.setText(details["subdir"])
52 elif "platform" in details:
53 self.platformLabel.setText(details["platform"])
54 else:
55 self.platformLabel.setText(self.tr("unknown"))
56 if "depends" in details:
57 self.dependenciesEdit.setPlainText("\n".join(details["depends"]))
58
59 if "timestamp" in details:
60 dt = QDateTime.fromMSecsSinceEpoch(details["timestamp"], Qt.UTC)
61 self.timestampLabel.setText(dt.toString("yyyy-MM-dd hh:mm:ss t"))
62
63 self.resize(600, 450)
64
65
66 class CondaPackageDetailsDialog(QDialog):
67 """
68 Class implementing a dialog to show package details.
69 """
70 def __init__(self, details, parent=None):
71 """
72 Constructor
73
74 @param details dictionary containing the package details
75 @type dict
76 @param parent reference to the parent widget
77 @type QWidget
78 """
79 super(CondaPackageDetailsDialog, self).__init__(parent)
80 self.setSizeGripEnabled(True)
81
82 self.__layout = QVBoxLayout(self)
83 self.setLayout(self.__layout)
84
85 self.__cw = CondaPackageDetailsWidget(details, self)
86 size = self.__cw.size()
87 self.__layout.addWidget(self.__cw)
88 self.__buttonBox = QDialogButtonBox(self)
89 self.__buttonBox.setStandardButtons(QDialogButtonBox.Close)
90 self.__layout.addWidget(self.__buttonBox)
91
92 self.resize(size)
93 self.setWindowTitle(self.tr("Package Details"))
94
95 self.__buttonBox.accepted.connect(self.accept)
96 self.__buttonBox.rejected.connect(self.reject)

eric ide

mercurial