Skip to content

Commit

Permalink
Adress review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinBuira committed Jan 7, 2025
1 parent dd9ca4f commit 5e9b020
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Mergin/version_viewer_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, parent=None):
super().__init__(parent)

# Keep ordered
self.versions = deque()
self.versions = []]

self.oldest = None
self.latest = None
Expand All @@ -85,12 +85,12 @@ def __init__(self, parent=None):
self.current_version = None

def latest_version(self):
if len(self.versions) == 0:
if not self.versions:
return None
return int_version(self.versions[0]["name"])

def oldest_version(self):
if len(self.versions) == 0:
if not self.versions:
return None
return int_version(self.versions[-1]["name"])

Expand Down Expand Up @@ -125,8 +125,9 @@ def data(self, index, role=Qt.DisplayRole):
font.setBold(True)
return font
elif role == Qt.ToolTipRole:
if index.column() == 2:
return format_datetime(self.versions[idx]["created"])
return f"""Version: {self.versions[idx]['name'] }
Author: {self.versions[idx]['author']}
Date: {format_datetime(self.versions[idx]['created'])}"""
elif role == VersionsTableModel.VERSION:
return int_version(self.versions[idx]["name"])
elif role == VersionsTableModel.VERSION_NAME:
Expand Down Expand Up @@ -280,7 +281,7 @@ def __init__(self, mc, parent=None):
self.history_treeview.verticalScrollBar().valueChanged.connect(self.on_scrollbar_changed)

self.selectionModel: QItemSelectionModel = self.history_treeview.selectionModel()
self.selectionModel.currentChanged.connect(self.current_version_changed)
self.selectionModel.currentChanged.connect(self.selected_version_changed)

self.has_selected_latest = False

Expand Down Expand Up @@ -437,7 +438,7 @@ def on_scrollbar_changed(self, value):
if self.ui.history_treeview.verticalScrollBar().maximum() <= value:
self.fetch_from_server()

def current_version_changed(self, current_index, previous_index):
def selected_version_changed(self, current_index, previous_index):
# Update the ui when the selected version change
item = self.versionModel.item_from_index(current_index)
version_name = item["name"]
Expand Down

0 comments on commit 5e9b020

Please sign in to comment.