Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPluginDialog.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
21 #include <qlayout.h>
22 #include <qpushbutton.h>
23 // Added by qt3to4:
24 #include <QGridLayout>
25 #include <QBoxLayout>
26 #include <QHBoxLayout>
27 #include <QTreeWidget>
28 #include <QTreeWidgetItem>
29 #include <QHeaderView>
30 
36 #include "TYPluginDialog.h"
37 
38 #define TR(id) OLocalizator::getString("TYPluginDialog", (id))
39 
40 TYPluginDialog::TYPluginDialog(QWidget* parent, const char* name, Qt::WindowFlags f)
41  : QDialog(parent, f), current_solver(QString(DEFAULT_SOLVER_UUID))
42 {
43  setObjectName(name);
44  setWindowTitle(TR("id_caption"));
45 
46  // Layout
47  QGridLayout* pLayout = new QGridLayout();
48  setLayout(pLayout);
49 
50  // Plug-in list
51  _pPluginListView = new QTreeWidget(this);
52  _pPluginListView->setColumnCount(6);
53  QStringList stringList;
54  stringList.append(TR("id_name"));
55  stringList.append(TR("id_author"));
56  stringList.append(TR("id_version"));
57  stringList.append(TR("id_description"));
58  stringList.append(TR("id_uuid"));
59  stringList.append(TR("id_filename"));
60  _pPluginListView->setHeaderLabels(stringList);
61  _pPluginListView->setRootIsDecorated(true);
62  _pPluginListView->setSelectionMode(QAbstractItemView::SingleSelection);
63  //_pPluginListView->setAllColumnsShowFocus(true);
64  pLayout->addWidget(_pPluginListView, 0, 0);
65 
66  if (getTYMainWnd()->getProjetFrame()->getProjet() &&
67  getTYMainWnd()->getProjetFrame()->getProjet()->getCurrentCalcul())
68  {
70  }
71 
72  TYPluginManager::TYPluginList& plugins = TYPluginManager::get()->getPluginList();
73  TYPluginManager::TYPluginList::iterator it = plugins.begin();
74  for (; it != plugins.end(); ++it)
75  {
76  QStringList labels;
77  labels.append((*it)->getPlugin()->getName());
78  labels.append((*it)->getPlugin()->getAuthor());
79  labels.append((*it)->getPlugin()->getVersion());
80  labels.append((*it)->getPlugin()->getDescription());
81  labels.append((*it)->getPlugin()->getUUID().toString());
82  labels.append((*it)->filename);
83  QTreeWidgetItem* item = new QTreeWidgetItem(_pPluginListView, labels);
84  if ((*it)->getPlugin()->getUUID() == current_solver)
85  {
86  _pPluginListView->setCurrentItem(item);
87  item->setSelected(true);
88  }
89  }
90 
91  // Push buttons
92  QBoxLayout* pBtnLayout = new QHBoxLayout();
93  pLayout->addLayout(pBtnLayout, 1, 0);
94  pBtnLayout->addStretch(1);
95 
96  _pOkBtn = new QPushButton(TR("id_ok_btn"), this);
97  _pOkBtn->setEnabled(false);
98  QObject::connect(_pOkBtn, &QPushButton::clicked, this, &TYPluginDialog::updateCurrentPlugin);
99  pBtnLayout->addWidget(_pOkBtn);
100 
101  QPushButton* pCloseBtn = new QPushButton(TR("id_cancel_btn"), this);
102  pCloseBtn->setShortcut(Qt::Key_Escape);
103  QObject::connect(pCloseBtn, &QPushButton::clicked, this, &TYPluginDialog::reject);
104  pBtnLayout->addWidget(pCloseBtn);
105 
106  QObject::connect(_pPluginListView, &QTreeWidget::itemSelectionChanged, this,
108  setEnableButton();
109 }
110 
112 {
113  QObject::disconnect(_pPluginListView, &QTreeWidget::itemSelectionChanged, this,
115  QObject::disconnect(_pOkBtn, &QPushButton::clicked, this, &TYPluginDialog::updateCurrentPlugin);
116 }
117 
119 {
120  current_solver = OGenID(_pPluginListView->selectedItems()[0]->text(4));
121  accept();
122 }
123 
125 {
126  if (!_pPluginListView->selectedItems()[0])
127  {
128  _pOkBtn->setEnabled(false);
129  }
130  else
131  {
132  _pOkBtn->setEnabled(true);
133  }
134 }
TYMainWindow * getTYMainWnd()
Retourne le pointeur sur la fenetre principale.
pour l'application Tympan (fichier header)
Fenetre principale de l'application Tympan (fichier header)
#define TR(id)
Boite de dialogue pour la selection du plugin de calcul (fichier header)
#define DEFAULT_SOLVER_UUID
Frame pour la gestion de projet (fichier header)
const char * name
Definition: idgen.h:28
const OGenID getSolverId() const
Get solver ID.
Definition: TYCalcul.h:465
TYProjetFrame * getProjetFrame()
Definition: TYMainWindow.h:76
TYPluginDialog(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=QFlag(0))
void updateCurrentPlugin()
Mets a jour le SolverInterface courant.
QPushButton * _pOkBtn
void setEnableButton()
Active ou non le bouton _pOkBtn.
QTreeWidget * _pPluginListView
virtual ~TYPluginDialog()
OGenID current_solver
std::list< TYPluginData * > TYPluginList
static LPTYPluginManager get()
LPTYProjet getProjet()
Definition: TYProjetFrame.h:58
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.h:426