def _clock_out(self): try: patts.clockout(list(patts.get_active_task().keys())[0]) for trigger in self._triggers: trigger() except: ExceptionDialog(format_exc()).exec_()
def setModel(self, model): super().setModel(model) current_task = patts.get_active_task() if current_task: parent_id = current_task[list(current_task.keys())[0]]['typeID'] else: parent_id = '0' child_tasks = patts.get_child_types(parent_id) self._select_box = QComboBox() i = 0 self._task_map = {} for task in child_tasks: self._select_box.addItem(child_tasks[task]['displayName']) self._task_map[i] = task i += 1 self.setIndexWidget(model.createIndex(0, 0), self._select_box) clockInButton = QPushButton(_('TaskTable.clockIn')) clockInButton.clicked.connect(self._clock_in) self.setIndexWidget(model.createIndex(0, 1), clockInButton) if parent_id != '0': clockOutButton = QPushButton(_('TaskTable.clockOut')) clockOutButton.clicked.connect(self._clock_out) self.setIndexWidget(model.createIndex(1, 2), clockOutButton) self.resizeColumnsToContents()