Salome HOME
Update copyrights
[modules/smesh.git] / src / Tools / Verima / Gui / monEditor.py
1 # Copyright (C) 2013-2019  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from qtsalome import *
21
22 class TableEditor(QDialog):
23
24      def __init__(self, table,parent):
25          QDialog.__init__(self)
26          self.setModal(False)
27          self.model= QSqlTableModel()
28          self.table=table
29          self.model.setTable(table.nom);
30          self.model.setEditStrategy(QSqlTableModel.OnManualSubmit)
31          self.model.select()
32          self.view = QTableView(self)
33          self.view.setModel(self.model)
34          
35
36          quitButton=QPushButton("Quit")
37          buttonBox=QDialogButtonBox(Qt.Vertical)
38          buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole);
39          quitButton.clicked.connect(self.close)
40
41          mainLayout = QHBoxLayout(self)
42          mainLayout.addWidget(self.view)
43          mainLayout.addWidget(buttonBox)
44          self.setLayout(mainLayout)
45
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()
51          self.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)
57
58      def donneLigne(self):
59          print("jjjjjjjjjjjjjjjj")
60
61      def setTitle(self):
62          fields=self.table.getFields()
63          index=0
64          for f in fields:
65            self.model.setHeaderData(index,Qt.Horizontal,fields)
66            index=index+1
67
68
69
70
71 #void TableEditor::submit()
72 #{
73 #     model->database().transaction();
74 #     if (model->submitAll()) {
75 #         model->database().commit();
76 #     } else {
77 #         model->database().rollback();
78 #         QMessageBox::warning(this, tr("Cached Table"),
79 #                              tr("The database reported an error: %1")
80 #                              .arg(model->lastError().text()));
81 #     }
82 #}
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"));