9#include "PointTableModel.h"
19#include "ControlMeasure.h"
20#include "ControlPoint.h"
22#include "IException.h"
26#include "SpecialPixel.h"
28#include "AbstractTableDelegate.h"
29#include "AbstractPointItem.h"
30#include "TableColumn.h"
31#include "TableColumnList.h"
32#include "PointTableDelegate.h"
33#include "AbstractTreeModel.h"
37 PointTableModel::PointTableModel(AbstractTreeModel *model) :
38 AbstractTableModel(model, new PointTableDelegate) {
39 connect(model, SIGNAL(filterCountsChanged(
int,
int)),
40 this, SIGNAL(filterCountsChanged(
int,
int)));
42 SIGNAL(treeSelectionChanged(QList< AbstractTreeItem * >)),
44 SLOT(handleTreeSelectionChanged(QList< AbstractTreeItem * >)));
48 PointTableModel::~PointTableModel() {
52 QList< AbstractTreeItem * > PointTableModel::getItems(
54 return getSortedItems(start, end, AbstractTreeModel::PointItems);
58 QList< AbstractTreeItem * > PointTableModel::getItems(
59 AbstractTreeItem *item1, AbstractTreeItem *item2) {
60 return getSortedItems(item1, item2, AbstractTreeModel::PointItems);
64 int PointTableModel::getVisibleRowCount()
const {
65 return getDataModel()->getVisibleItemCount(AbstractTreeModel::PointItems,
70 QList< AbstractTreeItem * > PointTableModel::getSelectedItems() {
71 return getDataModel()->getSelectedItems(AbstractTreeModel::PointItems,
76 QString PointTableModel::getWarningMessage(AbstractTreeItem
const *row,
77 TableColumn
const *column, QString valueToSave)
const {
78 return getPointWarningMessage(row, column, valueToSave);
82 void PointTableModel::setGlobalSelection(
bool selected) {
83 return getDataModel()->setGlobalSelection(selected,
84 AbstractTreeModel::AllItems);
88 int PointTableModel::indexOfVisibleItem(
89 AbstractTreeItem
const *item)
const {
90 return getDataModel()->indexOfVisibleItem(item,
91 AbstractTreeModel::PointItems,
96 QString PointTableModel::getPointWarningMessage(
97 AbstractTreeItem
const *row, TableColumn
const *column,
98 QString valueToSave) {
99 QString colTitle = column->getTitle();
100 AbstractPointItem::Column colType =
101 AbstractPointItem::getColumn(colTitle);
106 case AbstractPointItem::EditLock:
107 if (valueToSave.toLower() ==
"no" &&
108 row->getFormattedData(colTitle).toLower() ==
"yes") {
109 warningText =
"Are you sure you want to unlock control point [" +
110 row->getFormattedData() +
"] for editing?";
113 case AbstractPointItem::APrioriSPLatSigma:
114 case AbstractPointItem::APrioriSPLonSigma:
115 case AbstractPointItem::APrioriSPRadiusSigma: {
116 ControlPoint *point = (ControlPoint *) row->getPointer();
119 bool latSigmaValid = (point->GetAprioriSurfacePoint().
120 GetLatSigmaDistance().isValid());
121 bool lonSigmaValid = (point->GetAprioriSurfacePoint().
122 GetLonSigmaDistance().isValid());
123 bool radiusSigmaValid = (point->GetAprioriSurfacePoint().
124 GetLocalRadiusSigma().isValid());
126 if (!latSigmaValid && !lonSigmaValid && !radiusSigmaValid &&
127 valueToSave.toLower() !=
"null") {
128 warningText =
"The sigma values are currently null. The other "
129 "sigmas will be set to 10,000, which currently represents "
130 "'free'. Is this okay?";
134 case AbstractPointItem::APrioriSPLat:
135 case AbstractPointItem::APrioriSPLon:
136 case AbstractPointItem::APrioriSPRadius: {
137 ControlPoint *point = (ControlPoint *) row->getPointer();
140 bool latValid = (point->GetAprioriSurfacePoint().
141 GetLatitude().isValid());
142 bool lonValid = (point->GetAprioriSurfacePoint().
143 GetLongitude().isValid());
144 bool radiusValid = (point->GetAprioriSurfacePoint().
145 GetLocalRadius().isValid());
147 if (!latValid && !lonValid && !radiusValid &&
148 valueToSave.toLower() !=
"null") {
149 warningText =
"Some of the a priori surface point values are "
150 "currently null. The surface point lat and lon will be set "
151 "to 0 if they are null, and the radius will be set to "
152 "10,000 if it is null. Is this okay?";
165 void PointTableModel::handleTreeSelectionChanged(
166 QList< AbstractTreeItem * > newlySelectedItems) {
167 AbstractTableModel::handleTreeSelectionChanged(
168 newlySelectedItems, AbstractTreeItem::Point);
170 QList<AbstractTreeItem *> measureParentItems;
171 foreach (AbstractTreeItem * item, newlySelectedItems) {
172 if (item->getPointerType() == AbstractTreeItem::Measure) {
173 measureParentItems.append(item->parent());
177 if (measureParentItems.size()) {
178 AbstractTableModel::handleTreeSelectionChanged(
179 measureParentItems, AbstractTreeItem::Point);
184 TableColumnList *PointTableModel::createColumns() {
185 return AbstractPointItem::createColumns();
This is free and unencumbered software released into the public domain.