Example #1
0
	def DeleteButtonClicked(self):
		#---- Delete Entries in file tasks ----
		global taskList		
		currentTaskLine = str(self.ui.TaskListWidget.currentItem().text())		
		if not currentTaskLine == "":
			self.ui.TaskListWidget.clear()
			#self.count = 0
			CTL = currentTaskLine.split(",")
			f = open('tasks_test.txt')
			output = []
			for line in f:
				line = line.rstrip("\n")			
				x = line.split(",")
   				if not CTL[1] == x[1]:
					#print(line+","+str(predTaskId))						
     		   			output.append(x[0]+","+x[1]+","+x[2]+"\n")					
			f.close()			
			f = open('tasks_test.txt', 'w')
			f.writelines(output)
			f.close()
			for line in output:
				line = line.rstrip("\n")				
				x = line.split(",")
				self.ui.TaskListWidget.addItem(x[0]+","+x[1]+","+x[2])
		#---- Create New task list ----
			taskList = []
			f = open('tasks_test.txt')
			for line in f:
				line = line.rstrip("\n")
				x = line.split(",")
				task = Task(int(x[0]),x[1])
				task.duration = int(x[2])
				preds = self.getPredecessorsFromFile(task.id)
				task.predecessors = preds			
				taskList.append(task)
						
				#self.ui.TaskListWidget.addItem(line)					
			f.close()
		#---- Delete Entries in file dependencies---

			self.ui.DependencyListWidget.clear()
			#CTL
			f = open('dependencies_test.txt')
			output1 = []
			for line in f:
				line = line.rstrip("\n")			
				x = line.split(",")
   				if not int(CTL[0]) == int(x[0]):
					#print(line+","+str(predTaskId)
					str1 = ""	
					for i in range(0,len(x)):
						if not int(x[i]) == int(CTL[0]): 
     		   					str1=str1+str(x[i])+","
					str1= str1.rstrip(",")
					output1.append(str1+"\n")					
			f.close()
			f = open('dependencies_test.txt', 'w')
			f.writelines(output1)
			f.close()
			self.populateDependencyList()
Example #2
0
	def LoadFilesButtonClicked(self):
		global taskList		
		Dialog2 = loadFDialog()
		Dialog2.show()
    		ret = Dialog2.exec_()

		self.ui.TaskListWidget.clear()
		taskList = []
		f = open('tasks_test.txt')
		for line in f:
			line = line.rstrip("\n")
			x = line.split(",")
			task = Task(int(x[0]),x[1])
			task.duration = int(x[2])
			preds = self.getPredecessorsFromFile(task.id)
			task.predecessors = preds			
			taskList.append(task)
						
			self.ui.TaskListWidget.addItem(line)					
		f.close()
		self.populateDependencyList()
		for task in taskList:
			print(str(task.id)+" "+task.name)
			print(task.predecessors)		
		self.ui.ResourceListWidget.clear()
		f = open('resources_test.txt')
		temp = None		
		for line in f:
			line = line.rstrip("\n")			
			temp = line			
			self.ui.ResourceListWidget.addItem(line)					
		f.close()
		if(not temp == None):	
			temp = temp.split(",")
			self.resCount = int(temp[0])
		else:
			self.resCount = 0