Skip to content

Commit

Permalink
allow copying data from the Info view
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Nov 10, 2023
1 parent 9a74223 commit 2407716
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 27 additions & 1 deletion src/asammdf/gui/widgets/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ def _process_dict(d):
}


class Delegate(QtWidgets.QStyledItemDelegate):
def createEditor(self, parent, option, index):
self.editor = QtWidgets.QPlainTextEdit(parent)
self.editor.setReadOnly(True)
return self.editor

def setEditorData(self, editor, index):
if editor:
editor.setPlainText(index.data())

def setModelData(self, editor, model, index):
return


class FileWidget(WithMDIArea, Ui_file_widget, QtWidgets.QWidget):
open_new_file = QtCore.Signal(str)
full_screen_toggled = QtCore.Signal()
Expand Down Expand Up @@ -2282,7 +2296,8 @@ def aspect_changed(self, index):

elif self.aspects.tabText(current_index) == "Info":
self.info.clear()
# self.mdf.reload_header()
self.info.setItemDelegate(Delegate(self.info))

# info tab
try:
file_stats = os.stat(self.mdf.original_name)
Expand All @@ -2298,9 +2313,11 @@ def aspect_changed(self, index):
item = QtWidgets.QTreeWidgetItem()
item.setText(0, "Path")
item.setText(1, str(self.mdf.original_name))
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
children.append(item)

item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, "Size")
if file_stats is not None:
item.setText(1, f"{file_stats.st_size / 1024 / 1024:.1f} MB")
Expand All @@ -2316,6 +2333,7 @@ def aspect_changed(self, index):
else:
date_ = datetime.now(timezone.utc)
item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, "Created")
item.setText(1, date_.strftime("%d-%b-%Y %H:%M:%S"))
children.append(item)
Expand All @@ -2325,6 +2343,7 @@ def aspect_changed(self, index):
else:
date_ = datetime.now(timezone.utc)
item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, "Last modified")
item.setText(1, date_.strftime("%d-%b-%Y %H:%M:%S"))
children.append(item)
Expand All @@ -2339,11 +2358,13 @@ def aspect_changed(self, index):
children = []

item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, "Version")
item.setText(1, self.mdf.version)
children.append(item)

item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, "Program identification")
item.setText(
1,
Expand All @@ -2352,11 +2373,13 @@ def aspect_changed(self, index):
children.append(item)

item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, "Measurement start time")
item.setText(1, self.mdf.header.start_time_string())
children.append(item)

item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, "Measurement comment")
item.setText(1, self.mdf.header.description)
item.setTextAlignment(0, QtCore.Qt.AlignmentFlag.AlignTop)
Expand All @@ -2369,11 +2392,13 @@ def aspect_changed(self, index):
for name, value in self.mdf.header._common_properties.items():
if isinstance(value, dict):
tree = QtWidgets.QTreeWidgetItem()
tree.setFlags(tree.flags() | QtCore.Qt.ItemIsEditable)
tree.setText(0, name)
tree.setTextAlignment(0, QtCore.Qt.AlignmentFlag.AlignTop)

for subname, subvalue in value.items():
item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, subname)
item.setText(1, str(subvalue).strip())
item.setTextAlignment(0, QtCore.Qt.AlignmentFlag.AlignTop)
Expand All @@ -2384,6 +2409,7 @@ def aspect_changed(self, index):

else:
item = QtWidgets.QTreeWidgetItem()
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
item.setText(0, FRIENDLY_ATRRIBUTES.get(name, name))
item.setText(1, str(value).strip())
item.setTextAlignment(0, QtCore.Qt.AlignmentFlag.AlignTop)
Expand Down
2 changes: 1 addition & 1 deletion src/asammdf/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
""" asammdf version module """

__version__ = "7.3.19.dev5"
__version__ = "7.3.19.dev6"

0 comments on commit 2407716

Please sign in to comment.