Skip to content
Snippets Groups Projects
Commit c2d8352f authored by Thomas Holene Løkkeborg's avatar Thomas Holene Løkkeborg
Browse files

Merge branch 'endre-soi-fanenavn' into 'master'

#108 Fanenavn endres med SOI-tittel-endring

See merge request !85
parents 44d54e82 0add924e
No related branches found
No related tags found
1 merge request!85#108 Fanenavn endres med SOI-tittel-endring
Pipeline #83863 passed with stages
in 2 minutes and 32 seconds
......@@ -15,6 +15,7 @@ from PySide2.QtWidgets import (
)
from PySide2.QtGui import QIcon
from PySide2.QtCore import QTimer
from soitool.soi import SOI
from soitool.soi_workspace_widget import SOIWorkspaceWidget
from soitool.codebook_to_pdf import generate_codebook_pdf
from soitool.dialog_wrappers import exec_info_dialog
......@@ -219,10 +220,12 @@ class MainWindow(QMainWindow):
self.tabs.setCurrentWidget(tab)
def open_soi_workspace_tab(self):
"""Open and select tab containing a SOIWorkspaceWidget."""
tab = SOIWorkspaceWidget(self.database)
self.tabs.addTab(tab, tab.soi.title)
self.tabs.setCurrentWidget(tab)
"""Open and select tab containing a SOIWorkspaceWidget.
Tab will have newly created SOI.
"""
soi = SOI()
self.add_soi_tab(soi)
def close_tab(self, index):
"""Close tab at given index.
......@@ -309,11 +312,25 @@ class MainWindow(QMainWindow):
if len(file_path) > 0:
soi = import_soi(file_path, self.database)
self.add_soi_tab(soi)
# Create and select tab
tab = SOIWorkspaceWidget(self.database, soi)
self.tabs.addTab(tab, soi.title)
self.tabs.setCurrentWidget(tab)
def add_soi_tab(self, soi):
"""Add SOI tab with given SOI.
Parameters
----------
soi : soitool.soi.SOI
SOI to populate tab with.
"""
# Create and select tab
tab = SOIWorkspaceWidget(self.database, soi)
self.tabs.addTab(tab, soi.title)
self.tabs.setCurrentWidget(tab)
# Update tab-title when SOI-title changes
soi.add_update_property_listener(
lambda: self.tabs.setTabText(self.tabs.indexOf(tab), soi.title)
)
def regenerate_codes(self, auto=False):
"""Regenerate codebook-codes and update codebook-tab if open.
......
......@@ -103,6 +103,13 @@ class SOITableView(QTableView):
self.tab_widget.addTab(tab, soi.title)
self.tab_widget.setCurrentWidget(tab)
# Update tab-title when SOI-title changes
soi.add_update_property_listener(
lambda: self.tab_widget.setTabText(
self.tab_widget.indexOf(tab), soi.title
)
)
def setModel(self, model):
"""Set model, resize and hide 'SOI'-column.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment