Isis 3 Programmer Reference
MeasureTableModel.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "IsisDebug.h"
10 
11 #include "MeasureTableModel.h"
12 
13 #include <iostream>
14 
15 #include <QDebug>
16 #include <QList>
17 #include <QMessageBox>
18 #include <QStringList>
19 #include <QVariant>
20 
21 #include "ControlMeasure.h"
22 #include "ControlMeasure.h"
23 #include "Distance.h"
24 #include "IException.h"
25 #include "IString.h"
26 #include "Latitude.h"
27 #include "Longitude.h"
28 #include "SpecialPixel.h"
29 
30 #include "AbstractTableDelegate.h"
31 #include "AbstractMeasureItem.h"
32 #include "TableColumn.h"
33 #include "TableColumnList.h"
34 #include "MeasureTableDelegate.h"
35 #include "AbstractTreeModel.h"
36 
37 
38 namespace Isis {
39  MeasureTableModel::MeasureTableModel(AbstractTreeModel *model) :
40  AbstractTableModel(model, new MeasureTableDelegate) {
41  connect(model, SIGNAL(filterCountsChanged(int, int)),
42  this, SLOT(calculateFilterCounts()));
43  connect(model,
44  SIGNAL(treeSelectionChanged(QList< AbstractTreeItem * >)),
45  this,
46  SLOT(handleTreeSelectionChanged(QList< AbstractTreeItem * >)));
47  }
48 
49 
50  MeasureTableModel::~MeasureTableModel() {
51  }
52 
53 
54  QList< AbstractTreeItem * > MeasureTableModel::getItems(
55  int start, int end) {
56  return getSortedItems(start, end, AbstractTreeModel::MeasureItems);
57  }
58 
59 
60  QList< AbstractTreeItem * > MeasureTableModel::getItems(
61  AbstractTreeItem *item1, AbstractTreeItem *item2) {
62  return getSortedItems(item1, item2, AbstractTreeModel::MeasureItems);
63  }
64 
65 
66  int MeasureTableModel::getVisibleRowCount() const {
67  return getDataModel()->getVisibleItemCount(
68  AbstractTreeModel::MeasureItems, true);
69  }
70 
71 
72  QList< AbstractTreeItem * > MeasureTableModel::getSelectedItems() {
73  return getDataModel()->getSelectedItems(
74  AbstractTreeModel::MeasureItems, true);
75  }
76 
77 
78  QString MeasureTableModel::getWarningMessage(AbstractTreeItem const *row,
79  TableColumn const *column, QString valueToSave) const {
80  return getMeasureWarningMessage(row, column, valueToSave);
81  }
82 
83 
84  void MeasureTableModel::setGlobalSelection(bool selected) {
85  return getDataModel()->setGlobalSelection(selected,
86  AbstractTreeModel::MeasureItems);
87  }
88 
89 
90  void MeasureTableModel::calculateFilterCounts() {
91  int visible = getDataModel()->getVisibleItemCount(
92  AbstractTreeModel::MeasureItems, true);
93  int total = getDataModel()->getItemCount(
94  AbstractTreeModel::MeasureItems);
95 
96  emit filterCountsChanged(visible, total);
97  }
98 
99 
100  int MeasureTableModel::indexOfVisibleItem(
101  AbstractTreeItem const *item) const {
102  return getDataModel()->indexOfVisibleItem(item,
103  AbstractTreeModel::MeasureItems, true);
104  }
105 
106 
107  QString MeasureTableModel::getMeasureWarningMessage(
108  AbstractTreeItem const *row, TableColumn const *column,
109  QString valueToSave) {
110  QString colTitle = column->getTitle();
111  AbstractMeasureItem::Column colType =
112  AbstractMeasureItem::getColumn(colTitle);
113 
114  QString warningText;
115 
116  if (colType == AbstractMeasureItem::EditLock &&
117  valueToSave.toLower() == "no" &&
118  row->getFormattedData(colTitle).toLower() == "yes") {
119  QString pointColTitle =
120  AbstractMeasureItem::getColumnName(AbstractMeasureItem::PointId);
121  warningText = "Are you sure you want to unlock control measure [" +
122  row->getFormattedData() + "] in point [" +
123  row->getFormattedData(pointColTitle) + "] for editing?";
124  }
125 
126  return warningText;
127  }
128 
129 
130  void MeasureTableModel::handleTreeSelectionChanged(
131  QList< AbstractTreeItem * > newlySelectedItems) {
132  AbstractTableModel::handleTreeSelectionChanged(
133  newlySelectedItems, AbstractTreeItem::Measure);
134  }
135 
136 
137  TableColumnList *MeasureTableModel::createColumns() {
138  return AbstractMeasureItem::createColumns();
139  }
140 }
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16