9#include "PointTableDelegate.h"
19#include "ControlMeasure.h"
20#include "ControlPoint.h"
21#include "IException.h"
23#include "AbstractPointItem.h"
24#include "AbstractTreeItem.h"
25#include "PointTableModel.h"
26#include "TableColumn.h"
29 PointTableDelegate::PointTableDelegate() {
33 PointTableDelegate::~PointTableDelegate() {
37 QWidget *PointTableDelegate::getWidget(TableColumn
const *col)
const {
38 AbstractPointItem::Column column =
39 AbstractPointItem::getColumn(col->getTitle());
43 case AbstractPointItem::PointType:
44 case AbstractPointItem::EditLock:
45 case AbstractPointItem::Ignored:
46 case AbstractPointItem::Reference:
47 case AbstractPointItem::APrioriSPSource:
48 case AbstractPointItem::APrioriRadiusSource: {
52 case AbstractPointItem::PointType:
53 for (
int i = 0; i < ControlPoint::PointTypeCount; i++) {
58 case AbstractPointItem::EditLock:
59 combo->insertItem(0,
"Yes");
60 combo->insertItem(1,
"No");
62 case AbstractPointItem::Ignored:
63 combo->insertItem(0,
"Yes");
64 combo->insertItem(1,
"No");
66 case AbstractPointItem::Reference:
70 case AbstractPointItem::APrioriSPSource:
71 combo->insertItem(0,
"None");
72 combo->insertItem(1,
"User");
73 combo->insertItem(2,
"AverageOfMeasures");
74 combo->insertItem(3,
"Reference");
75 combo->insertItem(4,
"Basemap");
76 combo->insertItem(5,
"BundleSolution");
78 case AbstractPointItem::APrioriRadiusSource:
79 combo->insertItem(0,
"None");
80 combo->insertItem(1,
"User");
81 combo->insertItem(2,
"AverageOfMeasures");
82 combo->insertItem(3,
"Ellipsoid");
83 combo->insertItem(4,
"DEM");
84 combo->insertItem(5,
"BundleSolution");
95 return new QLineEdit();
98 QString msg =
"Could not create delegate widget for column ["
99 + col->getTitle() +
"]";
104 void PointTableDelegate::readData(
QWidget *widget,
105 AbstractTreeItem *row, TableColumn
const *col)
const {
106 QString columnTitle = col->getTitle();
107 AbstractPointItem::Column column =
108 AbstractPointItem::getColumn(columnTitle);
110 QString data = row->getFormattedData(columnTitle);
112 ControlPoint *point = (ControlPoint *)row->getPointer();
115 case AbstractPointItem::Reference: {
118 for (
int i = 0; i < point->GetNumMeasures(); i++)
119 combo->insertItem(i, point->GetMeasure(i)->GetCubeSerialNumber());
120 combo->setCurrentIndex(point->IndexOfRefMeasure());
124 case AbstractPointItem::PointType:
125 case AbstractPointItem::EditLock:
126 case AbstractPointItem::Ignored:
127 case AbstractPointItem::APrioriSPSource:
128 case AbstractPointItem::APrioriRadiusSource: {
132 case AbstractPointItem::PointType:
133 combo->setCurrentIndex(
134 (
int) point->StringToPointType(data));
136 case AbstractPointItem::EditLock:
137 combo->setCurrentIndex(point->IsEditLocked() ? 0 : 1);
139 case AbstractPointItem::Ignored:
140 combo->setCurrentIndex(point->IsIgnored() ? 0 : 1);
142 case AbstractPointItem::APrioriSPSource:
143 combo->setCurrentIndex(
144 (
int) point->StringToSurfacePointSource(data));
146 case AbstractPointItem::APrioriRadiusSource:
147 combo->setCurrentIndex(
148 (
int) point->StringToRadiusSource(data));
156 QLineEdit *lineEdit =
static_cast< QLineEdit *
>(widget);
157 lineEdit->setText(data);
163 void PointTableDelegate::readData(
QWidget *widget,
164 AbstractTreeItem *row, TableColumn
const *col,
165 QString newData)
const {
166 QString columnTitle = col->getTitle();
167 AbstractPointItem::Column column =
168 AbstractPointItem::getColumn(columnTitle);
170 QString data = row->getFormattedData(columnTitle);
172 ControlPoint *point = (ControlPoint *)row->getPointer();
175 case AbstractPointItem::Reference: {
178 for (
int i = 0; i < point->GetNumMeasures(); i++)
179 combo->insertItem(i, point->GetMeasure(i)->GetCubeSerialNumber());
181 combo->setCurrentIndex(point->IndexOfRefMeasure());
183 for (
int i = combo->count() - 1; i >= 0; --i)
184 if (combo->itemText(i).toLower().startsWith(newData.toLower()))
185 combo->setCurrentIndex(i);
189 case AbstractPointItem::PointType:
190 case AbstractPointItem::EditLock:
191 case AbstractPointItem::Ignored:
192 case AbstractPointItem::APrioriSPSource:
193 case AbstractPointItem::APrioriRadiusSource: {
197 case AbstractPointItem::PointType:
198 combo->setCurrentIndex(
199 (
int) point->StringToPointType(data));
201 case AbstractPointItem::EditLock:
202 combo->setCurrentIndex(point->IsEditLocked() ? 0 : 1);
204 case AbstractPointItem::Ignored:
205 combo->setCurrentIndex(point->IsIgnored() ? 0 : 1);
207 case AbstractPointItem::APrioriSPSource:
208 combo->setCurrentIndex(
209 (
int) point->StringToSurfacePointSource(data));
211 case AbstractPointItem::APrioriRadiusSource:
212 combo->setCurrentIndex(
213 (
int) point->StringToRadiusSource(data));
219 for (
int i = combo->count() - 1; i >= 0; --i)
220 if (combo->itemText(i).toLower().startsWith(newData.toLower()))
221 combo->setCurrentIndex(i);
225 QLineEdit *lineEdit =
static_cast< QLineEdit *
>(widget);
226 lineEdit->setText(newData);
232 void PointTableDelegate::saveData(
QWidget *widget,
233 AbstractTreeItem *row,
const TableColumn *col)
const {
234 AbstractPointItem::Column column =
235 AbstractPointItem::getColumn(col->getTitle());
240 case AbstractPointItem::PointType:
241 case AbstractPointItem::EditLock:
242 case AbstractPointItem::Ignored:
243 case AbstractPointItem::Reference:
244 case AbstractPointItem::APrioriSPSource:
245 case AbstractPointItem::APrioriRadiusSource: {
247 newData = combo->currentText();
251 QLineEdit *lineEdit =
static_cast< QLineEdit *
>(widget);
252 newData = lineEdit->text();
256 QString warningText = PointTableModel::getPointWarningMessage(
259 bool changeData =
true;
261 if (!warningText.isEmpty()) {
262 QMessageBox::StandardButton status = QMessageBox::warning(
263 NULL,
"Change cell?", warningText, QMessageBox::Yes |
266 changeData = (status == QMessageBox::Yes);
270 row->setData(col->getTitle(), newData);
PointType
These are the valid 'types' of point.
static QString PointTypeToString(PointType type)
Obtain a string representation of a given PointType.
@ Programmer
This error is for when a programmer made an API call that was illegal.
This is free and unencumbered software released into the public domain.