From c23a30b91628c8f940f0262492b68bde34a3eb98 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 15 Jun 2022 03:47:55 +0200 Subject: [PATCH] [Gui] remove unnecessary Boolean comparisons --- src/Gui/Application.cpp | 4 ++-- src/Gui/CommandView.cpp | 2 +- src/Gui/Document.cpp | 4 ++-- src/Gui/GestureNavigationStyle.cpp | 6 +++--- src/Gui/GuiApplicationNativeEventAware.cpp | 4 ++-- src/Gui/NetworkRetriever.cpp | 6 +++--- src/Gui/PythonConsole.cpp | 2 +- src/Gui/SplitView3DInventor.cpp | 2 +- src/Gui/Thumbnail.cpp | 2 +- src/Gui/TreeView.cpp | 2 +- src/Gui/View3DInventor.cpp | 2 +- src/Gui/View3DInventorViewer.cpp | 2 +- src/Gui/ViewProviderDocumentObject.cpp | 6 +++--- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index dbfe69dc90..521ca7b90f 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -546,7 +546,7 @@ void Application::open(const char* FileName, const char* Module) // in case of an automatically created empty document at startup App::Document* act = App::GetApplication().getActiveDocument(); Gui::Document* gui = this->getDocument(act); - if (act && act->countObjects() == 0 && gui && gui->isModified() == false){ + if (act && act->countObjects() == 0 && gui && !gui->isModified()){ Command::doCommand(Command::App, "App.closeDocument('%s')", act->getName()); qApp->processEvents(); // an update is needed otherwise the new view isn't shown } @@ -2410,7 +2410,7 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground) // appear incorrect due to an outdated cache. // See https://doc.qt.io/qt-5/qstyle.html#unpolish-1 // See https://forum.freecadweb.org/viewtopic.php?f=17&t=50783 - if (d->startingUp == false) { + if (!d->startingUp) { if (mdi->style()) mdi->style()->unpolish(qApp); } diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 03b036d55b..0feab25f5d 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -2152,7 +2152,7 @@ void StdCmdAxisCross::activated(int iMsg) Q_UNUSED(iMsg); Gui::View3DInventor* view = qobject_cast(Gui::getMainWindow()->activeWindow()); if (view) { - if (view->getViewer()->hasAxisCross() == false) + if (!view->getViewer()->hasAxisCross()) doCommand(Command::Gui,"Gui.ActiveDocument.ActiveView.setAxisCross(True)"); else doCommand(Command::Gui,"Gui.ActiveDocument.ActiveView.setAxisCross(False)"); diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index d6e7f88616..d28598bf11 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1356,7 +1356,7 @@ unsigned int Document::getMemSize (void) const void Document::Save (Base::Writer &writer) const { // It's only possible to add extra information if force of XML is disabled - if (writer.isForceXML() == false) { + if (!writer.isForceXML()) { writer.addFile("GuiDocument.xml", this); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Document"); @@ -1909,7 +1909,7 @@ void Document::detachView(Gui::BaseView* pcView, bool bPassiv) } // is already closing the document, and is not linked by other documents - if (d->_isClosing == false && + if (!d->_isClosing && App::PropertyXLink::getDocumentInList(getDocument()).empty()) { d->_pcAppWnd->onLastWindowClosed(this); diff --git a/src/Gui/GestureNavigationStyle.cpp b/src/Gui/GestureNavigationStyle.cpp index 3f4b953d43..bbb45068fb 100644 --- a/src/Gui/GestureNavigationStyle.cpp +++ b/src/Gui/GestureNavigationStyle.cpp @@ -893,9 +893,9 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent* const ev) return true; } - if ( (smev.isRelease(1) && this->button1down == false) - || (smev.isRelease(2) && this->button2down == false) - || (smev.isRelease(3) && this->button3down == false)) { + if ( (!smev.isRelease(1) && this->button1down) + || (!smev.isRelease(2) && this->button2down) + || (!smev.isRelease(3) && this->button3down)) { //a button release event cane, but we didn't see the corresponding down //event. Discard it. This discarding is relied upon in some hacks to //overcome buggy synthetic mouse input coming from Qt when doing diff --git a/src/Gui/GuiApplicationNativeEventAware.cpp b/src/Gui/GuiApplicationNativeEventAware.cpp index a2ebbf2ff2..beacab9a84 100644 --- a/src/Gui/GuiApplicationNativeEventAware.cpp +++ b/src/Gui/GuiApplicationNativeEventAware.cpp @@ -293,10 +293,10 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector& motio for (i = 0; i < 6; ++i) { if (motionDataArray[i] != 0) { - if (enabled[i] == false) + if (!enabled[i]) motionDataArray[i] = 0; else { - if (reversed[i] == true) + if (reversed[i]) motionDataArray[i] = - motionDataArray[i]; motionDataArray[i] = (int)((float)(motionDataArray[i]) * sensitivity[i] * generalSensitivity); } diff --git a/src/Gui/NetworkRetriever.cpp b/src/Gui/NetworkRetriever.cpp index bf9a7f1d0b..e55462bd52 100644 --- a/src/Gui/NetworkRetriever.cpp +++ b/src/Gui/NetworkRetriever.cpp @@ -261,9 +261,9 @@ bool NetworkRetriever::startDownload( const QString& startUrl ) if ( !d->dir.isEmpty() ) { QDir dir(d->dir); - if ( dir.exists( d->dir ) == false ) + if (!dir.exists(d->dir)) { - if ( dir.mkdir( d->dir ) == false) + if (!dir.mkdir(d->dir)) { Base::Console().Error("Directory '%s' could not be created.", (const char*)d->dir.toLatin1()); return true; // please, no error message @@ -534,7 +534,7 @@ void StdCmdDownloadOnlineHelp::activated(int iMsg) if (canStart) { bool ok = wget->startDownload(QString::fromLatin1(url.c_str())); - if ( ok == false ) + if (!ok) Base::Console().Error("The tool 'wget' couldn't be found. Please check your installation."); else if ( wget->isDownloading() && _pcAction ) _pcAction->setText(tr("Stop downloading")); diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index d11c0d667b..589dae0f13 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -971,7 +971,7 @@ void PythonConsole::mouseReleaseEvent( QMouseEvent *e ) if (e->button() == Qt::LeftButton) { QTextCursor cursor = this->textCursor(); - if (cursor.hasSelection() == false + if (!cursor.hasSelection() && cursor < this->inputBegin()) { cursor.movePosition( QTextCursor::End ); diff --git a/src/Gui/SplitView3DInventor.cpp b/src/Gui/SplitView3DInventor.cpp index 1f058250dd..125e2bc5e2 100644 --- a/src/Gui/SplitView3DInventor.cpp +++ b/src/Gui/SplitView3DInventor.cpp @@ -297,7 +297,7 @@ void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp r4 = ((col4 >> 24) & 0xff) / 255.0; g4 = ((col4 >> 16) & 0xff) / 255.0; b4 = ((col4 >> 8) & 0xff) / 255.0; for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) { (*it)->setBackgroundColor(QColor::fromRgbF(r1, g1, b1)); - if (rGrp.GetBool("UseBackgroundColorMid",false) == false) + if (!rGrp.GetBool("UseBackgroundColorMid",false)) (*it)->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3)); else (*it)->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3), SbColor(r4, g4, b4)); diff --git a/src/Gui/Thumbnail.cpp b/src/Gui/Thumbnail.cpp index 49e8ad87ca..d90fae75bf 100644 --- a/src/Gui/Thumbnail.cpp +++ b/src/Gui/Thumbnail.cpp @@ -73,7 +73,7 @@ unsigned int Thumbnail::getMemSize (void) const void Thumbnail::Save (Base::Writer &writer) const { // It's only possible to add extra information if force of XML is disabled - if (writer.isForceXML() == false) + if (!writer.isForceXML()) writer.addFile("thumbnails/Thumbnail.png", this); } diff --git a/src/Gui/TreeView.cpp b/src/Gui/TreeView.cpp index a8b1cff8a4..4afbc484c5 100644 --- a/src/Gui/TreeView.cpp +++ b/src/Gui/TreeView.cpp @@ -70,7 +70,7 @@ void TreeView::mouseDoubleClickEvent (QMouseEvent * event) getMainWindow()->setActiveWindow(view); } else if (item->getTypeId().isDerivedFrom(ViewProvider::getClassTypeId())) { - if (static_cast(item)->doubleClicked() == false) + if (!static_cast(item)->doubleClicked()) QTreeView::mouseDoubleClickEvent(event); } } diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index 661479a821..4d429c720a 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -428,7 +428,7 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M r3 = ((col3 >> 24) & 0xff) / 255.0; g3 = ((col3 >> 16) & 0xff) / 255.0; b3 = ((col3 >> 8) & 0xff) / 255.0; r4 = ((col4 >> 24) & 0xff) / 255.0; g4 = ((col4 >> 16) & 0xff) / 255.0; b4 = ((col4 >> 8) & 0xff) / 255.0; _viewer->setBackgroundColor(QColor::fromRgbF(r1, g1, b1)); - if (rGrp.GetBool("UseBackgroundColorMid",false) == false) + if (!rGrp.GetBool("UseBackgroundColorMid",false)) _viewer->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3)); else _viewer->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3), SbColor(r4, g4, b4)); diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 110212896a..2b6321eddd 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -510,7 +510,7 @@ void View3DInventorViewer::init() // Settings setSeekTime(0.4f); - if (isSeekValuePercentage() == false) + if (!isSeekValuePercentage()) setSeekValueAsPercentage(true); setSeekDistance(100); diff --git a/src/Gui/ViewProviderDocumentObject.cpp b/src/Gui/ViewProviderDocumentObject.cpp index 0741cdc2e1..d9f3ab59f0 100644 --- a/src/Gui/ViewProviderDocumentObject.cpp +++ b/src/Gui/ViewProviderDocumentObject.cpp @@ -172,7 +172,7 @@ void ViewProviderDocumentObject::onChanged(const App::Property* prop) } else if (prop == &Visibility) { // use this bit to check whether show() or hide() must be called - if (Visibility.testStatus(App::Property::User2) == false) { + if (!Visibility.testStatus(App::Property::User2)) { Visibility.setStatus(App::Property::User2, true); Visibility.getValue() ? show() : hide(); Visibility.setStatus(App::Property::User2, false); @@ -228,7 +228,7 @@ void ViewProviderDocumentObject::hide(void) { ViewProvider::hide(); // use this bit to check whether 'Visibility' must be adjusted - if (Visibility.testStatus(App::Property::User2) == false) { + if (!Visibility.testStatus(App::Property::User2)) { Visibility.setStatus(App::Property::User2, true); Visibility.setValue(false); Visibility.setStatus(App::Property::User2, false); @@ -292,7 +292,7 @@ void ViewProviderDocumentObject::show(void) } // use this bit to check whether 'Visibility' must be adjusted - if (Visibility.testStatus(App::Property::User2) == false) { + if (!Visibility.testStatus(App::Property::User2)) { Visibility.setStatus(App::Property::User2, true); Visibility.setValue(true); Visibility.setStatus(App::Property::User2, false);