Refactoring. VContainer is more independent now.
--HG-- branch : feature
This commit is contained in:
parent
4c7033492a
commit
8e8422c5fd
|
@ -27,10 +27,10 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vcontainer.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../libs/vgeometry/varc.h"
|
||||
#include "../libs/vgeometry/vsplinepath.h"
|
||||
#include "../../utils/logging.h"
|
||||
#include "vtranslatevars.h"
|
||||
|
||||
#include <QLineF>
|
||||
#include <QtAlgorithms>
|
||||
|
@ -47,8 +47,8 @@ QSet<const QString> VContainer::uniqueNames = QSet<const QString>();
|
|||
/**
|
||||
* @brief VContainer create empty container
|
||||
*/
|
||||
VContainer::VContainer()
|
||||
:d(new VContainerData)
|
||||
VContainer::VContainer(const VTranslateVars *trVars)
|
||||
:d(new VContainerData(trVars))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -384,10 +384,10 @@ void VContainer::UpdateDetail(quint32 id, const VDetail &detail)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VContainer::GetTableValue(const QString &name) const
|
||||
qreal VContainer::GetTableValue(const QString &name, MeasurementsType patternType) const
|
||||
{
|
||||
QSharedPointer<VVariable> m = GetVariable<VVariable>(name);
|
||||
if (qApp->patternType() == MeasurementsType::Standard)
|
||||
if (patternType == MeasurementsType::Standard)
|
||||
{
|
||||
m->SetValue(size(), height());
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ const QMap<QString, QSharedPointer<T> > VContainer::DataVar(const VarType &type)
|
|||
if (i.value()->GetType() == type)
|
||||
{
|
||||
QSharedPointer<T> var = GetVariable<T>(i.key());
|
||||
map.insert(qApp->TrVars()->VarToUser(i.key()), var);
|
||||
map.insert(d->trVars->VarToUser(i.key()), var);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include <QSet>
|
||||
#include <QSharedPointer>
|
||||
|
||||
class VTranslateVars;
|
||||
|
||||
#ifdef Q_CC_GNU
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
|
@ -49,14 +51,15 @@ class VContainerData : public QSharedData
|
|||
{
|
||||
public:
|
||||
|
||||
VContainerData()
|
||||
VContainerData(const VTranslateVars *trVars)
|
||||
:sizeName(size_M), heightName(height_M), gObjects(QHash<quint32, QSharedPointer<VGObject> >()),
|
||||
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()), details(QHash<quint32, VDetail>())
|
||||
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()), details(QHash<quint32, VDetail>()),
|
||||
trVars(trVars)
|
||||
{}
|
||||
|
||||
VContainerData(const VContainerData &data)
|
||||
:QSharedData(data), sizeName(data.sizeName), heightName(data.heightName), gObjects(data.gObjects),
|
||||
variables(data.variables), details(data.details)
|
||||
variables(data.variables), details(data.details), trVars(data.trVars)
|
||||
{}
|
||||
|
||||
virtual ~VContainerData();
|
||||
|
@ -76,6 +79,8 @@ public:
|
|||
* @brief details container of details
|
||||
*/
|
||||
QHash<quint32, VDetail> details;
|
||||
|
||||
const VTranslateVars *trVars;
|
||||
};
|
||||
|
||||
#ifdef Q_CC_GNU
|
||||
|
@ -89,7 +94,7 @@ class VContainer
|
|||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VContainer)
|
||||
public:
|
||||
VContainer();
|
||||
VContainer(const VTranslateVars *trVars);
|
||||
VContainer &operator=(const VContainer &data);
|
||||
VContainer(const VContainer &data);
|
||||
~VContainer();
|
||||
|
@ -98,7 +103,7 @@ public:
|
|||
const QSharedPointer<T> GeometricObject(const quint32 &id) const;
|
||||
const QSharedPointer<VGObject> GetGObject(quint32 id) const;
|
||||
const VDetail GetDetail(quint32 id) const;
|
||||
qreal GetTableValue(const QString& name) const;
|
||||
qreal GetTableValue(const QString& name, MeasurementsType patternType) const;
|
||||
template <typename T>
|
||||
QSharedPointer<T> GetVariable(QString name) const;
|
||||
static quint32 getId();
|
||||
|
|
|
@ -214,7 +214,8 @@ void DialogIncrements::FillMeasurements()
|
|||
if (qApp->patternType() == MeasurementsType::Standard)
|
||||
{
|
||||
QTableWidgetItem *item = new QTableWidgetItem(qApp->LocaleToString(
|
||||
data->GetTableValue(qApp->TrVars()->VarFromUser(iMap.key()))));
|
||||
data->GetTableValue(qApp->TrVars()->VarFromUser(iMap.key()),
|
||||
qApp->patternType())));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
SetItemViewOnly(item);
|
||||
ui->tableWidgetMeasurements->setItem(currentRow, 1, item);// calculated value
|
||||
|
@ -286,7 +287,7 @@ void DialogIncrements::FillIncrements()
|
|||
|
||||
if (qApp->patternType() == MeasurementsType::Standard)
|
||||
{
|
||||
item = new QTableWidgetItem(qApp->LocaleToString(data->GetTableValue(iMap.value())));
|
||||
item = new QTableWidgetItem(qApp->LocaleToString(data->GetTableValue(iMap.value(), qApp->patternType())));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
SetItemViewOnly(item);
|
||||
ui->tableWidgetIncrement->setItem(currentRow, 1, item);
|
||||
|
|
|
@ -137,7 +137,8 @@ void DialogEditWrongFormula::ValChenged(int row)
|
|||
{
|
||||
const QString name = qApp->TrVars()->VarFromUser(item->text());
|
||||
const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(name))
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(data->GetTableValue(name, qApp->patternType()))
|
||||
.arg(stable->GetGuiText());
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
|
@ -145,7 +146,8 @@ void DialogEditWrongFormula::ValChenged(int row)
|
|||
if (ui->radioButtonIncrements->isChecked())
|
||||
{
|
||||
const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text());
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(item->text()))
|
||||
const QString desc = QString("%1(%2) - %3").arg(item->text())
|
||||
.arg(data->GetTableValue(item->text(), qApp->patternType()))
|
||||
.arg(incr->GetDescription());
|
||||
ui->labelDescription->setText(desc);
|
||||
return;
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
|
||||
: QMainWindow(parent), listDetails(QVector<VLayoutDetail>()), currentScene(nullptr), tempSceneLayout(nullptr),
|
||||
pattern(new VContainer()), doc(nullptr), papers(QList<QGraphicsItem *>()), shadows(QList<QGraphicsItem *>()),
|
||||
pattern(new VContainer(qApp->TrVars())), doc(nullptr), papers(QList<QGraphicsItem *>()), shadows(QList<QGraphicsItem *>()),
|
||||
scenes(QList<QGraphicsScene *>()), details(QList<QList<QGraphicsItem *> >()), undoAction(nullptr),
|
||||
redoAction(nullptr), actionDockWidgetToolOptions(nullptr), curFile(QString()), isLayoutStale(true), isTiled(false)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user