Пример #1
0
	def editEventType(self, newType):

		oldEvent = self.propertyTable.ventureObject
		newEvent = None

		for t in events.itersubclasses(events.Event):
			if t.__name__ == newType:
				newEvent = t()
		
		if newEvent is None:
			return
		
		# replace old class with new class
		newEvent.parentAction = oldEvent.parentAction
		index = oldEvent.parentAction.events.index(oldEvent)
		oldEvent.parentAction.events[index] = newEvent
		
		self.propertyTable.ventureObject = newEvent
		self.hierarchyTree.selectedItems()[0].ventureObject = newEvent
		self.hierarchyTree.selectedItems()[0].setText(0, newEvent.type)
		
		self.updatePropertyTable()
Пример #2
0
	def updatePropertyTable(self):

		self.propertyTable.setHorizontalHeaderLabels( ['Property', 'Value'] )
		if len( self.hierarchyTree.selectedItems() ) == 0:
			self.propertyTable.setRowCount(0)
			return
		
		treeItem = self.hierarchyTree.selectedItems()[0]
		self.propertyTable.ventureObject = treeItem.ventureObject
		self.propertyTable.removeCellWidget(0,1)

		if treeItem.text(1) == 'Area':

			self.propertyTable.setRowCount(3)

			self.propertyTable.setItem( 0,0, QtGui.QTableWidgetItem('id') )
			self.propertyTable.setItem( 0,1, QtGui.QTableWidgetItem( treeItem.ventureObject.id ) )
			self.propertyTable.item(0,1).setFlags(Qt.NoItemFlags | Qt.ItemIsEnabled)

			self.propertyTable.setItem( 1,0, QtGui.QTableWidgetItem('name') )
			self.propertyTable.setItem( 1,1, QtGui.QTableWidgetItem( treeItem.ventureObject.name ) )

			self.propertyTable.setItem( 2,0, QtGui.QTableWidgetItem('entranceText') )
			self.propertyTable.setItem( 2,1, QtGui.QTableWidgetItem( treeItem.ventureObject.entranceText ) )

		elif treeItem.text(1) == 'Feature':
			
			self.propertyTable.setRowCount(2)

			self.propertyTable.setItem( 0,0, QtGui.QTableWidgetItem('name') )
			self.propertyTable.setItem( 0,1, QtGui.QTableWidgetItem( treeItem.ventureObject.name ) )

			self.propertyTable.setItem( 1,0, QtGui.QTableWidgetItem('description') )
			self.propertyTable.setItem( 1,1, QtGui.QTableWidgetItem( treeItem.ventureObject.description ) )

		elif treeItem.text(1) == 'Action':

			self.propertyTable.setRowCount(1)

			self.propertyTable.setItem( 0,0, QtGui.QTableWidgetItem('description') )
			self.propertyTable.setItem( 0,1, QtGui.QTableWidgetItem( treeItem.ventureObject.description ) )

		else:

			self.propertyTable.setRowCount( len(treeItem.ventureObject.properties)+1 )

			comboEvents = QtGui.QComboBox()
			for t in events.itersubclasses( events.Event ):
				comboEvents.addItem( t.__name__ )
			index = comboEvents.findText( type(treeItem.ventureObject).__name__ )
			comboEvents.setCurrentIndex( index )
			comboEvents.currentIndexChanged[str].connect( self.editEventType )

			self.propertyTable.setItem( 0,0, QtGui.QTableWidgetItem('type') )
			self.propertyTable.setCellWidget( 0,1, comboEvents )

			i = 1
			for name, value in treeItem.ventureObject.properties.items():
				self.propertyTable.setItem( i,0, QtGui.QTableWidgetItem(name) )
				self.propertyTable.setItem( i,1, QtGui.QTableWidgetItem(value) )
				i += 1


		# set all cells in col 0 read-only
		for index in range(0, self.propertyTable.rowCount()):
			item = self.propertyTable.item(index, 0).setFlags(Qt.NoItemFlags | Qt.ItemIsEnabled)