9#include "MeasureTableModel.h"
19#include "ControlMeasure.h"
20#include "ControlMeasure.h"
22#include "IException.h"
26#include "SpecialPixel.h"
28#include "AbstractTableDelegate.h"
29#include "AbstractMeasureItem.h"
30#include "TableColumn.h"
31#include "TableColumnList.h"
32#include "MeasureTableDelegate.h"
33#include "AbstractTreeModel.h"
37 MeasureTableModel::MeasureTableModel(AbstractTreeModel *model) :
38 AbstractTableModel(model, new MeasureTableDelegate) {
39 connect(model, SIGNAL(filterCountsChanged(
int,
int)),
40 this, SLOT(calculateFilterCounts()));
42 SIGNAL(treeSelectionChanged(QList< AbstractTreeItem * >)),
44 SLOT(handleTreeSelectionChanged(QList< AbstractTreeItem * >)));
48 MeasureTableModel::~MeasureTableModel() {
52 QList< AbstractTreeItem * > MeasureTableModel::getItems(
54 return getSortedItems(start, end, AbstractTreeModel::MeasureItems);
58 QList< AbstractTreeItem * > MeasureTableModel::getItems(
59 AbstractTreeItem *item1, AbstractTreeItem *item2) {
60 return getSortedItems(item1, item2, AbstractTreeModel::MeasureItems);
64 int MeasureTableModel::getVisibleRowCount()
const {
65 return getDataModel()->getVisibleItemCount(
66 AbstractTreeModel::MeasureItems,
true);
70 QList< AbstractTreeItem * > MeasureTableModel::getSelectedItems() {
71 return getDataModel()->getSelectedItems(
72 AbstractTreeModel::MeasureItems,
true);
76 QString MeasureTableModel::getWarningMessage(AbstractTreeItem
const *row,
77 TableColumn
const *column, QString valueToSave)
const {
78 return getMeasureWarningMessage(row, column, valueToSave);
82 void MeasureTableModel::setGlobalSelection(
bool selected) {
83 return getDataModel()->setGlobalSelection(selected,
84 AbstractTreeModel::MeasureItems);
88 void MeasureTableModel::calculateFilterCounts() {
89 int visible = getDataModel()->getVisibleItemCount(
90 AbstractTreeModel::MeasureItems,
true);
91 int total = getDataModel()->getItemCount(
92 AbstractTreeModel::MeasureItems);
94 emit filterCountsChanged(visible, total);
98 int MeasureTableModel::indexOfVisibleItem(
99 AbstractTreeItem
const *item)
const {
100 return getDataModel()->indexOfVisibleItem(item,
101 AbstractTreeModel::MeasureItems,
true);
105 QString MeasureTableModel::getMeasureWarningMessage(
106 AbstractTreeItem
const *row, TableColumn
const *column,
107 QString valueToSave) {
108 QString colTitle = column->getTitle();
109 AbstractMeasureItem::Column colType =
110 AbstractMeasureItem::getColumn(colTitle);
114 if (colType == AbstractMeasureItem::EditLock &&
115 valueToSave.toLower() ==
"no" &&
116 row->getFormattedData(colTitle).toLower() ==
"yes") {
117 QString pointColTitle =
118 AbstractMeasureItem::getColumnName(AbstractMeasureItem::PointId);
119 warningText =
"Are you sure you want to unlock control measure [" +
120 row->getFormattedData() +
"] in point [" +
121 row->getFormattedData(pointColTitle) +
"] for editing?";
128 void MeasureTableModel::handleTreeSelectionChanged(
129 QList< AbstractTreeItem * > newlySelectedItems) {
130 AbstractTableModel::handleTreeSelectionChanged(
131 newlySelectedItems, AbstractTreeItem::Measure);
135 TableColumnList *MeasureTableModel::createColumns() {
136 return AbstractMeasureItem::createColumns();
This is free and unencumbered software released into the public domain.