コード例 #1
0
	def __init__(self, parent):
		QtGui.QWizardPage.__init__(self, parent)
		self.dominateParent = parent
		self.setTitle('Welcome')
		self.setSubTitle('Select where you would like to upload this file to')
		
		self.configManager = DomConfigurator()
		layout = QtGui.QGridLayout(self)
		
		# Combo box
		configLabel = QtGui.QLabel('Choose Configuration')
		self.configBox   = QtGui.QComboBox(self)
		self.populate()
		
		self.connect(self.configBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.changeConfig)
		
		layout.addWidget(configLabel, 0, 0)
		layout.addWidget(self.configBox, 0, 1)
		
		# List
		self.listWidget  = QtGui.QListWidget(self)
		self.listWidget.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
		layout.addWidget(self.listWidget, 1, 0, 1, 3)
		
		self.connect(self.listWidget, QtCore.SIGNAL('itemSelectionChanged()'), lambda: self.emit(QtCore.SIGNAL('completeChanged()')))
		
		# Register fields for access from other pages with the field() method
		self.registerField("config", self.configBox, 'currentText')
		self.registerField("sites", self.listWidget, 'selectedItems', QtCore.SIGNAL('itemSelectionChanged()'))
		
		# Make us awesome sauce
		self.setLayout(layout)
		
		# And now fill in the suace's secret ingredients
		if len(self.configManager._list) > 0: self.changeConfig(self.configBox.currentText())
コード例 #2
0
	def run(self):
		# Get our configurations
		configManager = DomConfigurator()
		configObject  = configManager.getConfig(str(self.config))
		
		for destination in configObject:
			if str(destination['name']) in self.sites:
				destination['destination'] = str(destination['destination'].rstrip('/') + '/' + self.additional)
				flag, message = publish(destination, self.source)
				#print 'Flag: %s, Message: %s' % (flag, message)
				self.emit(QtCore.SIGNAL('updateProgress()'))
			#else:
				#print 'Skipping ' + destination['name']
		
		self.parent.finished = True
		self.parent.emit(QtCore.SIGNAL('completeChanged()'))
コード例 #3
0
class FirstPage(QtGui.QWizardPage):
	configBox = None
	domainateParent = None
	def __init__(self, parent):
		QtGui.QWizardPage.__init__(self, parent)
		self.dominateParent = parent
		self.setTitle('Welcome')
		self.setSubTitle('Select where you would like to upload this file to')
		
		self.configManager = DomConfigurator()
		layout = QtGui.QGridLayout(self)
		
		# Combo box
		configLabel = QtGui.QLabel('Choose Configuration')
		self.configBox   = QtGui.QComboBox(self)
		self.populate()
		
		self.connect(self.configBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.changeConfig)
		
		layout.addWidget(configLabel, 0, 0)
		layout.addWidget(self.configBox, 0, 1)
		
		# List
		self.listWidget  = QtGui.QListWidget(self)
		self.listWidget.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
		layout.addWidget(self.listWidget, 1, 0, 1, 3)
		
		self.connect(self.listWidget, QtCore.SIGNAL('itemSelectionChanged()'), lambda: self.emit(QtCore.SIGNAL('completeChanged()')))
		
		# Register fields for access from other pages with the field() method
		self.registerField("config", self.configBox, 'currentText')
		self.registerField("sites", self.listWidget, 'selectedItems', QtCore.SIGNAL('itemSelectionChanged()'))
		
		# Make us awesome sauce
		self.setLayout(layout)
		
		# And now fill in the suace's secret ingredients
		if len(self.configManager._list) > 0: self.changeConfig(self.configBox.currentText())
	
	def populate(self):
		'''Populates the list of configurations'''
		for config in self.configManager._list:
			self.configBox.addItem(config)
	
	def changeConfig(self, conf):
		'''Listens for a change in the configuration combo box and will
		populate the list of sites to upload to'''
		
		# First we try to get the crap from the file
		try:
			config = self.configManager.getConfig(str(conf))
		except Exception:
			QtGui.QMessageBox.critical(self, 'Error', 'Error reading the config.  Check file permissions or formatting')
			return None
		
		# Now we clear the current ones
		self.listWidget.clear()
		
		# Now we populate the ones from this thingy
		for site in config:
			MyListItem(site, self.listWidget)
		
		# Sort thingies!
		self.listWidget.sortItems()
	
	def validatePage(self):
		'''Override the base class's method.  Since the field() arguments isn't working, from what I can tell,
		I will do things this way rather than wrestle with that for an indeterminate amount of further time.'''
		# Since the QVariant bullshit in PyQt4 doesn't work the way the C++ examples do, I'm going to
		# say "f**k it" and just do things my way
		self.dominateParent.domConfig = self.configBox
		self.dominateParent.domSites  = self.listWidget
		
		return True
	
	def isComplete(self):
		if len(self.listWidget.selectedItems()) > 0: return True
		else: return False