Isis 3 Programmer Reference
QnetNewMeasureDialog.cpp
1 #include "QnetNewMeasureDialog.h"
2 
3 #include <algorithm>
4 #include <string>
5 
6 #include <QHBoxLayout>
7 #include <QLabel>
8 #include <QListWidget>
9 #include <QPushButton>
10 #include <QtWidgets>
11 
12 #include "ControlPoint.h"
13 #include "IString.h"
14 #include "QnetTool.h"
15 #include "SerialNumberList.h"
16 
17 namespace Isis {
28  QWidget *parent) : QDialog(parent) {
29  m_fileList = NULL;
30  m_okButton = NULL;
31  m_qnetTool = qnetTool;
32 
33  QLabel *listLabel = new QLabel("Select Files:");
34 
35  m_fileList = new QListWidget;
36  m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
37 
38  // Create OK & Cancel buttons
39  m_okButton = new QPushButton("OK");
40  //m_okButton->setEnabled(false);
41  QPushButton *cancelButton = new QPushButton("Cancel");
42  QHBoxLayout *buttonLayout = new QHBoxLayout;
43  buttonLayout->addWidget(m_okButton);
44  buttonLayout->addWidget(cancelButton);
45 
46  connect(m_okButton, SIGNAL(clicked()), this, SLOT(accept()));
47  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
48 
49  QVBoxLayout *vLayout = new QVBoxLayout;
50  vLayout->addWidget(listLabel);
51  vLayout->addWidget(m_fileList);
52  vLayout->addLayout(buttonLayout);
53 
54  setLayout(vLayout);
55  setWindowTitle("Add Measures to ControlPoint");
56 
57  }
58 
59 
68  QStringList pointFiles) {
69  int bottomMostSelectedItemIndex = 0;
70 
71  // Add all entries in the SerialNumberList
72  SerialNumberList *snList = m_qnetTool->serialNumberList();
73  for (int i = 0; i < snList->size(); i++) {
74  QString curSerialNum = snList->serialNumber(i);
75 
76  // Don't add if already in this point
77  if (point.HasSerialNumber(curSerialNum))
78  continue;
79 
80  // build new item...
81  QString label(snList->fileName(i));
82  QListWidgetItem *item = new QListWidgetItem(label);
83 
84  // if this entry of the SerialNumberList is also in the pointFiles then
85  // mark it as selected and insert after the last selected item (toward
86  // the top, otherwise add it to the end
87  if (pointFiles.contains(label)) {
88  m_fileList->insertItem(bottomMostSelectedItemIndex++, item);
89  item->setSelected(true);
90  }
91  else {
92  m_fileList->addItem(item);
93  }
94  }
95  }
96 
97 
98  QStringList QnetNewMeasureDialog::selectedFiles() const {
99  QStringList result;
100 
101  foreach (QListWidgetItem *fileItem, m_fileList->selectedItems()) {
102  result.append(fileItem->text());
103  }
104 
105  return result;
106  }
107 
108 
109  void QnetNewMeasureDialog::enableOkButton(const QString &text) {
110  m_okButton->setEnabled(!text.isEmpty());
111  }
112 }
QWidget
Isis::SerialNumberList::size
int size() const
How many serial number / filename combos are in the list.
Definition: SerialNumberList.cpp:384
QStringList
Isis::SerialNumberList
Serial Number list generator.
Definition: SerialNumberList.h:64
Isis::SerialNumberList::serialNumber
QString serialNumber(const QString &filename)
Return a serial number given a filename.
Definition: SerialNumberList.cpp:426
Isis::ControlPoint
A single control point.
Definition: ControlPoint.h:354
Isis::QnetNewMeasureDialog::QnetNewMeasureDialog
QnetNewMeasureDialog(QnetTool *qnetTool, QWidget *parent=0)
Contructor.
Definition: QnetNewMeasureDialog.cpp:27
Isis::QnetTool
Qnet tool operations.
Definition: QnetTool.h:256
Isis::QnetNewMeasureDialog::setFiles
void setFiles(ControlPoint point, QStringList pointFiles)
Definition: QnetNewMeasureDialog.cpp:67
QDialog
Isis::SerialNumberList::fileName
QString fileName(const QString &sn)
Return a filename given a serial number.
Definition: SerialNumberList.cpp:399
Isis::ControlPoint::HasSerialNumber
bool HasSerialNumber(QString serialNumber) const
Return true if given serial number exists in point.
Definition: ControlPoint.cpp:1746
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16