12 #include <QRadioButton>
13 #include <QPushButton>
14 #include <QButtonGroup>
15 #include <QGridLayout>
16 #include <QHBoxLayout>
17 #include <QVBoxLayout>
19 #include "CubeAttribute.h"
21 #include "GuiInputAttribute.h"
25 int GuiInputAttribute::GetAttributes(
const QString &defaultAttribute,
26 QString &newAttribute,
34 p_dialog->setWindowTitle(title);
37 p_dialog->SetAttributes(defaultAttribute);
38 if(p_dialog->exec() == QDialog::Accepted) {
39 newAttribute = p_dialog->GetAttributes();
42 newAttribute = defaultAttribute;
49 QRadioButton *allBands =
new QRadioButton(
"&All Bands");
50 allBands->setToolTip(
"Select all bands from the input cube");
52 QRadioButton *listBands =
new QRadioButton(
"&Band List");
53 listBands->setToolTip(
"Select any bands from the input cube");
56 p_buttonGroup =
new QButtonGroup();
57 p_buttonGroup->addButton(allBands);
58 p_buttonGroup->addButton(listBands);
59 p_buttonGroup->setExclusive(
true);
62 p_lineEdit =
new QLineEdit();
63 connect(allBands, SIGNAL(toggled(
bool)), p_lineEdit, SLOT(setDisabled(
bool)));
64 allBands->setChecked(
true);
67 QGridLayout *gridLayout =
new QGridLayout();
68 gridLayout->addWidget(allBands, 0, 0);
69 gridLayout->addWidget(listBands, 1, 0);
70 gridLayout->addWidget(p_lineEdit, 1, 1);
73 QPushButton *okButton =
new QPushButton(
"Ok");
74 connect(okButton, SIGNAL(clicked()),
this, SLOT(accept()));
76 QPushButton *cancelButton =
new QPushButton(
"Cancel");
77 connect(cancelButton, SIGNAL(clicked()),
this, SLOT(reject()));
81 QButtonGroup *actionGroup =
new QButtonGroup();
82 actionGroup->addButton(okButton);
83 actionGroup->addButton(cancelButton);
87 QHBoxLayout *actionLayout =
new QHBoxLayout();
88 actionLayout->addWidget(okButton);
89 actionLayout->addWidget(cancelButton);
92 QVBoxLayout *dialogLayout =
new QVBoxLayout(
this);
93 dialogLayout->addLayout(gridLayout);
94 dialogLayout->addLayout(actionLayout);
99 GuiInputAttribute::~GuiInputAttribute() {}
103 QString GuiInputAttribute::GetAttributes() {
105 if(p_lineEdit->isEnabled()) {
106 attStr = p_lineEdit->text().simplified();
107 attStr = attStr.remove(QRegExp(
"^[+]*"));
108 if (attStr.length() > 0) {
109 if (attStr.left(1) !=
"+") attStr.prepend(
'+');
117 void GuiInputAttribute::SetAttributes(
const QString &value) {
119 std::vector<QString> bands = att.bands();
120 if(bands.size() == 0) {
121 p_buttonGroup->buttons()[0]->setChecked(
true);
122 p_lineEdit->setText(
"");
125 p_buttonGroup->buttons()[1]->setChecked(
true);
126 p_lineEdit->setText(att.toString());