Wrap code for better readability

This commit is contained in:
Simon De Backer
2020-08-28 18:32:24 +02:00
parent d8cbcf3b54
commit f4550ab3b4
3 changed files with 51 additions and 28 deletions

View File

@@ -50,7 +50,9 @@ SelectAutonumW::SelectAutonumW(int type, QWidget *parent) :
setContext(NumerotationContext());
}
SelectAutonumW::SelectAutonumW(const NumerotationContext &context, int type, QWidget *parent) :
SelectAutonumW::SelectAutonumW(const NumerotationContext &context,
int type,
QWidget *parent) :
QWidget(parent),
ui(new Ui::SelectAutonumW),
m_edited_type(type)
@@ -85,7 +87,8 @@ SelectAutonumW::~SelectAutonumW()
selected in the diagram_chooser QcomboBox
@param context
*/
void SelectAutonumW::setContext(const NumerotationContext &context) {
void SelectAutonumW::setContext(const NumerotationContext &context)
{
m_context = context;
qDeleteAll(num_part_list_);
@@ -114,7 +117,8 @@ void SelectAutonumW::setContext(const NumerotationContext &context) {
@brief SelectAutonumW::toNumContext
@return the content to num_part_list to NumerotationContext
*/
NumerotationContext SelectAutonumW::toNumContext() const {
NumerotationContext SelectAutonumW::toNumContext() const
{
NumerotationContext nc;
foreach (NumPartEditorW *npew, num_part_list_)
nc << npew -> toNumContext();
@@ -139,7 +143,8 @@ void SelectAutonumW::on_add_button_clicked()
@brief SelectAutonumW::on_remove_button_clicked
* Action on remove button, remove the last NumPartEditor
*/
void SelectAutonumW::on_remove_button_clicked() {
void SelectAutonumW::on_remove_button_clicked()
{
//remove if @num_part_list contains more than one item
if (num_part_list_.size() > 1) {
NumPartEditorW *part = num_part_list_.takeLast();
@@ -246,17 +251,20 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
@brief SelectAutonumW::applyEnable
enable/disable the apply button
*/
void SelectAutonumW::applyEnable(bool b) {
void SelectAutonumW::applyEnable(bool b)
{
if (b){
bool valid= true;
foreach (NumPartEditorW *npe, num_part_list_)
if (!npe -> isValid())
valid= false;
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
ui->buttonBox->button(QDialogButtonBox::Apply)
->setEnabled(valid);
}
else {
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
ui->buttonBox->button(QDialogButtonBox::Apply)
->setEnabled(b);
}
if (m_edited_type == 0)
contextToFormula();
@@ -279,7 +287,8 @@ void SelectAutonumW::contextToFormula()
if (m_faw)
{
m_faw->clearContext();
m_faw->setContext(autonum::numerotationContextToFormula(toNumContext()));
m_faw->setContext(autonum::numerotationContextToFormula(
toNumContext()));
}
}

View File

@@ -31,6 +31,9 @@ namespace Ui {
class SelectAutonumW;
}
/**
@brief The SelectAutonumW class
*/
class SelectAutonumW : public QWidget
{
Q_OBJECT
@@ -38,7 +41,9 @@ class SelectAutonumW : public QWidget
//METHODS
public:
explicit SelectAutonumW(int type, QWidget *parent = nullptr);
explicit SelectAutonumW(const NumerotationContext &context, int type, QWidget *parent = nullptr);
explicit SelectAutonumW(const NumerotationContext &context,
int type,
QWidget *parent = nullptr);
~SelectAutonumW() override;
void setContext (const NumerotationContext &context);
@@ -70,7 +75,7 @@ class SelectAutonumW : public QWidget
NumerotationContext m_context;
FormulaAutonumberingW *m_feaw;
FormulaAutonumberingW *m_fcaw;
int m_edited_type = -1; //0 == element : 1 == conductor : 2 == folio
int m_edited_type = -1; ///<0 == element : 1 == conductor : 2 == folio
};
#endif // SELECTAUTONUMW_H

View File

@@ -175,14 +175,15 @@ bool QET::orthogonalProjection(const QPointF &point,
// determine le point d'intersection des deux droites = le projete orthogonal
QPointF intersection_point;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectType it = line.intersect(perpendicular_line,
&intersection_point); // ### Qt 6: remove
#else
#pragma message("@TODO remove code for QT 5.14 or later")
QLineF::IntersectType it = line.intersects(perpendicular_line,
&intersection_point);
QLineF::IntersectType it = line.
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
intersect // ### Qt 6: remove
#else
intersects
#endif
(perpendicular_line, &intersection_point);
// ne devrait pas arriver (mais bon...)
if (it == QLineF::NoIntersection) return(false);
@@ -399,7 +400,8 @@ QString QET::license() {
Windows
*/
QList<QChar> QET::forbiddenCharacters() {
return(QList<QChar>() << '\\' << '/' << ':' << '*' << '?' << '"' << '<' << '>' << '|');
return(QList<QChar>() << '\\' << '/' << ':' << '*' << '?' << '"'
<< '<' << '>' << '|');
}
/**
@@ -467,13 +469,17 @@ QString QET::joinWithSpaces(const QStringList &string_list) {
@return La liste des sous-chaines, sans echappement.
*/
QStringList QET::splitWithSpaces(const QString &string) {
// les chaines sont separees par des espaces non echappes = avec un nombre nul ou pair de backslashes devant
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "), QString::SkipEmptyParts);
#else
// les chaines sont separees par des espaces non echappes
// = avec un nombre nul ou pair de backslashes devant
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "), Qt::SkipEmptyParts);
QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "),
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QString
#else
Qt
#endif
::SkipEmptyParts);
QStringList returned_list;
foreach(QString escaped_string, escaped_strings) {
@@ -591,7 +597,8 @@ bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *
{
if (error_message)
{
*error_message = QString(QObject::tr("Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
*error_message = QString(QObject::tr(
"Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
}
return(false);
@@ -604,7 +611,8 @@ bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *
if (!file.commit())
{
if (error_message) {
*error_message = QString(QObject::tr("Une erreur est survenue lors de l'écriture du fichier %1, erreur %2 rencontrée.",
*error_message = QString(QObject::tr(
"Une erreur est survenue lors de l'écriture du fichier %1, erreur %2 rencontrée.",
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
}
@@ -713,7 +721,8 @@ bool QET::writeToFile(QDomDocument &xml_doc, QFile *file, QString *error_message
{
QFileInfo info_(*file);
*error_message = QString(
QObject::tr("Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
QObject::tr(
"Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
"error message when attempting to write an XML file")
).arg(info_.absoluteFilePath()).arg(file->error());
}