Skip to content

Commit 7a4f1ad

Browse files
committed
Add total size and file count display to source tab
1 parent 16b2b3d commit 7a4f1ad

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/vorta/assets/UI/source_tab.ui

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@
119119
<item>
120120
<layout class="QHBoxLayout" name="horizontalLayout"/>
121121
</item>
122+
<item>
123+
<widget class="QLabel" name="totalSizeLabel">
124+
<property name="text">
125+
<string/>
126+
</property>
127+
<property name="alignment">
128+
<set>Qt::AlignRight|Qt::AlignVCenter</set>
129+
</property>
130+
</widget>
131+
</item>
122132
<item>
123133
<spacer name="horizontalSpacer">
124134
<property name="orientation">

src/vorta/views/source_tab.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def set_path_info(self, path, data_size, files_count):
173173

174174
# enable sorting again
175175
self.sourceFilesWidget.setSortingEnabled(sorting)
176+
self.update_total_size()
176177

177178
def update_path_info(self, index_row: int):
178179
"""
@@ -245,7 +246,7 @@ def populate_from_profile(self):
245246

246247
for source in SourceFileModel.select().where(SourceFileModel.profile == profile):
247248
self.add_source_to_table(source, False)
248-
249+
self.update_total_size()
249250
# Fetch the Sort by Column and order
250251
sourcetab_sort_column = int(SettingsModel.get(key='sourcetab_sort_column').str_value)
251252
sourcetab_sort_order = int(SettingsModel.get(key='sourcetab_sort_order').str_value)
@@ -288,6 +289,7 @@ def source_add(self):
288289
if created:
289290
self.add_source_to_table(new_source)
290291
new_source.save()
292+
self.update_total_size()
291293

292294
def source_copy(self, index=None):
293295
"""
@@ -326,6 +328,27 @@ def source_remove(self):
326328
self.sourceFilesWidget.removeRow(index.row())
327329

328330
logger.debug(f"Removed source in row {index.row()}")
331+
self.update_total_size()
332+
333+
def update_total_size(self):
334+
"""
335+
Update the total size and files count for all sources.
336+
"""
337+
total_size, total_files = 0, 0
338+
339+
sources = SourceFileModel.select().where(SourceFileModel.profile == self.profile())
340+
for source in sources:
341+
if source.dir_size > 0:
342+
total_size += source.dir_size
343+
if source.dir_files_count > 0:
344+
total_files += source.dir_files_count
345+
346+
if total_size > 0:
347+
self.totalSizeLabel.setText(
348+
self.tr("Total Size: {}, {} files").format(pretty_bytes(total_size), total_files)
349+
)
350+
else:
351+
self.totalSizeLabel.setText("")
329352

330353
def show_exclude_dialog(self):
331354
window = ExcludeDialog(self.profile(), self)

0 commit comments

Comments
 (0)