Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYDirectivityWidget.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) 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.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
25 
26 #include <qmenu.h>
27 #include <qtablewidget.h>
28 
29 // Added by qt3to4:
30 #include <QGridLayout>
31 #include <QHeaderView>
32 #include <QtWidgets>
33 
34 #include "TYDirectivityWidget.h"
35 #include "TYElementWidget.h"
36 
37 #define TR(id) OLocalizator::getString("TYDirectivityWidget", (id))
38 
39 TYDirectivityWidget::TYDirectivityWidget(TYDirectivity* pElement, QWidget* _pParent /*=NULL*/)
40  : TYWidget(pElement, _pParent)
41 {
42  resize(300, 240);
43  setWindowTitle(TR("id_caption"));
44 
45  _elmW = new TYElementWidget(pElement, this);
46  _table = new QTableWidget();
47  _table->setColumnCount(3);
48  _table->setContextMenuPolicy(Qt::CustomContextMenu);
49  _table->setHorizontalHeaderItem(0, new QTableWidgetItem(TR("id_theta")));
50  _table->setHorizontalHeaderItem(1, new QTableWidgetItem(TR("id_phi")));
51  _table->setHorizontalHeaderItem(2, new QTableWidgetItem(TR("id_value")));
52 
53  QGridLayout* groupBoxLayout = new QGridLayout();
54  groupBoxLayout->addWidget(_table, 1, 0);
55 
56  QGroupBox* groupBox = new QGroupBox();
57  groupBox->setTitle(TR("id_tabangleval_box"));
58  groupBox->setLayout(groupBoxLayout);
59 
60  _directiviteLayout = new QGridLayout();
61  _directiviteLayout->addWidget(_elmW, 0, 0);
62  _directiviteLayout->addWidget(groupBox, 1, 0);
63  setLayout(_directiviteLayout);
64 
65  updateContent();
66 
67  connect(_table, &QTableWidget::customContextMenuRequested, this, &TYDirectivityWidget::showContextMenu);
68  connect(_table, &QTableWidget::itemChanged, this, &TYDirectivityWidget::apply);
69 }
70 
72 
74 {
76 
77  for (int i = 0; i < _table->rowCount(); i++)
78  {
79  _table->takeItem(i, 0);
80  _table->takeItem(i, 1);
81  }
82  _table->setRowCount(0);
83 }
84 
86 {
87  _elmW->apply();
88  emit modified();
89 }
90 
91 void TYDirectivityWidget::showContextMenu(const QPoint& pos)
92 {
93  QTableWidgetItem* item = _table->itemAt(pos);
94  if (item)
95  {
96  int row = _table->row(item);
97  QMenu* pMenu = new QMenu(this);
98  pMenu->addAction(TR("id_add"));
99 
100  if (row >= 0)
101  {
102  pMenu->addSeparator();
103  pMenu->addAction(TR("id_del"));
104  }
105 
106  pMenu->exec(pos);
107  }
108 }
#define TR(id)
outil IHM pourla directivite (fichier header)
outil IHM pour un element (fichier header)
void showContextMenu(const QPoint &pos)
TYElementWidget * _elmW
QGridLayout * _directiviteLayout
TYDirectivityWidget(TYDirectivity *pElement, QWidget *_pParent=NULL)
virtual void updateContent()
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()