Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
GuiListParameter.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7#include <QVBoxLayout>
8#include <QRadioButton>
9#include <QAbstractButton>
10#include <QList>
11
12#include "UserInterface.h"
13
14#include "GuiListParameter.h"
15
16namespace Isis {
17
18 GuiListParameter::GuiListParameter(QGridLayout *grid, UserInterface &ui,
19 int group, int param) :
20 GuiParameter(grid, ui, group, param) {
21
22 // Reset the default alignment of the label
23 p_label->setAlignment(Qt::AlignRight | Qt::AlignTop);
24
25
26 // Create a vertical box layout for the radio buttons and add it to
27 // the grid layout
28 QVBoxLayout *lo = new QVBoxLayout;
29 grid->addLayout(lo, param, 2);
30
31 // Create a button group so these buttons don't react to other buttons
32 // with the same parent
33 p_buttonGroup = new QButtonGroup();
34
35 // Create a button for each list item and add each to a button group and
36 // to the layout
37 for(int item = 0; item < ui.ParamListSize(group, param); item++) {
38 QString btext = ui.ParamListBrief(group, param, item);
39 btext += " (";
40 btext += ui.ParamListValue(group, param, item);
41 btext += ")";
42
43 // If there's helper buttons, create a vertical box layout
44 // and add it next to the radio buttons
45 if((item == 0) && (p_ui->HelpersSize(group, param) != 0)) {
46 // Create Vertical layout box
47 QVBoxLayout *vlo = new QVBoxLayout;
48 grid->addLayout(vlo, 0, 3);
49
50 // Get helpers and add to vertical layout
51 QWidget *helper = AddHelpers(p_buttonGroup);
52 vlo->addWidget(helper, 0, Qt::AlignTop);
53
54 RememberWidget(helper);
55 }
56 // Create radio button & add to vertical layout
57 QRadioButton *rb = new QRadioButton(btext);
58 rb->setObjectName(ui.ParamListValue(group, param, item));
59 lo->addWidget(rb);
60 p_buttonGroup->addButton(rb);
61 RememberWidget(rb);
62 }
63 connect(p_buttonGroup, SIGNAL(buttonClicked(QAbstractButton *)),
64 this, SIGNAL(ValueChanged()));
65
66 p_type = ListWidget;
67 }
68
69
70 GuiListParameter::~GuiListParameter() {
71 delete p_buttonGroup;
72 }
73
74
75 void GuiListParameter::Set(QString newValue) {
76 QString value = newValue.toUpper();
77
78 int foundAtButton = -1;
79 for(int i = 0; i < p_ui->ParamListSize(p_group, p_param); i++) {
80 QString option = p_ui->ParamListValue(p_group, p_param, i).toUpper();
81 //if(option.compare(0, value.size(), value) == 0) foundAtButton = i;
82 if(option == value) foundAtButton = i;
83 }
84
85 if(foundAtButton != -1) {
86 p_buttonGroup->buttons()[foundAtButton]->setChecked(true);
87 }
88
89 emit ValueChanged();
90 }
91
92
93 QString GuiListParameter::Value() {
94 if(p_buttonGroup->checkedButton() == 0) {
95 return "";
96 }
97
98 return p_ui->ParamListValue(p_group, p_param,
99 p_buttonGroup->buttons().indexOf(p_buttonGroup->checkedButton()));
100 }
101
102 std::vector<QString> GuiListParameter::Exclusions() {
103 std::vector<QString> list;
104
105 if(p_buttonGroup->checkedButton() == 0) return list;
106 int index = p_buttonGroup->buttons().indexOf(p_buttonGroup->checkedButton());
107
108 for(int i = 0; i < p_ui->ParamListExcludeSize(p_group, p_param, index); i++) {
109 QString s = p_ui->ParamListExclude(p_group, p_param, index, i);
110 list.push_back(s);
111 }
112
113 return list;
114 }
115}
116
virtual std::vector< QString > Exclusions()
Return list of current exclusions.
Command Line and Xml loader, validation, and access.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16