Use ellipsis the Qt way in the archive table (#169)

Showing the last 5 characters of the mount points doesn't give much
information, so we now allow the user to resize the mount_point column
and allow Qt to draw an ellipsis and the number of characters that
fit in the column (or the whole mount point if it fits).
This commit is contained in:
Antonio Larrosa 2019-01-28 01:41:42 +01:00 committed by Manuel Riel
parent 7526a03a21
commit eb50885371
1 changed files with 5 additions and 3 deletions

View File

@ -39,7 +39,7 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
header.setSectionResizeMode(0, QHeaderView.ResizeToContents)
header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
header.setSectionResizeMode(2, QHeaderView.ResizeToContents)
header.setSectionResizeMode(3, QHeaderView.ResizeToContents)
header.setSectionResizeMode(3, QHeaderView.Interactive)
header.setSectionResizeMode(4, QHeaderView.Stretch)
header.setStretchLastSection(True)
@ -49,6 +49,8 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
self.archiveTable.setSelectionBehavior(QTableView.SelectRows)
self.archiveTable.setSelectionMode(QTableView.SingleSelection)
self.archiveTable.setEditTriggers(QTableView.NoEditTriggers)
self.archiveTable.setWordWrap(False)
self.archiveTable.setTextElideMode(QtCore.Qt.ElideLeft)
self.archiveTable.setAlternatingRowColors(True)
self.archiveTable.cellDoubleClicked.connect(self.cell_double_clicked)
self.archiveTable.itemSelectionChanged.connect(self.update_mount_button_text)
@ -108,7 +110,7 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
mount_point = self.mount_points.get(archive.name)
if mount_point is not None:
item = QTableWidgetItem(f'{mount_point[-5:]}')
item = QTableWidgetItem(mount_point)
self.archiveTable.setItem(row, 3, item)
self.archiveTable.setItem(row, 4, QTableWidgetItem(archive.name))
@ -244,7 +246,7 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
self.update_mount_button_text()
archive_name = result['params']['current_archive']
row = self.row_of_archive(archive_name)
item = QTableWidgetItem(f"{result['cmd'][-1][-5:]}")
item = QTableWidgetItem(result['cmd'][-1])
self.archiveTable.setItem(row, 3, item)
def umount_action(self):