示例#1
0
文件: gui.py 项目: kostajh/qtimer
	def onStartTimers(self, items):
		if items:
			# Start any paused timers
			with qtimer.autocommit(self.backend.session) as sql:
				for item in items:
					status = item.timer.status
					if not status == STATUS_IDLE:
						continue
					session = Session(start=self.backend.roundTime(datetime.utcnow()), timer_id=item.timer.id)
					sql.add(session)
		else:
			# Create timer
			text, ok = QInputDialog.getText(self, 'Enter Timer Name', 'Enter new timer name:')
			if not ok:
				return

			item = self.ui.projects.selectedItems()

			tid = None
			if hasattr(item, 'ticket'):
				tid = item.ticket.id

			session = Session(start=self.backend.roundTime(datetime.utcnow()))
			timer = Timer(name=text, ticket_id=tid, sessions=[session])
			self.backend.session.add(timer)
			self.onFilterClicked(item, None)
示例#2
0
文件: gui.py 项目: kostajh/qtimer
	def onStopTimers(self, items):
		if not items:
			self.createErrorText('No timers selected.')
			return

		ids = []
		for item in items:
			ids.append(item.timer.id)

		values = {
			Session.end: self.backend.roundTime(datetime.utcnow())
		}

		with qtimer.autocommit(self.backend.session) as session:
			session.query(Session).filter(Session.timer_id.in_(ids))\
				.filter(Session.end == None).update(values, 'fetch')
		self.onFilterClicked(item, None)