1 | /* |
---|
2 | Copyright (C) 2012 |
---|
3 | Alejandro Mujica (amujica@cenditel.gob.ve) |
---|
4 | Erwin Paredes (eparedes@cenditel.gob.ve) |
---|
5 | José Ruiz (jruiz@cenditel.gob.ve) |
---|
6 | Rodolfo Rangel (rrangel@cenditel.gob.ve) |
---|
7 | Julie Vera (jvera@cenditel.gob.ve) |
---|
8 | |
---|
9 | CENDITEL Fundación Centro Nacional de Desarrollo e Investigación en |
---|
10 | Tecnologías Libres |
---|
11 | |
---|
12 | Este programa es software libre; Usted puede usarlo bajo los términos de la |
---|
13 | licencia de software GPL versión 2.0 de la Free Software Foundation. |
---|
14 | |
---|
15 | Este programa se distribuye con la esperanza de que sea útil, pero SIN |
---|
16 | NINGUNA GARANTÍA; tampoco las implícitas garantías de MERCANTILIDAD o |
---|
17 | ADECUACIÓN A UN PROPÓSITO PARTICULAR. |
---|
18 | Consulte la licencia GPL para más detalles. Usted debe recibir una copia |
---|
19 | de la GPL junto con este programa; si no, escriba a la Free Software |
---|
20 | Foundation Inc. 51 Franklin Street,5 Piso, Boston, MA 02110-1301, USA. |
---|
21 | */ |
---|
22 | |
---|
23 | /* |
---|
24 | Este archivo contiene la implementación de la clase NodeInfoForm. |
---|
25 | |
---|
26 | Autor: Alejandro J. Mujica |
---|
27 | Fecha: |
---|
28 | */ |
---|
29 | |
---|
30 | # include <QCloseEvent> |
---|
31 | |
---|
32 | # include <nodeInfoDock.H> |
---|
33 | # include <guiCommon.H> |
---|
34 | |
---|
35 | NodeInfoDock::NodeInfoDock(QWidget * _parent) |
---|
36 | : QDockWidget(_parent) { |
---|
37 | |
---|
38 | tree.setColumnCount(2); |
---|
39 | |
---|
40 | QStringList headers; |
---|
41 | |
---|
42 | headers.append("Propiedad"); |
---|
43 | headers.append("Valor"); |
---|
44 | tree.setHeaderLabels(headers); |
---|
45 | |
---|
46 | QTreeWidgetItem * parent = NULL; |
---|
47 | |
---|
48 | QTreeWidgetItem * child = NULL; |
---|
49 | |
---|
50 | parent = new QTreeWidgetItem; |
---|
51 | parent->setText(0, "Empresa"); |
---|
52 | |
---|
53 | child = new QTreeWidgetItem; |
---|
54 | child->setText(0, "R.I.F."); |
---|
55 | parent->addChild(child); |
---|
56 | |
---|
57 | child = new QTreeWidgetItem; |
---|
58 | child->setText(0, "Razón Social"); |
---|
59 | parent->addChild(child); |
---|
60 | |
---|
61 | child = new QTreeWidgetItem; |
---|
62 | child->setText(0, "Planta"); |
---|
63 | parent->addChild(child); |
---|
64 | |
---|
65 | tree.addTopLevelItem(parent); |
---|
66 | parent->setExpanded(true); |
---|
67 | |
---|
68 | parent = new QTreeWidgetItem; |
---|
69 | parent->setText(0, "Producto"); |
---|
70 | |
---|
71 | child = new QTreeWidgetItem; |
---|
72 | child->setText(0, "Nombre."); |
---|
73 | parent->addChild(child); |
---|
74 | |
---|
75 | child = new QTreeWidgetItem; |
---|
76 | child->setText(0, "Especificaciones técnicas"); |
---|
77 | parent->addChild(child); |
---|
78 | |
---|
79 | child = new QTreeWidgetItem; |
---|
80 | child->setText(0, "Código arancelario"); |
---|
81 | parent->addChild(child); |
---|
82 | |
---|
83 | child = new QTreeWidgetItem; |
---|
84 | child->setText(0, "Cantidad total declarada"); |
---|
85 | parent->addChild(child); |
---|
86 | |
---|
87 | child = new QTreeWidgetItem; |
---|
88 | child->setText(0, "Cantidad en la red"); |
---|
89 | parent->addChild(child); |
---|
90 | |
---|
91 | child = new QTreeWidgetItem; |
---|
92 | child->setText(0, "Precio unitario"); |
---|
93 | parent->addChild(child); |
---|
94 | |
---|
95 | child = new QTreeWidgetItem; |
---|
96 | child->setText(0, "Cap. de planta usada"); |
---|
97 | parent->addChild(child); |
---|
98 | |
---|
99 | tree.addTopLevelItem(parent); |
---|
100 | parent->setExpanded(true); |
---|
101 | |
---|
102 | parent = new QTreeWidgetItem; |
---|
103 | parent->setText(0, "Simulación"); |
---|
104 | |
---|
105 | child = new QTreeWidgetItem; |
---|
106 | child->setText(0, "Cantidad."); |
---|
107 | parent->addChild(child); |
---|
108 | |
---|
109 | child = new QTreeWidgetItem; |
---|
110 | child->setText(0, "Porcentaje"); |
---|
111 | parent->addChild(child); |
---|
112 | |
---|
113 | tree.addTopLevelItem(parent); |
---|
114 | parent->setExpanded(true); |
---|
115 | |
---|
116 | tree.setColumnWidth(0, 250); |
---|
117 | |
---|
118 | setWidget(&tree); |
---|
119 | setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); |
---|
120 | } |
---|
121 | |
---|
122 | void NodeInfoDock::slotSvgPanelClicked(Graph::Node * p) { |
---|
123 | |
---|
124 | this->p = p; |
---|
125 | |
---|
126 | if (this->p == NULL) { |
---|
127 | clear(); |
---|
128 | return; |
---|
129 | } |
---|
130 | |
---|
131 | Good * good = this->p->get_info().get(); |
---|
132 | |
---|
133 | tree.topLevelItem(0)->child(0)->setText(1, COMPANY(good)->getRif().c_str()); |
---|
134 | tree.topLevelItem(0)->child(1)->setText(1, |
---|
135 | COMPANY(good)->getName().c_str()); |
---|
136 | |
---|
137 | std::string plantName = good->getType() == INPUT_GOOD |
---|
138 | ? "" |
---|
139 | : (static_cast <Product *>(good))->getProducerPlant()->getName(); |
---|
140 | |
---|
141 | tree.topLevelItem(0)->child(2)->setText(1, plantName.c_str()); |
---|
142 | |
---|
143 | tree.topLevelItem(1)->child(0)->setText(1, good->getName().c_str()); |
---|
144 | tree.topLevelItem(1)-> |
---|
145 | child(1)->setText(1, good->getTechnicalSpecifications().c_str()); |
---|
146 | tree.topLevelItem(1)->child(2)->setText(1, good->getTariffCode().c_str()); |
---|
147 | |
---|
148 | QString text; |
---|
149 | |
---|
150 | text = QString(numtostr(good->getTotalQuantity()).c_str()); |
---|
151 | text.append(" "); |
---|
152 | text.append(good->getMeasurementUnit().c_str()); |
---|
153 | tree.topLevelItem(1)->child(3)->setText(1, text); |
---|
154 | |
---|
155 | text = QString(numtostr(good->getQuantity()).c_str()); |
---|
156 | text.append(" "); |
---|
157 | text.append(good->getMeasurementUnit().c_str()); |
---|
158 | tree.topLevelItem(1)->child(4)->setText(1, text); |
---|
159 | |
---|
160 | text = QString(numtostr(good->getUnitarianPrice()).c_str()); |
---|
161 | text.append(" Bs."); |
---|
162 | tree.topLevelItem(1)->child(5)->setText(1, text); |
---|
163 | |
---|
164 | text = QString(numtostr(good->getUsedCapacity()).c_str()); |
---|
165 | text.append("%"); |
---|
166 | tree.topLevelItem(1)->child(6)->setText(1, text); |
---|
167 | |
---|
168 | double q = good->getQuantity() * simPercent(p) / 100; |
---|
169 | |
---|
170 | text = QString(numtostr(q).c_str()); |
---|
171 | tree.topLevelItem(2)->child(0)->setText(1, text); |
---|
172 | |
---|
173 | text = QString(numtostr(simPercent(p)).c_str()); |
---|
174 | tree.topLevelItem(2)->child(1)->setText(1, text); |
---|
175 | } |
---|
176 | |
---|
177 | void NodeInfoDock::slotNodeSimPercentUpdated() { |
---|
178 | |
---|
179 | QString text; |
---|
180 | |
---|
181 | double q = p->get_info()->getQuantity() * simPercent(p) / 100; |
---|
182 | text = QString(numtostr(q).c_str()); |
---|
183 | tree.topLevelItem(2)->child(0)->setText(1, text); |
---|
184 | |
---|
185 | text = QString(numtostr(simPercent(p)).c_str()); |
---|
186 | tree.topLevelItem(2)->child(1)->setText(1, text); |
---|
187 | } |
---|
188 | |
---|
189 | void NodeInfoDock::clear() { |
---|
190 | |
---|
191 | QTreeWidgetItemIterator it(&tree); |
---|
192 | |
---|
193 | while (*it) { |
---|
194 | (*it)->setText(1, ""); |
---|
195 | ++it; |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | void NodeInfoDock::closeEvent(QCloseEvent * evt) { |
---|
200 | emit signalClosing(); |
---|
201 | evt->ignore(); |
---|
202 | } |
---|