Skip to content

Commit

Permalink
Fix backwards-compatible Qt6 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jwueller authored and chennes committed May 13, 2024
1 parent c12e1f8 commit 0e24e12
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/Gui/DlgParameterImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void DlgParameterImp::onFindGroupTtextChanged(const QString &SearchStr)

// at first reset all items to the default font and expand state
if (!foundList.empty()) {
for (QTreeWidgetItem* item : qAsConst(foundList)) {
for (QTreeWidgetItem* item : std::as_const(foundList)) {
item->setFont(0, defaultFont);
item->setForeground(0, defaultColor);
ExpandItem = item;
Expand Down Expand Up @@ -191,7 +191,7 @@ void DlgParameterImp::onFindGroupTtextChanged(const QString &SearchStr)
// reset background style sheet
if (!ui->findGroupLE->styleSheet().isEmpty())
ui->findGroupLE->setStyleSheet(QString());
for (QTreeWidgetItem* item : qAsConst(foundList)) {
for (QTreeWidgetItem* item : std::as_const(foundList)) {
item->setFont(0, boldFont);
item->setForeground(0, Qt::red);
// expand its parent to see the item
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DlgPropertyLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void DlgPropertyLink::init(const App::DocumentObjectT &prop, bool tryFilter) {
// For link list type property, try to auto filter type
if(tryFilter && isLinkList) {
Base::Type objType;
for(const auto& link : qAsConst(oldLinks)) {
for(const auto& link : std::as_const(oldLinks)) {
auto obj = link.getSubObject();
if(!obj)
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/DocumentModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ void DocumentModel::slotChangeObject(const Gui::ViewProviderDocumentObject& obj,
auto doc_index = static_cast<DocumentIndex*>(d->rootItem->child(row));
QList<ViewProviderIndex*> views;
doc_index->findViewProviders(obj, views);
for (const auto & view : qAsConst(views)) {
for (const auto & view : std::as_const(views)) {
DocumentModelIndex* parentitem = view->parent();
QModelIndex parent = createIndex(0,0,parentitem);
int row = view->row();
Expand Down Expand Up @@ -523,7 +523,7 @@ void DocumentModel::slotChangeObject(const Gui::ViewProviderDocumentObject& obj,
// get all occurrences of the view provider in the tree structure
QList<ViewProviderIndex*> obj_index;
doc_index->findViewProviders(obj, obj_index);
for (const auto & it : qAsConst(obj_index)) {
for (const auto & it : std::as_const(obj_index)) {
QModelIndex parent = createIndex(it->row(),0,it);
int count_obj = it->childCount();
beginRemoveRows(parent, 0, count_obj);
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DocumentRecovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ void DocumentRecoveryCleaner::subtractFiles(QStringList& files)
void DocumentRecoveryCleaner::subtractDirs(QFileInfoList& dirs)
{
if (!ignoreDirs.isEmpty() && !dirs.isEmpty()) {
for (const auto& it : qAsConst(ignoreDirs)) {
for (const auto& it : std::as_const(ignoreDirs)) {
dirs.removeOne(it);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/GraphvizView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,15 @@ bool GraphvizView::onMsg(const char* pMsg, const char**)
formatMap << qMakePair(QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF format")), QString::fromLatin1("pdf"));

QStringList filter;
for (const auto & it : qAsConst(formatMap)) {
for (const auto & it : std::as_const(formatMap)) {
filter << it.first;
}

QString selectedFilter;
QString fn = Gui::FileDialog::getSaveFileName(this, tr("Export graph"), QString(), filter.join(QLatin1String(";;")), &selectedFilter);
if (!fn.isEmpty()) {
QString format;
for (const auto & it : qAsConst(formatMap)) {
for (const auto & it : std::as_const(formatMap)) {
if (selectedFilter == it.first) {
format = it.second;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/Language/Translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ TStringMap Translator::supportedLocales() const

// List all .qm files
for (const auto& domainMap : d->mapLanguageTopLevelDomain) {
for (const auto& directoryName : qAsConst(d->paths)) {
for (const auto& directoryName : std::as_const(d->paths)) {
QDir dir(directoryName);
QString filter = QString::fromLatin1("*_%1.qm").arg(QString::fromStdString(domainMap.second));
QStringList fileNames = dir.entryList(QStringList(filter), QDir::Files, QDir::Name);
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/Macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool MacroFile::commit()
import << QString::fromLatin1("import FreeCAD");
QStringList body;

for (const auto& it : qAsConst(this->macroInProgress)) {
for (const auto& it : std::as_const(this->macroInProgress)) {
if (it.startsWith(QLatin1String("import ")) ||
it.startsWith(QLatin1String("#import "))) {
if (import.indexOf(it) == -1)
Expand All @@ -107,7 +107,7 @@ bool MacroFile::commit()

// write the data to the text file
str << header;
for (const auto& it : qAsConst(import)) {
for (const auto& it : std::as_const(import)) {
str << it << QLatin1Char('\n');
}
str << QLatin1Char('\n');
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/NotificationArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class NotificationsAction: public QWidgetAction

~NotificationsAction() override
{
for (auto* item : qAsConst(pushedItems)) {
for (auto* item : std::as_const(pushedItems)) {
if (item) {
delete item; // NOLINT
}
Expand Down Expand Up @@ -683,7 +683,7 @@ class NotificationsAction: public QWidgetAction
QMenu menu;

QAction* del = menu.addAction(tr("Delete"), this, [&]() {
for (auto it : qAsConst(selectedItems)) {
for (auto it : std::as_const(selectedItems)) {
delete it;
}
});
Expand Down
8 changes: 4 additions & 4 deletions src/Gui/Splashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,13 +850,13 @@ void AboutDialog::copyToClipboard()
<< '\n';
#endif
QLocale loc;
str << "Locale: " << loc.languageToString(loc.language()) << "/"
<< loc.countryToString(loc.country())
str << "Locale: " << QLocale::languageToString(loc.language()) << "/"
<< QLocale::countryToString(loc.country())
<< " (" << loc.name() << ")";
if (loc != QLocale::system()) {
loc = QLocale::system();
str << " [ OS: " << loc.languageToString(loc.language()) << "/"
<< loc.countryToString(loc.country())
str << " [ OS: " << QLocale::languageToString(loc.language()) << "/"
<< QLocale::countryToString(loc.country())
<< " (" << loc.name() << ") ]";
}
str << "\n";
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/StartupProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ void StartupPostProcess::showMainWindow()
// stop splash screen and set immediately the active window that may be of interest
// for scripts using Python binding for Qt
mainWindow->stopSplasher();
qtApp->setActiveWindow(mainWindow);
mainWindow->activateWindow();
}

void StartupPostProcess::activateWorkbench()
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/ToolBarManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ToolBarItem* ToolBarItem::findItem(const std::string& name)
return this;
}

for (auto it : qAsConst(_items)) {
for (auto it : std::as_const(_items)) {
if (it->_name == name) {
return it;
}
Expand Down Expand Up @@ -138,7 +138,7 @@ void ToolBarItem::removeItem(ToolBarItem* item)

void ToolBarItem::clear()
{
for (auto it : qAsConst(_items)) {
for (auto it : std::as_const(_items)) {
delete it;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Gui/propertyeditor/PropertyItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void PropertyItem::reset()
void PropertyItem::onChange()
{
if (hasExpression()) {
for(auto child : qAsConst(childItems)) {
for(auto child : std::as_const(childItems)) {
if(child && child->hasExpression()) {
child->setExpression(std::shared_ptr<App::Expression>());
}
Expand Down Expand Up @@ -309,7 +309,7 @@ int PropertyItem::columnCount() const
void PropertyItem::setReadOnly(bool ro)
{
readonly = ro;
for (auto it : qAsConst(childItems)) {
for (auto it : std::as_const(childItems)) {
it->setReadOnly(ro);
}
}
Expand All @@ -322,7 +322,7 @@ bool PropertyItem::isReadOnly() const
void PropertyItem::setLinked(bool value)
{
linked = value;
for (auto it : qAsConst(childItems)) {
for (auto it : std::as_const(childItems)) {
it->setLinked(value);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Drawing/Gui/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ CmdDrawingNewPage::CmdDrawingNewPage()
void CmdDrawingNewPage::activated(int iMsg)
{
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
QAction* a = qAsConst(pcAction)->actions()[iMsg];
QAction* a = std::as_const(pcAction)->actions()[iMsg];

std::string FeatName = getUniqueObjectName(
QCoreApplication::translate("Drawing_NewPage", "Page").toStdString().c_str());
Expand Down Expand Up @@ -204,7 +204,7 @@ Gui::Action* CmdDrawingNewPage::createAction(void)
pcAction->setProperty("defaultAction", QVariant(defaultId));
}
else if (!pcAction->actions().isEmpty()) {
pcAction->setIcon(qAsConst(pcAction)->actions()[0]->icon());
pcAction->setIcon(std::as_const(pcAction)->actions()[0]->icon());
pcAction->setProperty("defaultAction", QVariant(0));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Material/App/Materials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ QString Material::getAuthorAndLicense() const

void Material::addModel(const QString& uuid)
{
for (const auto& modelUUID : qAsConst(_allUuids)) {
for (const auto& modelUUID : std::as_const(_allUuids)) {
if (modelUUID == uuid) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Sketcher/Gui/EditDatumDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ void EditDatumDialog::drivingToggled(bool state)

void EditDatumDialog::datumChanged()
{
if (ui_ins_datum->labelEdit->text() != qAsConst(ui_ins_datum->labelEdit)->getHistory()[0]) {
if (ui_ins_datum->labelEdit->text()
!= std::as_const(ui_ins_datum->labelEdit)->getHistory()[0]) {
ui_ins_datum->cbDriving->setChecked(false);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ TaskSketcherConstraints::TaskSketcherConstraints(ViewProviderSketch* sketchView)
QWidgetAction* action = new QWidgetAction(this);
filterList = new ConstraintFilterList(this);
action->setDefaultWidget(filterList);
qAsConst(ui->filterButton)->addAction(action);
std::as_const(ui->filterButton)->addAction(action);

// Create local settings menu
// FIXME there is probably a smarter way to handle this menu
Expand Down Expand Up @@ -862,7 +862,7 @@ TaskSketcherConstraints::TaskSketcherConstraints(ViewProviderSketch* sketchView)
}
hGrp->Attach(this);

auto settingsBut = qAsConst(ui->settingsButton);
auto settingsBut = std::as_const(ui->settingsButton);

settingsBut->addAction(action1);
settingsBut->addAction(action2);
Expand Down Expand Up @@ -1040,8 +1040,8 @@ void TaskSketcherConstraints::onChangedSketchView(const Gui::ViewProvider& vp,
{
if (sketchView == &vp) {
if (&sketchView->Autoconstraints == &prop) {
QSignalBlocker block(qAsConst(ui->settingsButton)->actions()[0]);
qAsConst(ui->settingsButton)
QSignalBlocker block(std::as_const(ui->settingsButton)->actions()[0]);
std::as_const(ui->settingsButton)
->actions()[0]
->setChecked(sketchView->Autoconstraints.getValue());
}
Expand Down Expand Up @@ -1425,7 +1425,7 @@ void TaskSketcherConstraints::OnChange(Base::Subject<const char*>& rCaller, cons
}
if (actNum >= 0) {
assert(actNum < static_cast<int>(ui->settingsButton->actions().size()));
qAsConst(ui->settingsButton)->actions()[actNum]->setChecked(hGrp->GetBool(rcReason, false));
std::as_const(ui->settingsButton)->actions()[actNum]->setChecked(hGrp->GetBool(rcReason, false));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Sketcher/Gui/TaskSketcherElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class ElementWidgetIcons
{
int hue, sat, val, alp;
QIcon Normal = Gui::BitmapFactory().iconFromTheme(name);
QImage imgConstr(Normal.pixmap(qAsConst(Normal).availableSizes()[0]).toImage());
QImage imgConstr(Normal.pixmap(std::as_const(Normal).availableSizes()[0]).toImage());
QImage imgExt(imgConstr);
QImage imgInt(imgConstr);

Expand Down Expand Up @@ -1230,7 +1230,7 @@ void TaskSketcherElements::connectSignals()
&TaskSketcherElements::onFilterBoxStateChanged);
QObject::connect(
ui->settingsButton, &QToolButton::clicked, ui->settingsButton, &QToolButton::showMenu);
QObject::connect(qAsConst(ui->settingsButton)->actions()[0],
QObject::connect(std::as_const(ui->settingsButton)->actions()[0],
&QAction::changed,
this,
&TaskSketcherElements::onSettingsExtendedInformationChanged);
Expand All @@ -1250,7 +1250,7 @@ void TaskSketcherElements::createFilterButtonActions()
auto* action = new QWidgetAction(this);
filterList = new ElementFilterList(this);
action->setDefaultWidget(filterList);
qAsConst(ui->filterButton)->addAction(action);
std::as_const(ui->filterButton)->addAction(action);
}

void TaskSketcherElements::onFilterBoxStateChanged(int val)
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch* sketchView)
action->setChecked(state);
ui->manualUpdate->addAction(action);

QObject::connect(qAsConst(ui->manualUpdate)->actions()[0],
QObject::connect(std::as_const(ui->manualUpdate)->actions()[0],
&QAction::changed,
this,
&TaskSketcherMessages::onAutoUpdateStateChanged);
Expand Down Expand Up @@ -175,7 +175,7 @@ void TaskSketcherMessages::onLabelConstrainStatusLinkClicked(const QString& str)

void TaskSketcherMessages::onAutoUpdateStateChanged()
{
bool state = qAsConst(ui->manualUpdate)->actions()[0]->isChecked();
bool state = std::as_const(ui->manualUpdate)->actions()[0]->isChecked();

ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Sketcher");
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Start/Gui/FlowLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ QSize FlowLayout::sizeHint() const
QSize FlowLayout::minimumSize() const
{
QSize size;
for (auto item : qAsConst(itemList)) {
for (auto item : std::as_const(itemList)) {
size = size.expandedTo(item->minimumSize());
}

Expand Down Expand Up @@ -155,7 +155,7 @@ int FlowLayout::doLayout(const QRect& rect, bool testOnly) const
int y = effectiveRect.y();
int lineHeight = 0;

for (auto item : qAsConst(itemList)) {
for (auto item : std::as_const(itemList)) {
QWidget* wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/TechDraw/Gui/MDIViewPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ void MDIViewPage::sceneSelectionManager()
//add to m_qgSceneSelected anything that is in q_sceneSel
for (auto qts : sceneSel) {
bool found = false;
for (auto ms : qAsConst(m_qgSceneSelected)) {
for (auto ms : std::as_const(m_qgSceneSelected)) {
if (qts == ms) {
found = true;
break;
Expand All @@ -734,7 +734,7 @@ void MDIViewPage::sceneSelectionManager()

//remove items from m_qgSceneSelected that are not in q_sceneSel
QList<QGraphicsItem*> m_new;
for (auto m : qAsConst(m_qgSceneSelected)) {
for (auto m : std::as_const(m_qgSceneSelected)) {
for (auto q : sceneSel) {
if (m == q) {
m_new.push_back(m);
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/updatecrowdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def updateTranslatorCpp(lncode):

cppfile = os.path.join(os.path.dirname(__file__), "..", "Gui", "Language", "Translator.cpp")
l = QtCore.QLocale(lncode)
lnname = l.languageToString(l.language())
lnname = QtCore.QLocale.languageToString(l.language())

# read file contents
f = open(cppfile, "r")
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/xmlformat/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main(int argc, char* argv[])
}

// add the rest
for (const auto& it : qAsConst(attr)) {
for (const auto& it : std::as_const(attr)) {
sorted.append(it);
}

Expand Down

0 comments on commit 0e24e12

Please sign in to comment.