few bugfixes

This commit is contained in:
Marcel Paffrath 2017-04-19 16:05:45 +02:00
parent 80577dcfc7
commit f935da8296
2 changed files with 30 additions and 14 deletions

View File

@ -91,6 +91,7 @@ class MainWindow(QMainWindow):
self.project = None
self.array_map = None
self._metadata = None
self._eventChanged = False
self.poS_id = None
self.ae_id = None
@ -170,7 +171,7 @@ class MainWindow(QMainWindow):
self._event_layout.addWidget(self.eventBox)
self._event_layout.setStretch(1,1) #set stretch of item 1 to 1
self._main_layout.addLayout(self._event_layout)
self.eventBox.activated.connect(self.refreshTabs)
self.eventBox.activated.connect(self.refreshEvents)
# add tabs
self.tabs = QTabWidget()
@ -185,7 +186,6 @@ class MainWindow(QMainWindow):
self.tabs.addTab(self.dataPlot, 'Waveform Plot')
self.init_array_tab()
quitIcon = self.style().standardIcon(QStyle.SP_MediaStop)
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
@ -604,7 +604,7 @@ class MainWindow(QMainWindow):
self.eventBox.setCurrentIndex(0)
else:
self.eventBox.setCurrentIndex(nitems)
self.refreshTabs()
self.refreshEvents()
def fill_eventbox(self, eventlist):
model = self.eventBox.model()
@ -782,11 +782,17 @@ class MainWindow(QMainWindow):
return self.saveData()
return True
def refreshEvents(self):
self._eventChanged = True
self.refreshTabs()
def refreshTabs(self):
if self.tabs.currentIndex() == 0:
if hasattr(self.project, 'eventlist'):
if len(self.project.eventlist) > 0:
if self._eventChanged:
self.loadWaveformDataThread()
self._eventChanged = False
if self.tabs.currentIndex() == 1:
self.refresh_array_map()
@ -1197,15 +1203,15 @@ class MainWindow(QMainWindow):
widget.setLayout(grid_layout)
self.tabs.addTab(widget, 'Array Maps')
def init_array_map(self):
def init_array_map(self, index=1):
if not self.array_map:
self.get_metadata()
if not self.metadata:
return
self.array_map = map_projection(self)
self.tabs.removeTab(1)
self.array_map = map_projection(self)
self.tabs.addTab(self.array_map, 'Array Map')
self.tabs.setCurrentIndex(1)
self.tabs.setCurrentIndex(index)
def refresh_array_map(self):
if not self.array_map:
@ -1220,6 +1226,7 @@ class MainWindow(QMainWindow):
def set_metadata(self):
self.metadata = self.rm_thread.data
self.project.metadata = self.rm_thread.data
self.init_array_map()
def get_metadata(self):
@ -1240,6 +1247,10 @@ class MainWindow(QMainWindow):
self.read_metadata_thread(fninv)
return True
if hasattr(self.project, 'metadata'):
self.metadata = self.project.metadata
return True
settings = QSettings()
fninv = settings.value("inventoryFile", None)
@ -1368,9 +1379,14 @@ class MainWindow(QMainWindow):
if fnm[0]:
self.project = Project.load(fnm[0])
self.init_events(new=True)
if hasattr(self.project, 'metadata'):
self.init_array_map(index=0)
def saveProject(self):
if self.project:
if not self.project.location:
self.createNewProject(exists=True)
else:
self.project.save()
if not self.project.dirty:
qmb = QMessageBox(icon=QMessageBox.Information, text='Saved back project to file:\n{}'.format(self.project.location))

View File

@ -1 +1 @@
fd70-dirty
8057-dirty