Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/vorta/assets/UI/archivetab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
Expand Down Expand Up @@ -173,6 +170,11 @@
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Trigger</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1">
Expand Down
1 change: 1 addition & 0 deletions src/vorta/assets/icons/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/vorta/borg/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def process_result(self, result):
'repo': result['params']['repo_id'],
'duration': result['data']['archive']['duration'],
'size': result['data']['archive']['stats']['deduplicated_size'],
'trigger': result['params'].get('category', 'user'),
},
)
new_archive.save()
Expand Down
2 changes: 1 addition & 1 deletion src/vorta/store/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)
from .settings import get_misc_settings

SCHEMA_VERSION = 20
SCHEMA_VERSION = 21


@signals.post_save(sender=SettingsModel)
Expand Down
11 changes: 11 additions & 0 deletions src/vorta/store/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,17 @@ def run_migrations(current_schema, db_connection):
migrator.add_column(SettingsModel._meta.table_name, 'tooltip', pw.CharField(default='')),
)

if current_schema.version < 21:
_apply_schema_update(
current_schema,
21,
migrator.add_column(
ArchiveModel._meta.table_name,
'trigger',
pw.CharField(null=True),
),
)


def _apply_schema_update(current_schema, version_after, *operations):
with DB.atomic():
Expand Down
1 change: 1 addition & 0 deletions src/vorta/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class ArchiveModel(BaseModel):
time = pw.DateTimeField()
duration = pw.FloatField(null=True)
size = pw.IntegerField(null=True)
trigger = pw.CharField(null=True)

def formatted_time(self):
return
Expand Down
29 changes: 28 additions & 1 deletion src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
QLayout,
QMenu,
QMessageBox,
QStyledItemDelegate,
QTableView,
QTableWidgetItem,
QWidget,
Expand Down Expand Up @@ -57,6 +58,13 @@
SIZE_DECIMAL_DIGITS = 1


# from https://stackoverflow.com/questions/63177587/pyqt-tableview-align-icons-to-center
class IconDelegate(QStyledItemDelegate):
def initStyleOption(self, option, index):
super().initStyleOption(option, index)
option.decorationSize = option.rect.size() - QtCore.QSize(0, 10)


class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
prune_intervals = ['hour', 'day', 'week', 'month', 'year']

Expand All @@ -83,7 +91,10 @@ def __init__(self, parent=None, app=None):
header.setSectionResizeMode(2, QHeaderView.ResizeMode.ResizeToContents)
header.setSectionResizeMode(3, QHeaderView.ResizeMode.Interactive)
header.setSectionResizeMode(4, QHeaderView.ResizeMode.Stretch)
header.setStretchLastSection(True)
header.setSectionResizeMode(5, QHeaderView.ResizeMode.ResizeToContents)

delegate = IconDelegate(self.archiveTable)
self.archiveTable.setItemDelegateForColumn(5, delegate)

if sys.platform != 'darwin':
self._set_status('') # Set platform-specific hints.
Expand Down Expand Up @@ -255,6 +266,12 @@ def populate_from_profile(self):
self.toolBox.setItemText(0, self.tr('Archives for %s') % profile.repo.url)
archives = [s for s in profile.repo.archives.select().order_by(ArchiveModel.time.desc())]

# if no archive's name can be found in self.mount_points, then hide the mount point column
if not any(a.name in self.mount_points for a in archives):
self.archiveTable.hideColumn(3)
else:
self.archiveTable.showColumn(3)

sorting = self.archiveTable.isSortingEnabled()
self.archiveTable.setSortingEnabled(False)
best_unit = find_best_unit_for_sizes((a.size for a in archives), precision=SIZE_DECIMAL_DIGITS)
Expand All @@ -280,6 +297,16 @@ def populate_from_profile(self):

self.archiveTable.setItem(row, 4, QTableWidgetItem(archive.name))

if archive.trigger == 'scheduled':
item = QTableWidgetItem(get_colored_icon('clock-o'), '')
item.setToolTip(self.tr('Scheduled'))
self.archiveTable.setItem(row, 5, item)
elif archive.trigger == 'user':
item = QTableWidgetItem(get_colored_icon('user'), '')
item.setToolTip(self.tr('User initiated'))
item.setTextAlignment(Qt.AlignmentFlag.AlignRight)
self.archiveTable.setItem(row, 5, item)

self.archiveTable.setRowCount(len(archives))
self.archiveTable.setSortingEnabled(sorting)
item = self.archiveTable.item(0, 0)
Expand Down