1 | //! \file ModinspaceWindow.cpp |
---|
2 | //! \brief Implementation of the instructions file's window for visual_YAO. |
---|
3 | //! \version 2010/10/22 (yyyy/mm/dd) |
---|
4 | //! \author MAYAKI Abdouramane. |
---|
5 | |
---|
6 | /* |
---|
7 | Nom du Fichier: ModinspaceWindow.cpp |
---|
8 | Nom de classe: ModinspaceWindow |
---|
9 | Role: |
---|
10 | Nombre de methodes: |
---|
11 | Nombre d'attributs: |
---|
12 | */ |
---|
13 | |
---|
14 | #include "include/ModinspaceWindow.hpp" |
---|
15 | |
---|
16 | using namespace std; |
---|
17 | using namespace yao; |
---|
18 | |
---|
19 | |
---|
20 | //! \class OrderWindow(QWidget *parent) : QWidget(parent) |
---|
21 | //! \brief Implementation of the Order window for visual_YAO. |
---|
22 | |
---|
23 | /*********************************************************************************************************************************/ |
---|
24 | ModinspaceWindow::ModinspaceWindow(Table <Modul> *aModulTable, Table <Space> *aSpaceTable, Table <Operator> *anOperatorTable, Table <Order> *anOrderTable, QWidget *parent) : QWidget(parent), m_theLocalAxesTable(NULL), m_theLocalModulTable(NULL) { |
---|
25 | |
---|
26 | setupUi(this); |
---|
27 | |
---|
28 | m_localModulTable = aModulTable; |
---|
29 | m_localSpaceTable = aSpaceTable; |
---|
30 | m_localOperaTable = anOperatorTable; |
---|
31 | m_localOrderTable = anOrderTable; |
---|
32 | |
---|
33 | m_rightAxesButton->setIcon(QIcon("Images/icons/rightarrow2.png")); |
---|
34 | m_rightModulNameButton->setIcon(QIcon("Images/icons/rightarrow2.png")); |
---|
35 | |
---|
36 | m_spaceOrOperaNameComboBox->insertItem(0, ""); |
---|
37 | m_modulNameComboBox->insertItem(0, ""); |
---|
38 | |
---|
39 | m_axesComboBox->insertItem(0, ""); |
---|
40 | m_axesComboBox->insertItem(1, "YA1"); |
---|
41 | m_axesComboBox->insertItem(2, "YA2"); |
---|
42 | m_axesComboBox->insertItem(3, "YA3"); |
---|
43 | m_axesComboBox->insertItem(4, "YB1"); |
---|
44 | m_axesComboBox->insertItem(5, "YB2"); |
---|
45 | m_axesComboBox->insertItem(6, "YB3"); |
---|
46 | |
---|
47 | //For adding operaname in the combobox |
---|
48 | if (!m_localOperaTable->empty()) |
---|
49 | for (Table<Operator>::reverse_iterator it = m_localOperaTable->rbegin(); it != m_localOperaTable->rend(); it++) { |
---|
50 | |
---|
51 | m_spaceOrOperaNameComboBox->insertItem(1, QString(it->getName().c_str())); |
---|
52 | } |
---|
53 | //For adding space name in the combobox |
---|
54 | if (!m_localSpaceTable->empty()) |
---|
55 | for (Table<Space>::reverse_iterator it = m_localSpaceTable->rbegin(); it != m_localSpaceTable->rend(); it++) { |
---|
56 | |
---|
57 | m_spaceOrOperaNameComboBox->insertItem(1, QString(it->getName().c_str())); |
---|
58 | } |
---|
59 | //For adding modul names in the combobox |
---|
60 | if (!m_localModulTable->empty()) |
---|
61 | for (Table<Modul>::reverse_iterator it = m_localModulTable->rbegin(); it != m_localModulTable->rend(); it++) { |
---|
62 | |
---|
63 | m_modulNameComboBox->insertItem(1, QString(it->getName().c_str())); |
---|
64 | } |
---|
65 | |
---|
66 | m_axesModel = new QStandardItemModel(0, 1) ; |
---|
67 | m_modulNameModel = new QStandardItemModel(0, 0) ; |
---|
68 | m_outlineModel = new QStandardItemModel(0, 4) ; |
---|
69 | m_outlineModel->setHorizontalHeaderLabels(QStringList() << " " << " " << " " << " "); |
---|
70 | |
---|
71 | m_axesListView->setModel(m_axesModel); |
---|
72 | m_modulNameListView->setModel(m_modulNameModel); |
---|
73 | m_outlineTreeView1->setModel(m_outlineModel); |
---|
74 | //m_outlineTreeView1->resizeColumnsToContents(); |
---|
75 | //m_outlineTreeView1->setShowGrid(false); |
---|
76 | //connect(m_axesListView, SIGNAL(clicked(QModelIndex)), this, SLOT(deleteAxesRow(QModelIndex))); |
---|
77 | //connect(m_modulNameListView, SIGNAL(clicked(QModelIndex)), this, SLOT(deleteModulRow(QModelIndex))); |
---|
78 | |
---|
79 | connect(m_modinspaceDeleteButton, SIGNAL(clicked()), this, SLOT(deleteAxesRow())); |
---|
80 | connect(m_modinspaceDeleteButton, SIGNAL(clicked()), this, SLOT(deleteModulRow())); |
---|
81 | |
---|
82 | connect(m_rightAxesButton, SIGNAL(clicked()), this, SLOT(addTheAxesRow())); |
---|
83 | connect(m_rightModulNameButton, SIGNAL(clicked()), this, SLOT(addTheModulRow())); |
---|
84 | //connect(m_modinspaceDeleteButton, SIGNAL(clicked()), this, SLOT(deleteTheRow())); |
---|
85 | connect(m_beginOrEndComboBox, SIGNAL(currentIndexChanged (int )), this, SLOT(addBlockEndRow(int ))); |
---|
86 | //connect(m_blocEndCheckBox, SIGNAL(clicked(bool )), this, SLOT(addBlockEndRow(bool ))); |
---|
87 | //connect(m_endCheckBox, SIGNAL(clicked(bool )), this, SLOT(addEndRow(bool ))); |
---|
88 | |
---|
89 | } |
---|
90 | /******************************** implementation of method ***********************************/ |
---|
91 | void ModinspaceWindow::addBlockEndRow(int anInt) { |
---|
92 | |
---|
93 | int col = m_outlineModel->columnCount(); |
---|
94 | int row0 = m_outlineModel->rowCount(); |
---|
95 | static int ordercounter = 1; |
---|
96 | static int fordercounter = 0; |
---|
97 | |
---|
98 | switch(anInt) { |
---|
99 | case 0: break; |
---|
100 | case 1:{ |
---|
101 | m_outlineModel->setItem(row0, ordercounter + 1, new QStandardItem("order")); |
---|
102 | ordercounter++; |
---|
103 | } break; |
---|
104 | case 2: { |
---|
105 | |
---|
106 | m_outlineModel->setItem(row0, ordercounter, new QStandardItem("forder")); |
---|
107 | fordercounter++; |
---|
108 | }break; |
---|
109 | case 3: { |
---|
110 | m_outlineModel->setItem(row0, 0, new QStandardItem("forder")); |
---|
111 | m_spaceOrOperaNameComboBox->setDisabled(true); |
---|
112 | m_axesComboBox->setDisabled(true); |
---|
113 | } break; |
---|
114 | } |
---|
115 | |
---|
116 | //if (row0 >= 2){ |
---|
117 | |
---|
118 | // m_outlineModel->setItem(1, col, new QStandardItem("forder")); |
---|
119 | //} |
---|
120 | } |
---|
121 | /******************************** implementation of method ***********************************/ |
---|
122 | /*void ModinspaceWindow::addEndRow(bool aBool) { |
---|
123 | |
---|
124 | int row0 = m_outlineModel->rowCount(); |
---|
125 | if (aBool && row0 >= 2) |
---|
126 | m_outlineModel->setItem(row0, 0, new QStandardItem("forder")); |
---|
127 | |
---|
128 | }*/ |
---|
129 | /********************************* Implementation of the selectedFunction(QModelIndex index) method ***********************************/ |
---|
130 | /******************************** implementation of method ***********************************/ |
---|
131 | /*void ModinspaceWindow::callClicked(const QModelIndex &index) { |
---|
132 | |
---|
133 | QStandardItem *item = m_axesModel->itemFromIndex(index); |
---|
134 | |
---|
135 | //cout << "Voici le text: " << item->text().toStdString() << endl; |
---|
136 | |
---|
137 | }*/ |
---|
138 | /********************************* Implementation of the selectedFunction(QModelIndex index) method ***********************************/ |
---|
139 | void ModinspaceWindow::addTheAxesRow() { |
---|
140 | |
---|
141 | static int cpt = 0; |
---|
142 | |
---|
143 | QString theAxe = m_axesComboBox->currentText(); // |
---|
144 | string commonName; |
---|
145 | int row0 = m_outlineModel->rowCount(); |
---|
146 | int row1 = m_outlineModel->rowCount() + 1; |
---|
147 | |
---|
148 | if (theAxe.isEmpty()) return; //If the axes combobox is not empty, the space combobox will be verified. |
---|
149 | |
---|
150 | if (m_spaceOrOperaNameComboBox->currentText().isEmpty()) { |
---|
151 | |
---|
152 | QMessageBox::critical(this, "Avis", "Précisez d'abord l'espace ou l'opérateur avant de faire le choix des axes."); |
---|
153 | return; |
---|
154 | } |
---|
155 | |
---|
156 | QString spaceOrOpera = m_spaceOrOperaNameComboBox->currentText(); |
---|
157 | |
---|
158 | m_axesModel->setItem(m_axesModel->rowCount(), 0, new QStandardItem(theAxe)); |
---|
159 | m_axesComboBox->setCurrentIndex(0); |
---|
160 | |
---|
161 | if (!cpt) { |
---|
162 | |
---|
163 | //Order ord(&m_localModulTable) |
---|
164 | |
---|
165 | m_outlineModel->setItem(row0, 0, new QStandardItem("order")); |
---|
166 | m_outlineModel->setItem(row0, 1, new QStandardItem("modinpace")); |
---|
167 | m_outlineModel->setItem(row0, 2, new QStandardItem(spaceOrOpera)); |
---|
168 | m_outlineModel->setItem(row1, 1, new QStandardItem("order")); |
---|
169 | |
---|
170 | if(m_localSpaceTable->find(commonName)) |
---|
171 | m_localSpaceTable->find(commonName)->setCounterOrderHeader(true); |
---|
172 | else |
---|
173 | m_localOperaTable->find(commonName)->setCounterOrderHeader(true); |
---|
174 | |
---|
175 | cpt++; |
---|
176 | |
---|
177 | } //m_theLocalModulTable->push_back(); |
---|
178 | |
---|
179 | static int col = m_outlineModel->columnCount(); |
---|
180 | m_outlineModel->setItem(1, col-2, new QStandardItem(theAxe)); |
---|
181 | col++; |
---|
182 | //m_theLocalAxesTable->push_back(theAxe.toStdString()); |
---|
183 | //m_outlineModel->setItem(row1, 1, new QStandardItem("order")); |
---|
184 | |
---|
185 | //for (vector <string>::iterator it = m_theLocalAxesTable->begin(); it != m_theLocalAxesTable->end(); it++) |
---|
186 | //m_outlineModel->setItem(row1, m_outlineModel->columnCount(), new QStandardItem(QString(it->c_str()))); |
---|
187 | //m_outlineModel->setItem(row1, m_outlineModel->columnCount(), new QStandardItem(QString(theAxe))); |
---|
188 | //m_outlineModel->setItem(row1, 2, new QStandardItem("order")); |
---|
189 | |
---|
190 | |
---|
191 | //if (m_blocEndCheckBox->isChecked()) |
---|
192 | // ; |
---|
193 | } |
---|
194 | |
---|
195 | /********************************* Implementation of the addInstructionRow() method *************************************************/ |
---|
196 | void ModinspaceWindow::addTheModulRow() { |
---|
197 | |
---|
198 | QString theModul = m_modulNameComboBox->currentText(); |
---|
199 | |
---|
200 | int row0 = m_outlineModel->rowCount(); |
---|
201 | |
---|
202 | if (theModul.isEmpty()) return; |
---|
203 | |
---|
204 | m_modulNameModel->setItem(m_modulNameModel->rowCount(), 0, new QStandardItem(theModul)); |
---|
205 | m_outlineModel->setItem(row0, 2, new QStandardItem(theModul)); |
---|
206 | |
---|
207 | m_spaceOrOperaNameComboBox->setDisabled(true); |
---|
208 | m_axesComboBox->setDisabled(true); |
---|
209 | |
---|
210 | m_modulNameComboBox->setCurrentIndex(0); |
---|
211 | |
---|
212 | } |
---|
213 | |
---|
214 | /******************************* Implementation of the deleteModulRow(const QModelIndex &index) method ****************************************/ |
---|
215 | void ModinspaceWindow::deleteAxesRow() { |
---|
216 | |
---|
217 | //QStandardItem *item = m_axesModel->itemFromIndex(index); |
---|
218 | |
---|
219 | QItemSelectionModel *selectionFromAxes = m_axesListView->selectionModel(); |
---|
220 | //QItemSelectionModel *selectionFromModul = m_modulNameListView->selectionModel(); |
---|
221 | |
---|
222 | indexForAxes = selectionFromAxes->currentIndex(); |
---|
223 | //indexForModul = selectionFromModul->currentIndex(); |
---|
224 | |
---|
225 | QVariant axesElement = m_axesModel->data(indexForAxes, Qt::DisplayRole); |
---|
226 | //QVariant modulElement = m_modulNameModel->data(indexForModul, Qt::DisplayRole); |
---|
227 | |
---|
228 | if(axesElement.toString().isEmpty()) |
---|
229 | return; |
---|
230 | |
---|
231 | //if(!axesElement.toString().isEmpty()) |
---|
232 | m_axesModel->removeRows(m_axesListView->currentIndex().row(), 1);// Le 2Úme parametre indique le nombre de ligne à supprimer |
---|
233 | //else |
---|
234 | // if(!modulElement.toString().isEmpty()) |
---|
235 | // m_modulNameModel->removeRows(m_modulNameListView->currentIndex().row(), 1);// Le 2Úme parametre indique le nombre de ligne à supprimer |
---|
236 | |
---|
237 | |
---|
238 | } |
---|
239 | |
---|
240 | /******************************* Implementation of the deleteModulRow(const QModelIndex &index) method ****************************************/ |
---|
241 | void ModinspaceWindow::deleteModulRow() { |
---|
242 | |
---|
243 | |
---|
244 | //QStandardItem *item = m_modulNameModel->itemFromIndex(index); |
---|
245 | |
---|
246 | //QItemSelectionModel *selectionFromAxes = m_axesListView->selectionModel(); |
---|
247 | QItemSelectionModel *selectionFromModul = m_modulNameListView->selectionModel(); |
---|
248 | |
---|
249 | //indexForAxes = selectionFromAxes->currentIndex(); |
---|
250 | indexForModul = selectionFromModul->currentIndex(); |
---|
251 | |
---|
252 | //QVariant axesElement = m_axesModel->data(indexForAxes, Qt::DisplayRole); |
---|
253 | QVariant modulElement = m_modulNameModel->data(indexForModul, Qt::DisplayRole); |
---|
254 | |
---|
255 | if(modulElement.toString().isEmpty()) |
---|
256 | return; |
---|
257 | |
---|
258 | //if(!axesElement.toString().isEmpty()) |
---|
259 | // m_axesModel->removeRows(m_axesListView->currentIndex().row(), 1);// Le 2Úme parametre indique le nombre de ligne à supprimer |
---|
260 | //else |
---|
261 | // if(!modulElement.toString().isEmpty()) |
---|
262 | m_modulNameModel->removeRows(m_modulNameListView->currentIndex().row(), 1);// Le 2Úme parametre indique le nombre de ligne à supprimer |
---|
263 | |
---|
264 | |
---|
265 | } |
---|
266 | /***********************************************************************************************************************/ |
---|
267 | /***************************************************** End of file *****************************************************/ |
---|
268 | /***********************************************************************************************************************/ |
---|