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