Improve code style, Wrap code for better readability

This commit is contained in:
Simon De Backer
2020-08-16 14:22:36 +02:00
parent 60a5a83320
commit 76d16ab600
3 changed files with 167 additions and 61 deletions

View File

@@ -46,7 +46,8 @@ namespace autonum
sequentialNumbers::~sequentialNumbers() {}
sequentialNumbers &sequentialNumbers::operator=(const sequentialNumbers &other)
sequentialNumbers &sequentialNumbers::operator=(
const sequentialNumbers &other)
{
if (&other == this || other == *this)
return (*this);
@@ -90,22 +91,41 @@ namespace autonum
@return A QDomElement, if this sequential have no value,
the returned QDomELement is empty
*/
QDomElement sequentialNumbers::toXml(QDomDocument &document, const QString& tag_name) const
QDomElement sequentialNumbers::toXml(QDomDocument &document,
const QString& tag_name) const
{
QDomElement element = document.createElement(tag_name);
if (!unit.isEmpty())
element.appendChild(QETXML::textToDomElement(document, "unit", unit.join(";")));
element.appendChild(QETXML::textToDomElement(
document,
"unit",
unit.join(";")));
if (!unit_folio.isEmpty())
element.appendChild(QETXML::textToDomElement(document, "unitFolio", unit_folio.join(";")));
element.appendChild(QETXML::textToDomElement(
document,
"unitFolio",
unit_folio.join(";")));
if(!ten.isEmpty())
element.appendChild(QETXML::textToDomElement(document, "ten", ten.join(";")));
element.appendChild(QETXML::textToDomElement(
document,
"ten",
ten.join(";")));
if(!ten_folio.isEmpty())
element.appendChild(QETXML::textToDomElement(document, "tenFolio", ten_folio.join(";")));
element.appendChild(QETXML::textToDomElement(
document,
"tenFolio",
ten_folio.join(";")));
if(!hundred.isEmpty())
element.appendChild(QETXML::textToDomElement(document, "hundred", hundred.join(";")));
element.appendChild(QETXML::textToDomElement(
document,
"hundred",
hundred.join(";")));
if(!hundred_folio.isEmpty())
element.appendChild(QETXML::textToDomElement(document, "hundredFolio", hundred_folio.join(";")));
element.appendChild(QETXML::textToDomElement(
document,
"hundredFolio",
hundred_folio.join(";")));
return element;
}
@@ -164,9 +184,15 @@ namespace autonum
@param elmt - parent element (if any) of the formula
@return the string with variable assigned.
*/
QString AssignVariables::formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt)
QString AssignVariables::formulaToLabel(QString formula,
sequentialNumbers &seqStruct,
Diagram *diagram,
const Element *elmt)
{
AssignVariables av(std::move(formula), seqStruct, diagram, elmt);
AssignVariables av(std::move(formula),
seqStruct,
diagram,
elmt);
seqStruct = av.m_seq_struct;
return av.m_assigned_label;
}
@@ -174,12 +200,13 @@ namespace autonum
/**
@brief AssignVariables::replaceVariable
Replace the variables in @formula in form %{my-var}
to the corresponding value stored in @dc
to the corresponding value stored in dc
@param formula
@param dc
@return
*/
QString AssignVariables::replaceVariable(const QString &formula, const DiagramContext &dc)
QString AssignVariables::replaceVariable(const QString &formula,
const DiagramContext &dc)
{
QString str = formula;
str.replace("%{label}", dc.value("label").toString());
@@ -188,13 +215,15 @@ namespace autonum
str.replace("%{description}", dc.value("description").toString());
str.replace("%{designation}", dc.value("designation").toString());
str.replace("%{manufacturer}", dc.value("manufacturer").toString());
str.replace("%{manufacturer_reference}", dc.value("manufacturer_reference").toString());
str.replace("%{manufacturer_reference}",
dc.value("manufacturer_reference").toString());
str.replace("%{supplier}", dc.value("supplier").toString());
str.replace("%{quantity}", dc.value("quantity").toString());
str.replace("%{unity}", dc.value("unity").toString());
str.replace("%{auxiliary1}", dc.value("auxiliary1").toString());
str.replace("%{auxiliary2}", dc.value("auxiliary2").toString());
str.replace("%{machine_manufacturer_reference}", dc.value("machine_manufacturer_reference").toString());
str.replace("%{machine_manufacturer_reference}",
dc.value("machine_manufacturer_reference").toString());
str.replace("%{location}", dc.value("location").toString());
str.replace("%{function}", dc.value("function").toString());
str.replace("%{void}", QString());
@@ -203,7 +232,10 @@ namespace autonum
}
AssignVariables::AssignVariables(const QString& formula, const sequentialNumbers& seqStruct , Diagram *diagram, const Element *elmt):
AssignVariables::AssignVariables(const QString& formula,
const sequentialNumbers& seqStruct,
Diagram *diagram,
const Element *elmt):
m_diagram(diagram),
m_arg_formula(formula),
m_assigned_label(formula),
@@ -213,12 +245,31 @@ namespace autonum
{
if (m_diagram)
{
m_assigned_label.replace("%F", m_diagram -> border_and_titleblock.folio());
m_assigned_label.replace("%f", QString::number(m_diagram->folioIndex()+1));
m_assigned_label.replace("%id", QString::number(m_diagram->folioIndex()+1));
m_assigned_label.replace("%total", QString::number(m_diagram->border_and_titleblock.folioTotal()));
m_assigned_label.replace("%M", m_diagram -> border_and_titleblock.plant());
m_assigned_label.replace("%LM", m_diagram -> border_and_titleblock.locmach());
m_assigned_label.replace("%F",
m_diagram
-> border_and_titleblock
.folio());
m_assigned_label.replace("%f",
QString::number(
m_diagram
->folioIndex()+1));
m_assigned_label.replace("%id",
QString::number(
m_diagram
->folioIndex()+1));
m_assigned_label.replace("%total",
QString::number(
m_diagram
->border_and_titleblock
.folioTotal()));
m_assigned_label.replace("%M",
m_diagram
-> border_and_titleblock
.plant());
m_assigned_label.replace("%LM",
m_diagram
-> border_and_titleblock
.locmach());
QSettings settings;
if (m_element)

View File

@@ -25,8 +25,8 @@ class QStackedWidget;
class QDialogButtonBox;
/**
This class represents the configuration dialog for QElectroTech.
It displays "configuration pages", each page having to provide an icon and
a title.
It displays "configuration pages",
each page having to provide an icon and a title.
*/
class ConfigDialog : public QDialog {
Q_OBJECT

View File

@@ -31,25 +31,80 @@ class Createdxf
static void dxfBegin (const QString&);
static void dxfEnd(const QString&);
// you can add more functions to create more drawings.
static void drawCircle(const QString&,double,double,double,int);
static void drawArc(const QString&,double x,double y,double rad,double startAngle,double endAngle,int color);
static void drawCircle(const QString&,
double,
double,
double,
int);
static void drawArc(const QString&,
double x,
double y,
double rad,
double startAngle,
double endAngle,
int color);
static void drawDonut(QString,double,double,double,int);
static void drawArcEllipse (const QString &file_path, qreal x, qreal y, qreal w, qreal h, qreal startAngle, qreal spanAngle, qreal hotspot_x, qreal hotspot_y, qreal rotation_angle, const int &colorcode);
static void drawArcEllipse (const QString &file_path,
qreal x,
qreal y,
qreal w,
qreal h,
qreal startAngle,
qreal spanAngle,
qreal hotspot_x,
qreal hotspot_y,
qreal rotation_angle,
const int &colorcode);
static void drawEllipse (const QString &filepath, const QRectF &rect, const int &colorcode);
static void drawEllipse (const QString &filepath,
const QRectF &rect,
const int &colorcode);
static void drawRectangle(const QString &filepath,double,double,double,double,const int &colorcode);
static void drawRectangle(const QString &filepath, const QRectF &rect, const int &colorcode);
static void drawRectangle(const QString &filepath,
double,
double,
double,
double,
const int &colorcode);
static void drawRectangle(const QString &filepath,
const QRectF &rect,
const int &colorcode);
static void drawLine(const QString &filapath,double,double,double,double, const int &clorcode);
static void drawLine(const QString &filepath, const QLineF &line,const int &colorcode);
static void drawLine(const QString &filapath,
double,
double,
double,
double,
const int &clorcode);
static void drawLine(const QString &filepath,
const QLineF &line,
const int &colorcode);
static void drawText(const QString&,const QString&,double,double,double,double,int);
static void drawTextAligned(const QString& fileName, const QString& text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign, int colour, bool leftAlign = false, float scale = 0);
static void drawText(const QString&,
const QString&,
double,double,
double,
double,
int);
static void drawTextAligned(const QString& fileName,
const QString& text,
double x,
double y,
double height,
double rotation,
double oblique,
int hAlign,
int vAlign,
double xAlign,
int colour,
bool leftAlign = false,
float scale = 0);
static int getcolorCode (const long red, const long green, const long blue);
static int getcolorCode (const long red,
const long green,
const long blue);
static long RGBcodeTable[];
static const double sheetWidth;