Isis 3.0 Programmer Reference
Back | Home
QnetNewPointDialog.cpp
1 #include "QnetNewPointDialog.h"
2 
3 #include <algorithm>
4 
5 #include <QHBoxLayout>
6 #include <QLabel>
7 #include <QLineEdit>
8 #include <QListWidget>
9 #include <QPushButton>
10 #include <QtWidgets>
11 
12 #include "ControlNet.h"
13 #include "IString.h"
14 #include "QnetTool.h"
15 #include "SerialNumberList.h"
16 
17 namespace Isis {
34  QnetNewPointDialog::QnetNewPointDialog(QnetTool *qnetTool, QString defaultPointId,
35  QWidget *parent) : QDialog(parent) {
36 
37  m_ptIdEdit = NULL;
38  m_fileList = NULL;
39  m_ptIdLabel = NULL;
40  m_okButton = NULL;
41 
42  m_qnetTool = qnetTool;
43 
44  m_ptIdLabel = new QLabel("Point ID:");
45  m_ptIdEdit = new QLineEdit;
46  m_ptIdLabel->setBuddy(m_ptIdEdit);
47  m_ptIdEdit->setText(defaultPointId);
48  m_ptIdEdit->selectAll();
49  connect(m_ptIdEdit, SIGNAL(textChanged(const QString &)),
50  this, SLOT(enableOkButton(const QString &)));
51 
52  QLabel *listLabel = new QLabel("Select Files:");
53 
54  m_fileList = new QListWidget;
55  m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
56 
57  // Create OK & Cancel buttons
58  m_okButton = new QPushButton("OK");
59  // If the last point id used was never saved to network, do not set ok
60  // button to faslse
61  enableOkButton("");
62 
63  QPushButton *cancelButton = new QPushButton("Cancel");
64  QHBoxLayout *buttonLayout = new QHBoxLayout;
65  buttonLayout->addWidget(m_okButton);
66  buttonLayout->addWidget(cancelButton);
67 
68  connect(m_okButton, SIGNAL(clicked()), this, SLOT(accept()));
69  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
70 
71  QHBoxLayout *ptIdLayout = new QHBoxLayout;
72  ptIdLayout->addWidget(m_ptIdLabel);
73  ptIdLayout->addWidget(m_ptIdEdit);
74 
75  QVBoxLayout *vLayout = new QVBoxLayout;
76  vLayout->addLayout(ptIdLayout);
77  vLayout->addWidget(listLabel);
78  vLayout->addWidget(m_fileList);
79  vLayout->addLayout(buttonLayout);
80 
81  setLayout(vLayout);
82  setWindowTitle("Create New ControlPoint");
83 
84  }
85 
86 
87  QString QnetNewPointDialog::pointId() const {
88  return m_ptIdEdit->text();
89  }
90 
91 
92  QStringList QnetNewPointDialog::selectedFiles() const {
93  QStringList result;
94 
95  foreach (QListWidgetItem *fileItem, m_fileList->selectedItems()) {
96  result.append(fileItem->text());
97  }
98 
99  return result;
100  }
101 
102 
111 
112  int bottomMostSelectedItemIndex = 0;
113 
114  SerialNumberList *snList = m_qnetTool->serialNumberList();
115  for (int i = 0; i < snList->size(); i++) {
116 
117  // build new item...
118  QString label = snList->fileName(i);
119  QListWidgetItem *item = new QListWidgetItem(label);
120 
121  // if this entry of the SerialNumberList is also in the pointFiles then
122  // mark it as selected and insert after the last selected item (toward
123  // the top of the list). Otherwise just add the item to the end of the
124  // list
125  if (pointFiles.contains(label)) {
126  m_fileList->insertItem(bottomMostSelectedItemIndex++, item);
127  item->setSelected(true);
128  }
129  else {
130  m_fileList->addItem(item);
131  }
132  }
133  }
134 
135 
142  void QnetNewPointDialog::enableOkButton(const QString &) {
143  m_okButton->setEnabled(!m_ptIdEdit->text().isEmpty() &&
144  !m_qnetTool->controlNet()->ContainsPoint(m_ptIdEdit->text()));
145  }
146 
147 
148 }
void enableOkButton(const QString &text)
bool ContainsPoint(QString pointId) const
Definition: ControlNet.cpp:781
int size() const
How many serial number / filename combos are in the list.
void setFiles(QStringList pointFiles)
QnetNewPointDialog(QnetTool *qnetTool, QString defaultPointId, QWidget *parent=0)
QnetNewPointDialog constructor.
QString fileName(const QString &sn)
Return a filename given a serial number.
Qnet tool operations.
Definition: QnetTool.h:251
Serial Number list generator.

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 ISIS Support Center
File Modified: 07/12/2023 23:27:39