Skip to content

Commit

Permalink
Merge pull request #237 from chStaiger/develop
Browse files Browse the repository at this point in the history
Hot fix for incompatibility with ibridges 1.0.1
  • Loading branch information
chStaiger authored Jul 25, 2024
2 parents 992f0b1 + ff1d98d commit 52851d3
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 76 deletions.
45 changes: 27 additions & 18 deletions ibridgesgui/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ def browse(self):

# Browser table behaviour
self.browser_table.doubleClicked.connect(self.update_path)
self.browser_table.clicked.connect(self.fill_info)
self.browser_table.clicked.connect(self.fill_info_tab_content)

# Load info tabs when requested
self.info_tabs.currentChanged.connect(self.fill_info_tab_content)

# Bottom tab view buttons
# Metadata
Expand Down Expand Up @@ -232,24 +235,30 @@ def load_browser_table(self):
self.browser_table.setRowCount(0)
self.error_label.setText("Collection does not exist.")

def fill_info(self):
"""Fill lower tabs with info."""
def fill_info_tab_content(self):
"""Fill the info of the selected lower tab."""
if self.browser_table.currentRow() == -1:
self.error_label.setText("Please select an item from the table.")
return

irods_path = self._get_item_path(self.browser_table.currentRow())
if irods_path is None:
self.error_label.setText("Please select an item in the table.")
self.error_label.clear()
self._clear_info_tabs()
self.delete_browser.clear()
self.meta_table.setRowCount(0)
self.acl_table.setRowCount(0)
self.replica_table.setRowCount(0)
irods_path = self._get_item_path(self.browser_table.currentRow())
self._clear_info_tabs()
tab_name = self.info_tabs.currentWidget().objectName()
try:
self._fill_preview_tab(irods_path)
self._fill_metadata_tab(irods_path)
self._fill_acls_tab(irods_path)
self._fill_replicas_tab(irods_path)
except Exception:
self.logger.exception("Cannot load info tabs.")
self.error_label.setText("Cannot load info tabs. Consult the logs.")
if tab_name == "metadata":
self._fill_metadata_tab(irods_path)
elif tab_name == "permissions":
self._fill_acls_tab(irods_path)
elif tab_name == "replicas":
self._fill_replicas_tab(irods_path)
elif tab_name == "preview":
self._fill_preview_tab(irods_path)
except Exception as err:
self.logger.exception("Error loading %s of %s .", tab_name, irods_path)
self.error_label.setText(f"Error loading {tab_name} of {irods_path}: {repr(err)}")

def set_icat_meta(self):
"""Button metadata set."""
Expand All @@ -274,7 +283,7 @@ def delete_icat_meta(self):

# @PyQt6.QtCore.pyqtSlot(PyQt6.QtCore.QModelIndex)
def edit_metadata(self, index):
"""Load selected metadata into edit fields."""
"""Load selected metadata info edit fields."""
self.error_label.clear()
self.meta_key_field.clear()
self.meta_value_field.clear()
Expand Down Expand Up @@ -506,7 +515,6 @@ def _fill_preview_tab(self, irods_path):
try:
with obj.open("r") as objfd:
content = [objfd.read(1024).decode("utf-8")]
# self.preview_browser.append(preview_string)
except Exception as error:
content = [
f"No Preview for: {irods_path}",
Expand All @@ -518,6 +526,7 @@ def _fill_preview_tab(self, irods_path):
else:
content = [f"No Preview for: {irods_path}"]
populate_textfield(self.preview_browser, content)
self.preview_browser.verticalScrollBar().setValue(0)

def _get_item_path(self, row):
item_name = self.browser_table.item(row, 1).text()
Expand Down
74 changes: 40 additions & 34 deletions ibridgesgui/ui_files/tabBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,6 @@ def setupUi(self, tabBrowser):
self.info_tabs = QtWidgets.QTabWidget(parent=tabBrowser)
self.info_tabs.setStyleSheet("")
self.info_tabs.setObjectName("info_tabs")
self.preview = QtWidgets.QWidget()
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(False)
font.setItalic(False)
self.preview.setFont(font)
self.preview.setAutoFillBackground(False)
self.preview.setObjectName("preview")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.preview)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.preview_browser = QtWidgets.QTextBrowser(parent=self.preview)
self.preview_browser.setObjectName("preview_browser")
self.verticalLayout_2.addWidget(self.preview_browser)
self.info_tabs.addTab(self.preview, "")
self.metadata = QtWidgets.QWidget()
self.metadata.setObjectName("metadata")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.metadata)
Expand Down Expand Up @@ -251,11 +237,25 @@ def setupUi(self, tabBrowser):
self.gridLayout_2.addWidget(self.add_meta_button, 7, 0, 1, 1)
self.horizontalLayout.addLayout(self.gridLayout_2)
self.info_tabs.addTab(self.metadata, "")
self.accession = QtWidgets.QWidget()
self.accession.setObjectName("accession")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.accession)
self.preview = QtWidgets.QWidget()
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(False)
font.setItalic(False)
self.preview.setFont(font)
self.preview.setAutoFillBackground(False)
self.preview.setObjectName("preview")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.preview)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.preview_browser = QtWidgets.QTextBrowser(parent=self.preview)
self.preview_browser.setObjectName("preview_browser")
self.verticalLayout_2.addWidget(self.preview_browser)
self.info_tabs.addTab(self.preview, "")
self.permissions = QtWidgets.QWidget()
self.permissions.setObjectName("permissions")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.permissions)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.acl_table = QtWidgets.QTableWidget(parent=self.accession)
self.acl_table = QtWidgets.QTableWidget(parent=self.permissions)
self.acl_table.setMinimumSize(QtCore.QSize(600, 0))
self.acl_table.setStyleSheet("")
self.acl_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents)
Expand All @@ -276,33 +276,33 @@ def setupUi(self, tabBrowser):
self.horizontalLayout_2.addWidget(self.acl_table)
self.gridLayout_4 = QtWidgets.QGridLayout()
self.gridLayout_4.setObjectName("gridLayout_4")
self.label_11 = QtWidgets.QLabel(parent=self.accession)
self.label_11 = QtWidgets.QLabel(parent=self.permissions)
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(False)
font.setItalic(False)
self.label_11.setFont(font)
self.label_11.setObjectName("label_11")
self.gridLayout_4.addWidget(self.label_11, 0, 0, 1, 1)
self.label_13 = QtWidgets.QLabel(parent=self.accession)
self.label_13 = QtWidgets.QLabel(parent=self.permissions)
self.label_13.setObjectName("label_13")
self.gridLayout_4.addWidget(self.label_13, 4, 0, 1, 1)
self.label_8 = QtWidgets.QLabel(parent=self.accession)
self.label_8 = QtWidgets.QLabel(parent=self.permissions)
self.label_8.setObjectName("label_8")
self.gridLayout_4.addWidget(self.label_8, 4, 1, 1, 1)
self.label_10 = QtWidgets.QLabel(parent=self.accession)
self.label_10 = QtWidgets.QLabel(parent=self.permissions)
self.label_10.setObjectName("label_10")
self.gridLayout_4.addWidget(self.label_10, 4, 2, 1, 1)
self.label_7 = QtWidgets.QLabel(parent=self.accession)
self.label_7 = QtWidgets.QLabel(parent=self.permissions)
self.label_7.setObjectName("label_7")
self.gridLayout_4.addWidget(self.label_7, 4, 3, 1, 1)
self.acl_user_field = QtWidgets.QLineEdit(parent=self.accession)
self.acl_user_field = QtWidgets.QLineEdit(parent=self.permissions)
self.acl_user_field.setObjectName("acl_user_field")
self.gridLayout_4.addWidget(self.acl_user_field, 6, 0, 1, 1)
self.acl_zone_field = QtWidgets.QLineEdit(parent=self.accession)
self.acl_zone_field = QtWidgets.QLineEdit(parent=self.permissions)
self.acl_zone_field.setObjectName("acl_zone_field")
self.gridLayout_4.addWidget(self.acl_zone_field, 6, 1, 1, 1)
self.acl_box = QtWidgets.QComboBox(parent=self.accession)
self.acl_box = QtWidgets.QComboBox(parent=self.permissions)
self.acl_box.setObjectName("acl_box")
self.acl_box.addItem("")
self.acl_box.setItemText(0, "")
Expand All @@ -313,12 +313,12 @@ def setupUi(self, tabBrowser):
self.acl_box.addItem("")
self.acl_box.addItem("")
self.gridLayout_4.addWidget(self.acl_box, 6, 2, 1, 1)
self.recurisive_box = QtWidgets.QComboBox(parent=self.accession)
self.recurisive_box = QtWidgets.QComboBox(parent=self.permissions)
self.recurisive_box.setObjectName("recurisive_box")
self.recurisive_box.addItem("")
self.recurisive_box.addItem("")
self.gridLayout_4.addWidget(self.recurisive_box, 6, 3, 1, 1)
self.add_acl_button = QtWidgets.QPushButton(parent=self.accession)
self.add_acl_button = QtWidgets.QPushButton(parent=self.permissions)
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(False)
Expand All @@ -328,15 +328,15 @@ def setupUi(self, tabBrowser):
self.gridLayout_4.addWidget(self.add_acl_button, 6, 4, 1, 1)
spacerItem5 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.gridLayout_4.addItem(spacerItem5, 8, 0, 1, 1)
self.owner = QtWidgets.QLabel(parent=self.accession)
self.owner = QtWidgets.QLabel(parent=self.permissions)
self.owner.setObjectName("owner")
self.gridLayout_4.addWidget(self.owner, 9, 0, 1, 1)
self.owner_label = QtWidgets.QLabel(parent=self.accession)
self.owner_label = QtWidgets.QLabel(parent=self.permissions)
self.owner_label.setText("")
self.owner_label.setObjectName("owner_label")
self.gridLayout_4.addWidget(self.owner_label, 9, 1, 1, 1)
self.horizontalLayout_2.addLayout(self.gridLayout_4)
self.info_tabs.addTab(self.accession, "")
self.info_tabs.addTab(self.permissions, "")
self.replicas = QtWidgets.QWidget()
self.replicas.setObjectName("replicas")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.replicas)
Expand Down Expand Up @@ -395,7 +395,7 @@ def setupUi(self, tabBrowser):
self.verticalLayout.addWidget(self.error_label)

self.retranslateUi(tabBrowser)
self.info_tabs.setCurrentIndex(4)
self.info_tabs.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(tabBrowser)

def retranslateUi(self, tabBrowser):
Expand All @@ -420,7 +420,6 @@ def retranslateUi(self, tabBrowser):
item.setText(_translate("tabBrowser", "Created"))
item = self.browser_table.horizontalHeaderItem(5)
item.setText(_translate("tabBrowser", "Modified"))
self.info_tabs.setTabText(self.info_tabs.indexOf(self.preview), _translate("tabBrowser", "Preview"))
self.meta_table.setSortingEnabled(True)
item = self.meta_table.horizontalHeaderItem(0)
item.setText(_translate("tabBrowser", "Key"))
Expand All @@ -436,6 +435,13 @@ def retranslateUi(self, tabBrowser):
self.label_6.setText(_translate("tabBrowser", "Value"))
self.add_meta_button.setText(_translate("tabBrowser", "Add"))
self.info_tabs.setTabText(self.info_tabs.indexOf(self.metadata), _translate("tabBrowser", "Metadata"))
self.preview_browser.setHtml(_translate("tabBrowser", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"hr { height: 1px; border-width: 0; }\n"
"</style></head><body style=\" font-family:\'.AppleSystemUIFont\'; font-size:16pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Click to load preview.</p></body></html>"))
self.info_tabs.setTabText(self.info_tabs.indexOf(self.preview), _translate("tabBrowser", "Preview"))
self.acl_table.setSortingEnabled(True)
item = self.acl_table.horizontalHeaderItem(0)
item.setText(_translate("tabBrowser", "User"))
Expand All @@ -460,7 +466,7 @@ def retranslateUi(self, tabBrowser):
self.recurisive_box.setItemText(1, _translate("tabBrowser", "True"))
self.add_acl_button.setText(_translate("tabBrowser", "Add/Update"))
self.owner.setText(_translate("tabBrowser", "Owner: "))
self.info_tabs.setTabText(self.info_tabs.indexOf(self.accession), _translate("tabBrowser", "Permissions"))
self.info_tabs.setTabText(self.info_tabs.indexOf(self.permissions), _translate("tabBrowser", "Permissions"))
self.replica_table.setSortingEnabled(True)
item = self.replica_table.horizontalHeaderItem(0)
item.setText(_translate("tabBrowser", "Replica"))
Expand Down
53 changes: 31 additions & 22 deletions ibridgesgui/ui_files/tabBrowser.ui
Original file line number Diff line number Diff line change
Expand Up @@ -324,28 +324,8 @@ QTabWidget#info_tabs
<string notr="true"/>
</property>
<property name="currentIndex">
<number>4</number>
<number>0</number>
</property>
<widget class="QWidget" name="preview">
<property name="font">
<font>
<pointsize>16</pointsize>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<attribute name="title">
<string>Preview</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTextBrowser" name="preview_browser"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="metadata">
<attribute name="title">
<string>Metadata</string>
Expand Down Expand Up @@ -499,7 +479,36 @@ QTabWidget#info_tabs
</item>
</layout>
</widget>
<widget class="QWidget" name="accession">
<widget class="QWidget" name="preview">
<property name="font">
<font>
<pointsize>16</pointsize>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<attribute name="title">
<string>Preview</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTextBrowser" name="preview_browser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.AppleSystemUIFont'; font-size:16pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Click to load preview.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="permissions">
<attribute name="title">
<string>Permissions</string>
</attribute>
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PyQt6>=6.4.2
ibridges
pyinstaller==6.8.0
pyinstaller==6.9.0
setproctitle==1.3.3
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flake8==7.1.0
pylint==3.2.5
pytest==8.2.2
pytest==8.3.1
pytest-cov==5.0.0

0 comments on commit 52851d3

Please sign in to comment.