9#include "MeasureTableDelegate.h"
20#include "ControlMeasure.h"
21#include "ControlMeasure.h"
22#include "IException.h"
25#include "AbstractMeasureItem.h"
26#include "AbstractTreeItem.h"
27#include "MeasureTableModel.h"
28#include "TableColumn.h"
31 MeasureTableDelegate::MeasureTableDelegate() {
35 MeasureTableDelegate::~MeasureTableDelegate() {
39 QWidget *MeasureTableDelegate::getWidget(TableColumn
const *col)
41 AbstractMeasureItem::Column column =
42 AbstractMeasureItem::getColumn(col->getTitle());
45 case AbstractMeasureItem::Ignored:
46 case AbstractMeasureItem::EditLock: {
49 combo->insertItem(0,
"Yes");
50 combo->insertItem(1,
"No");
53 case AbstractMeasureItem::Type: {
56 combo->insertItem(0,
"Candidate");
57 combo->insertItem(1,
"Manual");
58 combo->insertItem(2,
"RegisteredPixel");
59 combo->insertItem(3,
"RegisteredSubPixel");
63 QLineEdit *lineEdit =
new QLineEdit;
68 IString msg =
"Could not create delegate widget for column ["
69 + col->getTitle() +
"]";
74 void MeasureTableDelegate::readData(
QWidget *widget,
75 AbstractTreeItem *row, TableColumn
const *col)
const {
76 AbstractMeasureItem::Column column =
77 AbstractMeasureItem::getColumn(col->getTitle());
79 QString data = row->getFormattedData(col->getTitle());
81 ControlMeasure *measure = (ControlMeasure *)row->getPointer();
84 case AbstractMeasureItem::EditLock: {
86 if (measure->IsEditLocked())
87 combo->setCurrentIndex(0);
89 combo->setCurrentIndex(1);
92 case AbstractMeasureItem::Ignored: {
94 if (measure->IsIgnored())
95 combo->setCurrentIndex(0);
97 combo->setCurrentIndex(1);
100 case AbstractMeasureItem::Type: {
102 combo->setCurrentIndex((
int) measure->StringToMeasureType(data));
106 QLineEdit *lineEdit =
static_cast< QLineEdit *
>(widget);
107 lineEdit->setText(data);
113 void MeasureTableDelegate::readData(
QWidget *widget,
114 AbstractTreeItem *row, TableColumn
const *col,
115 QString newData)
const {
116 AbstractMeasureItem::Column column =
117 AbstractMeasureItem::getColumn(col->getTitle());
119 QString data = row->getFormattedData(col->getTitle());
121 ControlMeasure *measure = (ControlMeasure *) row->getPointer();
124 case AbstractMeasureItem::EditLock: {
127 if (measure->IsEditLocked())
128 combo->setCurrentIndex(0);
130 combo->setCurrentIndex(1);
132 if (QString(
"yes").startsWith(newData.toLower()))
133 combo->setCurrentIndex(0);
134 else if (QString(
"no").startsWith(newData.toLower()))
135 combo->setCurrentIndex(1);
139 case AbstractMeasureItem::Ignored: {
142 if (measure->IsIgnored())
143 combo->setCurrentIndex(0);
145 combo->setCurrentIndex(1);
147 if (QString(
"yes").startsWith(newData.toLower()))
148 combo->setCurrentIndex(0);
149 if (QString(
"no").startsWith(newData.toLower()))
150 combo->setCurrentIndex(1);
154 case AbstractMeasureItem::Type: {
157 combo->setCurrentIndex((
int) measure->StringToMeasureType(data));
159 for (
int i = combo->count() - 1; i >= 0; --i)
160 if (combo->itemText(i).toLower().startsWith(newData.toLower()))
161 combo->setCurrentIndex(i);
166 QLineEdit *lineEdit =
static_cast< QLineEdit *
>(widget);
167 lineEdit->setText(newData);
173 void MeasureTableDelegate::saveData(
QWidget *widget,
174 AbstractTreeItem *row, TableColumn
const *col)
const {
175 AbstractMeasureItem::Column column =
176 AbstractMeasureItem::getColumn(col->getTitle());
180 case AbstractMeasureItem::EditLock:
181 case AbstractMeasureItem::Ignored:
182 case AbstractMeasureItem::Type: {
184 newData = combo->currentText();
188 QLineEdit *lineEdit =
static_cast< QLineEdit *
>(widget);
189 newData = lineEdit->text();
193 QString warningText = MeasureTableModel::getMeasureWarningMessage(
196 bool changeData =
true;
198 if (!warningText.isEmpty()) {
199 QMessageBox::StandardButton status = QMessageBox::warning(
200 NULL,
"Change cell?", warningText, QMessageBox::Yes |
203 changeData = (status == QMessageBox::Yes);
207 row->setData(col->getTitle(), newData);
@ Programmer
This error is for when a programmer made an API call that was illegal.
This is free and unencumbered software released into the public domain.