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

@ -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_protection_cb, 5);
#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
#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
{
auto check_box = static_cast<QCheckBox *>(m_button_group.button(0));
@ -352,7 +356,7 @@ QString BOMExportDialog::headers() const
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"))
{

View File

@ -36,7 +36,8 @@ class BOMExportDialog : public QDialog
Q_OBJECT
public:
explicit BOMExportDialog(QETProject *project, QWidget *parent = nullptr);
explicit BOMExportDialog(QETProject *project,
QWidget *parent = nullptr);
~BOMExportDialog() override;
virtual int exec() override;
@ -60,7 +61,8 @@ class BOMExportDialog : public QDialog
QString headers() const;
bool createDataBase();
void populateDataBase();
QHash<QString, QString> elementInfoToString(Element *elmt) const;
QHash<QString, QString> elementInfoToString(
Element *elmt) const;
QString queryStr() const;
void updateQueryLine();
void fillSavedQuery();

View File

@ -66,7 +66,8 @@ void diagramselection::load_TableDiagram() {
QTableWidgetItem *item_State = new QTableWidgetItem();
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_State -> setData(Qt::CheckStateRole, Qt::Checked);

View File

@ -115,11 +115,14 @@ bool DynamicElementTextModel::indexIsInGroup(const QModelIndex &index) const
/**
@brief DynamicElementTextModel::itemsForText
@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 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;
@ -127,7 +130,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
return qsi_list;
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);
@ -136,11 +141,15 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
src->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QString title;
if (deti->textFrom() == DynamicElementTextItem::UserText) title = tr("Texte utilisateur");
else if (deti->textFrom() == DynamicElementTextItem::ElementInfo) title = tr("Information de l'élément");
if (deti->textFrom() == DynamicElementTextItem::UserText)
title = tr("Texte utilisateur");
else if (deti->textFrom() == DynamicElementTextItem::ElementInfo)
title = tr("Information de l'élément");
else title = tr("Texte composé");
QStandardItem *srca = new QStandardItem(title);
srca->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
srca->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
srca->setData(textFrom, Qt::UserRole+1);
qsi_list << src << srca;
@ -151,7 +160,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
usr->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QStandardItem *usra = new QStandardItem(deti->toPlainText());
usra->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
usra->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
usra->setData(DynamicElementTextModel::userText, Qt::UserRole+1);
qsi_list.clear();
@ -162,10 +173,17 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *info = new QStandardItem(tr("Information"));
info->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QStandardItem *infoa = new QStandardItem(QETApp::elementTranslatedInfoKey(deti->infoName()));
infoa->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
infoa->setData(DynamicElementTextModel::infoText, Qt::UserRole+1); //Use to know the edited thing
infoa->setData(deti->infoName(), Qt::UserRole+2); //Use to know to element info name
QStandardItem *infoa =
new QStandardItem(
QETApp::elementTranslatedInfoKey(
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 << info << infoa;
@ -178,12 +196,18 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
DiagramContext dc;
if(deti->elementUseForInfo())
dc = deti->elementUseForInfo()->elementInformations();
QStandardItem *compositea = new QStandardItem(deti->compositeText().isEmpty() ?
tr("Mon texte composé") :
autonum::AssignVariables::replaceVariable(deti->compositeText(), dc));
compositea->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
compositea->setData(DynamicElementTextModel::compositeText, Qt::UserRole+1); //Use to know the edited thing
compositea->setData(deti->compositeText(), Qt::UserRole+2); //Use to know to element composite formula
QStandardItem *compositea = new QStandardItem(deti->compositeText().isEmpty()
? tr("Mon texte composé")
: autonum::AssignVariables::replaceVariable(
deti->compositeText(), dc));
compositea->setFlags(Qt::ItemIsSelectable
| 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 << composite << compositea;
@ -196,7 +220,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *siza = new QStandardItem();
siza->setData(deti->font().pointSize(), Qt::EditRole);
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 << size << siza;
@ -224,7 +250,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
colora->setData(deti->color(), Qt::ForegroundRole);
colora->setData(deti->color(), Qt::EditRole);
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 << color << colora;
@ -238,7 +266,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
frame_a->setCheckable(true);
frame_a->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked);
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 << frame << frame_a;
@ -251,7 +281,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *width_a = new QStandardItem;
width_a->setData(deti->textWidth(), Qt::EditRole);
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 << width << width_a;
@ -266,7 +298,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *x_pos_a = new QStandardItem;
x_pos_a->setData(deti->pos().x(), Qt::EditRole);
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 << x_pos << x_pos_a;
@ -279,7 +313,9 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *y_pos_a = new QStandardItem;
y_pos_a->setData(deti->pos().y(), Qt::EditRole);
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 << y_pos << y_pos_a;
@ -291,8 +327,11 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
QStandardItem *rot_a = new QStandardItem;
rot_a->setData(deti->rotation(), Qt::EditRole);
rot_a->setData(DynamicElementTextModel::rotation, Qt::UserRole+1);
rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
rot_a->setData(DynamicElementTextModel::rotation,
Qt::UserRole+1);
rot_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear();;
qsi_list << rot << rot_a;
@ -303,9 +342,13 @@ QList<QStandardItem *> DynamicElementTextModel::itemsForText(DynamicElementTextI
alignment->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QStandardItem *alignmenta = new QStandardItem(tr("Éditer"));
alignmenta->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
alignmenta->setData(DynamicElementTextModel::txtAlignment, Qt::UserRole+1);
alignmenta->setData(QVariant::fromValue(deti->alignment()), Qt::UserRole+2);
alignmenta->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
alignmenta->setData(DynamicElementTextModel::txtAlignment,
Qt::UserRole+1);
alignmenta->setData(QVariant::fromValue(deti->alignment()),
Qt::UserRole+2);
qsi_list.clear();
qsi_list << alignment << alignmenta;
@ -354,10 +397,12 @@ void DynamicElementTextModel::removeText(DynamicElementTextItem *deti)
/**
@brief DynamicElementTextModel::textFromIndex
@param index
@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.
@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.
*/
DynamicElementTextItem *DynamicElementTextModel::textFromIndex(const QModelIndex &index) const
DynamicElementTextItem *DynamicElementTextModel::textFromIndex(
const QModelIndex &index) const
{
if(!index.isValid())
return nullptr;
@ -371,11 +416,13 @@ DynamicElementTextItem *DynamicElementTextModel::textFromIndex(const QModelIndex
/**
@brief DynamicElementTextModel::textFromItem
@param item
@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.
@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.
Note can return nullptr
*/
DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *item) const
DynamicElementTextItem *DynamicElementTextModel::textFromItem(
QStandardItem *item) const
{
//Get the item of the column 0
if(item->column() == 1)
@ -426,9 +473,10 @@ DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *ite
/**
@brief DynamicElementTextModel::indexFromText
@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))
return m_texts_list.value(text)->index();
@ -439,11 +487,14 @@ QModelIndex DynamicElementTextModel::indexFromText(DynamicElementTextItem *text)
/**
@brief DynamicElementTextModel::undoForEditedText
@param 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.
In other word, if the returned QUndoCommand have no child, that mean there is no change.
@return A QUndoCommand that describe all changes made for deti.
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.
*/
QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo) const
QUndoCommand *DynamicElementTextModel::undoForEditedText(
DynamicElementTextItem *deti,
QUndoCommand *parent_undo) const
{
QUndoCommand *undo = nullptr;
@ -565,11 +616,14 @@ QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem
@brief DynamicElementTextModel::undoForEditedGroup
@param group
@param parent_undo
@return A QUndoCommand that describe all changes made for @group.
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.
@return A QUndoCommand that describe all changes made for group.
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.
*/
QUndoCommand *DynamicElementTextModel::undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo) const
QUndoCommand *DynamicElementTextModel::undoForEditedGroup(
ElementTextItemGroup *group,
QUndoCommand *parent_undo) const
{
QUndoCommand *undo = nullptr;
if(parent_undo)
@ -640,7 +694,10 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
//Group
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);
QStandardItem *empty_qsi = new QStandardItem(0);
@ -664,8 +721,11 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
default: break;}
QStandardItem *alignment_a = new QStandardItem(text);
alignment_a->setData(DynamicElementTextModel::grpAlignment, Qt::UserRole+1);
alignment_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
alignment_a->setData(DynamicElementTextModel::grpAlignment,
Qt::UserRole+1);
alignment_a->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled
| Qt::ItemIsEditable);
qsi_list.clear();
qsi_list << alignment << alignment_a;
grp->appendRow(qsi_list);
@ -677,7 +737,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *x_pos_a = new QStandardItem;
x_pos_a->setData(group->pos().x(), Qt::EditRole);
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 << x_pos << x_pos_a;
@ -690,7 +752,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *y_pos_a = new QStandardItem;
y_pos_a->setData(group->pos().y(), Qt::EditRole);
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 << y_pos << y_pos_a;
@ -703,7 +767,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *rot_a = new QStandardItem;
rot_a->setData(group->rotation(), Qt::EditRole);
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 << rot << rot_a;
grp->appendRow(qsi_list);
@ -715,7 +781,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *v_adj_a = new QStandardItem;
v_adj_a->setData(group->verticalAdjustment(), Qt::EditRole);
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 << v_adj << v_adj_a;
grp->appendRow(qsi_list);
@ -728,7 +796,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
frame_a->setCheckable(true);
frame_a->setCheckState(group->frame()? Qt::Checked : Qt::Unchecked);
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 << frame_ << frame_a;
grp->appendRow(qsi_list);
@ -740,9 +810,14 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group)
QStandardItem *hold_bottom_a = new QStandardItem();
hold_bottom_a->setCheckable(true);
hold_bottom_a->setCheckState(group->holdToBottomPage() ? Qt::Checked : Qt::Unchecked);
hold_bottom_a->setData(DynamicElementTextModel::grpHoldBottom, Qt::UserRole+1);
hold_bottom_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
hold_bottom_a->setCheckState(group->holdToBottomPage()
? Qt::Checked
: 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 << hold_bottom << hold_bottom_a;
grp->appendRow(qsi_list);
@ -780,13 +855,15 @@ void DynamicElementTextModel::removeGroup(ElementTextItemGroup *group)
@param deti
@param group
*/
void DynamicElementTextModel::addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group)
void DynamicElementTextModel::addTextToGroup(DynamicElementTextItem *deti,
ElementTextItemGroup *group)
{
QStandardItem *group_item = m_groups_list.value(group);
group_item->appendRow(itemsForText(deti));
}
void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group)
void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti,
ElementTextItemGroup *group)
{
Q_UNUSED(group)
@ -802,10 +879,12 @@ void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti,
/**
@brief DynamicElementTextModel::groupFromIndex
@param index
@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.
@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.
*/
ElementTextItemGroup *DynamicElementTextModel::groupFromIndex(const QModelIndex &index) const
ElementTextItemGroup *DynamicElementTextModel::groupFromIndex(
const QModelIndex &index) const
{
if(!index.isValid())
return nullptr;
@ -819,10 +898,12 @@ ElementTextItemGroup *DynamicElementTextModel::groupFromIndex(const QModelIndex
/**
@brief DynamicElementTextModel::groupFromItem
@param item
@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.
@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.
*/
ElementTextItemGroup *DynamicElementTextModel::groupFromItem(QStandardItem *item) const
ElementTextItemGroup *DynamicElementTextModel::groupFromItem(
QStandardItem *item) const
{
//Get the item of the column 0
if(item->column() == 1)
@ -845,10 +926,11 @@ ElementTextItemGroup *DynamicElementTextModel::groupFromItem(QStandardItem *item
/**
@brief DynamicElementTextModel::indexFromGroup
@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
*/
QModelIndex DynamicElementTextModel::indexFromGroup(ElementTextItemGroup *group) const
QModelIndex DynamicElementTextModel::indexFromGroup(
ElementTextItemGroup *group) const
{
if(m_groups_list.keys().contains(group))
return m_groups_list.value(group)->index();
@ -870,7 +952,10 @@ bool DynamicElementTextModel::indexIsText(const QModelIndex &index) const
if(index.column() == 1)
{
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
item = itemFromIndex(this->index(index.row(),0));
}
@ -886,8 +971,8 @@ bool DynamicElementTextModel::indexIsText(const QModelIndex &index) const
/**
@brief DynamicElementTextModel::indexIsGroup
@param index
@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 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.
*/
bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const
{
@ -897,7 +982,9 @@ bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const
if(index.column() == 1)
{
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
item = itemFromIndex(this->index(index.row(),0));
}
@ -910,7 +997,12 @@ bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const
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);
@ -963,9 +1055,14 @@ bool DynamicElementTextModel::canDropMimeData(const QMimeData *data, Qt::DropAct
@param row
@param column
@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)
@ -1093,11 +1190,14 @@ QStringList DynamicElementTextModel::mimeTypes() const
/**
@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 tf
*/
void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf)
void DynamicElementTextModel::enableSourceText(
DynamicElementTextItem *deti,
DynamicElementTextItem::TextFrom tf)
{
if (!m_texts_list.contains(deti))
return;
@ -1128,7 +1228,8 @@ void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, Dyn
Enable/disable the item "group rotation" according the option hold to bottom
@param group
*/
void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *group)
void DynamicElementTextModel::enableGroupRotationAndPos(
ElementTextItemGroup *group)
{
if(!m_groups_list.contains(group))
return;
@ -1146,12 +1247,21 @@ void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *gr
}
else
{
qsi->child(x_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
qsi->child(x_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);
qsi->child(x_grp_row, 0)->setFlags(Qt::ItemIsSelectable
| Qt::ItemIsEnabled);
qsi->child(x_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,9 +1320,12 @@ 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
//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)
//We emit the signal only if @qsi is in the second column,
//because the data are stored on this column
//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();
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);
if (!qsi)
@ -1387,7 +1501,9 @@ void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, V
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);
if (!qsi)
@ -1448,7 +1564,10 @@ DynamicTextItemDelegate::DynamicTextItemDelegate(QObject *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())
{
@ -1615,7 +1734,10 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
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())
{
@ -1726,7 +1848,8 @@ bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
{
//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,
//the value is commited when the spinbox lose focus or enter key is pressed
//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" || \
@ -1752,7 +1875,8 @@ bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
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)
{
QComboBox *qcb = static_cast<QComboBox *>(object);
@ -1767,7 +1891,8 @@ bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
@param deti
@return A list of available info of element
*/
QStringList DynamicTextItemDelegate::availableInfo(DynamicElementTextItem *deti) const
QStringList DynamicTextItemDelegate::availableInfo(
DynamicElementTextItem *deti) const
{
QStringList qstrl;

View File

@ -135,6 +135,8 @@ Qt::CheckState ElementInfoPartWidget::EraseTextCheckState() const {
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());
}

View File

@ -33,7 +33,8 @@
@param parent
the parent widget
*/
LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) :
LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt,
QWidget *parent) :
AbstractElementPropertiesEditorWidget(parent),
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_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_link_action, &QAction::triggered, this, &LinkSingleElementWidget::linkTriggered);
connect(m_show_qtwi,
&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]()
{
@ -59,7 +66,10 @@ LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent)
QHeaderView *qhv = ui->m_tree_widget->header();
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]()
{
QByteArray qba = qhv->saveState();
@ -105,8 +115,14 @@ void LinkSingleElementWidget::setElement(Element *element)
//Remove connection of previous edited element
if (m_element)
{
disconnect(m_element->diagram()->project(), &QETProject::diagramRemoved, this, &LinkSingleElementWidget::diagramWasRemovedFromProject);
disconnect(m_element.data(), &Element::linkedElementChanged, this, &LinkSingleElementWidget::updateUi);
disconnect(m_element->diagram()->project(),
&QETProject::diagramRemoved,
this,
&LinkSingleElementWidget::diagramWasRemovedFromProject);
disconnect(m_element.data(),
&Element::linkedElementChanged,
this,
&LinkSingleElementWidget::updateUi);
m_element->setHighlighted(false);
}
@ -124,12 +140,16 @@ void LinkSingleElementWidget::setElement(Element *element)
if (m_element->linkType() & Element::Slave)
m_filter = Element::Master;
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
m_filter = Element::Simple;
connect(m_element->diagram()->project(), &QETProject::diagramRemoved, this, &LinkSingleElementWidget::diagramWasRemovedFromProject);
connect(m_element.data(), &Element::linkedElementChanged, this, &LinkSingleElementWidget::updateUi, Qt::QueuedConnection);
connect(m_element->diagram()->project(), &QETProject::diagramRemoved,
this, &LinkSingleElementWidget::diagramWasRemovedFromProject);
connect(m_element.data(), &Element::linkedElementChanged,
this, &LinkSingleElementWidget::updateUi, Qt::QueuedConnection);
updateUi();
}
@ -234,7 +254,8 @@ void LinkSingleElementWidget::buildTree()
if (settings.value("genericpanel/folio", false).toBool())
{
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;
}
else
@ -415,11 +436,19 @@ void LinkSingleElementWidget::setUpHeaderLabels()
{
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
{
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())
{
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
{
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
* 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
*/
void LinkSingleElementWidget::diagramWasRemovedFromProject()
{
//We use a timer because if the removed diagram 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
// We use a timer because if the removed diagram
// 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()));
}
@ -473,19 +519,25 @@ void LinkSingleElementWidget::linkTriggered()
}
else
{
//In no live edit mode, we set the background of the qtwi green, to inform the user
//which element will be linked when he press the apply button
//In no live edit mode, we set the background of the qtwi green,
// to inform the user
// which element will be linked when he press the apply button
if (m_pending_qtwi)
{
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++)
{
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;
}
@ -518,7 +570,8 @@ void LinkSingleElementWidget::showButtons()
ui->m_search_field->hide();
}
void LinkSingleElementWidget::headerCustomContextMenuRequested(const QPoint &pos)
void LinkSingleElementWidget::headerCustomContextMenuRequested(
const QPoint &pos)
{
m_context_menu->clear();
m_context_menu->addAction(m_save_header_state);
@ -544,13 +597,16 @@ void LinkSingleElementWidget::on_m_unlink_pb_clicked()
@param item
@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);
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);
}
@ -558,14 +614,18 @@ void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem
elmt->diagram()->showMe();
elmt->setHighlighted(true);
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.
//See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea
//add the size of the header to display the topleft of the QMenu
//at the position of the mouse.
//See doc about QWidget::customContextMenuRequested
//section related to QAbstractScrollArea
QPoint point = pos;
point.ry()+=ui->m_tree_widget->header()->height();
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
Search all items which match with @arg1 and shows it, other items is hidden.
If @arg1 is empty, show all items.
Search all items which match with arg1 and shows it,
other items is hidden.
If arg1 is empty, show all items.
@param arg1
*/
void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1)

View File

@ -37,7 +37,10 @@ MarginsEditDialog::~MarginsEditDialog()
}
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 accepted : bool to know if dialog is accepted
@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 (accepted) {

View File

@ -34,12 +34,15 @@ class MarginsEditDialog : public QDialog
Q_OBJECT
public:
explicit MarginsEditDialog(QMargins margins = QMargins(), QWidget *parent = nullptr);
explicit MarginsEditDialog(QMargins margins = QMargins(),
QWidget *parent = nullptr);
~MarginsEditDialog();
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:
Ui::MarginsEditDialog *ui;

View File

@ -221,7 +221,9 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
@param parent_undo : undo parent to use.
@param parent : parent widget.
*/
PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo, QWidget *parent) :
PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor,
QUndoCommand *parent_undo,
QWidget *parent) :
QDialog(parent),
ui(new Ui::PotentialSelectorDialog),
m_conductor(conductor),
@ -236,11 +238,14 @@ PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor, QUndoComm
/**
@brief PotentialSelectorDialog::PotentialSelectorDialog
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 : parent widget
*/
PotentialSelectorDialog::PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo, QWidget *parent) :
PotentialSelectorDialog::PotentialSelectorDialog(Element *report,
QUndoCommand *parent_undo,
QWidget *parent) :
QDialog(parent),
ui(new Ui::PotentialSelectorDialog),
m_conductor(nullptr),
@ -264,7 +269,9 @@ PotentialSelectorDialog::~PotentialSelectorDialog()
*/
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;
if(!m_potential_selector->m_properties_list_1.isEmpty())
@ -275,13 +282,18 @@ void PotentialSelectorDialog::buildWidget()
if(!cp1.m_function.isEmpty())
text1.append(tr("\nFonction : %1").arg(cp1.m_function));
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())
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())
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;
if(!m_potential_selector->m_properties_list_2.isEmpty())
cp2 = m_potential_selector->m_properties_list_2.first();
@ -291,11 +303,14 @@ void PotentialSelectorDialog::buildWidget()
if(!cp2.m_function.isEmpty())
text2.append(tr("\nFonction : %1").arg(cp2.m_function));
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())
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())
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 *rb2 = new QRadioButton(text2, this);
@ -304,24 +319,35 @@ void PotentialSelectorDialog::buildWidget()
{
if(t)
{
this->m_sequential_num = this->m_potential_selector->m_seq_num_1;
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;
this->m_sequential_num =
this->m_potential_selector->m_seq_num_1;
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)
{
if(t)
{
this->m_sequential_num = this->m_potential_selector->m_seq_num_2;
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;
this->m_sequential_num =
this->m_potential_selector->m_seq_num_2;
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,
//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(2, rb2);
@ -348,13 +374,16 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
if (m_parent_undo)
undo = m_parent_undo;
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;
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())
diagram = m_report->diagram();
@ -371,18 +400,33 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
old_value.setValue(cond->properties());
new_value.setValue(new_properties);
old_seq.setValue(cond->sequenceNum());
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
new QPropertyUndoCommand(cond,
"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");
foreach(ConductorProperties cp, m_properties_list)
{
if (cp.m_formula.contains(rx))
{
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"
"Veuillez saisir une formule compatible pour ce potentiel.\n"
@ -403,7 +447,11 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
ConductorProperties new_properties = cond->properties();
new_properties.m_formula = new_formula;
new_value.setValue(new_properties);
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
new QPropertyUndoCommand(cond,
"properties",
old_value,
new_value,
undo);
}
break;
@ -428,8 +476,16 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
old_seq.setValue(m_conductor->sequenceNum());
new_seq.setValue(m_sequential_num);
new QPropertyUndoCommand(m_conductor, "sequenceNum", old_seq, new_seq, undo);
new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, undo);
new QPropertyUndoCommand(m_conductor,
"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
foreach(Conductor *cond, m_conductor->relatedPotentialConductors())
@ -439,12 +495,21 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
old_value.setValue(cond->properties());
new_value.setValue(new_properties);
old_seq.setValue(cond->sequenceNum());
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
new QPropertyUndoCommand(cond,
"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)
return;
//There isn't a parent, we push the undo command to diagram undo stack.

View File

@ -28,13 +28,16 @@ class Element;
class AbstractPotentialSelector
{
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 bool isValid() const = 0;
autonum::sequentialNumbers m_seq_num_1, m_seq_num_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;
};
@ -44,17 +47,22 @@ namespace Ui {
/**
@brief The PotentialSelectorDialog class
This dialog is used when user try to connect two existing potential together.
The dialog ask to user to make a choice between the properties of the two existing potential,
This dialog is used when user try to connect
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.
*
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.
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.
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
*/
class PotentialSelectorDialog : public QDialog
@ -62,11 +70,19 @@ class PotentialSelectorDialog : public QDialog
Q_OBJECT
public:
static ConductorProperties chosenProperties(QList<ConductorProperties> list, QWidget *parent = nullptr);
static ConductorProperties chosenProperties(
QList<ConductorProperties> list,
QWidget *parent = nullptr);
public:
explicit PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr);
explicit PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr);
explicit PotentialSelectorDialog(
Conductor *conductor,
QUndoCommand *parent_undo = nullptr,
QWidget *parent = nullptr);
explicit PotentialSelectorDialog(
Element *report,
QUndoCommand *parent_undo = nullptr,
QWidget *parent = nullptr);
~PotentialSelectorDialog() override;

View File

@ -39,7 +39,6 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *p
connect(projectAutoNumConfigPage,SIGNAL(saveCurrentTbp()),newDiagramPage,SLOT(saveCurrentTbp()));
connect(projectAutoNumConfigPage,SIGNAL(loadSavedTbp()),newDiagramPage,SLOT(loadSavedTbp()));
m_properties_dialog->setMinimumHeight(690);
}
/**
@ -72,6 +71,8 @@ void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) {
Change the current displayed tab to folio tab.
*/
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);
}

View File

@ -58,7 +58,8 @@ XRefPropertiesWidget::~XRefPropertiesWidget()
set new properties for this widget
@param properties
*/
void XRefPropertiesWidget::setProperties(const QHash <QString, XRefProperties> &properties) {
void XRefPropertiesWidget::setProperties(const QHash <QString,
XRefProperties> &properties) {
m_properties = properties;
updateDisplay();
m_previous_type_index = ui->m_type_cb->currentIndex();
@ -118,11 +119,16 @@ void XRefPropertiesWidget::saveProperties(int index) {
QString type = ui->m_type_cb->itemData(index).toString();
XRefProperties xrp = m_properties[type];
if (ui->m_display_has_cross_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Cross);
else if (ui->m_display_has_contacts_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Contacts);
if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom")
if (ui->m_display_has_cross_rb->isChecked())
xrp.setDisplayHas(XRefProperties::Cross);
else if (ui->m_display_has_contacts_rb->isChecked())
xrp.setDisplayHas(XRefProperties::Contacts);
if (ui->m_snap_to_cb->itemData(
ui->m_snap_to_cb->currentIndex()).toString()
== "bottom")
xrp.setSnapTo(XRefProperties::Bottom);
else xrp.setSnapTo(XRefProperties::Label);
else
xrp.setSnapTo(XRefProperties::Label);