예제 #1
0
 def new_dialog(self):
     '''
     Display a dialog for adding a new row.
     Values from a newly-created row are put into the "data" variable.
     Perhaps this is a hack, but it seems to work okay.
     '''
     
     dialog = InputDialog(NEW_DIALOG, self.fields, self.backend, parent=self)
     data = [] # Pass a created row back through this variable
     dialog.set_data(data)
     ret = dialog.exec_()
     if ret == QtGui.QDialog.Accepted:
         items = self.items_to_model(data)
         self.table_model.appendRow(items)
예제 #2
0
 def edit_dialog(self):
     '''A dialog for editing an existing row.'''
     
     # Check that a row is highlighted
     row_num = self.current_row_num()
     if row_num == None:
         return
     
     # Get a highlighted row's values as a list of strings.
     col_count = self.table_model.columnCount()
     row = [self.table_model.item(row_num, i) for i in range(col_count)]
     data = map(lambda x: x.data(role=QtCore.Qt.DisplayRole).toString(), row)
     
     # Create and display an edit dialog.
     dialog = InputDialog(EDIT_DIALOG, self.fields, self.backend, parent=self)
     dialog.set_data(data)
     ret = dialog.exec_()
     if ret == QtGui.QDialog.Accepted:
         self.recycle_row(row_num)