class ChooseAction (QWidget):
def __init__(self, parent=None, db=None):
+ """Sets up the list of buttons and associated actions"""
QWidget.__init__(self,parent)
self.db = db
- self.l1 = QLabel("<h1>Select a task:<h1>")
+ self.l1 = QLabel("<h1>Hall Directory</h1><h1>Select a task:</h1>")
self.l1.setAlignment(QtCore.Qt.AlignCenter)
self.pb1 = QCommandLinkButton("&Add a person to the directory","If you haven't seen this program before, hit this button.")
self.pb2 = QCommandLinkButton("&Edit a directory record","If you've already added your data, but want to edit it, hit this button.")
self.pb3 = QCommandLinkButton("&Import photos","To match picture from a camera to entered data, hit this button.")
self.pb4 = QCommandLinkButton("E&xport as document","To export the directory as a document for printing, hit this button.")
+ self.pb5 = QCommandLinkButton("&Perform Analytics","To analyze the data you have (and are lacking), hit this button.")
self.layout = QGridLayout()
self.layout.addWidget(self.l1,0,0,1,3)
self.layout.addWidget(self.pb1,1,1,1,1)
self.layout.addWidget(self.pb2,2,1,1,1)
self.layout.addWidget(self.pb3,3,1,1,1)
self.layout.addWidget(self.pb4,4,1,1,1)
+ self.layout.addWidget(self.pb5,5,1,1,1)
QtCore.QObject.connect(self.pb1, QtCore.SIGNAL("clicked()"), self.addPerson)
QtCore.QObject.connect(self.pb2, QtCore.SIGNAL("clicked()"), self.editPerson)
QtCore.QObject.connect(self.pb3, QtCore.SIGNAL("clicked()"), self.importPhotos)
QtCore.QObject.connect(self.pb4, QtCore.SIGNAL("clicked()"), self.exportDocument)
+ QtCore.QObject.connect(self.pb5, QtCore.SIGNAL("clicked()"), self.runAnalytics)
self.setLayout(self.layout)
def addPerson(self):
+ """Slot triggered to add a person. Runs the NewPersonWizard."""
wiz = NewPersonWizard(self,self.db)
wiz.exec_()
wiz = None
def editPerson(self):
+ """Emits the signal editPerson(), so parent can swap to the EditPerson widget"""
self.emit(QtCore.SIGNAL("editPerson()"))
def importPhotos(self):
+ """Emits the signal mergePhotos(), so parent can swap to the MergePhotos widget"""
self.emit(QtCore.SIGNAL("mergePhotos()"))
def exportDocument(self):
+ """Gets a filename to export the current database to, then emits the exportDocument(QString) signal so parent can pass it to the document exporter"""
fileName = QFileDialog.getSaveFileName(self, "Save new file as:", ".", "OpenDocument Text Documents (*.odt)")
if not fileName.isEmpty():
if not fileName.endsWith(".odt"): # if they leave off the extension, add it
fileName = fileName.append(".odt")
self.emit(QtCore.SIGNAL("exportDocument(QString)"),fileName)
+ def runAnalytics(self):
+ """Emits the signal runAnalytics(), so parent can swap to Analytics widget"""
+ self.emit(QtCore.SIGNAL("runAnalytics()"))
+