File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
GuiComboBoxParameter.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include <QVBoxLayout>
8 #include <QComboBox>
9 #include <QList>
10 
11 #include "UserInterface.h"
12 
13 #include "GuiParameter.h"
14 #include "GuiComboBoxParameter.h"
15 
16 namespace Isis {
17 
18  GuiComboBoxParameter::GuiComboBoxParameter(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  // Create a vertical box layout for the combo box and add it to
26  // the grid layout
27  QVBoxLayout *lo = new QVBoxLayout;
28  grid->addLayout(lo, param, 2);
29 
30  // Create a combo box
31  p_combo = new QComboBox();
32 
33  // Create a menu item in the combo box for each list item and add it
34  // to the layout
35  for(int item = 0; item < ui.ParamListSize(group, param); item++) {
36  QString btext = ui.ParamListBrief(group, param, item);
37  btext += " (";
38  btext += ui.ParamListValue(group, param, item);
39  btext += ")";
40  p_combo->insertItem(item, btext);
41  }
42  lo->addWidget(p_combo);
43  connect(p_combo, SIGNAL(activated(int)),
44  this, SIGNAL(ValueChanged()));
45 
46  p_type = ComboWidget;
47  RememberWidget(p_combo);
48  }
49 
50 
51  GuiComboBoxParameter::~GuiComboBoxParameter() {
52  delete p_combo;
53  }
54 
55 
56  void GuiComboBoxParameter::Set(QString newValue) {
57  IString value = newValue;
58  value.UpCase();
59 
60  int foundAtButton = -1;
61  for(int i = 0; i < p_ui->ParamListSize(p_group, p_param); i++) {
62  IString option = p_ui->ParamListValue(p_group, p_param, i);
63  option.UpCase();
64  //if(option.compare(0, value.size(), value) == 0) foundAtButton = i;
65  if(option == value) foundAtButton = i;
66  }
67 
68  if(foundAtButton != -1) {
69  p_combo->setCurrentIndex(foundAtButton);
70  }
71 
72  emit ValueChanged();
73  }
74 
75 
76  QString GuiComboBoxParameter::Value() {
77  return p_ui->ParamListValue(p_group, p_param,
78  p_combo->currentIndex());
79  }
80 
81  std::vector<QString> GuiComboBoxParameter::Exclusions() {
82  std::vector<QString> list;
83 
84  int index = p_combo->currentIndex();
85 
86  for(int i = 0; i < p_ui->ParamListExcludeSize(p_group, p_param, index); i++) {
87  QString s = p_ui->ParamListExclude(p_group, p_param, index, i);
88  list.push_back(s);
89  }
90 
91  return list;
92  }
93 
94  void GuiComboBoxParameter::setOption (int option) {
95  std::cout << "Combo box option: " << option << std::endl;
96  }
97 }
Isis::GuiParameter::RememberWidget
void RememberWidget(QWidget *w)
Add widgets to a list for enabling/disabling.
Definition: GuiParameter.cpp:212
IsisAml::ParamListSize
int ParamListSize(const int &group, const int &param) const
Returns the number of options in the specified parameter's list.
Definition: IsisAml.cpp:1601
IsisAml::ParamListValue
QString ParamListValue(const int &group, const int &param, const int &option) const
Returns the option value for a specific option to a parameter.
Definition: IsisAml.cpp:1615
QComboBox
IsisAml::ParamListExcludeSize
int ParamListExcludeSize(const int &group, const int &param, const int &option) const
Returns the number of items in a parameters list exclude section.
Definition: IsisAml.cpp:1660
IsisAml::ParamListExclude
QString ParamListExclude(const int &group, const int &param, const int &option, const int &exclude) const
Returns the parameter name to be excluded if this option is selected.
Definition: IsisAml.cpp:1675
Isis::GuiComboBoxParameter::Exclusions
virtual std::vector< QString > Exclusions()
Return list of current exclusions.
Definition: GuiComboBoxParameter.cpp:81
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:31