Improve code style

This commit is contained in:
Simon De Backer 2020-08-16 14:25:31 +02:00
parent 6c806d151d
commit e55d336dc1
9 changed files with 85 additions and 56 deletions

View File

@ -547,7 +547,8 @@ QList<CustomElementPart*> StyleEditor::currentParts() const {
/** /**
@brief StyleEditor::isStyleEditable @brief StyleEditor::isStyleEditable
@param cep_list @param cep_list
@return true if all of the content of cep_list can be edited by style editor, else return false. @return true if all of the content of cep_list
can be edited by style editor, else return false.
*/ */
bool StyleEditor::isStyleEditable(QList<CustomElementPart *> cep_list) bool StyleEditor::isStyleEditable(QList<CustomElementPart *> cep_list)
{ {

View File

@ -29,7 +29,9 @@
@param part @param part
@param parent @param parent
*/ */
PolygonEditor::PolygonEditor(QETElementEditor *editor, PartPolygon *part, QWidget *parent) : PolygonEditor::PolygonEditor(QETElementEditor *editor,
PartPolygon *part,
QWidget *parent) :
ElementItemEditor(editor, parent), ElementItemEditor(editor, parent),
ui(new Ui::PolygonEditor), ui(new Ui::PolygonEditor),
m_part(part) m_part(part)
@ -52,10 +54,22 @@ PolygonEditor::~PolygonEditor() {
void PolygonEditor::setUpChangeConnections() void PolygonEditor::setUpChangeConnections()
{ {
m_change_connections << connect(m_part, &PartPolygon::polygonChanged, this, &PolygonEditor::updateForm); m_change_connections << connect(m_part,
m_change_connections << connect(m_part, &PartPolygon::closedChange, this, &PolygonEditor::updateForm); &PartPolygon::polygonChanged,
m_change_connections << connect(m_part, &PartPolygon::xChanged, this, &PolygonEditor::updateForm); this,
m_change_connections << connect(m_part, &PartPolygon::yChanged, this, &PolygonEditor::updateForm); &PolygonEditor::updateForm);
m_change_connections << connect(m_part,
&PartPolygon::closedChange,
this,
&PolygonEditor::updateForm);
m_change_connections << connect(m_part,
&PartPolygon::xChanged,
this,
&PolygonEditor::updateForm);
m_change_connections << connect(m_part,
&PartPolygon::yChanged,
this,
&PolygonEditor::updateForm);
} }
void PolygonEditor::disconnectChangeConnections() void PolygonEditor::disconnectChangeConnections()
@ -131,7 +145,8 @@ void PolygonEditor::updateForm()
ui->m_points_list_tree->addTopLevelItem(qtwi); ui->m_points_list_tree->addTopLevelItem(qtwi);
} }
ui->m_close_polygon_cb->setChecked(m_part->isClosed()); ui->m_close_polygon_cb->setChecked(m_part->isClosed());
ui->m_remove_point_action->setEnabled(m_part->polygon().size() > 2 ? true : false); ui->m_remove_point_action->setEnabled(m_part->polygon().size()
> 2 ? true : false);
} }
/** /**
@ -185,7 +200,11 @@ void PolygonEditor::on_m_close_polygon_cb_stateChanged(int arg1)
bool close = ui->m_close_polygon_cb->isChecked(); bool close = ui->m_close_polygon_cb->isChecked();
if (close != m_part->isClosed()) if (close != m_part->isClosed())
{ {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "closed", m_part->property("closed"), close); QPropertyUndoCommand *undo =
new QPropertyUndoCommand(m_part,
"closed",
m_part->property("closed"),
close);
undo->setText(tr("Modifier un polygone")); undo->setText(tr("Modifier un polygone"));
undoStack().push(undo); undoStack().push(undo);
} }
@ -195,7 +214,8 @@ void PolygonEditor::on_m_close_polygon_cb_stateChanged(int arg1)
@brief PolygonEditor::on_m_points_list_tree_itemChanged @brief PolygonEditor::on_m_points_list_tree_itemChanged
Update the polygon according to the current value of the tree editor Update the polygon according to the current value of the tree editor
*/ */
void PolygonEditor::on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int column) void PolygonEditor::on_m_points_list_tree_itemChanged(QTreeWidgetItem *item,
int column)
{ {
Q_UNUSED(item); Q_UNUSED(item);
Q_UNUSED(column); Q_UNUSED(column);
@ -207,13 +227,21 @@ void PolygonEditor::on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int
QPolygonF points = pointsFromTree(); QPolygonF points = pointsFromTree();
if (points.count() < 2) if (points.count() < 2)
{ {
QET::QetMessageBox::warning(this, tr("Erreur", "message box title"), tr("Le polygone doit comporter au moins deux points.", "message box content")); QET::QetMessageBox::warning(this,
tr("Erreur",
"message box title"),
tr("Le polygone doit comporter au moins deux points.",
"message box content"));
return; return;
} }
if (points != m_part->polygon()) if (points != m_part->polygon())
{ {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "polygon", m_part->property("polygon"), points); QPropertyUndoCommand *undo = new QPropertyUndoCommand(
m_part,
"polygon",
m_part->property("polygon"),
points);
undo->setText(tr("Modifier un polygone")); undo->setText(tr("Modifier un polygone"));
undoStack().push(undo); undoStack().push(undo);
} }