Wrap code for better readability

This commit is contained in:
Simon De Backer
2020-08-20 21:58:23 +02:00
parent 0c00d83b27
commit 331918d143
41 changed files with 716 additions and 190 deletions

View File

@@ -49,13 +49,24 @@ void NumerotationContext::clear () {
@param initialvalue
@return true if value is append
*/
bool NumerotationContext::addValue(const QString &type, const QVariant &value, const int increase, const int initialvalue) {
if (!keyIsAcceptable(type) && !value.canConvert(QVariant::String)) return false;
if (keyIsNumber(type) && !value.canConvert(QVariant::Int)) return false;
bool NumerotationContext::addValue(const QString &type,
const QVariant &value,
const int increase,
const int initialvalue) {
if (!keyIsAcceptable(type) && !value.canConvert(QVariant::String))
return false;
if (keyIsNumber(type) && !value.canConvert(QVariant::Int))
return false;
QString valuestr = value.toString();
valuestr.remove("|");
content_ << type + "|" + valuestr + "|" + QString::number(increase) + "|" + QString::number(initialvalue);
content_ << type
+ "|"
+ valuestr
+ "|"
+ QString::number(increase)
+ "|"
+ QString::number(initialvalue);
return true;
}

View File

@@ -33,7 +33,10 @@ class NumerotationContext
NumerotationContext ();
NumerotationContext (QDomElement &);
void clear();
bool addValue(const QString &, const QVariant & = QVariant(1), const int = 1, const int = 0);
bool addValue(const QString &,
const QVariant & = QVariant(1),
const int = 1,
const int = 0);
QString operator[] (const int &) const;
void operator << (const NumerotationContext &);
int size() const;

View File

@@ -37,10 +37,18 @@ NumPartEditorW::NumPartEditorW(int type, QWidget *parent) :
}
/**
@brief NumPartEditorW::NumPartEditorW
Constructor
Build with value of @context at position i
Build with value of context at position i
@param context
@param i
@param type
@param parent
*/
NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, int type, QWidget *parent):
NumPartEditorW::NumPartEditorW (NumerotationContext &context,
int i,
int type,
QWidget *parent):
QWidget(parent),
ui(new Ui::NumPartEditorW),
intValidator (new QIntValidator(0,99999,this)),
@@ -86,21 +94,40 @@ void NumPartEditorW::setVisibleItems()
QStringList items;
if (m_edited_type == 2)
{
items << tr("Chiffre 1") << tr("Chiffre 01")
<< tr("Chiffre 001")
<< tr("Texte");
items << tr("Chiffre 1")
<< tr("Chiffre 01")
<< tr("Chiffre 001")
<< tr("Texte");
}
else if (m_edited_type == 1)
{
items << tr("Chiffre 1") << tr("Chiffre 1 - Folio") << tr("Chiffre 01")
<< tr("Chiffre 01 - Folio") << tr("Chiffre 001") << tr("Chiffre 001 - Folio")
<< tr("Texte") << tr("N° folio") << tr("Folio") << tr("Installation") << tr("Locmach");
items << tr("Chiffre 1")
<< tr("Chiffre 1 - Folio")
<< tr("Chiffre 01")
<< tr("Chiffre 01 - Folio")
<< tr("Chiffre 001")
<< tr("Chiffre 001 - Folio")
<< tr("Texte")
<< tr("N° folio")
<< tr("Folio")
<< tr("Installation")
<< tr("Locmach");
}
else
items << tr("Chiffre 1") << tr("Chiffre 1 - Folio") << tr("Chiffre 01")
<< tr("Chiffre 01 - Folio") << tr("Chiffre 001") << tr("Chiffre 001 - Folio")
<< tr("Texte") << tr("N° folio") << tr("Folio") << tr("Installation") << tr("Locmach")
<< tr("Element Line") << tr("Element Column") << tr("Element Prefix");
items << tr("Chiffre 1")
<< tr("Chiffre 1 - Folio")
<< tr("Chiffre 01")
<< tr("Chiffre 01 - Folio")
<< tr("Chiffre 001")
<< tr("Chiffre 001 - Folio")
<< tr("Texte")
<< tr("N° folio")
<< tr("Folio")
<< tr("Installation")
<< tr("Locmach")
<< tr("Element Line")
<< tr("Element Column")
<< tr("Element Prefix");
ui->type_cb->insertItems(0,items);
}
@@ -155,10 +182,17 @@ NumerotationContext NumPartEditorW::toNumContext() {
type_str = "elementprefix";
break;
}
if (type_str == "unitfolio" || type_str == "tenfolio" || type_str == "hundredfolio")
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value(), ui->value_field->displayText().toInt());
if (type_str == "unitfolio"
|| type_str == "tenfolio"
|| type_str == "hundredfolio")
nc.addValue(type_str,
ui -> value_field -> displayText(),
ui -> increase_spinBox -> value(),
ui->value_field->displayText().toInt());
else
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value());
nc.addValue(type_str,
ui -> value_field -> displayText(),
ui -> increase_spinBox -> value());
return nc;
}
@@ -167,8 +201,13 @@ NumerotationContext NumPartEditorW::toNumContext() {
@return true if value field isn't empty or if type is folio
*/
bool NumPartEditorW::isValid() {
if (type_ == folio || type_ == idfolio || type_ == elementline || type_ == plant || type_ == locmach ||
type_ == elementcolumn || type_ == elementprefix) {return true;}
if (type_ == folio
|| type_ == idfolio
|| type_ == elementline
|| type_ == plant
|| type_ == locmach
|| type_ == elementcolumn
|| type_ == elementprefix) {return true;}
else if(ui -> value_field -> text().isEmpty()) {return false;}
else return true;
}