Improve code style, Wrap code for better readability

This commit is contained in:
Simon De Backer 2020-08-16 14:23:59 +02:00
parent 8144e9b21b
commit 928b56f2bf
22 changed files with 656 additions and 363 deletions

View File

@ -39,11 +39,11 @@
@param parent widget @param parent widget
*/ */
BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) : BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::BOMExportDialog), ui(new Ui::BOMExportDialog),
m_project(project) m_project(project)
{ {
ui->setupUi(this); ui->setupUi(this);
m_export_info.insert("pos", tr("Position")); m_export_info.insert("pos", tr("Position"));
m_export_info.insert("folio_title", tr("Titre du folio")); m_export_info.insert("folio_title", tr("Titre du folio"));
@ -59,10 +59,14 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
m_button_group.addButton(ui->m_coil_cb, 4); m_button_group.addButton(ui->m_coil_cb, 4);
m_button_group.addButton(ui->m_protection_cb, 5); m_button_group.addButton(ui->m_protection_cb, 5);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](int id) connect(&m_button_group,
static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
[this](int id)
#else #else
#pragma message("@TODO remove code for QT 5.15 or later") #pragma message("@TODO remove code for QT 5.15 or later")
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), [this](int id) connect(&m_button_group,
static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked),
[this](int id)
#endif #endif
{ {
auto check_box = static_cast<QCheckBox *>(m_button_group.button(0)); auto check_box = static_cast<QCheckBox *>(m_button_group.button(0));
@ -352,7 +356,7 @@ QString BOMExportDialog::headers() const
header_string += "\n"; header_string += "\n";
} }
else if (!queryStr().isEmpty()) //Try to retreive the header according to the sql query else if (!queryStr().isEmpty())//Try to retreive the header according to the sql query
{ {
if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM")) if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM"))
{ {

View File

@ -33,44 +33,46 @@ class BOMExportDialog;
class BOMExportDialog : public QDialog class BOMExportDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BOMExportDialog(QETProject *project, QWidget *parent = nullptr); explicit BOMExportDialog(QETProject *project,
~BOMExportDialog() override; QWidget *parent = nullptr);
~BOMExportDialog() override;
virtual int exec() override; virtual int exec() override;
QStringList selectedKeys() const; QStringList selectedKeys() const;
QString translatedKeys(const QString &key) const; QString translatedKeys(const QString &key) const;
private slots: private slots:
void on_m_add_pb_clicked(); void on_m_add_pb_clicked();
void on_m_remove_pb_clicked(); void on_m_remove_pb_clicked();
void on_m_up_pb_clicked(); void on_m_up_pb_clicked();
void on_m_down_pb_clicked(); void on_m_down_pb_clicked();
void on_m_save_name_le_textChanged(const QString &arg1); void on_m_save_name_le_textChanged(const QString &arg1);
void on_m_format_as_nomenclature_rb_toggled(bool checked); void on_m_format_as_nomenclature_rb_toggled(bool checked);
void on_m_edit_sql_query_cb_clicked(); void on_m_edit_sql_query_cb_clicked();
void on_m_save_current_conf_pb_clicked(); void on_m_save_current_conf_pb_clicked();
void on_m_load_pb_clicked(); void on_m_load_pb_clicked();
private: private:
void setUpItems(); void setUpItems();
QString getBom(); QString getBom();
QString headers() const; QString headers() const;
bool createDataBase(); bool createDataBase();
void populateDataBase(); void populateDataBase();
QHash<QString, QString> elementInfoToString(Element *elmt) const; QHash<QString, QString> elementInfoToString(
QString queryStr() const; Element *elmt) const;
void updateQueryLine(); QString queryStr() const;
void fillSavedQuery(); void updateQueryLine();
void fillSavedQuery();
private: private:
Ui::BOMExportDialog *ui; Ui::BOMExportDialog *ui;
QETProject *m_project = nullptr; QETProject *m_project = nullptr;
QSqlDatabase m_data_base; QSqlDatabase m_data_base;
QSqlQuery m_insert_query; QSqlQuery m_insert_query;
QString m_custom_query; QString m_custom_query;
QHash <QString, QString> m_export_info; QHash <QString, QString> m_export_info;
QButtonGroup m_button_group; QButtonGroup m_button_group;
QList <QListWidgetItem *> m_items_list; QList <QListWidgetItem *> m_items_list;

View File

@ -19,10 +19,10 @@
#include "ui_configsaveloaderwidget.h" #include "ui_configsaveloaderwidget.h"
ConfigSaveLoaderWidget::ConfigSaveLoaderWidget(QWidget *parent) : ConfigSaveLoaderWidget::ConfigSaveLoaderWidget(QWidget *parent) :
QGroupBox(parent), QGroupBox(parent),
ui(new Ui::ConfigSaveLoaderWidget) ui(new Ui::ConfigSaveLoaderWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
} }
ConfigSaveLoaderWidget::~ConfigSaveLoaderWidget() ConfigSaveLoaderWidget::~ConfigSaveLoaderWidget()

View File

@ -34,7 +34,7 @@ class ConfigSaveLoaderWidget;
*/ */
class ConfigSaveLoaderWidget : public QGroupBox class ConfigSaveLoaderWidget : public QGroupBox
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ConfigSaveLoaderWidget(QWidget *parent = nullptr); explicit ConfigSaveLoaderWidget(QWidget *parent = nullptr);

View File

@ -46,7 +46,7 @@ DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *pare
setWindowFlags(Qt::Sheet); setWindowFlags(Qt::Sheet);
#endif #endif
setWindowTitle(tr("Propriétés du folio", "window title")); setWindowTitle(tr("Propriétés du folio", "window title"));
//Border widget //Border widget
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, this); BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, this);
@ -148,8 +148,8 @@ void DiagramPropertiesDialog::editAutonum()
Open folio autonum editor Open folio autonum editor
*/ */
void DiagramPropertiesDialog::editAutoFolioNum () { void DiagramPropertiesDialog::editAutoFolioNum () {
ProjectPropertiesDialog ppd (m_diagram->project(), this); ProjectPropertiesDialog ppd (m_diagram->project(), this);
ppd.setCurrentPage(ProjectPropertiesDialog::Autonum); ppd.setCurrentPage(ProjectPropertiesDialog::Autonum);
ppd.changeToFolio(); ppd.changeToFolio();
ppd.exec(); ppd.exec();
} }

View File

@ -37,7 +37,7 @@ class DiagramPropertiesDialog : public QDialog {
public slots: public slots:
void editAutonum (); void editAutonum ();
void editAutoFolioNum (); void editAutoFolioNum ();
private: private:
Diagram *m_diagram; Diagram *m_diagram;

View File

@ -66,7 +66,8 @@ void diagramselection::load_TableDiagram() {
QTableWidgetItem *item_State = new QTableWidgetItem(); QTableWidgetItem *item_State = new QTableWidgetItem();
QString diagram_title = list_diagram_.at(i) -> title(); QString diagram_title = list_diagram_.at(i) -> title();
if (diagram_title.isEmpty()) diagram_title = tr("Folio sans titre"); if (diagram_title.isEmpty())
diagram_title = tr("Folio sans titre");
item_Name -> setData(Qt::DisplayRole, diagram_title); item_Name -> setData(Qt::DisplayRole, diagram_title);
item_State -> setData(Qt::CheckStateRole, Qt::Checked); item_State -> setData(Qt::CheckStateRole, Qt::Checked);

View File

@ -32,15 +32,15 @@
#include <QUndoCommand> #include <QUndoCommand>
DynamicElementTextItemEditor::DynamicElementTextItemEditor(Element *element, QWidget *parent) : DynamicElementTextItemEditor::DynamicElementTextItemEditor(Element *element, QWidget *parent) :
AbstractElementPropertiesEditorWidget(parent), AbstractElementPropertiesEditorWidget(parent),
ui(new Ui::DynamicElementTextItemEditor) ui(new Ui::DynamicElementTextItemEditor)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->m_tree_view->setItemDelegate(new DynamicTextItemDelegate(ui->m_tree_view)); ui->m_tree_view->setItemDelegate(new DynamicTextItemDelegate(ui->m_tree_view));
ui->m_remove_selection->setDisabled(true); ui->m_remove_selection->setDisabled(true);
setElement(element); setElement(element);
} }
DynamicElementTextItemEditor::~DynamicElementTextItemEditor() DynamicElementTextItemEditor::~DynamicElementTextItemEditor()
@ -50,17 +50,17 @@ DynamicElementTextItemEditor::~DynamicElementTextItemEditor()
void DynamicElementTextItemEditor::setElement(Element *element) void DynamicElementTextItemEditor::setElement(Element *element)
{ {
if (m_element == element) if (m_element == element)
return; return;
m_element = element; m_element = element;
DynamicElementTextModel *old_model = m_model; DynamicElementTextModel *old_model = m_model;
m_model = new DynamicElementTextModel(element, ui->m_tree_view); m_model = new DynamicElementTextModel(element, ui->m_tree_view);
connect(m_model, &DynamicElementTextModel::dataChanged, this, &DynamicElementTextItemEditor::dataEdited); connect(m_model, &DynamicElementTextModel::dataChanged, this, &DynamicElementTextItemEditor::dataEdited);
ui->m_tree_view->setModel(m_model); ui->m_tree_view->setModel(m_model);
if(old_model) if(old_model)
delete old_model; delete old_model;
} }
@ -198,10 +198,10 @@ void DynamicElementTextItemEditor::dataEdited()
*/ */
void DynamicElementTextItemEditor::on_m_add_text_clicked() void DynamicElementTextItemEditor::on_m_add_text_clicked()
{ {
if (!m_element) if (!m_element)
return; return;
DynamicElementTextItem *deti = new DynamicElementTextItem(m_element); DynamicElementTextItem *deti = new DynamicElementTextItem(m_element);
if (m_element->diagram()) if (m_element->diagram())
{ {
m_element->diagram()->undoStack().push(new AddElementTextCommand(m_element, deti)); m_element->diagram()->undoStack().push(new AddElementTextCommand(m_element, deti));
@ -219,9 +219,9 @@ void DynamicElementTextItemEditor::on_m_add_text_clicked()
*/ */
void DynamicElementTextItemEditor::on_m_remove_selection_clicked() void DynamicElementTextItemEditor::on_m_remove_selection_clicked()
{ {
DynamicElementTextItem *deti = m_model->textFromIndex(ui->m_tree_view->currentIndex()); DynamicElementTextItem *deti = m_model->textFromIndex(ui->m_tree_view->currentIndex());
if(deti) if(deti)
{ {
if(m_element->diagram()) if(m_element->diagram())
{ {
DiagramContent dc; DiagramContent dc;
@ -229,7 +229,7 @@ void DynamicElementTextItemEditor::on_m_remove_selection_clicked()
m_element->diagram()->undoStack().push(new DeleteQGraphicsItemCommand(m_element->diagram(), dc)); m_element->diagram()->undoStack().push(new DeleteQGraphicsItemCommand(m_element->diagram(), dc));
} }
return; return;
} }
ElementTextItemGroup *group = m_model->groupFromIndex(ui->m_tree_view->currentIndex()); ElementTextItemGroup *group = m_model->groupFromIndex(ui->m_tree_view->currentIndex());
if(group && m_element.data()->diagram()) if(group && m_element.data()->diagram())
m_element.data()->diagram()->undoStack().push(new RemoveTextsGroupCommand(m_element.data(), group)); m_element.data()->diagram()->undoStack().push(new RemoveTextsGroupCommand(m_element.data(), group));
@ -259,10 +259,10 @@ void DynamicElementTextItemEditor::on_m_tree_view_clicked(const QModelIndex &ind
void DynamicElementTextItemEditor::on_m_export_pb_clicked() void DynamicElementTextItemEditor::on_m_export_pb_clicked()
{ {
ExportElementTextPattern eetp(m_element); ExportElementTextPattern eetp(m_element);
} }
void DynamicElementTextItemEditor::on_m_import_pb_clicked() void DynamicElementTextItemEditor::on_m_import_pb_clicked()
{ {
ImportElementTextPattern ietp(m_element); ImportElementTextPattern ietp(m_element);
} }

View File

@ -61,9 +61,9 @@ DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *pare
QStandardItemModel(parent), QStandardItemModel(parent),
m_element(element) m_element(element)
{ {
setColumnCount(2); setColumnCount(2);
setHeaderData(0, Qt::Horizontal, tr("Propriété"), Qt::DisplayRole); setHeaderData(0, Qt::Horizontal, tr("Propriété"), Qt::DisplayRole);
setHeaderData(1, Qt::Horizontal, tr("Valeur"), Qt::DisplayRole); setHeaderData(1, Qt::Horizontal, tr("Valeur"), Qt::DisplayRole);
connect(this, &DynamicElementTextModel::itemChanged, this, &DynamicElementTextModel::itemDataChanged); connect(this, &DynamicElementTextModel::itemChanged, this, &DynamicElementTextModel::itemDataChanged);
@ -77,7 +77,7 @@ DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *pare
for (ElementTextItemGroup *grp : m_element.data()->textGroups()) for (ElementTextItemGroup *grp : m_element.data()->textGroups())
addGroup(grp); addGroup(grp);
for (DynamicElementTextItem *deti : m_element.data()->dynamicTextItems()) for (DynamicElementTextItem *deti : m_element.data()->dynamicTextItems())
this->appendRow(itemsForText(deti)); this->appendRow(itemsForText(deti));
} }
@ -115,61 +115,79 @@ bool DynamicElementTextModel::indexIsInGroup(const QModelIndex &index) const
/** /**
@brief DynamicElementTextModel::itemsForText @brief DynamicElementTextModel::itemsForText
@param deti @param deti
@return The items for the text @deti, if the text @deti is already managed by this model @return The items for the text deti,
if the text deti is already managed by this model
the returned list is empty the returned list is empty
The returned items haven't got the same number of childs if the text is in a group or not. The returned items haven't got the same number
of childs if the text is in a group or not.
*/ */
QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextItem *deti) QList<QStandardItem *> DynamicElementTextModel::itemsForText(
DynamicElementTextItem *deti)
{ {
QList <QStandardItem *> qsi_list; QList <QStandardItem *> qsi_list;
if(m_texts_list.keys().contains(deti)) if(m_texts_list.keys().contains(deti))
return qsi_list; return qsi_list;
QStandardItem *qsi = new QStandardItem(deti->toPlainText()); QStandardItem *qsi = new QStandardItem(deti->toPlainText());
qsi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled |Qt::ItemIsDragEnabled); qsi->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
|Qt::ItemIsDragEnabled);
qsi->setIcon(QET::Icons::PartText); qsi->setIcon(QET::Icons::PartText);
//Source of text //Source of text
QStandardItem *src = new QStandardItem(tr("Source du texte")); QStandardItem *src = new QStandardItem(tr("Source du texte"));
src->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); src->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QString title; QString title;
if (deti->textFrom() == DynamicElementTextItem::UserText) title = tr("Texte utilisateur"); if (deti->textFrom() == DynamicElementTextItem::UserText)
else if (deti->textFrom() == DynamicElementTextItem::ElementInfo) title = tr("Information de l'élément"); title = tr("Texte utilisateur");
else if (deti->textFrom() == DynamicElementTextItem::ElementInfo)
title = tr("Information de l'élément");
else title = tr("Texte composé"); else title = tr("Texte composé");
QStandardItem *srca = new QStandardItem(title); QStandardItem *srca = new QStandardItem(title);
srca->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); srca->setFlags(Qt::ItemIsSelectable
srca->setData(textFrom, Qt::UserRole+1); | Qt::ItemIsEnabled
| Qt::ItemIsEditable);
srca->setData(textFrom, Qt::UserRole+1);
qsi_list << src << srca; qsi_list << src << srca;
qsi->appendRow(qsi_list); qsi->appendRow(qsi_list);
//User text //User text
QStandardItem *usr = new QStandardItem(tr("Texte")); QStandardItem *usr = new QStandardItem(tr("Texte"));
usr->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); usr->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QStandardItem *usra = new QStandardItem(deti->toPlainText()); QStandardItem *usra = new QStandardItem(deti->toPlainText());
usra->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); usra->setFlags(Qt::ItemIsSelectable
usra->setData(DynamicElementTextModel::userText, Qt::UserRole+1); | Qt::ItemIsEnabled
| Qt::ItemIsEditable);
usra->setData(DynamicElementTextModel::userText, Qt::UserRole+1);
qsi_list.clear(); qsi_list.clear();
qsi_list << usr << usra; qsi_list << usr << usra;
qsi->appendRow(qsi_list); qsi->appendRow(qsi_list);
//Info text //Info text
QStandardItem *info = new QStandardItem(tr("Information")); QStandardItem *info = new QStandardItem(tr("Information"));
info->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); info->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QStandardItem *infoa = new QStandardItem(QETApp::elementTranslatedInfoKey(deti->infoName())); QStandardItem *infoa =
infoa->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); new QStandardItem(
infoa->setData(DynamicElementTextModel::infoText, Qt::UserRole+1); //Use to know the edited thing QETApp::elementTranslatedInfoKey(
infoa->setData(deti->infoName(), Qt::UserRole+2); //Use to know to element info name deti->infoName()));
infoa->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
//Use to know the edited thing
infoa->setData(DynamicElementTextModel::infoText, Qt::UserRole+1);
//Use to know to element info name
infoa->setData(deti->infoName(), Qt::UserRole+2);
qsi_list.clear(); qsi_list.clear();
qsi_list << info << infoa; qsi_list << info << infoa;
qsi->appendRow(qsi_list); qsi->appendRow(qsi_list);
//Composite text //Composite text
QStandardItem *composite = new QStandardItem(tr("Texte composé")); QStandardItem *composite = new QStandardItem(tr("Texte composé"));
@ -178,28 +196,36 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
DiagramContext dc; DiagramContext dc;
if(deti->elementUseForInfo()) if(deti->elementUseForInfo())
dc = deti->elementUseForInfo()->elementInformations(); dc = deti->elementUseForInfo()->elementInformations();
QStandardItem *compositea = new QStandardItem(deti->compositeText().isEmpty() ? QStandardItem *compositea = new QStandardItem(deti->compositeText().isEmpty()
tr("Mon texte composé") : ? tr("Mon texte composé")
autonum::AssignVariables::replaceVariable(deti->compositeText(), dc)); : autonum::AssignVariables::replaceVariable(
compositea->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); deti->compositeText(), dc));
compositea->setData(DynamicElementTextModel::compositeText, Qt::UserRole+1); //Use to know the edited thing compositea->setFlags(Qt::ItemIsSelectable
compositea->setData(deti->compositeText(), Qt::UserRole+2); //Use to know to element composite formula | Qt::ItemIsEnabled
| Qt::ItemIsEditable);
//Use to know the edited thing
compositea->setData(DynamicElementTextModel::compositeText,
Qt::UserRole+1);
//Use to know to element composite formula
compositea->setData(deti->compositeText(), Qt::UserRole+2);
qsi_list.clear(); qsi_list.clear();
qsi_list << composite << compositea; qsi_list << composite << compositea;
qsi->appendRow(qsi_list); qsi->appendRow(qsi_list);
//Size //Size
QStandardItem *size = new QStandardItem(tr("Taille")); QStandardItem *size = new QStandardItem(tr("Taille"));
size->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); size->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QStandardItem *siza = new QStandardItem(); QStandardItem *siza = new QStandardItem();
siza->setData(deti->font().pointSize(), Qt::EditRole); siza->setData(deti->font().pointSize(), Qt::EditRole);
siza->setData(DynamicElementTextModel::size, Qt::UserRole+1); siza->setData(DynamicElementTextModel::size, Qt::UserRole+1);
siza->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); siza->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << size << siza; qsi_list << size << siza;
qsi->appendRow(qsi_list); qsi->appendRow(qsi_list);
//Font //Font
@ -216,18 +242,20 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
qsi_list << font << fonta; qsi_list << font << fonta;
qsi->appendRow(qsi_list); qsi->appendRow(qsi_list);
//Color //Color
QStandardItem *color = new QStandardItem(tr("Couleur")); QStandardItem *color = new QStandardItem(tr("Couleur"));
color->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); color->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QStandardItem *colora = new QStandardItem; QStandardItem *colora = new QStandardItem;
colora->setData(deti->color(), Qt::ForegroundRole); colora->setData(deti->color(), Qt::ForegroundRole);
colora->setData(deti->color(), Qt::EditRole); colora->setData(deti->color(), Qt::EditRole);
colora->setData(DynamicElementTextModel::color, Qt::UserRole+1); colora->setData(DynamicElementTextModel::color, Qt::UserRole+1);
colora->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); colora->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << color << colora; qsi_list << color << colora;
qsi->appendRow(qsi_list); qsi->appendRow(qsi_list);
//Frame //Frame
@ -238,7 +266,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
frame_a->setCheckable(true); frame_a->setCheckable(true);
frame_a->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked); frame_a->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked);
frame_a->setData(DynamicElementTextModel::frame, Qt::UserRole+1); frame_a->setData(DynamicElementTextModel::frame, Qt::UserRole+1);
frame_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); frame_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsUserCheckable);
qsi_list.clear(); qsi_list.clear();
qsi_list << frame << frame_a; qsi_list << frame << frame_a;
@ -251,7 +281,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *width_a = new QStandardItem; QStandardItem *width_a = new QStandardItem;
width_a->setData(deti->textWidth(), Qt::EditRole); width_a->setData(deti->textWidth(), Qt::EditRole);
width_a->setData(DynamicElementTextModel::textWidth, Qt::UserRole+1); width_a->setData(DynamicElementTextModel::textWidth, Qt::UserRole+1);
width_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); width_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << width << width_a; qsi_list << width << width_a;
@ -266,7 +298,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *x_pos_a = new QStandardItem; QStandardItem *x_pos_a = new QStandardItem;
x_pos_a->setData(deti->pos().x(), Qt::EditRole); x_pos_a->setData(deti->pos().x(), Qt::EditRole);
x_pos_a->setData(DynamicElementTextModel::pos, Qt::UserRole+1); x_pos_a->setData(DynamicElementTextModel::pos, Qt::UserRole+1);
x_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); x_pos_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << x_pos << x_pos_a; qsi_list << x_pos << x_pos_a;
@ -279,7 +313,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *y_pos_a = new QStandardItem; QStandardItem *y_pos_a = new QStandardItem;
y_pos_a->setData(deti->pos().y(), Qt::EditRole); y_pos_a->setData(deti->pos().y(), Qt::EditRole);
y_pos_a->setData(DynamicElementTextModel::pos, Qt::UserRole+1); y_pos_a->setData(DynamicElementTextModel::pos, Qt::UserRole+1);
y_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); y_pos_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << y_pos << y_pos_a; qsi_list << y_pos << y_pos_a;
@ -291,8 +327,11 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *rot_a = new QStandardItem; QStandardItem *rot_a = new QStandardItem;
rot_a->setData(deti->rotation(), Qt::EditRole); rot_a->setData(deti->rotation(), Qt::EditRole);
rot_a->setData(DynamicElementTextModel::rotation, Qt::UserRole+1); rot_a->setData(DynamicElementTextModel::rotation,
rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); Qt::UserRole+1);
rot_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear();; qsi_list.clear();;
qsi_list << rot << rot_a; qsi_list << rot << rot_a;
@ -303,9 +342,13 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
alignment->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); alignment->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QStandardItem *alignmenta = new QStandardItem(tr("Éditer")); QStandardItem *alignmenta = new QStandardItem(tr("Éditer"));
alignmenta->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); alignmenta->setFlags(Qt::ItemIsSelectable
alignmenta->setData(DynamicElementTextModel::txtAlignment, Qt::UserRole+1); | Qt::ItemIsEnabled
alignmenta->setData(QVariant::fromValue(deti->alignment()), Qt::UserRole+2); | Qt::ItemIsEditable);
alignmenta->setData(DynamicElementTextModel::txtAlignment,
Qt::UserRole+1);
alignmenta->setData(QVariant::fromValue(deti->alignment()),
Qt::UserRole+2);
qsi_list.clear(); qsi_list.clear();
qsi_list << alignment << alignmenta; qsi_list << alignment << alignmenta;
@ -318,7 +361,7 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
empty_qsi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); empty_qsi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
qsi_list << qsi << empty_qsi; qsi_list << qsi << empty_qsi;
m_texts_list.insert(deti, qsi); m_texts_list.insert(deti, qsi);
blockSignals(true); blockSignals(true);
enableSourceText(deti, deti->textFrom()); enableSourceText(deti, deti->textFrom());
blockSignals(false); blockSignals(false);
@ -343,41 +386,45 @@ void DynamicElementTextModel::addText(DynamicElementTextItem *deti)
void DynamicElementTextModel::removeText(DynamicElementTextItem *deti) void DynamicElementTextModel::removeText(DynamicElementTextItem *deti)
{ {
if (!m_texts_list.contains(deti)) if (!m_texts_list.contains(deti))
return; return;
QModelIndex text_index = m_texts_list.value(deti)->index(); QModelIndex text_index = m_texts_list.value(deti)->index();
this->removeRow(text_index.row(), text_index.parent()); this->removeRow(text_index.row(), text_index.parent());
m_texts_list.remove(deti); m_texts_list.remove(deti);
setConnection(deti, false); setConnection(deti, false);
} }
/** /**
@brief DynamicElementTextModel::textFromIndex @brief DynamicElementTextModel::textFromIndex
@param index @param index
@return the text associated with @index. Returned value can be nullptr @return the text associated with index. Returned value can be nullptr
@Index can be a child of an index associated with a text and can be the column 0 or 1. Index can be a child of an index associated with a text
and can be the column 0 or 1.
*/ */
DynamicElementTextItem *DynamicElementTextModel::textFromIndex(const QModelIndex &index) const DynamicElementTextItem *DynamicElementTextModel::textFromIndex(
const QModelIndex &index) const
{ {
if(!index.isValid()) if(!index.isValid())
return nullptr; return nullptr;
if (QStandardItem *item = itemFromIndex(index)) if (QStandardItem *item = itemFromIndex(index))
return textFromItem(item); return textFromItem(item);
else else
return nullptr; return nullptr;
} }
/** /**
@brief DynamicElementTextModel::textFromItem @brief DynamicElementTextModel::textFromItem
@param item @param item
@return the text associated with @item. Return value can be nullptr @return the text associated with item. Return value can be nullptr
@item can be a child of an item associated with a text and can be the column 0 or 1. item can be a child of an item associated with a text
and can be the column 0 or 1.
Note can return nullptr Note can return nullptr
*/ */
DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *item) const DynamicElementTextItem *DynamicElementTextModel::textFromItem(
QStandardItem *item) const
{ {
//Get the item of the column 0 //Get the item of the column 0
if(item->column() == 1) if(item->column() == 1)
{ {
if(item->parent()) if(item->parent())
@ -385,7 +432,7 @@ DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *ite
else else
item = itemFromIndex(index(item->row(),0)); item = itemFromIndex(index(item->row(),0));
} }
//Item haven't got parent, so they can be only a text or a group //Item haven't got parent, so they can be only a text or a group
if(!item->parent()) if(!item->parent())
{ {
if(m_texts_list.values().contains(item)) if(m_texts_list.values().contains(item))
@ -426,9 +473,10 @@ DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *ite
/** /**
@brief DynamicElementTextModel::indexFromText @brief DynamicElementTextModel::indexFromText
@param text @param text
@return the QModelIndex for @text, or a default QModelIndex if not match @return the QModelIndex for text, or a default QModelIndex if not match
*/ */
QModelIndex DynamicElementTextModel::indexFromText(DynamicElementTextItem *text) const QModelIndex DynamicElementTextModel::indexFromText(
DynamicElementTextItem *text) const
{ {
if(m_texts_list.contains(text)) if(m_texts_list.contains(text))
return m_texts_list.value(text)->index(); return m_texts_list.value(text)->index();
@ -439,11 +487,14 @@ QModelIndex DynamicElementTextModel::indexFromText(DynamicElementTextItem *text)
/** /**
@brief DynamicElementTextModel::undoForEditedText @brief DynamicElementTextModel::undoForEditedText
@param deti @param deti
@return A QUndoCommand that describe all changes made for @deti. @return A QUndoCommand that describe all changes made for deti.
Each change made for @deti is append as a child of the returned QUndoCommand. Each change made for deti is append as a child of the returned QUndoCommand.
In other word, if the returned QUndoCommand have no child, that mean there is no change. In other word, if the returned QUndoCommand have no child,
that mean there is no change.
*/ */
QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo) const QUndoCommand *DynamicElementTextModel::undoForEditedText(
DynamicElementTextItem *deti,
QUndoCommand *parent_undo) const
{ {
QUndoCommand *undo = nullptr; QUndoCommand *undo = nullptr;
@ -565,11 +616,14 @@ QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem
@brief DynamicElementTextModel::undoForEditedGroup @brief DynamicElementTextModel::undoForEditedGroup
@param group @param group
@param parent_undo @param parent_undo
@return A QUndoCommand that describe all changes made for @group. @return A QUndoCommand that describe all changes made for group.
Each change made for @group is append as a child of the returned QUndoCommand. Each change made for group is append as a child of the returned QUndoCommand.
In other word, if the returned QUndoCommand have no child, that mean there is no change. In other word, if the returned QUndoCommand have no child,
that mean there is no change.
*/ */
QUndoCommand *DynamicElementTextModel::undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo) const QUndoCommand *DynamicElementTextModel::undoForEditedGroup(
ElementTextItemGroup *group,
QUndoCommand *parent_undo) const
{ {
QUndoCommand *undo = nullptr; QUndoCommand *undo = nullptr;
if(parent_undo) if(parent_undo)
@ -640,7 +694,10 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
//Group //Group
QStandardItem *grp = new QStandardItem(group->name()); QStandardItem *grp = new QStandardItem(group->name());
grp->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable); grp->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsDropEnabled
| Qt::ItemIsEditable);
grp->setIcon(QET::Icons::textGroup); grp->setIcon(QET::Icons::textGroup);
QStandardItem *empty_qsi = new QStandardItem(0); QStandardItem *empty_qsi = new QStandardItem(0);
@ -664,8 +721,11 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
default: break;} default: break;}
QStandardItem *alignment_a = new QStandardItem(text); QStandardItem *alignment_a = new QStandardItem(text);
alignment_a->setData(DynamicElementTextModel::grpAlignment, Qt::UserRole+1); alignment_a->setData(DynamicElementTextModel::grpAlignment,
alignment_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); Qt::UserRole+1);
alignment_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << alignment << alignment_a; qsi_list << alignment << alignment_a;
grp->appendRow(qsi_list); grp->appendRow(qsi_list);
@ -677,7 +737,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *x_pos_a = new QStandardItem; QStandardItem *x_pos_a = new QStandardItem;
x_pos_a->setData(group->pos().x(), Qt::EditRole); x_pos_a->setData(group->pos().x(), Qt::EditRole);
x_pos_a->setData(DynamicElementTextModel::grpPos, Qt::UserRole+1); x_pos_a->setData(DynamicElementTextModel::grpPos, Qt::UserRole+1);
x_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); x_pos_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << x_pos << x_pos_a; qsi_list << x_pos << x_pos_a;
@ -690,7 +752,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *y_pos_a = new QStandardItem; QStandardItem *y_pos_a = new QStandardItem;
y_pos_a->setData(group->pos().y(), Qt::EditRole); y_pos_a->setData(group->pos().y(), Qt::EditRole);
y_pos_a->setData(DynamicElementTextModel::grpPos, Qt::UserRole+1); y_pos_a->setData(DynamicElementTextModel::grpPos, Qt::UserRole+1);
y_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); y_pos_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << y_pos << y_pos_a; qsi_list << y_pos << y_pos_a;
@ -703,7 +767,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *rot_a = new QStandardItem; QStandardItem *rot_a = new QStandardItem;
rot_a->setData(group->rotation(), Qt::EditRole); rot_a->setData(group->rotation(), Qt::EditRole);
rot_a->setData(DynamicElementTextModel::grpRotation, Qt::UserRole+1); rot_a->setData(DynamicElementTextModel::grpRotation, Qt::UserRole+1);
rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); rot_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << rot << rot_a; qsi_list << rot << rot_a;
grp->appendRow(qsi_list); grp->appendRow(qsi_list);
@ -715,7 +781,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *v_adj_a = new QStandardItem; QStandardItem *v_adj_a = new QStandardItem;
v_adj_a->setData(group->verticalAdjustment(), Qt::EditRole); v_adj_a->setData(group->verticalAdjustment(), Qt::EditRole);
v_adj_a->setData(DynamicElementTextModel::grpVAdjust, Qt::UserRole+1); v_adj_a->setData(DynamicElementTextModel::grpVAdjust, Qt::UserRole+1);
v_adj_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); v_adj_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear(); qsi_list.clear();
qsi_list << v_adj << v_adj_a; qsi_list << v_adj << v_adj_a;
grp->appendRow(qsi_list); grp->appendRow(qsi_list);
@ -728,7 +796,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
frame_a->setCheckable(true); frame_a->setCheckable(true);
frame_a->setCheckState(group->frame()? Qt::Checked : Qt::Unchecked); frame_a->setCheckState(group->frame()? Qt::Checked : Qt::Unchecked);
frame_a->setData(DynamicElementTextModel::grpFrame, Qt::UserRole+1); frame_a->setData(DynamicElementTextModel::grpFrame, Qt::UserRole+1);
frame_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); frame_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsUserCheckable);
qsi_list.clear(); qsi_list.clear();
qsi_list << frame_ << frame_a; qsi_list << frame_ << frame_a;
grp->appendRow(qsi_list); grp->appendRow(qsi_list);
@ -740,9 +810,14 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *hold_bottom_a = new QStandardItem(); QStandardItem *hold_bottom_a = new QStandardItem();
hold_bottom_a->setCheckable(true); hold_bottom_a->setCheckable(true);
hold_bottom_a->setCheckState(group->holdToBottomPage() ? Qt::Checked : Qt::Unchecked); hold_bottom_a->setCheckState(group->holdToBottomPage()
hold_bottom_a->setData(DynamicElementTextModel::grpHoldBottom, Qt::UserRole+1); ? Qt::Checked
hold_bottom_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); : Qt::Unchecked);
hold_bottom_a->setData(DynamicElementTextModel::grpHoldBottom,
Qt::UserRole+1);
hold_bottom_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsUserCheckable);
qsi_list.clear(); qsi_list.clear();
qsi_list << hold_bottom << hold_bottom_a; qsi_list << hold_bottom << hold_bottom_a;
grp->appendRow(qsi_list); grp->appendRow(qsi_list);
@ -780,13 +855,15 @@ void DynamicElementTextModel::removeGroup(ElementTextItemGroup *group)
@param deti @param deti
@param group @param group
*/ */
void DynamicElementTextModel::addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group) void DynamicElementTextModel::addTextToGroup(DynamicElementTextItem *deti,
ElementTextItemGroup *group)
{ {
QStandardItem *group_item = m_groups_list.value(group); QStandardItem *group_item = m_groups_list.value(group);
group_item->appendRow(itemsForText(deti)); group_item->appendRow(itemsForText(deti));
} }
void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group) void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti,
ElementTextItemGroup *group)
{ {
Q_UNUSED(group) Q_UNUSED(group)
@ -802,29 +879,33 @@ void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti,
/** /**
@brief DynamicElementTextModel::groupFromIndex @brief DynamicElementTextModel::groupFromIndex
@param index @param index
@return the group associated with @index. Return value can be nullptr @return the group associated with index. Return value can be nullptr
@Index can be a child of an index associated with a group and can be the column 0 or 1. @Index can be a child of an index associated with a group
and can be the column 0 or 1.
*/ */
ElementTextItemGroup *DynamicElementTextModel::groupFromIndex(const QModelIndex &index) const ElementTextItemGroup *DynamicElementTextModel::groupFromIndex(
const QModelIndex &index) const
{ {
if(!index.isValid()) if(!index.isValid())
return nullptr; return nullptr;
if (QStandardItem *item = itemFromIndex(index)) if (QStandardItem *item = itemFromIndex(index))
return groupFromItem(item); return groupFromItem(item);
else else
return nullptr; return nullptr;
} }
/** /**
@brief DynamicElementTextModel::groupFromItem @brief DynamicElementTextModel::groupFromItem
@param item @param item
@return the group associated with @item. Return value can be nullptr @return the group associated with item. Return value can be nullptr
@item can be a child of an item associated with a group and can be the column 0 or 1. item can be a child of an item associated with a group
and can be the column 0 or 1.
*/ */
ElementTextItemGroup *DynamicElementTextModel::groupFromItem(QStandardItem *item) const ElementTextItemGroup *DynamicElementTextModel::groupFromItem(
QStandardItem *item) const
{ {
//Get the item of the column 0 //Get the item of the column 0
if(item->column() == 1) if(item->column() == 1)
{ {
if(item->parent()) if(item->parent())
@ -845,10 +926,11 @@ ElementTextItemGroup *DynamicElementTextModel::groupFromItem(QStandardItem *item
/** /**
@brief DynamicElementTextModel::indexFromGroup @brief DynamicElementTextModel::indexFromGroup
@param group @param group
@return The index associated to the group @group @return The index associated to the group group
or a default QModelIndex if not match or a default QModelIndex if not match
*/ */
QModelIndex DynamicElementTextModel::indexFromGroup(ElementTextItemGroup *group) const QModelIndex DynamicElementTextModel::indexFromGroup(
ElementTextItemGroup *group) const
{ {
if(m_groups_list.keys().contains(group)) if(m_groups_list.keys().contains(group))
return m_groups_list.value(group)->index(); return m_groups_list.value(group)->index();
@ -870,7 +952,10 @@ bool DynamicElementTextModel::indexIsText(const QModelIndex &index) const
if(index.column() == 1) if(index.column() == 1)
{ {
if(index.parent().isValid()) if(index.parent().isValid())
item = itemFromIndex(index.parent().QModelIndex::model()->index(index.row(),0)); item = itemFromIndex(index.parent()
.QModelIndex::model()->index(
index.row(),
0));
else else
item = itemFromIndex(this->index(index.row(),0)); item = itemFromIndex(this->index(index.row(),0));
} }
@ -886,8 +971,8 @@ bool DynamicElementTextModel::indexIsText(const QModelIndex &index) const
/** /**
@brief DynamicElementTextModel::indexIsGroup @brief DynamicElementTextModel::indexIsGroup
@param index @param index
@return True if @index represente a group, both for the column 0 and 1. @return True if index represente a group, both for the column 0 and 1.
Return false if @index is a child of an index associated to a group. Return false if index is a child of an index associated to a group.
*/ */
bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const
{ {
@ -897,7 +982,9 @@ bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const
if(index.column() == 1) if(index.column() == 1)
{ {
if(index.parent().isValid()) if(index.parent().isValid())
item = itemFromIndex(index.parent().QModelIndex::model()->index(index.row(),0)); item = itemFromIndex(index.parent()
.QModelIndex::model()->index(
index.row(),0));
else else
item = itemFromIndex(this->index(index.row(),0)); item = itemFromIndex(this->index(index.row(),0));
} }
@ -910,7 +997,12 @@ bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const
return false; return false;
} }
bool DynamicElementTextModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const bool DynamicElementTextModel::canDropMimeData(
const QMimeData *data,
Qt::DropAction action,
int row,
int column,
const QModelIndex &parent) const
{ {
Q_UNUSED(action); Q_UNUSED(action);
@ -963,9 +1055,14 @@ bool DynamicElementTextModel::canDropMimeData(const QMimeData *data, Qt::DropAct
@param row @param row
@param column @param column
@param parent @param parent
@return In any case return false, for overwrite the default behavior of model. @return In any case return false,
for overwrite the default behavior of model.
*/ */
bool DynamicElementTextModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) bool DynamicElementTextModel::dropMimeData(const QMimeData *data,
Qt::DropAction action,
int row,
int column,
const QModelIndex &parent)
{ {
Q_UNUSED(action) Q_UNUSED(action)
@ -1093,11 +1190,14 @@ QStringList DynamicElementTextModel::mimeTypes() const
/** /**
@brief DynamicElementTextModel::enableSourceText @brief DynamicElementTextModel::enableSourceText
Enable the good field, according to the current source of text, for the edited text @deti Enable the good field, according to the current source of text,
for the edited text @deti
@param deti @param deti
@param tf @param tf
*/ */
void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf) void DynamicElementTextModel::enableSourceText(
DynamicElementTextItem *deti,
DynamicElementTextItem::TextFrom tf)
{ {
if (!m_texts_list.contains(deti)) if (!m_texts_list.contains(deti))
return; return;
@ -1128,7 +1228,8 @@ void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, Dyn
Enable/disable the item "group rotation" according the option hold to bottom Enable/disable the item "group rotation" according the option hold to bottom
@param group @param group
*/ */
void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *group) void DynamicElementTextModel::enableGroupRotationAndPos(
ElementTextItemGroup *group)
{ {
if(!m_groups_list.contains(group)) if(!m_groups_list.contains(group))
return; return;
@ -1146,12 +1247,21 @@ void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *gr
} }
else else
{ {
qsi->child(x_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); qsi->child(x_grp_row, 0)->setFlags(Qt::ItemIsSelectable
qsi->child(x_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); | Qt::ItemIsEnabled);
qsi->child(y_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); qsi->child(x_grp_row, 1)->setFlags(Qt::ItemIsSelectable
qsi->child(y_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); | Qt::ItemIsEnabled
qsi->child(rot_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); | Qt::ItemIsEditable);
qsi->child(rot_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); qsi->child(y_grp_row, 0)->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled);
qsi->child(y_grp_row, 1)->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi->child(rot_grp_row, 0)->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled);
qsi->child(rot_grp_row, 1)->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
} }
} }
@ -1210,11 +1320,14 @@ void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
} }
} }
//We emit the signal only if @qsi is in the second column, because the data are stored on this column //We emit the signal only if @qsi is in the second column,
//the first column is use only for display the title of the property, except for the name of texts group //because the data are stored on this column
if((m_groups_list.values().contains(qsi) || qsi->column() == 1) && !m_block_dataChanged) //the first column is use only for display the title of the property,
//except for the name of texts group
if((m_groups_list.values().contains(qsi) || qsi->column() == 1)
&& !m_block_dataChanged)
emit dataChanged(); emit dataChanged();
if(deti) deti->updateXref(); if(deti) deti->updateXref();
} }
/** /**
@ -1295,7 +1408,8 @@ void DynamicElementTextModel::setConnection(ElementTextItemGroup *group, bool se
} }
} }
void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, ValueType type) void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti,
ValueType type)
{ {
QStandardItem *qsi = m_texts_list.value(deti); QStandardItem *qsi = m_texts_list.value(deti);
if (!qsi) if (!qsi)
@ -1387,7 +1501,9 @@ void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, V
m_block_dataChanged = false; m_block_dataChanged = false;
} }
void DynamicElementTextModel::updateDataFromGroup(ElementTextItemGroup *group, DynamicElementTextModel::ValueType type) void DynamicElementTextModel::updateDataFromGroup(
ElementTextItemGroup *group,
DynamicElementTextModel::ValueType type)
{ {
QStandardItem *qsi = m_groups_list.value(group); QStandardItem *qsi = m_groups_list.value(group);
if (!qsi) if (!qsi)
@ -1445,10 +1561,13 @@ void DynamicElementTextModel::updateDataFromGroup(ElementTextItemGroup *group, D
***************************************************/ ***************************************************/
DynamicTextItemDelegate::DynamicTextItemDelegate(QObject *parent) : DynamicTextItemDelegate::DynamicTextItemDelegate(QObject *parent) :
QStyledItemDelegate(parent) QStyledItemDelegate(parent)
{} {}
QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const QWidget *DynamicTextItemDelegate::createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{ {
switch (index.data(Qt::UserRole+1).toInt()) switch (index.data(Qt::UserRole+1).toInt())
{ {
@ -1615,7 +1734,10 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
return QStyledItemDelegate::createEditor(parent, option, index); return QStyledItemDelegate::createEditor(parent, option, index);
} }
void DynamicTextItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const void DynamicTextItemDelegate::setModelData(
QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{ {
if (index.isValid()) if (index.isValid())
{ {
@ -1725,10 +1847,11 @@ void DynamicTextItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *
bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event) bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
{ {
//This is a bad hack, for change the normal behavior : //This is a bad hack, for change the normal behavior :
//in normal behavior, the value is commited when the spinbox lose focus or enter key is pressed //in normal behavior,
//With this hack the value is commited each time the value change without the need to validate. //the value is commited when the spinbox lose focus or enter key is pressed
//then the change is apply in live //With this hack the value is commited each time the value change without the need to validate.
//then the change is apply in live
if(object->objectName() == "pos_dialog" || object->objectName() == "font_size" || object->objectName() == "rot_spinbox" || \ if(object->objectName() == "pos_dialog" || object->objectName() == "font_size" || object->objectName() == "rot_spinbox" || \
object->objectName() == "group_rotation" || object->objectName() == "group_v_adjustment" || object->objectName() == "width_spinbox" ||\ object->objectName() == "group_rotation" || object->objectName() == "group_v_adjustment" || object->objectName() == "width_spinbox" ||\
object->objectName() == "group_pos") object->objectName() == "group_pos")
@ -1752,7 +1875,8 @@ bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
return true; return true;
} }
//Like the hack above, change the current index of the combobox, apply the change immediately, no need to lose focus or press enter. //Like the hack above, change the current index of the combobox,
// apply the change immediately, no need to lose focus or press enter.
if((object->objectName() == "text_from" || object->objectName() == "info_text" || object->objectName() == "group_alignment") && event->type() == QEvent::FocusIn) if((object->objectName() == "text_from" || object->objectName() == "info_text" || object->objectName() == "group_alignment") && event->type() == QEvent::FocusIn)
{ {
QComboBox *qcb = static_cast<QComboBox *>(object); QComboBox *qcb = static_cast<QComboBox *>(object);
@ -1767,7 +1891,8 @@ bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
@param deti @param deti
@return A list of available info of element @return A list of available info of element
*/ */
QStringList DynamicTextItemDelegate::availableInfo(DynamicElementTextItem *deti) const QStringList DynamicTextItemDelegate::availableInfo(
DynamicElementTextItem *deti) const
{ {
QStringList qstrl; QStringList qstrl;

View File

@ -135,6 +135,8 @@ Qt::CheckState ElementInfoPartWidget::EraseTextCheckState() const {
void ElementInfoPartWidget::on_m_erase_text_clicked() void ElementInfoPartWidget::on_m_erase_text_clicked()
{ {
ui->line_edit->setText(ui->m_erase_text->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); ui->line_edit->setText(ui->m_erase_text->isChecked()
? SearchAndReplaceWorker::eraseText()
: QString());
ui->line_edit->setDisabled(ui->m_erase_text->isChecked()); ui->line_edit->setDisabled(ui->m_erase_text->isChecked());
} }

View File

@ -292,7 +292,7 @@ void ElementPropertiesWidget::updateUi()
default: default:
break; break;
} }
m_list_editor << new DynamicElementTextItemEditor(m_element, this); m_list_editor << new DynamicElementTextItemEditor(m_element, this);
//Add each editors in tab widget //Add each editors in tab widget
for (AbstractElementPropertiesEditorWidget *aepew : m_list_editor) for (AbstractElementPropertiesEditorWidget *aepew : m_list_editor)
@ -376,7 +376,7 @@ QWidget *ElementPropertiesWidget::generalWidget()
connect(find_in_panel, SIGNAL(clicked()), this, SLOT(findInPanel())); connect(find_in_panel, SIGNAL(clicked()), this, SLOT(findInPanel()));
QPushButton *edit_element = new QPushButton(QET::Icons::ElementEdit, tr("Éditer l'élément"), general_widget); QPushButton *edit_element = new QPushButton(QET::Icons::ElementEdit, tr("Éditer l'élément"), general_widget);
connect(edit_element, SIGNAL(clicked()), this, SLOT(editElement())); connect(edit_element, SIGNAL(clicked()), this, SLOT(editElement()));
QHBoxLayout *hlayout_ = new QHBoxLayout; QHBoxLayout *hlayout_ = new QHBoxLayout;
hlayout_->addWidget(find_in_panel); hlayout_->addWidget(find_in_panel);
hlayout_->addWidget(edit_element); hlayout_->addWidget(edit_element);
vlayout_->addLayout(hlayout_); vlayout_->addLayout(hlayout_);

View File

@ -427,7 +427,7 @@ void IndiTextPropertiesWidget::on_m_advanced_editor_pb_clicked() {
void IndiTextPropertiesWidget::on_m_break_html_pb_clicked() void IndiTextPropertiesWidget::on_m_break_html_pb_clicked()
{ {
if (m_text) { if (m_text) {
m_text->setPlainText(m_text->toPlainText()); m_text->setPlainText(m_text->toPlainText());
} }
for (QPointer<IndependentTextItem> piti : m_text_list) { for (QPointer<IndependentTextItem> piti : m_text_list) {

View File

@ -33,7 +33,8 @@
@param parent @param parent
the parent widget the parent widget
*/ */
LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) : LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt,
QWidget *parent) :
AbstractElementPropertiesEditorWidget(parent), AbstractElementPropertiesEditorWidget(parent),
ui(new Ui::LinkSingleElementWidget) ui(new Ui::LinkSingleElementWidget)
{ {
@ -46,8 +47,14 @@ LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent)
m_show_element = new QAction(tr("Montrer l'élément esclave"), this); m_show_element = new QAction(tr("Montrer l'élément esclave"), this);
m_save_header_state = new QAction(tr("Enregistrer la disposition"), this); m_save_header_state = new QAction(tr("Enregistrer la disposition"), this);
connect(m_show_qtwi, &QAction::triggered, [this]() {this->on_m_tree_widget_itemDoubleClicked(this->m_qtwi_at_context_menu, 0);}); connect(m_show_qtwi,
connect(m_link_action, &QAction::triggered, this, &LinkSingleElementWidget::linkTriggered); &QAction::triggered,
[this]()
{this->on_m_tree_widget_itemDoubleClicked(this->m_qtwi_at_context_menu, 0);});
connect(m_link_action,
&QAction::triggered,
this,
&LinkSingleElementWidget::linkTriggered);
connect(m_show_element, &QAction::triggered, [this]() connect(m_show_element, &QAction::triggered, [this]()
{ {
@ -59,7 +66,10 @@ LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent)
QHeaderView *qhv = ui->m_tree_widget->header(); QHeaderView *qhv = ui->m_tree_widget->header();
qhv->setContextMenuPolicy(Qt::CustomContextMenu); qhv->setContextMenuPolicy(Qt::CustomContextMenu);
connect(qhv, &QHeaderView::customContextMenuRequested, this, &LinkSingleElementWidget::headerCustomContextMenuRequested); connect(qhv,
&QHeaderView::customContextMenuRequested,
this,
&LinkSingleElementWidget::headerCustomContextMenuRequested);
connect(m_save_header_state, &QAction::triggered, [this, qhv]() connect(m_save_header_state, &QAction::triggered, [this, qhv]()
{ {
QByteArray qba = qhv->saveState(); QByteArray qba = qhv->saveState();
@ -105,8 +115,14 @@ void LinkSingleElementWidget::setElement(Element *element)
//Remove connection of previous edited element //Remove connection of previous edited element
if (m_element) if (m_element)
{ {
disconnect(m_element->diagram()->project(), &QETProject::diagramRemoved, this, &LinkSingleElementWidget::diagramWasRemovedFromProject); disconnect(m_element->diagram()->project(),
disconnect(m_element.data(), &Element::linkedElementChanged, this, &LinkSingleElementWidget::updateUi); &QETProject::diagramRemoved,
this,
&LinkSingleElementWidget::diagramWasRemovedFromProject);
disconnect(m_element.data(),
&Element::linkedElementChanged,
this,
&LinkSingleElementWidget::updateUi);
m_element->setHighlighted(false); m_element->setHighlighted(false);
} }
@ -124,12 +140,16 @@ void LinkSingleElementWidget::setElement(Element *element)
if (m_element->linkType() & Element::Slave) if (m_element->linkType() & Element::Slave)
m_filter = Element::Master; m_filter = Element::Master;
else if (m_element->linkType() & Element::AllReport) else if (m_element->linkType() & Element::AllReport)
m_filter = m_element->linkType() == Element::NextReport? Element::PreviousReport : Element::NextReport; m_filter = m_element->linkType() == Element::NextReport
? Element::PreviousReport
: Element::NextReport;
else else
m_filter = Element::Simple; m_filter = Element::Simple;
connect(m_element->diagram()->project(), &QETProject::diagramRemoved, this, &LinkSingleElementWidget::diagramWasRemovedFromProject); connect(m_element->diagram()->project(), &QETProject::diagramRemoved,
connect(m_element.data(), &Element::linkedElementChanged, this, &LinkSingleElementWidget::updateUi, Qt::QueuedConnection); this, &LinkSingleElementWidget::diagramWasRemovedFromProject);
connect(m_element.data(), &Element::linkedElementChanged,
this, &LinkSingleElementWidget::updateUi, Qt::QueuedConnection);
updateUi(); updateUi();
} }
@ -234,7 +254,8 @@ void LinkSingleElementWidget::buildTree()
if (settings.value("genericpanel/folio", false).toBool()) if (settings.value("genericpanel/folio", false).toBool())
{ {
autonum::sequentialNumbers seq; autonum::sequentialNumbers seq;
QString F =autonum::AssignVariables::formulaToLabel(diag->border_and_titleblock.folio(), seq, diag, elmt); QString F =autonum::AssignVariables::formulaToLabel(
diag->border_and_titleblock.folio(), seq, diag, elmt);
str_list << F; str_list << F;
} }
else else
@ -415,11 +436,19 @@ void LinkSingleElementWidget::setUpHeaderLabels()
{ {
if (settings.value("genericpanel/folio", false).toBool()) if (settings.value("genericpanel/folio", false).toBool())
{ {
list << tr("Label") << tr("Commentaire") << tr("Label de folio") << tr("Position") << tr("Titre de folio"); list << tr("Label")
<< tr("Commentaire")
<< tr("Label de folio")
<< tr("Position")
<< tr("Titre de folio");
} }
else else
{ {
list << tr("Label") << tr("Commentaire") << tr("N° de folio") << tr("Position") << tr("Titre de folio"); list << tr("Label")
<< tr("Commentaire")
<< tr("N° de folio")
<< tr("Position")
<< tr("Titre de folio");
} }
} }
@ -427,11 +456,25 @@ void LinkSingleElementWidget::setUpHeaderLabels()
{ {
if (settings.value("genericpanel/folio", false).toBool()) if (settings.value("genericpanel/folio", false).toBool())
{ {
list << tr("N° de fil") << tr("Fonction") << tr("Tension / Protocole") << tr("Couleur du conducteur") << tr("Section du conducteur") << tr("Label de folio") << tr("Position") << tr("Titre de folio"); list << tr("N° de fil")
<< tr("Fonction")
<< tr("Tension / Protocole")
<< tr("Couleur du conducteur")
<< tr("Section du conducteur")
<< tr("Label de folio")
<< tr("Position")
<< tr("Titre de folio");
} }
else else
{ {
list << tr("N° de fil") << tr("Fonction") << tr("Tension / Protocole") << tr("Couleur du conducteur") << tr("Section du conducteur") << tr("N° de folio") << tr("Position") << tr("Titre de folio"); list << tr("N° de fil")
<< tr("Fonction")
<< tr("Tension / Protocole")
<< tr("Couleur du conducteur")
<< tr("Section du conducteur")
<< tr("N° de folio")
<< tr("Position")
<< tr("Titre de folio");
} }
} }
@ -440,13 +483,16 @@ void LinkSingleElementWidget::setUpHeaderLabels()
/** /**
@brief LinkSingleElementWidget::diagramWasRemovedFromProject @brief LinkSingleElementWidget::diagramWasRemovedFromProject
* This slot is called when a diagram is removed from the parent project of edited element This slot is called when a diagram
is removed from the parent project of edited element
to update the content of this widget to update the content of this widget
*/ */
void LinkSingleElementWidget::diagramWasRemovedFromProject() void LinkSingleElementWidget::diagramWasRemovedFromProject()
{ {
//We use a timer because if the removed diagram contain the master element linked to the edited element // We use a timer because if the removed diagram
//we must to wait for this elements be unlinked, else the list of available master isn't up to date // contain the master element linked to the edited element
// we must to wait for this elements be unlinked,
// else the list of available master isn't up to date
QTimer::singleShot(10, this, SLOT(updateUi())); QTimer::singleShot(10, this, SLOT(updateUi()));
} }
@ -473,19 +519,25 @@ void LinkSingleElementWidget::linkTriggered()
} }
else else
{ {
//In no live edit mode, we set the background of the qtwi green, to inform the user //In no live edit mode, we set the background of the qtwi green,
//which element will be linked when he press the apply button // to inform the user
// which element will be linked when he press the apply button
if (m_pending_qtwi) if (m_pending_qtwi)
{ {
for(int i=0 ; i<6 ; i++) for(int i=0 ; i<6 ; i++)
{ {
m_pending_qtwi->setBackground(i,QBrush(Qt::white, Qt::NoBrush)); m_pending_qtwi->setBackground(i,
QBrush(
Qt::white,
Qt::NoBrush));
} }
} }
for (int i=0 ; i<6 ; i++) for (int i=0 ; i<6 ; i++)
{ {
m_qtwi_at_context_menu->setBackground(i,QBrush(Qt::green,Qt::SolidPattern)); m_qtwi_at_context_menu->setBackground(i,
QBrush(Qt::green,
Qt::SolidPattern));
} }
m_pending_qtwi = m_qtwi_at_context_menu; m_pending_qtwi = m_qtwi_at_context_menu;
} }
@ -518,7 +570,8 @@ void LinkSingleElementWidget::showButtons()
ui->m_search_field->hide(); ui->m_search_field->hide();
} }
void LinkSingleElementWidget::headerCustomContextMenuRequested(const QPoint &pos) void LinkSingleElementWidget::headerCustomContextMenuRequested(
const QPoint &pos)
{ {
m_context_menu->clear(); m_context_menu->clear();
m_context_menu->addAction(m_save_header_state); m_context_menu->addAction(m_save_header_state);
@ -544,13 +597,16 @@ void LinkSingleElementWidget::on_m_unlink_pb_clicked()
@param item @param item
@param column @param column
*/ */
void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column) void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked(
QTreeWidgetItem *item,
int column)
{ {
Q_UNUSED(column); Q_UNUSED(column);
if (m_showed_element) if (m_showed_element)
{ {
disconnect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted())); disconnect(m_showed_element, SIGNAL(destroyed()),
this, SLOT(showedElementWasDeleted()));
m_showed_element->setHighlighted(false); m_showed_element->setHighlighted(false);
} }
@ -558,14 +614,18 @@ void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem
elmt->diagram()->showMe(); elmt->diagram()->showMe();
elmt->setHighlighted(true); elmt->setHighlighted(true);
m_showed_element = elmt; m_showed_element = elmt;
connect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted())); connect(m_showed_element, SIGNAL(destroyed()),
this, SLOT(showedElementWasDeleted()));
} }
void LinkSingleElementWidget::on_m_tree_widget_customContextMenuRequested(const QPoint &pos) void LinkSingleElementWidget::on_m_tree_widget_customContextMenuRequested(
const QPoint &pos)
{ {
//add the size of the header to display the topleft of the QMenu at the position of the mouse. //add the size of the header to display the topleft of the QMenu
//See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea //at the position of the mouse.
//See doc about QWidget::customContextMenuRequested
//section related to QAbstractScrollArea
QPoint point = pos; QPoint point = pos;
point.ry()+=ui->m_tree_widget->header()->height(); point.ry()+=ui->m_tree_widget->header()->height();
point = ui->m_tree_widget->mapToGlobal(point); point = ui->m_tree_widget->mapToGlobal(point);
@ -600,8 +660,9 @@ void LinkSingleElementWidget::on_m_show_this_pb_clicked()
/** /**
@brief LinkSingleElementWidget::on_m_search_field_textEdited @brief LinkSingleElementWidget::on_m_search_field_textEdited
Search all items which match with @arg1 and shows it, other items is hidden. Search all items which match with arg1 and shows it,
If @arg1 is empty, show all items. other items is hidden.
If arg1 is empty, show all items.
@param arg1 @param arg1
*/ */
void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1) void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1)

View File

@ -21,10 +21,10 @@
#include <QScopedPointer> #include <QScopedPointer>
MarginsEditDialog::MarginsEditDialog(QMargins margins, QWidget *parent) : MarginsEditDialog::MarginsEditDialog(QMargins margins, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::MarginsEditDialog) ui(new Ui::MarginsEditDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->m_top_sb->setValue(margins.top()); ui->m_top_sb->setValue(margins.top());
ui->m_left_sb->setValue(margins.left()); ui->m_left_sb->setValue(margins.left());
ui->m_right_sb->setValue(margins.right()); ui->m_right_sb->setValue(margins.right());
@ -37,7 +37,10 @@ MarginsEditDialog::~MarginsEditDialog()
} }
QMargins MarginsEditDialog::margins() const { QMargins MarginsEditDialog::margins() const {
return QMargins(ui->m_left_sb->value(), ui->m_top_sb->value(), ui->m_right_sb->value(), ui->m_bottom_sb->value()); return QMargins(ui->m_left_sb->value(),
ui->m_top_sb->value(),
ui->m_right_sb->value(),
ui->m_bottom_sb->value());
} }
/** /**
@ -45,11 +48,15 @@ QMargins MarginsEditDialog::margins() const {
@param margins : margins to set by default @param margins : margins to set by default
@param accepted : bool to know if dialog is accepted @param accepted : bool to know if dialog is accepted
@param parent : parent widget. @param parent : parent widget.
@return The a margins with the edited value if dialog is accepted or a default constructed QMargins() if dialog is rejected @return The a margins with the edited value if dialog is accepted
or a default constructed QMargins() if dialog is rejected
*/ */
QMargins MarginsEditDialog::getMargins(QMargins margins, bool *accepted, QWidget *parent) QMargins MarginsEditDialog::getMargins(QMargins margins,
bool *accepted,
QWidget *parent)
{ {
QScopedPointer<MarginsEditDialog> d(new MarginsEditDialog(margins, parent)); QScopedPointer<MarginsEditDialog> d(
new MarginsEditDialog(margins, parent));
if (d->exec()) if (d->exec())
{ {
if (accepted) { if (accepted) {

View File

@ -31,18 +31,21 @@ class MarginsEditDialog;
*/ */
class MarginsEditDialog : public QDialog class MarginsEditDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MarginsEditDialog(QMargins margins = QMargins(), QWidget *parent = nullptr); explicit MarginsEditDialog(QMargins margins = QMargins(),
~MarginsEditDialog(); QWidget *parent = nullptr);
~MarginsEditDialog();
QMargins margins() const; QMargins margins() const;
static QMargins getMargins(QMargins margins = QMargins(), bool *accepted = nullptr, QWidget *parent = nullptr); static QMargins getMargins(QMargins margins = QMargins(),
bool *accepted = nullptr,
QWidget *parent = nullptr);
private: private:
Ui::MarginsEditDialog *ui; Ui::MarginsEditDialog *ui;
}; };
#endif // MARGINSEDITDIALOG_H #endif // MARGINSEDITDIALOG_H

View File

@ -93,7 +93,7 @@ void MultiPasteDialog::updatePreview()
void MultiPasteDialog::on_m_button_box_accepted() void MultiPasteDialog::on_m_button_box_accepted()
{ {
if(m_pasted_content.count()) if(m_pasted_content.count())
{ {
m_diagram->undoStack().beginMacro(tr("Multi-collage")); m_diagram->undoStack().beginMacro(tr("Multi-collage"));

View File

@ -221,7 +221,9 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
@param parent_undo : undo parent to use. @param parent_undo : undo parent to use.
@param parent : parent widget. @param parent : parent widget.
*/ */
PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo, QWidget *parent) : PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor,
QUndoCommand *parent_undo,
QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::PotentialSelectorDialog), ui(new Ui::PotentialSelectorDialog),
m_conductor(conductor), m_conductor(conductor),
@ -236,11 +238,14 @@ PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor, QUndoComm
/** /**
@brief PotentialSelectorDialog::PotentialSelectorDialog @brief PotentialSelectorDialog::PotentialSelectorDialog
Constructor when we link two potentiels together, with a folio report. Constructor when we link two potentiels together, with a folio report.
@param report : one of the report used to link the potentials (report must be linked to another report) @param report : one of the report used to link the potentials
(report must be linked to another report)
@param parent_undo : undo parent to use @param parent_undo : undo parent to use
@param parent : parent widget @param parent : parent widget
*/ */
PotentialSelectorDialog::PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo, QWidget *parent) : PotentialSelectorDialog::PotentialSelectorDialog(Element *report,
QUndoCommand *parent_undo,
QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::PotentialSelectorDialog), ui(new Ui::PotentialSelectorDialog),
m_conductor(nullptr), m_conductor(nullptr),
@ -254,7 +259,7 @@ PotentialSelectorDialog::PotentialSelectorDialog(Element *report, QUndoCommand *
PotentialSelectorDialog::~PotentialSelectorDialog() PotentialSelectorDialog::~PotentialSelectorDialog()
{ {
delete ui; delete ui;
delete m_potential_selector; delete m_potential_selector;
} }
@ -264,7 +269,9 @@ PotentialSelectorDialog::~PotentialSelectorDialog()
*/ */
void PotentialSelectorDialog::buildWidget() void PotentialSelectorDialog::buildWidget()
{ {
QString text1(tr("%n conducteurs composent le potentiel suivant :", "", m_potential_selector->m_conductor_number_1)); QString text1(tr("%n conducteurs composent le potentiel suivant :",
"",
m_potential_selector->m_conductor_number_1));
ConductorProperties cp1; ConductorProperties cp1;
if(!m_potential_selector->m_properties_list_1.isEmpty()) if(!m_potential_selector->m_properties_list_1.isEmpty())
@ -275,13 +282,18 @@ void PotentialSelectorDialog::buildWidget()
if(!cp1.m_function.isEmpty()) if(!cp1.m_function.isEmpty())
text1.append(tr("\nFonction : %1").arg(cp1.m_function)); text1.append(tr("\nFonction : %1").arg(cp1.m_function));
if(!cp1.m_tension_protocol.isEmpty()) if(!cp1.m_tension_protocol.isEmpty())
text1.append(tr("\nTension/protocole : %1").arg(cp1.m_tension_protocol)); text1.append(tr("\nTension/protocole : %1")
.arg(cp1.m_tension_protocol));
if(!cp1.m_wire_color.isEmpty()) if(!cp1.m_wire_color.isEmpty())
text1.append(tr("\nCouleur du conducteur : %1").arg(cp1.m_wire_color)); text1.append(tr("\nCouleur du conducteur : %1")
.arg(cp1.m_wire_color));
if(!cp1.m_wire_section.isEmpty()) if(!cp1.m_wire_section.isEmpty())
text1.append(tr("\nSection du conducteur : %1").arg(cp1.m_wire_section)); text1.append(tr("\nSection du conducteur : %1")
.arg(cp1.m_wire_section));
QString text2(tr("%n conducteurs composent le potentiel suivant :", "", m_potential_selector->m_conductor_number_2)); QString text2(tr("%n conducteurs composent le potentiel suivant :",
"",
m_potential_selector->m_conductor_number_2));
ConductorProperties cp2; ConductorProperties cp2;
if(!m_potential_selector->m_properties_list_2.isEmpty()) if(!m_potential_selector->m_properties_list_2.isEmpty())
cp2 = m_potential_selector->m_properties_list_2.first(); cp2 = m_potential_selector->m_properties_list_2.first();
@ -291,11 +303,14 @@ void PotentialSelectorDialog::buildWidget()
if(!cp2.m_function.isEmpty()) if(!cp2.m_function.isEmpty())
text2.append(tr("\nFonction : %1").arg(cp2.m_function)); text2.append(tr("\nFonction : %1").arg(cp2.m_function));
if(!cp2.m_tension_protocol.isEmpty()) if(!cp2.m_tension_protocol.isEmpty())
text2.append(tr("\nTension/protocole : %1").arg(cp2.m_tension_protocol)); text2.append(tr("\nTension/protocole : %1")
.arg(cp2.m_tension_protocol));
if(!cp2.m_wire_color.isEmpty()) if(!cp2.m_wire_color.isEmpty())
text2.append(tr("\nCouleur du conducteur : %1").arg(cp2.m_wire_color)); text2.append(tr("\nCouleur du conducteur : %1")
.arg(cp2.m_wire_color));
if(!cp2.m_wire_section.isEmpty()) if(!cp2.m_wire_section.isEmpty())
text2.append(tr("\nSection du conducteur : %1").arg(cp2.m_wire_section)); text2.append(tr("\nSection du conducteur : %1")
.arg(cp2.m_wire_section));
QRadioButton *rb1 = new QRadioButton(text1, this); QRadioButton *rb1 = new QRadioButton(text1, this);
QRadioButton *rb2 = new QRadioButton(text2, this); QRadioButton *rb2 = new QRadioButton(text2, this);
@ -304,24 +319,35 @@ void PotentialSelectorDialog::buildWidget()
{ {
if(t) if(t)
{ {
this->m_sequential_num = this->m_potential_selector->m_seq_num_1; this->m_sequential_num =
this->m_properties_list = this->m_potential_selector->m_properties_list_1; this->m_potential_selector->m_seq_num_1;
this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_2; this->m_properties_list =
this->m_potential_selector
->m_properties_list_1;
this->m_conductors_to_change =
this->m_potential_selector
->m_conductors_list_2;
} }
}); });
connect(rb2, &QRadioButton::toggled, [this](bool t) connect(rb2, &QRadioButton::toggled, [this](bool t)
{ {
if(t) if(t)
{ {
this->m_sequential_num = this->m_potential_selector->m_seq_num_2; this->m_sequential_num =
this->m_properties_list = this->m_potential_selector->m_properties_list_2; this->m_potential_selector->m_seq_num_2;
this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_1; this->m_properties_list =
this->m_potential_selector
->m_properties_list_2;
this->m_conductors_to_change =
this->m_potential_selector
->m_conductors_list_1;
} }
}); });
//Set the radio button of potential with the bigger number of conductors, //Set the radio button of potential with the bigger number of conductors,
//at first position, and check it //at first position, and check it
if (m_potential_selector->m_conductor_number_1 >= m_potential_selector->m_conductor_number_2) if (m_potential_selector->m_conductor_number_1 >=
m_potential_selector->m_conductor_number_2)
{ {
ui->verticalLayout->insertWidget(1, rb1); ui->verticalLayout->insertWidget(1, rb1);
ui->verticalLayout->insertWidget(2, rb2); ui->verticalLayout->insertWidget(2, rb2);
@ -348,13 +374,16 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
if (m_parent_undo) if (m_parent_undo)
undo = m_parent_undo; undo = m_parent_undo;
else else
undo = new QUndoCommand(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption")); undo = new QUndoCommand(
tr("Modifier les propriétés de plusieurs conducteurs",
"undo caption"));
Diagram * diagram = nullptr; Diagram * diagram = nullptr;
if (m_report) if (m_report)
{ {
if ((m_report->linkType() & Element::AllReport) && !m_report->isFree()) if ((m_report->linkType() & Element::AllReport)
&& !m_report->isFree())
{ {
if (m_report->diagram()) if (m_report->diagram())
diagram = m_report->diagram(); diagram = m_report->diagram();
@ -363,7 +392,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
QVariant old_seq, new_seq; QVariant old_seq, new_seq;
new_seq.setValue(m_sequential_num); new_seq.setValue(m_sequential_num);
//Set the new properties for each conductors of the new potential //Set the new properties for each conductors of the new potential
foreach(Conductor *cond, m_conductors_to_change) foreach(Conductor *cond, m_conductors_to_change)
{ {
ConductorProperties new_properties = cond->properties(); ConductorProperties new_properties = cond->properties();
@ -371,18 +400,33 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
old_value.setValue(cond->properties()); old_value.setValue(cond->properties());
new_value.setValue(new_properties); new_value.setValue(new_properties);
old_seq.setValue(cond->sequenceNum()); old_seq.setValue(cond->sequenceNum());
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo); new QPropertyUndoCommand(cond,
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo); "sequenceNum",
old_seq,
new_seq,
undo);
new QPropertyUndoCommand(cond,
"properties",
old_value,
new_value,
undo);
} }
//Check if formula of the new potential have incompatible variable with folio report //Check if formula of the new potential
// have incompatible variable with folio report
QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM"); QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM");
foreach(ConductorProperties cp, m_properties_list) foreach(ConductorProperties cp, m_properties_list)
{ {
if (cp.m_formula.contains(rx)) if (cp.m_formula.contains(rx))
{ {
QStringList forbidden_str; QStringList forbidden_str;
forbidden_str << "%sequf_" << "%seqtf_" << "%seqhf_" << "%id" << "%F" << "%M" << "%LM"; forbidden_str << "%sequf_"
<< "%seqtf_"
<< "%seqhf_"
<< "%id"
<< "%F"
<< "%M"
<< "%LM";
QString text(tr("La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n" QString text(tr("La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n"
"Veuillez saisir une formule compatible pour ce potentiel.\n" "Veuillez saisir une formule compatible pour ce potentiel.\n"
@ -403,7 +447,11 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
ConductorProperties new_properties = cond->properties(); ConductorProperties new_properties = cond->properties();
new_properties.m_formula = new_formula; new_properties.m_formula = new_formula;
new_value.setValue(new_properties); new_value.setValue(new_properties);
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo); new QPropertyUndoCommand(cond,
"properties",
old_value,
new_value,
undo);
} }
break; break;
@ -428,8 +476,16 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
old_seq.setValue(m_conductor->sequenceNum()); old_seq.setValue(m_conductor->sequenceNum());
new_seq.setValue(m_sequential_num); new_seq.setValue(m_sequential_num);
new QPropertyUndoCommand(m_conductor, "sequenceNum", old_seq, new_seq, undo); new QPropertyUndoCommand(m_conductor,
new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, undo); "sequenceNum",
old_seq,
new_seq,
undo);
new QPropertyUndoCommand(m_conductor,
"properties",
old_value,
new_value,
undo);
//Set the new properties for each conductors of the new potential //Set the new properties for each conductors of the new potential
foreach(Conductor *cond, m_conductor->relatedPotentialConductors()) foreach(Conductor *cond, m_conductor->relatedPotentialConductors())
@ -439,15 +495,24 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
old_value.setValue(cond->properties()); old_value.setValue(cond->properties());
new_value.setValue(new_properties); new_value.setValue(new_properties);
old_seq.setValue(cond->sequenceNum()); old_seq.setValue(cond->sequenceNum());
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo); new QPropertyUndoCommand(cond,
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo); "sequenceNum",
old_seq,
new_seq,
undo);
new QPropertyUndoCommand(cond,
"properties",
old_value,
new_value,
undo);
} }
} }
//There is an undo parent, we stop here, the owner of m_parent_undo will push it to an undo stack //There is an undo parent, we stop here,
//the owner of m_parent_undo will push it to an undo stack
if (m_parent_undo) if (m_parent_undo)
return; return;
//There isn't a parent, we push the undo command to diagram undo stack. //There isn't a parent, we push the undo command to diagram undo stack.
if (diagram) if (diagram)
diagram->undoStack().push(undo); diagram->undoStack().push(undo);
} }

View File

@ -28,13 +28,16 @@ class Element;
class AbstractPotentialSelector class AbstractPotentialSelector
{ {
public: public:
AbstractPotentialSelector() : m_conductor_number_1(0), m_conductor_number_2(0) {} AbstractPotentialSelector()
: m_conductor_number_1(0)
, m_conductor_number_2(0) {}
virtual ~AbstractPotentialSelector() {} virtual ~AbstractPotentialSelector() {}
virtual bool isValid() const = 0; virtual bool isValid() const = 0;
autonum::sequentialNumbers m_seq_num_1, m_seq_num_2; autonum::sequentialNumbers m_seq_num_1, m_seq_num_2;
int m_conductor_number_1, m_conductor_number_2; int m_conductor_number_1, m_conductor_number_2;
QList<ConductorProperties> m_properties_list_1, m_properties_list_2; QList<ConductorProperties> m_properties_list_1,
m_properties_list_2;
QList <Conductor *> m_conductors_list_1, m_conductors_list_2; QList <Conductor *> m_conductors_list_1, m_conductors_list_2;
}; };
@ -44,41 +47,54 @@ namespace Ui {
/** /**
@brief The PotentialSelectorDialog class @brief The PotentialSelectorDialog class
This dialog is used when user try to connect two existing potential together. This dialog is used when user try to connect
The dialog ask to user to make a choice between the properties of the two existing potential, two existing potential together.
The dialog ask to user to make a choice between
the properties of the two existing potential,
to apply it for the new potential. to apply it for the new potential.
*
Each constructor have a QUndoCommand @parent_undo for parameter Each constructor have a QUndoCommand @parent_undo for parameter
If @parent_undo isn't null, when user click on OK button, the dialog will use the parent-undo If @parent_undo isn't null, when user click on OK button,
the dialog will use the parent-undo
as parent of the undo command that describe the changes. as parent of the undo command that describe the changes.
If @parent_undo is null, the created undo-command is push to the undo stack of the parent diagram of a conductor in potential. If parent_undo is null, the created undo-command is push
to the undo stack of the parent diagram of a conductor in potential.
else we apply the change without a QUndoCommand. else we apply the change without a QUndoCommand.
the static function chosenProperties, open a dialog who ask user to make a choice between the given the static function chosenProperties,
open a dialog who ask user to make a choice between the given
properties properties
*/ */
class PotentialSelectorDialog : public QDialog class PotentialSelectorDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
static ConductorProperties chosenProperties(QList<ConductorProperties> list, QWidget *parent = nullptr); static ConductorProperties chosenProperties(
QList<ConductorProperties> list,
QWidget *parent = nullptr);
public: public:
explicit PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr); explicit PotentialSelectorDialog(
explicit PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr); Conductor *conductor,
~PotentialSelectorDialog() override; QUndoCommand *parent_undo = nullptr,
QWidget *parent = nullptr);
explicit PotentialSelectorDialog(
Element *report,
QUndoCommand *parent_undo = nullptr,
QWidget *parent = nullptr);
~PotentialSelectorDialog() override;
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();
private: private:
void buildWidget(); void buildWidget();
private: private:
Ui::PotentialSelectorDialog *ui; Ui::PotentialSelectorDialog *ui;
Conductor *m_conductor; Conductor *m_conductor;
Element *m_report; Element *m_report;
QUndoCommand *m_parent_undo; QUndoCommand *m_parent_undo;
autonum::sequentialNumbers m_sequential_num; autonum::sequentialNumbers m_sequential_num;

View File

@ -28,18 +28,17 @@
@param parent : parent widget of this dialog @param parent : parent widget of this dialog
*/ */
ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *parent) { ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *parent) {
NewDiagramPage *newDiagramPage = new NewDiagramPage(project,parent,this); NewDiagramPage *newDiagramPage = new NewDiagramPage(project,parent,this);
ProjectAutoNumConfigPage *projectAutoNumConfigPage = new ProjectAutoNumConfigPage (project); ProjectAutoNumConfigPage *projectAutoNumConfigPage = new ProjectAutoNumConfigPage (project);
m_properties_dialog = new ConfigDialog (parent); m_properties_dialog = new ConfigDialog (parent);
m_properties_dialog -> setWindowTitle(QObject::tr("Propriétés du projet", "window title")); m_properties_dialog -> setWindowTitle(QObject::tr("Propriétés du projet", "window title"));
m_properties_dialog -> addPage(new ProjectMainConfigPage (project)); m_properties_dialog -> addPage(new ProjectMainConfigPage (project));
m_properties_dialog -> addPage(newDiagramPage); m_properties_dialog -> addPage(newDiagramPage);
m_properties_dialog -> addPage(projectAutoNumConfigPage); m_properties_dialog -> addPage(projectAutoNumConfigPage);
connect(projectAutoNumConfigPage,SIGNAL(setAutoNum(QString)),newDiagramPage,SLOT(setFolioAutonum(QString))); connect(projectAutoNumConfigPage,SIGNAL(setAutoNum(QString)),newDiagramPage,SLOT(setFolioAutonum(QString)));
connect(projectAutoNumConfigPage,SIGNAL(saveCurrentTbp()),newDiagramPage,SLOT(saveCurrentTbp())); connect(projectAutoNumConfigPage,SIGNAL(saveCurrentTbp()),newDiagramPage,SLOT(saveCurrentTbp()));
connect(projectAutoNumConfigPage,SIGNAL(loadSavedTbp()),newDiagramPage,SLOT(loadSavedTbp())); connect(projectAutoNumConfigPage,SIGNAL(loadSavedTbp()),newDiagramPage,SLOT(loadSavedTbp()));
m_properties_dialog->setMinimumHeight(690); m_properties_dialog->setMinimumHeight(690);
} }
/** /**
@ -72,6 +71,8 @@ void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) {
Change the current displayed tab to folio tab. Change the current displayed tab to folio tab.
*/ */
void ProjectPropertiesDialog::changeToFolio() { void ProjectPropertiesDialog::changeToFolio() {
ProjectAutoNumConfigPage *autoNumPage = static_cast <ProjectAutoNumConfigPage*>(m_properties_dialog->pages.at(2)); ProjectAutoNumConfigPage *autoNumPage =
static_cast <ProjectAutoNumConfigPage*>(
m_properties_dialog->pages.at(2));
autoNumPage->changeToTab(3); autoNumPage->changeToTab(3);
} }

View File

@ -39,7 +39,7 @@ class ProjectPropertiesDialog : public QObject {
~ProjectPropertiesDialog() override; ~ProjectPropertiesDialog() override;
void exec(); void exec();
void setCurrentPage(ProjectPropertiesDialog::Page); void setCurrentPage(ProjectPropertiesDialog::Page);
void changeToFolio(); void changeToFolio();
private: private:
ConfigDialog *m_properties_dialog; ConfigDialog *m_properties_dialog;

View File

@ -427,7 +427,7 @@ void TitleBlockPropertiesWidget::on_m_date_now_pb_clicked() {
Open Auto Folio Num dialog Open Auto Folio Num dialog
*/ */
void TitleBlockPropertiesWidget::on_m_edit_autofolionum_pb_clicked() { void TitleBlockPropertiesWidget::on_m_edit_autofolionum_pb_clicked() {
emit openAutoNumFolioEditor(ui->auto_page_cb->currentText()); emit openAutoNumFolioEditor(ui->auto_page_cb->currentText());
if (ui->auto_page_cb->currentText()!=tr("Créer un Folio Numérotation Auto")) if (ui->auto_page_cb->currentText()!=tr("Créer un Folio Numérotation Auto"))
{ {
//still to implement: load current auto folio num settings //still to implement: load current auto folio num settings

View File

@ -58,7 +58,8 @@ XRefPropertiesWidget::~XRefPropertiesWidget()
set new properties for this widget set new properties for this widget
@param properties @param properties
*/ */
void XRefPropertiesWidget::setProperties(const QHash <QString, XRefProperties> &properties) { void XRefPropertiesWidget::setProperties(const QHash <QString,
XRefProperties> &properties) {
m_properties = properties; m_properties = properties;
updateDisplay(); updateDisplay();
m_previous_type_index = ui->m_type_cb->currentIndex(); m_previous_type_index = ui->m_type_cb->currentIndex();
@ -94,11 +95,11 @@ void XRefPropertiesWidget::setReadOnly(bool ro) {
*/ */
void XRefPropertiesWidget::buildUi() void XRefPropertiesWidget::buildUi()
{ {
ui -> m_type_cb -> addItem(tr("Bobine"), "coil"); ui -> m_type_cb -> addItem(tr("Bobine"), "coil");
ui -> m_type_cb -> addItem(tr("Organe de protection"), "protection"); ui -> m_type_cb -> addItem(tr("Organe de protection"), "protection");
ui -> m_type_cb -> addItem(tr("Commutateur / bouton"), "commutator"); ui -> m_type_cb -> addItem(tr("Commutateur / bouton"), "commutator");
ui -> m_snap_to_cb -> addItem(tr("En bas de page"), "bottom"); ui -> m_snap_to_cb -> addItem(tr("En bas de page"), "bottom");
ui -> m_snap_to_cb -> addItem(tr("Sous le label de l'élément"), "label"); ui -> m_snap_to_cb -> addItem(tr("Sous le label de l'élément"), "label");
ui -> m_xrefpos_cb -> addItem(tr("Top"),"top"); ui -> m_xrefpos_cb -> addItem(tr("Top"),"top");
@ -118,11 +119,16 @@ void XRefPropertiesWidget::saveProperties(int index) {
QString type = ui->m_type_cb->itemData(index).toString(); QString type = ui->m_type_cb->itemData(index).toString();
XRefProperties xrp = m_properties[type]; XRefProperties xrp = m_properties[type];
if (ui->m_display_has_cross_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Cross); if (ui->m_display_has_cross_rb->isChecked())
else if (ui->m_display_has_contacts_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Contacts); xrp.setDisplayHas(XRefProperties::Cross);
if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom") else if (ui->m_display_has_contacts_rb->isChecked())
xrp.setSnapTo(XRefProperties::Bottom); xrp.setDisplayHas(XRefProperties::Contacts);
else xrp.setSnapTo(XRefProperties::Label); if (ui->m_snap_to_cb->itemData(
ui->m_snap_to_cb->currentIndex()).toString()
== "bottom")
xrp.setSnapTo(XRefProperties::Bottom);
else
xrp.setSnapTo(XRefProperties::Label);