1 | #include <Wt/WText> |
---|
2 | #include <Wt/WVBoxLayout> |
---|
3 | #include <Wt/WHBoxLayout> |
---|
4 | #include <Wt/WContainerWidget> |
---|
5 | #include <Wt/WImage> |
---|
6 | |
---|
7 | #include "GWt_sectionToExecute.h" |
---|
8 | #include "GWt_softwarePanel.h" |
---|
9 | |
---|
10 | GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,GWt_softwarePanel* sPanel) |
---|
11 | :WContainerWidget(), |
---|
12 | firstElement(first), |
---|
13 | lastElement(last), |
---|
14 | software(soft), |
---|
15 | softwarePanel(sPanel) |
---|
16 | { |
---|
17 | Wt::WHBoxLayout* mainContainerLayout = new Wt::WHBoxLayout(); |
---|
18 | mainContainerLayout->setContentsMargins(0,0,0,0); |
---|
19 | |
---|
20 | Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget(); |
---|
21 | Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout(); |
---|
22 | labelAndComboContainerLayout->setContentsMargins(0,0,0,0); |
---|
23 | |
---|
24 | Wt::WContainerWidget* labelAndComboInsideContainer = new Wt::WContainerWidget(); |
---|
25 | Wt::WHBoxLayout* labelAndComboInsideContainerLayout = new Wt::WHBoxLayout(); |
---|
26 | labelAndComboInsideContainerLayout->setContentsMargins(0,0,0,0); |
---|
27 | |
---|
28 | labelAndComboInsideContainerLayout->addWidget(new Wt::WText(" from : ")); |
---|
29 | labelAndComboInsideContainerLayout->addWidget(first); |
---|
30 | labelAndComboInsideContainerLayout->addWidget(new Wt::WText(" to : ")); |
---|
31 | labelAndComboInsideContainerLayout->addWidget(last); |
---|
32 | labelAndComboInsideContainerLayout->addWidget(soft); |
---|
33 | |
---|
34 | labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout); |
---|
35 | |
---|
36 | labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer); |
---|
37 | labelAndComboContainerLayout->addStretch (10); |
---|
38 | |
---|
39 | labelAndComboContainer->setLayout(labelAndComboContainerLayout); |
---|
40 | |
---|
41 | // add label and Combo containers |
---|
42 | mainContainerLayout->addWidget(labelAndComboContainer); |
---|
43 | |
---|
44 | |
---|
45 | // add errors and warning layout |
---|
46 | warningsContainer_ = new Wt::WContainerWidget(); |
---|
47 | errorsContainer_ = new Wt::WContainerWidget(); |
---|
48 | |
---|
49 | Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget(); |
---|
50 | Wt::WVBoxLayout* vLayoutContainer = new Wt::WVBoxLayout(); |
---|
51 | |
---|
52 | vLayoutContainer->addWidget(warningsContainer_); |
---|
53 | vLayoutContainer->addWidget(errorsContainer_); |
---|
54 | vLayoutContainer->addStretch (100); |
---|
55 | |
---|
56 | Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout(); |
---|
57 | Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout(); |
---|
58 | |
---|
59 | |
---|
60 | // fill containers |
---|
61 | Wt::WImage* imgWarning = new WImage ("/htdocs/warning.png"); |
---|
62 | Wt::WImage* imgError = new WImage ("/htdocs/error.png"); |
---|
63 | |
---|
64 | // resize images |
---|
65 | imgWarning->resize(20,20); |
---|
66 | imgError->resize(20,20); |
---|
67 | |
---|
68 | warningsLabel_ = new Wt::WLabel(""); |
---|
69 | errorsLabel_ = new Wt::WLabel(""); |
---|
70 | |
---|
71 | hLayoutContainerWarnings->addWidget(imgWarning); |
---|
72 | hLayoutContainerWarnings->addWidget(warningsLabel_); |
---|
73 | hLayoutContainerErrors->addWidget(imgError); |
---|
74 | hLayoutContainerErrors->addWidget(errorsLabel_); |
---|
75 | |
---|
76 | warningsAndErrorsContainer->addWidget(warningsLabel_); |
---|
77 | warningsAndErrorsContainer->addWidget(errorsLabel_); |
---|
78 | |
---|
79 | |
---|
80 | // set Layouts |
---|
81 | warningsContainer_->setLayout(hLayoutContainerWarnings); |
---|
82 | errorsContainer_->setLayout(hLayoutContainerErrors); |
---|
83 | |
---|
84 | warningsAndErrorsContainer->setLayout(vLayoutContainer); |
---|
85 | |
---|
86 | // add warnings and errors containers |
---|
87 | // mainContainerLayout->addWidget(warningsAndErrorsContainer); |
---|
88 | |
---|
89 | this->setLayout(mainContainerLayout); |
---|
90 | |
---|
91 | |
---|
92 | firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections); |
---|
93 | lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections); |
---|
94 | software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections); |
---|
95 | |
---|
96 | manageWarningsAndErrors(); |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | void GWt_sectionToExecute::setFirstElementCurrentSelection(Wt::WString txt){ |
---|
101 | for (int a=0; a< firstElement->count(); a++) { |
---|
102 | if (firstElement->itemText(a) == txt) { |
---|
103 | firstElement->setCurrentIndex (a); |
---|
104 | return; |
---|
105 | } |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | void GWt_sectionToExecute::setLastElementCurrentSelection(Wt::WString txt){ |
---|
110 | for (int a=0; a< lastElement->count(); a++) { |
---|
111 | if (lastElement->itemText(a) == txt) { |
---|
112 | lastElement->setCurrentIndex (a); |
---|
113 | return; |
---|
114 | } |
---|
115 | } |
---|
116 | } |
---|
117 | |
---|
118 | void GWt_sectionToExecute::setSoftwareElementCurrentSelection(Wt::WString txt){ |
---|
119 | for (int a=0; a< software->count(); a++) { |
---|
120 | if (software->itemText(a) == txt) { |
---|
121 | software->setCurrentIndex (a); |
---|
122 | return; |
---|
123 | } |
---|
124 | } |
---|
125 | } |
---|
126 | |
---|
127 | |
---|
128 | void GWt_sectionToExecute::manageWarningsAndErrors(){ |
---|
129 | if (warningsLabel_->text() == "") { |
---|
130 | warningsContainer_->hide(); |
---|
131 | } else { |
---|
132 | warningsContainer_->show(); |
---|
133 | } |
---|
134 | if (errorsLabel_->text() == "") { |
---|
135 | errorsContainer_->hide(); |
---|
136 | } else { |
---|
137 | errorsContainer_->show(); |
---|
138 | } |
---|
139 | |
---|
140 | } |
---|