1 # Copyright (C) 2013-2021 EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from qtsalome import *
22 class TableEditor(QDialog):
24 def __init__(self, table,parent):
25 QDialog.__init__(self)
27 self.model= QSqlTableModel()
29 self.model.setTable(table.nom);
30 self.model.setEditStrategy(QSqlTableModel.OnManualSubmit)
32 self.view = QTableView(self)
33 self.view.setModel(self.model)
36 quitButton=QPushButton("Quit")
37 buttonBox=QDialogButtonBox(Qt.Vertical)
38 buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole);
39 quitButton.clicked.connect(self.close)
41 mainLayout = QHBoxLayout(self)
42 mainLayout.addWidget(self.view)
43 mainLayout.addWidget(buttonBox)
44 self.setLayout(mainLayout)
46 self.setWindowTitle("Table des " + table.nom)
47 self.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
48 self.view.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
49 self.view.resizeColumnsToContents()
50 self.view.adjustSize()
52 self.view.pressed[QModelIndex].connect(self.donneLigne)
53 self.view.itemPressed[QTableWidgetItem].connect(self.donneLigne)
54 self.view.clicked[QModelIndex].connect(self.donneLigne)
55 self.view.clicked.connect(self.donneLigne)
56 self.view.pressed.connect(self.donneLigne)
59 print("jjjjjjjjjjjjjjjj")
62 fields=self.table.getFields()
65 self.model.setHeaderData(index,Qt.Horizontal,fields)
71 #void TableEditor::submit()
73 # model->database().transaction();
74 # if (model->submitAll()) {
75 # model->database().commit();
77 # model->database().rollback();
78 # QMessageBox::warning(this, tr("Cached Table"),
79 # tr("The database reported an error: %1")
80 # .arg(model->lastError().text()));
83 # submitButton = new QPushButton(tr("Submit"));
84 # submitButton->setDefault(true);
85 # revertButton = new QPushButton(tr("&Revert"));
86 # buttonBox->addButton(submitButton, QDialogButtonBox::ActionRole);
87 # buttonBox->addButton(revertButton, QDialogButtonBox::ActionRole);
88 # connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
89 # connect(revertButton, SIGNAL(clicked()), model, SLOT(revertAll()));
90 # quitButton = new QPushButton(tr("Quit"));