Continue improving dialog Dimension restrictions.
This commit is contained in:
parent
4a1d20810c
commit
4a12c1ca74
|
@ -28,6 +28,55 @@
|
||||||
#include "dialogrestrictdimension.h"
|
#include "dialogrestrictdimension.h"
|
||||||
#include "ui_dialogrestrictdimension.h"
|
#include "ui_dialogrestrictdimension.h"
|
||||||
|
|
||||||
|
#include <QTableWidgetItem>
|
||||||
|
|
||||||
|
#include "../vpatterndb/variables/vmeasurement.h"
|
||||||
|
#include "../vwidgets/vdecorationaligningdelegate.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<int> FilterByMinimum(const QVector<int> &base, int restriction)
|
||||||
|
{
|
||||||
|
if (restriction <= 0)
|
||||||
|
{
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<int> filtered;
|
||||||
|
filtered.reserve(base.size());
|
||||||
|
for(auto &b : base)
|
||||||
|
{
|
||||||
|
if (b >= restriction)
|
||||||
|
{
|
||||||
|
filtered.append(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<int> FilterByMaximum(const QVector<int> &base, int restriction)
|
||||||
|
{
|
||||||
|
if (restriction <= 0)
|
||||||
|
{
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<int> filtered;
|
||||||
|
filtered.reserve(base.size());
|
||||||
|
for(auto &b : base)
|
||||||
|
{
|
||||||
|
if (b <= restriction)
|
||||||
|
{
|
||||||
|
filtered.append(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogRestrictDimension::DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions,
|
DialogRestrictDimension::DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions,
|
||||||
const QMap<QString, QPair<int, int>> &restrictions,
|
const QMap<QString, QPair<int, int>> &restrictions,
|
||||||
|
@ -41,6 +90,22 @@ DialogRestrictDimension::DialogRestrictDimension(const QList<MeasurementDimensio
|
||||||
m_restrictions(restrictions)
|
m_restrictions(restrictions)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->tableWidget->setItemDelegate(
|
||||||
|
new VDecorationAligningDelegate(Qt::AlignHCenter | Qt::AlignCenter, ui->tableWidget));
|
||||||
|
|
||||||
|
connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &DialogRestrictDimension::RowSelected);
|
||||||
|
|
||||||
|
connect(ui->comboBoxDimensionA, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&DialogRestrictDimension::DimensionAChanged);
|
||||||
|
|
||||||
|
connect(ui->comboBoxMin, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&DialogRestrictDimension::MinRestrictionChanged);
|
||||||
|
connect(ui->comboBoxMax, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&DialogRestrictDimension::MaxRestrictionChanged);
|
||||||
|
|
||||||
|
InitDimensionsBaseValues();
|
||||||
|
InitTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -48,3 +113,480 @@ DialogRestrictDimension::~DialogRestrictDimension()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::changeEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::LanguageChange)
|
||||||
|
{
|
||||||
|
// retranslate designer form (single inheritance approach)
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
|
||||||
|
auto RetranslateControls = [this](int index, QLabel *name, QComboBox *control)
|
||||||
|
{
|
||||||
|
SCASSERT(name != nullptr)
|
||||||
|
SCASSERT(control != nullptr)
|
||||||
|
|
||||||
|
if (m_dimensions.size() > index)
|
||||||
|
{
|
||||||
|
MeasurementDimension_p dimension = m_dimensions.at(index);
|
||||||
|
|
||||||
|
name->setText(VAbstartMeasurementDimension::DimensionName(dimension->Type())+QChar(':'));
|
||||||
|
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension->Type(),
|
||||||
|
dimension->IsCircumference(),
|
||||||
|
m_fullCircumference));
|
||||||
|
|
||||||
|
InitDimensionGradation(dimension, control);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (not m_oneDimesionRestriction)
|
||||||
|
{
|
||||||
|
RetranslateControls(0, ui->labelDimensionA, ui->comboBoxDimensionA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remember to call base class implementation
|
||||||
|
QDialog::changeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::RowSelected()
|
||||||
|
{
|
||||||
|
EnableRestrictionControls(false);
|
||||||
|
|
||||||
|
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
int base1 = 0;
|
||||||
|
int base2 = 0;
|
||||||
|
MeasurementDimension_p dimension;
|
||||||
|
|
||||||
|
if (m_oneDimesionRestriction)
|
||||||
|
{
|
||||||
|
base1 = item->data(Qt::UserRole).toInt();
|
||||||
|
|
||||||
|
if (m_dimensions.size() > 1)
|
||||||
|
{
|
||||||
|
dimension = m_dimensions.at(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||||
|
base2 = item->data(Qt::UserRole).toInt();
|
||||||
|
|
||||||
|
if (m_dimensions.size() > 2)
|
||||||
|
{
|
||||||
|
dimension = m_dimensions.at(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<int, int> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2),
|
||||||
|
QPair<int, int>(0, 0));
|
||||||
|
|
||||||
|
if (dimension.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<int> bases = dimension->ValidBases();
|
||||||
|
|
||||||
|
ui->comboBoxMin->blockSignals(true);
|
||||||
|
ui->comboBoxMin->clear();
|
||||||
|
QVector<int> filtered = FilterByMaximum(bases, restriction.second);
|
||||||
|
FillBases(filtered, dimension, ui->comboBoxMin);
|
||||||
|
int index = ui->comboBoxMin->findData(restriction.first);
|
||||||
|
ui->comboBoxMin->setCurrentIndex(index != -1 ? index : 0);
|
||||||
|
ui->comboBoxMin->blockSignals(false);
|
||||||
|
|
||||||
|
ui->comboBoxMax->blockSignals(true);
|
||||||
|
ui->comboBoxMax->clear();
|
||||||
|
filtered = FilterByMinimum(bases, restriction.first);
|
||||||
|
FillBases(FilterByMinimum(bases, restriction.first), dimension, ui->comboBoxMax);
|
||||||
|
index = ui->comboBoxMax->findData(restriction.second);
|
||||||
|
ui->comboBoxMax->setCurrentIndex(index != -1 ? index : ui->comboBoxMax->count() - 1);
|
||||||
|
ui->comboBoxMax->blockSignals(false);
|
||||||
|
|
||||||
|
EnableRestrictionControls(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::DimensionAChanged()
|
||||||
|
{
|
||||||
|
InitTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::MinRestrictionChanged()
|
||||||
|
{
|
||||||
|
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
int base1 = 0;
|
||||||
|
int base2 = 0;
|
||||||
|
|
||||||
|
if (m_oneDimesionRestriction)
|
||||||
|
{
|
||||||
|
base1 = item->data(Qt::UserRole).toInt();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||||
|
base2 = item->data(Qt::UserRole).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString coordinates = VMeasurement::CorrectionHash(base1, base2);
|
||||||
|
QPair<int, int> restriction = m_restrictions.value(coordinates, QPair<int, int>(0, 0));
|
||||||
|
|
||||||
|
restriction.first = ui->comboBoxMin->currentData().toInt();
|
||||||
|
m_restrictions.insert(coordinates, restriction);
|
||||||
|
|
||||||
|
const int currentRow = ui->tableWidget->currentRow();
|
||||||
|
RefreshTable();
|
||||||
|
|
||||||
|
ui->tableWidget->blockSignals(true);
|
||||||
|
ui->tableWidget->selectRow(currentRow);
|
||||||
|
ui->tableWidget->blockSignals(false);
|
||||||
|
|
||||||
|
RowSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::MaxRestrictionChanged()
|
||||||
|
{
|
||||||
|
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
int base1 = 0;
|
||||||
|
int base2 = 0;
|
||||||
|
|
||||||
|
if (m_oneDimesionRestriction)
|
||||||
|
{
|
||||||
|
base1 = item->data(Qt::UserRole).toInt();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||||
|
base2 = item->data(Qt::UserRole).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString coordinates = VMeasurement::CorrectionHash(base1, base2);
|
||||||
|
QPair<int, int> restriction = m_restrictions.value(coordinates, QPair<int, int>(0, 0));
|
||||||
|
|
||||||
|
restriction.second = ui->comboBoxMax->currentData().toInt();
|
||||||
|
m_restrictions.insert(coordinates, restriction);
|
||||||
|
|
||||||
|
const int currentRow = ui->tableWidget->currentRow();
|
||||||
|
RefreshTable();
|
||||||
|
|
||||||
|
ui->tableWidget->blockSignals(true);
|
||||||
|
ui->tableWidget->selectRow(currentRow);
|
||||||
|
ui->tableWidget->blockSignals(false);
|
||||||
|
|
||||||
|
RowSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::InitDimensionsBaseValues()
|
||||||
|
{
|
||||||
|
auto DimensionsBaseValue = [this](int index, QLabel *name, QComboBox *control)
|
||||||
|
{
|
||||||
|
SCASSERT(name != nullptr)
|
||||||
|
SCASSERT(control != nullptr)
|
||||||
|
|
||||||
|
if (m_dimensions.size() > index)
|
||||||
|
{
|
||||||
|
MeasurementDimension_p dimension = m_dimensions.at(index);
|
||||||
|
const QString unit = UnitsToStr(dimension->Units(), true);
|
||||||
|
name->setText(VAbstartMeasurementDimension::DimensionName(dimension->Type())+QChar(':'));
|
||||||
|
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension->Type(),
|
||||||
|
dimension->IsCircumference(),
|
||||||
|
m_fullCircumference));
|
||||||
|
|
||||||
|
InitDimensionGradation(dimension, control);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (not m_oneDimesionRestriction)
|
||||||
|
{
|
||||||
|
if (m_dimensions.size() > 0)
|
||||||
|
{
|
||||||
|
DimensionsBaseValue(0, ui->labelDimensionA, ui->comboBoxDimensionA);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->labelDimensionA->setVisible(false);
|
||||||
|
ui->comboBoxDimensionA->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->labelDimensionA->setVisible(false);
|
||||||
|
ui->comboBoxDimensionA->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::InitDimensionGradation(const MeasurementDimension_p &dimension, QComboBox *control)
|
||||||
|
{
|
||||||
|
SCASSERT(control != nullptr)
|
||||||
|
|
||||||
|
int current = -1;
|
||||||
|
if (control->currentIndex() != -1)
|
||||||
|
{
|
||||||
|
current = control->currentData().toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
control->blockSignals(true);
|
||||||
|
control->clear();
|
||||||
|
|
||||||
|
FillBases(dimension->ValidBases(), dimension, control);
|
||||||
|
|
||||||
|
int i = control->findData(current);
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
control->setCurrentIndex(i);
|
||||||
|
control->blockSignals(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
control->blockSignals(false);
|
||||||
|
control->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::InitTable()
|
||||||
|
{
|
||||||
|
ui->tableWidget->blockSignals(true);
|
||||||
|
ui->tableWidget->clear();
|
||||||
|
|
||||||
|
auto InitHeaders = [this](int index)
|
||||||
|
{
|
||||||
|
if (m_dimensions.size() > index)
|
||||||
|
{
|
||||||
|
MeasurementDimension_p dimensionA = m_dimensions.at(index-1);
|
||||||
|
const QVector<int> basesA = dimensionA->ValidBases();
|
||||||
|
ui->tableWidget->setRowCount(basesA.size());
|
||||||
|
ui->tableWidget->setVerticalHeaderLabels(DimensionLabels(basesA, dimensionA));
|
||||||
|
|
||||||
|
MeasurementDimension_p dimensionB = m_dimensions.at(index);
|
||||||
|
const QVector<int> basesB = dimensionB->ValidBases();
|
||||||
|
ui->tableWidget->setColumnCount(basesB.size());
|
||||||
|
ui->tableWidget->setHorizontalHeaderLabels(DimensionLabels(basesB, dimensionB));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
InitHeaders(m_oneDimesionRestriction ? 1 : 2);
|
||||||
|
ui->tableWidget->blockSignals(false);
|
||||||
|
|
||||||
|
RefreshTable();
|
||||||
|
ui->tableWidget->selectRow(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::RefreshTable()
|
||||||
|
{
|
||||||
|
QVector<int> basesRow;
|
||||||
|
QVector<int> basesColumn;
|
||||||
|
|
||||||
|
if (m_oneDimesionRestriction)
|
||||||
|
{
|
||||||
|
if (m_dimensions.size() >= 2)
|
||||||
|
{
|
||||||
|
MeasurementDimension_p dimensionA = m_dimensions.at(0);
|
||||||
|
basesRow = dimensionA->ValidBases();
|
||||||
|
|
||||||
|
MeasurementDimension_p dimensionB = m_dimensions.at(1);
|
||||||
|
basesColumn = dimensionB->ValidBases();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_dimensions.size() >= 3)
|
||||||
|
{
|
||||||
|
MeasurementDimension_p dimensionA = m_dimensions.at(1);
|
||||||
|
basesRow = dimensionA->ValidBases();
|
||||||
|
|
||||||
|
MeasurementDimension_p dimensionB = m_dimensions.at(2);
|
||||||
|
basesColumn = dimensionB->ValidBases();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tableWidget->blockSignals(true);
|
||||||
|
ui->tableWidget->clearContents();
|
||||||
|
|
||||||
|
for(int row=0; row < basesRow.size(); ++row)
|
||||||
|
{
|
||||||
|
for(int column=0; column < basesColumn.size(); ++column)
|
||||||
|
{
|
||||||
|
AddCell(row, column, basesRow.at(row), basesColumn.at(column));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
|
ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
|
|
||||||
|
ui->tableWidget->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::AddCell(int row, int column, int rowValue, int columnValue)
|
||||||
|
{
|
||||||
|
auto *item = new QTableWidgetItem();
|
||||||
|
item->setData(Qt::UserRole, rowValue);
|
||||||
|
|
||||||
|
int base1 = 0;
|
||||||
|
int base2 = 0;
|
||||||
|
|
||||||
|
if (m_oneDimesionRestriction)
|
||||||
|
{
|
||||||
|
base1 = rowValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||||
|
base2 = rowValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<int, int> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2),
|
||||||
|
QPair<int, int>(0, 0));
|
||||||
|
|
||||||
|
bool leftRestriction = true;
|
||||||
|
if (restriction.first > 0 && restriction.first <= restriction.second)
|
||||||
|
{
|
||||||
|
leftRestriction = columnValue >= restriction.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rightRestriction = true;
|
||||||
|
if (restriction.second > 0 && restriction.second >= restriction.first)
|
||||||
|
{
|
||||||
|
rightRestriction = columnValue <= restriction.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftRestriction && rightRestriction)
|
||||||
|
{
|
||||||
|
item->setIcon(QIcon("://icon/24x24/star.png"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item->setIcon(QIcon("://icon/24x24/close.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the item non-editable (view only), and non-selectable
|
||||||
|
Qt::ItemFlags flags = item->flags();
|
||||||
|
flags &= ~(Qt::ItemIsEditable); // reset/clear the flag
|
||||||
|
item->setFlags(flags);
|
||||||
|
|
||||||
|
ui->tableWidget->setItem(row, column, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::EnableRestrictionControls(bool enable)
|
||||||
|
{
|
||||||
|
if (not enable)
|
||||||
|
{
|
||||||
|
ui->comboBoxMin->blockSignals(true);
|
||||||
|
ui->comboBoxMin->setCurrentIndex(-1);
|
||||||
|
ui->comboBoxMin->blockSignals(false);
|
||||||
|
|
||||||
|
ui->comboBoxMax->blockSignals(true);
|
||||||
|
ui->comboBoxMax->setCurrentIndex(-1);
|
||||||
|
ui->comboBoxMax->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->groupBoxRestriction->setEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRestrictDimension::FillBases(const QVector<int> &bases, const MeasurementDimension_p &dimension,
|
||||||
|
QComboBox *control)
|
||||||
|
{
|
||||||
|
SCASSERT(control != nullptr)
|
||||||
|
|
||||||
|
const QString units = UnitsToStr(dimension->Units(), true);
|
||||||
|
|
||||||
|
if (dimension->Type() == MeasurementDimension::X)
|
||||||
|
{
|
||||||
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
control->addItem(QString("%1 %2").arg(base).arg(units), base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dimension->Type() == MeasurementDimension::Y)
|
||||||
|
{
|
||||||
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (dimension->IsCircumference())
|
||||||
|
{
|
||||||
|
control->addItem(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
control->addItem(QString::number(base), base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
||||||
|
{
|
||||||
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
control->addItem(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases, const MeasurementDimension_p &dimension)
|
||||||
|
{
|
||||||
|
const bool showUnits = dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X;
|
||||||
|
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
|
||||||
|
|
||||||
|
QStringList labels;
|
||||||
|
|
||||||
|
if (dimension->Type() == MeasurementDimension::X)
|
||||||
|
{
|
||||||
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
labels.append(QString("%1 %2").arg(base).arg(units));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dimension->Type() == MeasurementDimension::Y)
|
||||||
|
{
|
||||||
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (dimension->IsCircumference())
|
||||||
|
{
|
||||||
|
labels.append(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
labels.append(QString::number(base));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
||||||
|
{
|
||||||
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
labels.append(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
|
@ -35,9 +35,12 @@
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class DialogRestrictDimension;
|
class DialogRestrictDimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class QTableWidgetItem;
|
||||||
|
|
||||||
|
|
||||||
class DialogRestrictDimension : public QDialog
|
class DialogRestrictDimension : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -50,6 +53,15 @@ public:
|
||||||
|
|
||||||
QMap<QString, QPair<int, int> > Restrictions() const;
|
QMap<QString, QPair<int, int> > Restrictions() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void changeEvent(QEvent* event) override;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void RowSelected();
|
||||||
|
void DimensionAChanged();
|
||||||
|
void MinRestrictionChanged();
|
||||||
|
void MaxRestrictionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogRestrictDimension)
|
Q_DISABLE_COPY(DialogRestrictDimension)
|
||||||
Ui::DialogRestrictDimension *ui;
|
Ui::DialogRestrictDimension *ui;
|
||||||
|
@ -58,6 +70,20 @@ private:
|
||||||
bool m_fullCircumference;
|
bool m_fullCircumference;
|
||||||
QList<MeasurementDimension_p> m_dimensions;
|
QList<MeasurementDimension_p> m_dimensions;
|
||||||
QMap<QString, QPair<int, int>> m_restrictions;
|
QMap<QString, QPair<int, int>> m_restrictions;
|
||||||
|
|
||||||
|
void InitDimensionsBaseValues();
|
||||||
|
void InitDimensionGradation(const MeasurementDimension_p &dimension, QComboBox *control);
|
||||||
|
void InitTable();
|
||||||
|
|
||||||
|
void RefreshTable();
|
||||||
|
|
||||||
|
void AddCell(int row, int column, int rowValue, int columnValue);
|
||||||
|
|
||||||
|
void EnableRestrictionControls(bool enable);
|
||||||
|
|
||||||
|
void FillBases(const QVector<int> &bases, const MeasurementDimension_p &dimension, QComboBox *control);
|
||||||
|
|
||||||
|
QStringList DimensionLabels(const QVector<int> &bases, const MeasurementDimension_p &dimension);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -6,44 +6,22 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>844</width>
|
<width>699</width>
|
||||||
<height>683</height>
|
<height>566</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Restrict dimension</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../share/resources/tapeicon.qrc">
|
||||||
|
<normaloff>:/tapeicon/64x64/logo.png</normaloff>:/tapeicon/64x64/logo.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="1" column="3">
|
<item row="0" column="0">
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QComboBox" name="comboBoxDimensionB"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QComboBox" name="comboBoxDimensionA"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLabel" name="labelDimensioB">
|
|
||||||
<property name="text">
|
|
||||||
<string>Dimension B:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -62,21 +40,11 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="2">
|
||||||
<spacer name="horizontalSpacer_3">
|
<widget class="QComboBox" name="comboBoxDimensionA"/>
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="0" column="3">
|
||||||
<spacer name="horizontalSpacer_4">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -91,74 +59,73 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="splitter">
|
<widget class="QTableWidget" name="tableWidget">
|
||||||
<property name="orientation">
|
<property name="sizePolicy">
|
||||||
<enum>Qt::Vertical</enum>
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>4</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTableWidget" name="tableWidget">
|
<property name="editTriggers">
|
||||||
<property name="sizePolicy">
|
<set>QAbstractItemView::CurrentChanged|QAbstractItemView::SelectedClicked</set>
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
</property>
|
||||||
<horstretch>0</horstretch>
|
<property name="selectionMode">
|
||||||
<verstretch>4</verstretch>
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
</sizepolicy>
|
</property>
|
||||||
</property>
|
<property name="selectionBehavior">
|
||||||
</widget>
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
<widget class="QGroupBox" name="groupBoxRestriction">
|
</property>
|
||||||
<property name="enabled">
|
<property name="iconSize">
|
||||||
<bool>false</bool>
|
<size>
|
||||||
</property>
|
<width>24</width>
|
||||||
<property name="title">
|
<height>24</height>
|
||||||
<string>Restriction</string>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
</widget>
|
||||||
<item row="0" column="1">
|
</item>
|
||||||
<widget class="QComboBox" name="comboBoxMin"/>
|
<item>
|
||||||
</item>
|
<widget class="QGroupBox" name="groupBoxRestriction">
|
||||||
<item row="0" column="0">
|
<property name="enabled">
|
||||||
<widget class="QLabel" name="label_4">
|
<bool>false</bool>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Min:</string>
|
<property name="title">
|
||||||
</property>
|
<string>Restriction</string>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Max:</string>
|
<string>Min:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QComboBox" name="comboBoxMax"/>
|
<widget class="QComboBox" name="comboBoxMin"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<spacer name="horizontalSpacer_5">
|
<spacer name="horizontalSpacer_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="0" column="3">
|
||||||
<spacer name="horizontalSpacer_6">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string>Max:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
</widget>
|
||||||
<size>
|
</item>
|
||||||
<width>40</width>
|
<item row="0" column="4">
|
||||||
<height>20</height>
|
<widget class="QComboBox" name="comboBoxMax"/>
|
||||||
</size>
|
</item>
|
||||||
</property>
|
</layout>
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -173,7 +140,9 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../share/resources/tapeicon.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
|
|
|
@ -2548,8 +2548,10 @@ void TMainWindow::InitDimensionsBaseValue()
|
||||||
if (dimensions.size() > index)
|
if (dimensions.size() > index)
|
||||||
{
|
{
|
||||||
MeasurementDimension_p dimension = dimensions.at(index);
|
MeasurementDimension_p dimension = dimensions.at(index);
|
||||||
name->setText(DimensionName(dimension->Type())+QChar(':'));
|
name->setText(VAbstartMeasurementDimension::DimensionName(dimension->Type())+QChar(':'));
|
||||||
name->setToolTip(DimensionToolTip(dimension->Type(), dimension->IsCircumference()));
|
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension->Type(),
|
||||||
|
dimension->IsCircumference(),
|
||||||
|
m->IsFullCircumference()));
|
||||||
|
|
||||||
if (dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X)
|
if (dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X)
|
||||||
{
|
{
|
||||||
|
@ -2591,10 +2593,10 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
|
||||||
control->blockSignals(true);
|
control->blockSignals(true);
|
||||||
control->clear();
|
control->clear();
|
||||||
|
|
||||||
|
const QVector<int> bases = DimensionRestrictedValues(index, dimension);
|
||||||
|
|
||||||
if (dimension->Type() == MeasurementDimension::X)
|
if (dimension->Type() == MeasurementDimension::X)
|
||||||
{
|
{
|
||||||
const QVector<int> bases = DimensionRestrictedValues(index, dimension);
|
|
||||||
|
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
{
|
{
|
||||||
control->addItem(QString("%1 %2").arg(base).arg(unit), base);
|
control->addItem(QString("%1 %2").arg(base).arg(unit), base);
|
||||||
|
@ -2602,8 +2604,6 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
|
||||||
}
|
}
|
||||||
else if (dimension->Type() == MeasurementDimension::Y)
|
else if (dimension->Type() == MeasurementDimension::Y)
|
||||||
{
|
{
|
||||||
const QVector<int> bases = dimension->ValidBases();
|
|
||||||
|
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
{
|
{
|
||||||
if (dimension->IsCircumference())
|
if (dimension->IsCircumference())
|
||||||
|
@ -2618,8 +2618,6 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
|
||||||
}
|
}
|
||||||
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
||||||
{
|
{
|
||||||
const QVector<int> bases = dimension->ValidBases();
|
|
||||||
|
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
{
|
{
|
||||||
control->addItem(QString("%1 %2").arg(fc ? base*2 : base).arg(unit), base);
|
control->addItem(QString("%1 %2").arg(fc ? base*2 : base).arg(unit), base);
|
||||||
|
@ -2653,13 +2651,15 @@ void TMainWindow::InitDimensionControls()
|
||||||
|
|
||||||
if (name == nullptr)
|
if (name == nullptr)
|
||||||
{
|
{
|
||||||
name = new QLabel(DimensionName(dimension->Type())+QChar(':'));
|
name = new QLabel(VAbstartMeasurementDimension::DimensionName(dimension->Type())+QChar(':'));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name->setText(DimensionName(dimension->Type())+QChar(':'));
|
name->setText(VAbstartMeasurementDimension::DimensionName(dimension->Type())+QChar(':'));
|
||||||
}
|
}
|
||||||
name->setToolTip(DimensionToolTip(dimension->Type(), dimension->IsCircumference()));
|
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension->Type(),
|
||||||
|
dimension->IsCircumference(),
|
||||||
|
m->IsFullCircumference()));
|
||||||
|
|
||||||
if (control == nullptr)
|
if (control == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -2686,8 +2686,10 @@ void TMainWindow::InitDimesionShifts()
|
||||||
{
|
{
|
||||||
MeasurementDimension_p dimension = dimensions.at(index);
|
MeasurementDimension_p dimension = dimensions.at(index);
|
||||||
|
|
||||||
name->setText(tr("Shift (%1):").arg(DimensionName(dimension->Type())));
|
name->setText(tr("Shift (%1):").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
|
||||||
name->setToolTip(DimensionToolTip(dimension->Type(), dimension->IsCircumference()));
|
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension->Type(),
|
||||||
|
dimension->IsCircumference(),
|
||||||
|
m->IsFullCircumference()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2709,7 +2711,7 @@ void TMainWindow::InitTable()
|
||||||
{
|
{
|
||||||
MeasurementDimension_p dimension = dimensions.at(0);
|
MeasurementDimension_p dimension = dimensions.at(0);
|
||||||
ui->tableWidget->horizontalHeaderItem(ColumnShiftA)->setText(
|
ui->tableWidget->horizontalHeaderItem(ColumnShiftA)->setText(
|
||||||
tr("%1 shift").arg(DimensionName(dimension->Type())));
|
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dimensions.size() < 2)
|
if (dimensions.size() < 2)
|
||||||
|
@ -2720,7 +2722,7 @@ void TMainWindow::InitTable()
|
||||||
{
|
{
|
||||||
MeasurementDimension_p dimension = dimensions.at(1);
|
MeasurementDimension_p dimension = dimensions.at(1);
|
||||||
ui->tableWidget->horizontalHeaderItem(ColumnShiftB)->setText(
|
ui->tableWidget->horizontalHeaderItem(ColumnShiftB)->setText(
|
||||||
tr("%1 shift").arg(DimensionName(dimension->Type())));
|
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dimensions.size() < 3)
|
if (dimensions.size() < 3)
|
||||||
|
@ -2731,7 +2733,7 @@ void TMainWindow::InitTable()
|
||||||
{
|
{
|
||||||
MeasurementDimension_p dimension = dimensions.at(2);
|
MeasurementDimension_p dimension = dimensions.at(2);
|
||||||
ui->tableWidget->horizontalHeaderItem(ColumnShiftC)->setText(
|
ui->tableWidget->horizontalHeaderItem(ColumnShiftC)->setText(
|
||||||
tr("%1 shift").arg(DimensionName(dimension->Type())));
|
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3888,51 +3890,6 @@ void TMainWindow::SetCurrentPatternUnit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QString TMainWindow::DimensionName(MeasurementDimension type)
|
|
||||||
{
|
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
case MeasurementDimension::X:
|
|
||||||
return tr("Height");
|
|
||||||
case MeasurementDimension::Y:
|
|
||||||
return tr("Size");
|
|
||||||
case MeasurementDimension::W:
|
|
||||||
return tr("Hip");
|
|
||||||
case MeasurementDimension::Z:
|
|
||||||
return tr("Waist");
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QString TMainWindow::DimensionToolTip(MeasurementDimension type, bool circumference)
|
|
||||||
{
|
|
||||||
const bool fc = m->IsFullCircumference();
|
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
case MeasurementDimension::X:
|
|
||||||
return tr("Height");
|
|
||||||
case MeasurementDimension::Y:
|
|
||||||
if (circumference)
|
|
||||||
{
|
|
||||||
return fc ? tr("Chest full circumference") : tr("Chest half circumference");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return tr("Size");
|
|
||||||
}
|
|
||||||
return circumference ? tr("Chest circumference") : tr("Size");
|
|
||||||
case MeasurementDimension::W:
|
|
||||||
return fc ? tr("Hip full circumference") : tr("Hip half circumference");
|
|
||||||
case MeasurementDimension::Z:
|
|
||||||
return fc ? tr("Waist full circumference") : tr("Waist half circumference");
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::ShowDimensionControls()
|
void TMainWindow::ShowDimensionControls()
|
||||||
{
|
{
|
||||||
|
|
|
@ -240,9 +240,6 @@ private:
|
||||||
|
|
||||||
void SetCurrentPatternUnit();
|
void SetCurrentPatternUnit();
|
||||||
|
|
||||||
QString DimensionName(MeasurementDimension type);
|
|
||||||
QString DimensionToolTip(MeasurementDimension type, bool circumference);
|
|
||||||
|
|
||||||
void ShowDimensionControls();
|
void ShowDimensionControls();
|
||||||
void SetDimensionBases();
|
void SetDimensionBases();
|
||||||
void SetCurrentDimensionValues();
|
void SetCurrentDimensionValues();
|
||||||
|
|
|
@ -155,6 +155,50 @@ bool VAbstartMeasurementDimension::IsUnitsValid()
|
||||||
return m_units == Unit::Cm || m_units == Unit::Mm || m_units == Unit::Inch;
|
return m_units == Unit::Cm || m_units == Unit::Mm || m_units == Unit::Inch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstartMeasurementDimension::DimensionName(MeasurementDimension type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case MeasurementDimension::X:
|
||||||
|
return tr("Height");
|
||||||
|
case MeasurementDimension::Y:
|
||||||
|
return tr("Size");
|
||||||
|
case MeasurementDimension::W:
|
||||||
|
return tr("Hip");
|
||||||
|
case MeasurementDimension::Z:
|
||||||
|
return tr("Waist");
|
||||||
|
default:
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstartMeasurementDimension::DimensionToolTip(MeasurementDimension type, bool circumference, bool fc)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case MeasurementDimension::X:
|
||||||
|
return tr("Height");
|
||||||
|
case MeasurementDimension::Y:
|
||||||
|
if (circumference)
|
||||||
|
{
|
||||||
|
return fc ? tr("Chest full circumference") : tr("Chest half circumference");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return tr("Size");
|
||||||
|
}
|
||||||
|
return circumference ? tr("Chest circumference") : tr("Size");
|
||||||
|
case MeasurementDimension::W:
|
||||||
|
return fc ? tr("Hip full circumference") : tr("Hip half circumference");
|
||||||
|
case MeasurementDimension::Z:
|
||||||
|
return fc ? tr("Waist full circumference") : tr("Waist half circumference");
|
||||||
|
default:
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// VXMeasurementDimension
|
// VXMeasurementDimension
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VXMeasurementDimension::VXMeasurementDimension(Unit units)
|
VXMeasurementDimension::VXMeasurementDimension(Unit units)
|
||||||
|
|
|
@ -83,6 +83,9 @@ public:
|
||||||
QVector<int> ValidBases() const;
|
QVector<int> ValidBases() const;
|
||||||
QStringList ValidBasesList() const;
|
QStringList ValidBasesList() const;
|
||||||
|
|
||||||
|
static QString DimensionName(MeasurementDimension type);
|
||||||
|
static QString DimensionToolTip(MeasurementDimension type, bool circumference, bool fc);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Unit m_units{Unit::Cm};
|
Unit m_units{Unit::Cm};
|
||||||
int m_minValue{0};
|
int m_minValue{0};
|
||||||
|
|
|
@ -89,5 +89,9 @@
|
||||||
<file>icon/32x32/broken_link@2x.png</file>
|
<file>icon/32x32/broken_link@2x.png</file>
|
||||||
<file>icon/32x32/link.png</file>
|
<file>icon/32x32/link.png</file>
|
||||||
<file>icon/32x32/link@2x.png</file>
|
<file>icon/32x32/link@2x.png</file>
|
||||||
|
<file>icon/24x24/star.png</file>
|
||||||
|
<file>icon/24x24/star@2x.png</file>
|
||||||
|
<file>icon/24x24/close.png</file>
|
||||||
|
<file>icon/24x24/close@2x.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
src/libs/vmisc/share/resources/icon/24x24/close.png
Normal file
BIN
src/libs/vmisc/share/resources/icon/24x24/close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 548 B |
BIN
src/libs/vmisc/share/resources/icon/24x24/close@2x.png
Normal file
BIN
src/libs/vmisc/share/resources/icon/24x24/close@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 753 B |
BIN
src/libs/vmisc/share/resources/icon/24x24/star.png
Normal file
BIN
src/libs/vmisc/share/resources/icon/24x24/star.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 659 B |
BIN
src/libs/vmisc/share/resources/icon/24x24/star@2x.png
Normal file
BIN
src/libs/vmisc/share/resources/icon/24x24/star@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 827 B |
|
@ -119,7 +119,7 @@ public:
|
||||||
static QStringList WholeListSizes(Unit patternUnit);
|
static QStringList WholeListSizes(Unit patternUnit);
|
||||||
static bool IsGradationSizeValid(const QString &size);
|
static bool IsGradationSizeValid(const QString &size);
|
||||||
static bool IsGradationHeightValid(const QString &height);
|
static bool IsGradationHeightValid(const QString &height);
|
||||||
static QString CorrectionHash(qreal baseA, qreal baseB, qreal baseC);
|
static QString CorrectionHash(qreal baseA, qreal baseB=0, qreal baseC=0);
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VMeasurementData> d;
|
QSharedDataPointer<VMeasurementData> d;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class VComboBoxDelegate : public QItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VComboBoxDelegate(const QStringList &items, QObject *parent = nullptr);
|
explicit VComboBoxDelegate(const QStringList &items, QObject *parent = nullptr);
|
||||||
|
|
||||||
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const override;
|
const QModelIndex &index) const override;
|
||||||
|
|
48
src/libs/vwidgets/vdecorationaligningdelegate.cpp
Normal file
48
src/libs/vwidgets/vdecorationaligningdelegate.cpp
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vdecorationaligningdelegate.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 6 10, 2020
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2020 Valentina project
|
||||||
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
#include "vdecorationaligningdelegate.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VDecorationAligningDelegate::VDecorationAligningDelegate(Qt::Alignment alignment, QObject *parent)
|
||||||
|
: QStyledItemDelegate(parent), m_alignment(alignment)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDecorationAligningDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
QIcon icon = QIcon(qvariant_cast<QIcon>(index.data(Qt::DecorationRole)));
|
||||||
|
|
||||||
|
if (option.state & QStyle::State_Selected)
|
||||||
|
{
|
||||||
|
painter->fillRect(option.rect, option.palette.highlight());
|
||||||
|
}
|
||||||
|
|
||||||
|
icon.paint(painter, option.rect, m_alignment);
|
||||||
|
}
|
57
src/libs/vwidgets/vdecorationaligningdelegate.h
Normal file
57
src/libs/vwidgets/vdecorationaligningdelegate.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vdecorationaligningdelegate.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 6 10, 2020
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2020 Valentina project
|
||||||
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
#ifndef VDECORATIONALIGNINGDELEGATE_H
|
||||||
|
#define VDECORATIONALIGNINGDELEGATE_H
|
||||||
|
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VDecorationAligningDelegate : public QStyledItemDelegate
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit VDecorationAligningDelegate(Qt::Alignment alignment, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
Qt::Alignment Alignment() const;
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VDecorationAligningDelegate)
|
||||||
|
Qt::Alignment const m_alignment;
|
||||||
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline Qt::Alignment VDecorationAligningDelegate::Alignment() const
|
||||||
|
{
|
||||||
|
return m_alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // VDECORATIONALIGNINGDELEGATE_H
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/vcomboboxdelegate.cpp \
|
$$PWD/vcomboboxdelegate.cpp \
|
||||||
|
$$PWD/vdecorationaligningdelegate.cpp \
|
||||||
$$PWD/velidedlabel.cpp \
|
$$PWD/velidedlabel.cpp \
|
||||||
$$PWD/vmaingraphicsscene.cpp \
|
$$PWD/vmaingraphicsscene.cpp \
|
||||||
$$PWD/vmaingraphicsview.cpp \
|
$$PWD/vmaingraphicsview.cpp \
|
||||||
|
@ -33,6 +34,7 @@ SOURCES += \
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/stable.h \
|
$$PWD/stable.h \
|
||||||
$$PWD/vcomboboxdelegate.h \
|
$$PWD/vcomboboxdelegate.h \
|
||||||
|
$$PWD/vdecorationaligningdelegate.h \
|
||||||
$$PWD/velidedlabel.h \
|
$$PWD/velidedlabel.h \
|
||||||
$$PWD/vmaingraphicsscene.h \
|
$$PWD/vmaingraphicsscene.h \
|
||||||
$$PWD/vmaingraphicsview.h \
|
$$PWD/vmaingraphicsview.h \
|
||||||
|
|
Loading…
Reference in New Issue
Block a user