mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-28 20:39:59 +01:00
Try Clazy fix-its
clazy is a compiler plugin which allows clang to understand Qt semantics. You get more than 50 Qt related compiler warnings, ranging from unneeded memory allocations to misusage of API, including fix-its for automatic refactoring. https://invent.kde.org/sdk/clazy
This commit is contained in:
@@ -184,7 +184,7 @@ void AddTextsGroupCommand::redo()
|
||||
}
|
||||
else
|
||||
{
|
||||
for(DynamicElementTextItem *deti : m_deti_list)
|
||||
for (DynamicElementTextItem* deti : std::as_const(m_deti_list))
|
||||
m_element.data()->addTextToGroup(
|
||||
deti,
|
||||
m_group.data());
|
||||
@@ -194,7 +194,7 @@ void AddTextsGroupCommand::redo()
|
||||
else if(m_group)
|
||||
{
|
||||
m_element.data()->addTextGroup(m_group.data());
|
||||
for(DynamicElementTextItem *deti : m_deti_list)
|
||||
for (DynamicElementTextItem* deti : std::as_const(m_deti_list))
|
||||
m_element.data()->addTextToGroup(deti, m_group.data());
|
||||
}
|
||||
}
|
||||
@@ -236,8 +236,9 @@ void RemoveTextsGroupCommand::undo()
|
||||
if(m_element && m_group)
|
||||
{
|
||||
m_element.data()->addTextGroup(m_group.data());
|
||||
|
||||
for(const QPointer<DynamicElementTextItem>& p : m_text_list)
|
||||
|
||||
for (const QPointer<DynamicElementTextItem>& p :
|
||||
std::as_const(m_text_list))
|
||||
if(p)
|
||||
m_element.data()->addTextToGroup(
|
||||
p.data(),
|
||||
@@ -252,7 +253,8 @@ void RemoveTextsGroupCommand::redo()
|
||||
{
|
||||
if(m_element && m_group)
|
||||
{
|
||||
for(const QPointer<DynamicElementTextItem>& p : m_text_list)
|
||||
for (const QPointer<DynamicElementTextItem>& p :
|
||||
std::as_const(m_text_list))
|
||||
if(p)
|
||||
m_element.data()->removeTextFromGroup(
|
||||
p.data(),
|
||||
|
||||
@@ -60,7 +60,8 @@ bool ChangeElementInformationCommand::mergeWith(const QUndoCommand *other)
|
||||
//In case of other undo_undo have the same elements as keys
|
||||
if (m_map.size() == other_undo->m_map.size())
|
||||
{
|
||||
for (auto key : other_undo->m_map.keys()) {
|
||||
for (const auto& key : other_undo->m_map.keys())
|
||||
{
|
||||
if (!m_map.keys().contains(key)) {
|
||||
return false;
|
||||
}
|
||||
@@ -69,12 +70,13 @@ bool ChangeElementInformationCommand::mergeWith(const QUndoCommand *other)
|
||||
//Other_undo will be merged with this undo :
|
||||
//Replace the new_info values of this m_map
|
||||
//by the new_info values of other_undo's m_map
|
||||
for (auto key : other_undo->m_map.keys())
|
||||
{
|
||||
m_map.insert(key,
|
||||
qMakePair(
|
||||
m_map.value(key).first,
|
||||
other_undo->m_map.value(key).second));
|
||||
for (const auto& key : other_undo->m_map.keys())
|
||||
{
|
||||
m_map.insert(
|
||||
key,
|
||||
qMakePair(
|
||||
m_map.value(key).first,
|
||||
other_undo->m_map.value(key).second));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -113,8 +115,7 @@ void ChangeElementInformationCommand::updateProjectDB()
|
||||
//need to have a list of element instead of QPointer<Element>
|
||||
//for the function elementInfoChange of the database
|
||||
QList<Element *> list_;
|
||||
for (auto p_elmt : m_map.keys())
|
||||
list_ << p_elmt.data();
|
||||
for (const auto& p_elmt : m_map.keys()) list_ << p_elmt.data();
|
||||
|
||||
elmt->diagram()->project()->dataBase()->elementInfoChanged(list_);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand(
|
||||
|
||||
//When removing a deti we must know its parent item, for re-adding deti as child of the parent
|
||||
//when undoing this command
|
||||
for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts)
|
||||
for (DynamicElementTextItem* deti :
|
||||
std::as_const(m_removed_contents.m_element_texts))
|
||||
{
|
||||
if(deti->parentGroup())
|
||||
m_grp_texts_hash.insert(deti, deti->parentGroup());
|
||||
@@ -73,7 +74,9 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand(
|
||||
}
|
||||
|
||||
//The deletion of the groups is not managed by this undo, but by a RemoveTextsGroupCommand
|
||||
for(ElementTextItemGroup *group : m_removed_contents.m_texts_groups) {
|
||||
for (ElementTextItemGroup* group :
|
||||
std::as_const(m_removed_contents.m_texts_groups))
|
||||
{
|
||||
new RemoveTextsGroupCommand(group->parentElement(), group, this);
|
||||
}
|
||||
|
||||
@@ -81,7 +84,7 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand(
|
||||
setPotentialsOfRemovedElements();
|
||||
|
||||
//Get all linkeds table of removed table.
|
||||
for (auto table : m_removed_contents.m_tables)
|
||||
for (auto table : std::as_const(m_removed_contents.m_tables))
|
||||
{
|
||||
//Table is already managed, jump to next loop
|
||||
if (m_table_scene_hash.keys().contains(table))
|
||||
@@ -122,7 +125,7 @@ DeleteQGraphicsItemCommand::~DeleteQGraphicsItemCommand()
|
||||
*/
|
||||
void DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements()
|
||||
{
|
||||
for (Element *elmt : m_removed_contents.m_elements)
|
||||
for (Element* elmt : std::as_const(m_removed_contents.m_elements))
|
||||
{
|
||||
//a list of terminals who have at least two conductors docked in.
|
||||
QList<Terminal *> terminals_list;
|
||||
@@ -179,7 +182,8 @@ void DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements()
|
||||
//If a conductor was already created between these two terminals
|
||||
//in this undo command, from another removed element, we do nothing
|
||||
bool exist_ = false;
|
||||
for (QPair<Terminal *, Terminal *> pair : m_connected_terminals)
|
||||
for (QPair<Terminal*, Terminal*> pair :
|
||||
std::as_const(m_connected_terminals))
|
||||
{
|
||||
if (pair.first == hub_terminal && pair.second == t) {
|
||||
exist_ = true;
|
||||
@@ -226,7 +230,7 @@ Terminal *DeleteQGraphicsItemCommand::terminalInSamePotential(
|
||||
{
|
||||
QList<Conductor *> conductor_list = terminal->conductors();
|
||||
conductor_list.removeAll(conductor_to_exclude);
|
||||
for(Conductor *c : conductor_list)
|
||||
for (Conductor* c : std::as_const(conductor_list))
|
||||
{
|
||||
Terminal *other_terminal = c->terminal1 == terminal ? c->terminal2 : c->terminal1;
|
||||
if(!m_removed_contents.items(DiagramContent::Elements).contains(other_terminal->parentElement())) {
|
||||
@@ -234,7 +238,7 @@ Terminal *DeleteQGraphicsItemCommand::terminalInSamePotential(
|
||||
}
|
||||
}
|
||||
//No one of direct conductor of terminal are docked to an element which is not removed
|
||||
for(Conductor *c : conductor_list)
|
||||
for (Conductor* c : std::as_const(conductor_list))
|
||||
{
|
||||
Terminal *other_terminal = c->terminal1 == terminal ? c->terminal2 : c->terminal1;
|
||||
Terminal *terminal_to_return = terminalInSamePotential(other_terminal, c);
|
||||
@@ -258,11 +262,12 @@ void DeleteQGraphicsItemCommand::undo()
|
||||
m_diagram->addItem(item);
|
||||
|
||||
//We relink element after every element was added to diagram
|
||||
for(Element *e : m_removed_contents.m_elements)
|
||||
for (Element* e : std::as_const(m_removed_contents.m_elements))
|
||||
for(Element *elmt : m_link_hash[e])
|
||||
e->linkToElement(elmt);
|
||||
|
||||
for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts)
|
||||
for (DynamicElementTextItem* deti :
|
||||
std::as_const(m_removed_contents.m_element_texts))
|
||||
{
|
||||
if(m_elmt_text_hash.keys().contains(deti))
|
||||
m_elmt_text_hash.value(deti)->addDynamicTextItem(deti);
|
||||
@@ -307,14 +312,15 @@ void DeleteQGraphicsItemCommand::redo()
|
||||
}
|
||||
}
|
||||
|
||||
for(Element *e : m_removed_contents.m_elements)
|
||||
for (Element* e : std::as_const(m_removed_contents.m_elements))
|
||||
{
|
||||
//Get linked element, for relink it at undo
|
||||
if (!e->linkedElements().isEmpty())
|
||||
m_link_hash.insert(e, e->linkedElements());
|
||||
}
|
||||
|
||||
for(DynamicElementTextItem *deti : m_removed_contents.m_element_texts)
|
||||
for (DynamicElementTextItem* deti :
|
||||
std::as_const(m_removed_contents.m_element_texts))
|
||||
{
|
||||
if(deti->parentGroup() && deti->parentGroup()->parentElement())
|
||||
deti->parentGroup()->parentElement()->removeTextFromGroup(deti, deti->parentGroup());
|
||||
|
||||
@@ -203,7 +203,7 @@ void LinkElementCommand::redo()
|
||||
QStringList str_txt;
|
||||
QStringList str_funct;
|
||||
QStringList str_tens;
|
||||
for (const Conductor *c : c_list)
|
||||
for (const Conductor* c : std::as_const(c_list))
|
||||
{
|
||||
str_txt << c->properties().text;
|
||||
str_funct << c->properties().m_function;
|
||||
|
||||
@@ -74,8 +74,8 @@ m_diagram(diagram)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (QPropertyUndoCommand *undo : m_undo)
|
||||
|
||||
for (QPropertyUndoCommand* undo : std::as_const(m_undo))
|
||||
undo->setAnimated(true, false);
|
||||
}
|
||||
}
|
||||
@@ -87,8 +87,8 @@ void RotateSelectionCommand::undo()
|
||||
{
|
||||
m_diagram->showMe();
|
||||
QUndoCommand::undo();
|
||||
|
||||
for(const QPointer<ConductorTextItem>& cti : m_cond_text)
|
||||
|
||||
for (const QPointer<ConductorTextItem>& cti : std::as_const(m_cond_text))
|
||||
{
|
||||
cti->forceRotateByUser(m_rotate_by_user.value(cti.data()));
|
||||
if(!cti->wasRotateByUser())
|
||||
@@ -103,11 +103,11 @@ void RotateSelectionCommand::redo()
|
||||
{
|
||||
m_diagram->showMe();
|
||||
QUndoCommand::redo();
|
||||
|
||||
for(const QPointer<ConductorTextItem>& cti : m_cond_text)
|
||||
{
|
||||
m_rotate_by_user.insert(cti, cti->wasRotateByUser());
|
||||
cti->forceRotateByUser(true);
|
||||
|
||||
for (const QPointer<ConductorTextItem>& cti : std::as_const(m_cond_text))
|
||||
{
|
||||
m_rotate_by_user.insert(cti, cti->wasRotateByUser());
|
||||
cti->forceRotateByUser(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,10 +69,10 @@ m_diagram(diagram)
|
||||
}
|
||||
if(!text.isNull())
|
||||
setText(text);
|
||||
|
||||
for(DiagramTextItem *dti : texts_list)
|
||||
|
||||
for (DiagramTextItem* dti : std::as_const(texts_list))
|
||||
setupAnimation(dti, "rotation", dti->rotation(), m_rotation);
|
||||
for(ElementTextItemGroup *grp : groups_list)
|
||||
for (ElementTextItemGroup* grp : std::as_const(groups_list))
|
||||
setupAnimation(grp, "rotation", grp->rotation(), m_rotation);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user