Beispiel #1
0
	def __init__(self):
		super(MainWindow, self).__init__()

		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)

		self.aboutDialog = AboutDialog(self)
		self.loginDialog = LoginDialog(self)
		self.addAdminDialog = AddAdminDialog(self)
		self.ganttDiagram = GanttDialog(self)
		
		self.ui.actionAbout.triggered.connect(self.aboutDialog.open)
		self.ui.actionLogin.triggered.connect(self.openLoginDialog)
		self.ui.actionLogout.triggered.connect(self.logout)
		self.ui.actionLogout.setDisabled(True)
		self.ui.actionExit_2.triggered.connect(self.close)
		
		self.ui.actionViewCompanies.triggered.connect(self.showTableTrigger('companies'))
		self.ui.actionViewUsers.triggered.connect(self.showTableTrigger('users'))
		self.ui.actionViewEmployees.triggered.connect(self.showTableTrigger('employees'))
		self.ui.actionViewProjects.triggered.connect(self.showTableTrigger('projects'))
		self.ui.actionViewContracts.triggered.connect(self.showTableTrigger('contracts'))
		self.ui.actionViewProjectEmployees.triggered.connect(self.showTableTrigger('projectEmployees'))
		self.ui.actionViewTasks.triggered.connect(self.showTableTrigger('tasks'))
		self.ui.actionViewJobs.triggered.connect(self.showTableTrigger('jobs'))
		self.ui.actionViewTasksDependencies.triggered.connect(self.showTableTrigger('tasksDependencies'))
		self.ui.actionJobs.triggered.connect(self.showTableTrigger('jobs', True))
		self.ui.actionGantt_diagram.triggered.connect(self.showGanttDiagram)
		self.loginDialog.loginSignal.connect(self.login)

		if not len(appInst.getAdmins()):
			self.addAdminDialog.open()
Beispiel #2
0
class MainWindow(QtGui.QMainWindow):
	def showTableTrigger(self, tableName, param = None):
		return lambda: self.showTable(tableName, param)

	def showGanttDiagram(self):
		self.ganttDiagram.update()
		self.ganttDiagram.open()

	def __init__(self):
		super(MainWindow, self).__init__()

		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)

		self.aboutDialog = AboutDialog(self)
		self.loginDialog = LoginDialog(self)
		self.addAdminDialog = AddAdminDialog(self)
		self.ganttDiagram = GanttDialog(self)
		
		self.ui.actionAbout.triggered.connect(self.aboutDialog.open)
		self.ui.actionLogin.triggered.connect(self.openLoginDialog)
		self.ui.actionLogout.triggered.connect(self.logout)
		self.ui.actionLogout.setDisabled(True)
		self.ui.actionExit_2.triggered.connect(self.close)
		
		self.ui.actionViewCompanies.triggered.connect(self.showTableTrigger('companies'))
		self.ui.actionViewUsers.triggered.connect(self.showTableTrigger('users'))
		self.ui.actionViewEmployees.triggered.connect(self.showTableTrigger('employees'))
		self.ui.actionViewProjects.triggered.connect(self.showTableTrigger('projects'))
		self.ui.actionViewContracts.triggered.connect(self.showTableTrigger('contracts'))
		self.ui.actionViewProjectEmployees.triggered.connect(self.showTableTrigger('projectEmployees'))
		self.ui.actionViewTasks.triggered.connect(self.showTableTrigger('tasks'))
		self.ui.actionViewJobs.triggered.connect(self.showTableTrigger('jobs'))
		self.ui.actionViewTasksDependencies.triggered.connect(self.showTableTrigger('tasksDependencies'))
		self.ui.actionJobs.triggered.connect(self.showTableTrigger('jobs', True))
		self.ui.actionGantt_diagram.triggered.connect(self.showGanttDiagram)
		self.loginDialog.loginSignal.connect(self.login)

		if not len(appInst.getAdmins()):
			self.addAdminDialog.open()

	def openLoginDialog(self):
		self.loginDialog.ui.usernameEdit.setText('')
		self.loginDialog.ui.passwordEdit.setText('')
		self.loginDialog.open()

	def logout(self):
		self.ui.actionLogin.setDisabled(False)
		self.ui.actionLogout.setDisabled(True)
		app.logout()
	
	@QtCore.pyqtSlot(str, str)
	def login(self, username, password):
		try:
			app.login(username, password)
			self.ui.actionLogin.setDisabled(True)
			self.ui.actionLogout.setDisabled(False)
		except NoResultFound:
			raise DBException('Invalid login or password')
		
	def changeState(self, state):
		self.ui.statusLabel.setText(state)

	def showTable(self, tableName, param):
		if tableName == 'companies':
			table = ViewTableCompanies(self)
		elif tableName == 'users':
			table = ViewTableUsers(self)
		elif tableName == 'employees':
			table = ViewTableEmployees(self)
		elif tableName == 'projects':
			table = ViewTableProjects(self)
		elif tableName == 'contracts':
			table = ViewTableContracts(self)
		elif tableName == 'projectEmployees':
			table = ViewTableProjectEmployees(self)
		elif tableName == 'tasks':
			table = ViewTableTasks(self)
		elif tableName == 'jobs':
			table = ViewTableJobs(self, param)
		elif tableName == 'tasksDependencies':
			table = ViewTableTaskDependencies(self)
		else:
			table = ViewTables(self, tableName)
		self.ui.mdiArea.addSubWindow(table)
		table.show()