mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +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:
@@ -128,7 +128,7 @@ void SearchAndReplaceWorker::replaceElement(QList<Element *> list)
|
||||
{
|
||||
DiagramContext old_context;
|
||||
DiagramContext new_context = old_context = elmt->elementInformations();
|
||||
for (QString key : QETInformation::elementInfoKeys())
|
||||
for (const QString& key : QETInformation::elementInfoKeys())
|
||||
{
|
||||
new_context.addValue(key, applyChange(old_context.value(key).toString(),
|
||||
m_element_context.value(key).toString()));
|
||||
@@ -219,7 +219,7 @@ void SearchAndReplaceWorker::replaceConductor(QList<Conductor *> list)
|
||||
{
|
||||
QSet <Conductor *> conductors_list = c->relatedPotentialConductors(true);
|
||||
conductors_list << c;
|
||||
for (Conductor *cc : conductors_list)
|
||||
for (Conductor* cc : std::as_const(conductors_list))
|
||||
{
|
||||
QVariant old_value, new_value;
|
||||
old_value.setValue(cc->properties());
|
||||
@@ -270,22 +270,26 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
return;
|
||||
}
|
||||
|
||||
for (Diagram *dd : diagrams) {
|
||||
for (Diagram* dd : std::as_const(diagrams))
|
||||
{
|
||||
if (dd->project() != project_) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (Element *elmt : elements) {
|
||||
for (Element* elmt : std::as_const(elements))
|
||||
{
|
||||
if (!elmt->diagram() || elmt->diagram()->project() != project_) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (IndependentTextItem *text : texts) {
|
||||
for (IndependentTextItem* text : std::as_const(texts))
|
||||
{
|
||||
if (!text->diagram() || text->diagram()->project() != project_) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (Conductor *cc : conductors) {
|
||||
for (Conductor* cc : std::as_const(conductors))
|
||||
{
|
||||
if (!cc->diagram() || cc->diagram()->project() != project_) {
|
||||
return;
|
||||
}
|
||||
@@ -300,7 +304,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
project_->undoStack()->beginMacro(QObject::tr("Rechercher / remplacer avancé"));
|
||||
if (who == 0)
|
||||
{
|
||||
for (Diagram *diagram : diagrams)
|
||||
for (Diagram* diagram : std::as_const(diagrams))
|
||||
{
|
||||
TitleBlockProperties old_properties = diagram->border_and_titleblock.exportTitleBlock();
|
||||
TitleBlockProperties new_properties = replaceAdvanced(diagram);
|
||||
@@ -311,7 +315,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
}
|
||||
else if (who == 1)
|
||||
{
|
||||
for (Element *element : elements)
|
||||
for (Element* element : std::as_const(elements))
|
||||
{
|
||||
DiagramContext old_context = element->elementInformations();
|
||||
DiagramContext new_context = replaceAdvanced(element);
|
||||
@@ -322,7 +326,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
}
|
||||
else if (who == 2)
|
||||
{
|
||||
for (Conductor *conductor : conductors)
|
||||
for (Conductor* conductor : std::as_const(conductors))
|
||||
{
|
||||
ConductorProperties old_properties = conductor->properties();
|
||||
ConductorProperties new_properties = replaceAdvanced(conductor);
|
||||
@@ -331,7 +335,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
QSet <Conductor *> potential_conductors = conductor->relatedPotentialConductors(true);
|
||||
potential_conductors << conductor;
|
||||
|
||||
for (Conductor *c : potential_conductors)
|
||||
for (Conductor* c : std::as_const(potential_conductors))
|
||||
{
|
||||
QVariant old_value, new_value;
|
||||
old_value.setValue(c->properties());
|
||||
@@ -343,7 +347,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
}
|
||||
else if (who == 3)
|
||||
{
|
||||
for (IndependentTextItem *text : texts)
|
||||
for (IndependentTextItem* text : std::as_const(texts))
|
||||
{
|
||||
QRegularExpression rx(m_advanced_struct.search);
|
||||
if (!rx.isValid())
|
||||
|
||||
@@ -95,17 +95,20 @@ void replaceAdvancedDialog::fillWhatComboBox(int index)
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
for (QString str : QETInformation::diagramInfoKeys()) {
|
||||
for (const QString& str : QETInformation::diagramInfoKeys())
|
||||
{
|
||||
ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str);
|
||||
}
|
||||
}
|
||||
else if (index == 1) {
|
||||
for (QString str : QETInformation::elementInfoKeys()) {
|
||||
for (const QString& str : QETInformation::elementInfoKeys())
|
||||
{
|
||||
ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str);
|
||||
}
|
||||
}
|
||||
else if (index == 2) {
|
||||
for (auto str : QETInformation::conductorInfoKeys()) {
|
||||
for (const auto& str : QETInformation::conductorInfoKeys())
|
||||
{
|
||||
ui->m_what_cb->addItem(QETInformation::translatedInfoKey(str), str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,9 @@ ReplaceElementDialog::~ReplaceElementDialog()
|
||||
void ReplaceElementDialog::setContext(DiagramContext context)
|
||||
{
|
||||
m_context = context;
|
||||
|
||||
for (ElementInfoPartWidget *eipw : m_eipw_list) {
|
||||
|
||||
for (ElementInfoPartWidget* eipw : std::as_const(m_eipw_list))
|
||||
{
|
||||
eipw->setText(m_context[eipw->key()].toString());
|
||||
}
|
||||
}
|
||||
@@ -73,8 +74,8 @@ void ReplaceElementDialog::buildWidget()
|
||||
connect(ui->m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_) {
|
||||
this->done(ui->m_button_box->buttonRole(button_));
|
||||
});
|
||||
|
||||
for (QString str : QETInformation::elementInfoKeys())
|
||||
|
||||
for (const QString& str : QETInformation::elementInfoKeys())
|
||||
{
|
||||
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this);
|
||||
eipw->setEraseTextVisible(true);
|
||||
|
||||
@@ -127,7 +127,7 @@ void SearchAndReplaceWidget::clear()
|
||||
qDeleteAll(m_conductor_hash.keys());
|
||||
m_conductor_hash.clear();
|
||||
|
||||
for (QTreeWidgetItem *qtwi : m_category_qtwi)
|
||||
for (QTreeWidgetItem* qtwi : std::as_const(m_category_qtwi))
|
||||
qtwi->setHidden(false);
|
||||
|
||||
ui->m_tree_widget->collapseAll();
|
||||
@@ -284,18 +284,17 @@ void SearchAndReplaceWidget::fillItemsList()
|
||||
dc += DiagramContent(diagram, false);
|
||||
}
|
||||
|
||||
for (Element *elmt : dc.m_elements)
|
||||
addElement(elmt);
|
||||
for (Element* elmt : std::as_const(dc.m_elements)) addElement(elmt);
|
||||
|
||||
//Sort child of each "element type" tree item.
|
||||
//we hide, "element type" tree item, if they do not have children
|
||||
for(QTreeWidgetItem *qtwi : m_qtwi_elmts)
|
||||
for (QTreeWidgetItem* qtwi : std::as_const(m_qtwi_elmts))
|
||||
{
|
||||
qtwi->sortChildren(0, Qt::AscendingOrder);
|
||||
qtwi->setHidden(qtwi->childCount() ? false : true);
|
||||
}
|
||||
|
||||
for (IndependentTextItem *iti : dc.m_text_fields)
|
||||
for (IndependentTextItem* iti : std::as_const(dc.m_text_fields))
|
||||
{
|
||||
QTreeWidgetItem *qtwi = new QTreeWidgetItem(m_indi_text_qtwi);
|
||||
qtwi->setText(0, iti->toPlainText());
|
||||
@@ -306,7 +305,7 @@ void SearchAndReplaceWidget::fillItemsList()
|
||||
|
||||
m_indi_text_qtwi->sortChildren(0, Qt::AscendingOrder);
|
||||
|
||||
for (Conductor *c : dc.m_potential_conductors)
|
||||
for (Conductor* c : std::as_const(dc.m_potential_conductors))
|
||||
{
|
||||
QTreeWidgetItem *qtwi = new QTreeWidgetItem(m_conductor_qtwi);
|
||||
qtwi->setText(0, c->properties().text);
|
||||
@@ -379,7 +378,8 @@ void SearchAndReplaceWidget::search()
|
||||
(*it)->setHidden(false);
|
||||
}
|
||||
|
||||
for (QTreeWidgetItem *item : m_category_qtwi) {
|
||||
for (QTreeWidgetItem* item : std::as_const(m_category_qtwi))
|
||||
{
|
||||
item->setExpanded(false);
|
||||
}
|
||||
m_root_qtwi->setExpanded(true);
|
||||
@@ -442,9 +442,9 @@ void SearchAndReplaceWidget::search()
|
||||
}
|
||||
|
||||
QPalette background = ui->m_search_le->palette();
|
||||
background.setColor(QPalette::Base, match
|
||||
? QColor("#E0FFF0")
|
||||
: QColor("#FFE0EF"));
|
||||
background.setColor(
|
||||
QPalette::Base,
|
||||
match ? QColor(0xE0FFF0) : QColor(0xFFE0EF));
|
||||
ui->m_search_le->setPalette(background);
|
||||
|
||||
//Go to the first occurrence
|
||||
@@ -488,7 +488,8 @@ void SearchAndReplaceWidget::setUpConenctions()
|
||||
connect(m_select_elements, &QAction::triggered, [this]()
|
||||
{
|
||||
DiagramContent dc(m_diagram_hash.value(ui->m_tree_widget->currentItem()), false);
|
||||
for (auto elmt : dc.m_elements) {
|
||||
for (auto elmt : std::as_const(dc.m_elements))
|
||||
{
|
||||
if (auto item = m_element_hash.key(elmt)) {
|
||||
item->setCheckState(0, Qt::Checked);
|
||||
}
|
||||
@@ -508,7 +509,8 @@ void SearchAndReplaceWidget::setUpConenctions()
|
||||
connect(m_select_texts, &QAction::triggered, [this]()
|
||||
{
|
||||
DiagramContent dc(m_diagram_hash.value(ui->m_tree_widget->currentItem()), false);
|
||||
for (auto text : dc.m_text_fields) {
|
||||
for (auto text : std::as_const(dc.m_text_fields))
|
||||
{
|
||||
if (auto item = m_text_hash.key(text)) {
|
||||
item->setCheckState(0, Qt::Checked);
|
||||
}
|
||||
@@ -858,7 +860,8 @@ QStringList SearchAndReplaceWidget::searchTerms(Diagram *diagram)
|
||||
list.append(prop.indexrev);
|
||||
list.append(prop.folio);
|
||||
list.append(prop.date.toString());
|
||||
for (QString key : prop.context.keys()) {
|
||||
for (const QString& key : prop.context.keys())
|
||||
{
|
||||
list.append(prop.context.value(key).toString());
|
||||
}
|
||||
|
||||
@@ -874,7 +877,7 @@ QStringList SearchAndReplaceWidget::searchTerms(Element *element)
|
||||
{
|
||||
QStringList list;
|
||||
DiagramContext context = element->elementInformations();
|
||||
for (QString key : QETInformation::elementInfoKeys())
|
||||
for (const QString& key : QETInformation::elementInfoKeys())
|
||||
{
|
||||
QString str = context.value(key).toString();
|
||||
if (!str.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user