11 #include "MeasureTableModel.h"
17 #include <QMessageBox>
18 #include <QStringList>
21 #include "ControlMeasure.h"
22 #include "ControlMeasure.h"
24 #include "IException.h"
27 #include "Longitude.h"
28 #include "SpecialPixel.h"
30 #include "AbstractTableDelegate.h"
31 #include "AbstractMeasureItem.h"
32 #include "TableColumn.h"
33 #include "TableColumnList.h"
34 #include "MeasureTableDelegate.h"
35 #include "AbstractTreeModel.h"
39 MeasureTableModel::MeasureTableModel(AbstractTreeModel *model) :
40 AbstractTableModel(model, new MeasureTableDelegate) {
41 connect(model, SIGNAL(filterCountsChanged(
int,
int)),
42 this, SLOT(calculateFilterCounts()));
50 MeasureTableModel::~MeasureTableModel() {
56 return getSortedItems(start, end, AbstractTreeModel::MeasureItems);
61 AbstractTreeItem *item1, AbstractTreeItem *item2) {
62 return getSortedItems(item1, item2, AbstractTreeModel::MeasureItems);
66 int MeasureTableModel::getVisibleRowCount()
const {
67 return getDataModel()->getVisibleItemCount(
68 AbstractTreeModel::MeasureItems,
true);
73 return getDataModel()->getSelectedItems(
74 AbstractTreeModel::MeasureItems,
true);
78 QString MeasureTableModel::getWarningMessage(AbstractTreeItem
const *row,
79 TableColumn
const *column, QString valueToSave)
const {
80 return getMeasureWarningMessage(row, column, valueToSave);
84 void MeasureTableModel::setGlobalSelection(
bool selected) {
85 return getDataModel()->setGlobalSelection(selected,
86 AbstractTreeModel::MeasureItems);
90 void MeasureTableModel::calculateFilterCounts() {
91 int visible = getDataModel()->getVisibleItemCount(
92 AbstractTreeModel::MeasureItems,
true);
93 int total = getDataModel()->getItemCount(
94 AbstractTreeModel::MeasureItems);
96 emit filterCountsChanged(visible, total);
100 int MeasureTableModel::indexOfVisibleItem(
101 AbstractTreeItem
const *item)
const {
102 return getDataModel()->indexOfVisibleItem(item,
103 AbstractTreeModel::MeasureItems,
true);
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);
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?";
130 void MeasureTableModel::handleTreeSelectionChanged(
132 AbstractTableModel::handleTreeSelectionChanged(
133 newlySelectedItems, AbstractTreeItem::Measure);
137 TableColumnList *MeasureTableModel::createColumns() {
138 return AbstractMeasureItem::createColumns();