changed eventlist string and coloring, [bug]: picks not displayed

This commit is contained in:
Marcel Paffrath 2017-04-20 14:03:26 +02:00
parent f5dcfc654d
commit bcc58e4937
2 changed files with 54 additions and 15 deletions

View File

@ -163,7 +163,7 @@ class MainWindow(QMainWindow):
self._main_layout = QVBoxLayout() self._main_layout = QVBoxLayout()
# add event combo box # add event combo box
self.eventBox = QComboBox() self.eventBox = self.createEventBox()
self.eventBox.setMaxVisibleItems(30) self.eventBox.setMaxVisibleItems(30)
self.eventBox.setEnabled(False) self.eventBox.setEnabled(False)
self._event_layout = QHBoxLayout() self._event_layout = QHBoxLayout()
@ -539,8 +539,11 @@ class MainWindow(QMainWindow):
def getCurrentEvent(self): def getCurrentEvent(self):
for event in self.project.eventlist: for event in self.project.eventlist:
if event.path == self.eventBox.currentText(): if event.path == self.getCurrentEventPath():
return event return event
def getCurrentEventPath(self):
return str(self.eventBox.currentText().split('|')[0]).strip()
def getLastEvent(self): def getLastEvent(self):
return self.recentfiles[0] return self.recentfiles[0]
@ -585,7 +588,7 @@ class MainWindow(QMainWindow):
def getWFFnames_from_eventlist(self): def getWFFnames_from_eventlist(self):
if self.dataStructure: if self.dataStructure:
searchPath = self.dataStructure.expandDataPath() searchPath = self.dataStructure.expandDataPath()
directory = self.eventBox.currentText() directory = self.getCurrentEventPath()
self.fnames = [os.path.join(directory, f) for f in os.listdir(directory)] self.fnames = [os.path.join(directory, f) for f in os.listdir(directory)]
else: else:
raise DatastructureError('not specified') raise DatastructureError('not specified')
@ -611,15 +614,25 @@ class MainWindow(QMainWindow):
self.project.add_eventlist(eventlist) self.project.add_eventlist(eventlist)
self.init_events() self.init_events()
def createEventBox(self):
qcb = QComboBox()
palette = qcb.palette()
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight,
QtGui.QBrush(QtGui.QColor(0,0,127,127)))
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight,
QtGui.QBrush(QtGui.QColor(0,0,127,127)))
qcb.setPalette(palette)
return qcb
def init_events(self, new=False): def init_events(self, new=False):
nitems = self.eventBox.count() nitems = self.eventBox.count()
self.eventBox.clear()
if len(self.project.eventlist) == 0: if len(self.project.eventlist) == 0:
print('No events to init.') print('No events to init.')
self.clearWaveformDataPlot() self.clearWaveformDataPlot()
return return
self.eventBox.setEnabled(True) self.eventBox.setEnabled(True)
self.fill_eventbox(self.project.eventlist) self.fill_eventbox()
if new: if new:
self.eventBox.setCurrentIndex(0) self.eventBox.setCurrentIndex(0)
else: else:
@ -627,19 +640,41 @@ class MainWindow(QMainWindow):
self.refreshEvents() self.refreshEvents()
tabindex = self.tabs.currentIndex() tabindex = self.tabs.currentIndex()
def fill_eventbox(self, eventlist): def fill_eventbox(self):
index=self.eventBox.currentIndex()
self.eventBox.clear()
model = self.eventBox.model() model = self.eventBox.model()
for event in self.project.eventlist: for event in self.project.eventlist:
event = event.path event_path = event.path
item = QtGui.QStandardItem(str(event)) event_npicks = 0
event_nautopicks = 0
if event.picks:
event_npicks = len(event.picks)
if event.autopicks:
event_nautopicks = len(event.autopicks)
event_ref = event.isRefEvent()
event_test = event.isTestEvent()
text = '{path} | manual: [{p}] | auto: [{a}] | ref: {ref} | test: {test}'
text = text.format(path=event_path,
p=event_npicks,
a=event_nautopicks,
ref=event_ref,
test=event_test)
item = QtGui.QStandardItem(str(text))
# if ref: set different color e.g. # if ref: set different color e.g.
#item.setBackground(QtGui.QColor('teal')) if event_ref:
item.setBackground(QtGui.QColor('cyan'))
if event_test:
item.setBackground(QtGui.QColor('yellow'))
item.setForeground(QtGui.QColor('black')) item.setForeground(QtGui.QColor('black'))
font = item.font() font = item.font()
font.setPointSize(10) font.setPointSize(10)
item.setFont(font) item.setFont(font)
model.appendRow(item) model.appendRow(item)
self.eventBox.setCurrentIndex(index)
def filename_from_action(self, action): def filename_from_action(self, action):
if action.data() is None: if action.data() is None:
filt = "Supported file formats" \ filt = "Supported file formats" \
@ -1285,7 +1320,8 @@ class MainWindow(QMainWindow):
item_ref.setCheckState(QtCore.Qt.Unchecked) item_ref.setCheckState(QtCore.Qt.Unchecked)
event.setTestEvent(True) event.setTestEvent(True)
elif column == 2 and not item_test.checkState(): elif column == 2 and not item_test.checkState():
event.setTestEvent(False) event.setTestEvent(False)
self.fill_eventbox()
elif column == 3: elif column == 3:
#update event notes #update event notes
notes = table[row][3].text() notes = table[row][3].text()
@ -1303,8 +1339,10 @@ class MainWindow(QMainWindow):
item_path = QtGui.QTableWidgetItem() item_path = QtGui.QTableWidgetItem()
item_ref = QtGui.QTableWidgetItem() item_ref = QtGui.QTableWidgetItem()
item_test = QtGui.QTableWidgetItem() item_test = QtGui.QTableWidgetItem()
item_notes = QtGui.QTableWidgetItem() item_notes = QtGui.QTableWidgetItem()
item_ref.setBackground(QtGui.QColor('cyan'))
item_test.setBackground(QtGui.QColor('yellow'))
item_path.setText(event.path) item_path.setText(event.path)
item_notes.setText(event.notes) item_notes.setText(event.notes)
if event.picks: if event.picks:
@ -1336,7 +1374,7 @@ class MainWindow(QMainWindow):
header.setResizeMode(QtGui.QHeaderView.ResizeToContents) header.setResizeMode(QtGui.QHeaderView.ResizeToContents)
header.setStretchLastSection(True) header.setStretchLastSection(True)
self.qtl.cellChanged[int, int].connect(cell_changed) self.qtl.cellChanged[int, int].connect(cell_changed)
self.events_layout.addWidget(self.qtl) self.events_layout.addWidget(self.qtl)
self.tabs.setCurrentIndex(index) self.tabs.setCurrentIndex(index)
@ -1522,6 +1560,7 @@ class MainWindow(QMainWindow):
self.createNewProject(exists=True) self.createNewProject(exists=True)
def draw(self): def draw(self):
#self.fill_eventbox()
self.getPlotWidget().draw() self.getPlotWidget().draw()
def setDirty(self, value): def setDirty(self, value):

View File

@ -1 +1 @@
227f-dirty f5dcf-dirty