diff --git a/src/app/container/vformula.cpp b/src/app/container/vformula.cpp index 5afc18612..222ae5d75 100644 --- a/src/app/container/vformula.cpp +++ b/src/app/container/vformula.cpp @@ -79,7 +79,7 @@ bool VFormula::operator==(const VFormula &formula) const if (this->formula == formula.getFormula() && this->value == formula.getStringValue() && this->checkZero == formula.getCheckZero() && this->data == formula.getData() && this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() && - this->_error == formula.error() && this->dValue == formula.getDoubleValue()) + this->_error == formula.error() && qFuzzyCompare(this->dValue, formula.getDoubleValue())) { isEqual = true; } diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 49f776ff1..d4dd30a49 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -67,7 +67,7 @@ MainWindow::MainWindow(QWidget *parent) comboBoxDraws(nullptr), curFile(QString()), mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs{nullptr, nullptr, nullptr, nullptr, nullptr}, separatorAct(nullptr), autoSaveTimer(nullptr), guiEnabled(true), gradationHeights(nullptr), - gradationSizes(nullptr) + gradationSizes(nullptr), toolOptions(nullptr) { CreateActions(); CreateMenus(); diff --git a/src/app/visualization/vistoolsplinepath.cpp b/src/app/visualization/vistoolsplinepath.cpp index b4698e350..5e022ec7c 100644 --- a/src/app/visualization/vistoolsplinepath.cpp +++ b/src/app/visualization/vistoolsplinepath.cpp @@ -113,7 +113,11 @@ void VisToolSplinePath::setMode(const Mode &value) //--------------------------------------------------------------------------------------------------------------------- QGraphicsEllipseItem *VisToolSplinePath::getPoint(unsigned int i) { - if (points.size() - 1 >= i && points.isEmpty() == false) + if (points.size() == 0) + { + nullptr; + } + else if (static_cast(points.size() - 1) >= i && points.isEmpty() == false) { return points.at(i); } diff --git a/src/app/widgets/vformulapropertyeditor.cpp b/src/app/widgets/vformulapropertyeditor.cpp index 8219732ee..2873b84a3 100644 --- a/src/app/widgets/vformulapropertyeditor.cpp +++ b/src/app/widgets/vformulapropertyeditor.cpp @@ -41,8 +41,8 @@ using namespace VPE; // VFormulaPropertyEditor //--------------------------------------------------------------------------------------------------------------------- -VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) : - QWidget(parent) +VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) + : QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr), Spacer(nullptr) { setAutoFillBackground(true); diff --git a/src/app/widgets/vformulapropertyeditor.h b/src/app/widgets/vformulapropertyeditor.h index 622facc76..9c3eecf25 100644 --- a/src/app/widgets/vformulapropertyeditor.h +++ b/src/app/widgets/vformulapropertyeditor.h @@ -68,6 +68,7 @@ private slots: void onToolButtonClicked(); private: + Q_DISABLE_COPY(VFormulaPropertyEditor) VFormula formula; QToolButton* ToolButton; QLabel* TextLabel; diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp index c8dbe184c..54fc0ff65 100644 --- a/src/app/widgets/vmaingraphicsview.cpp +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -41,12 +41,11 @@ //--------------------------------------------------------------------------------------------------------------------- GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view) - : QObject(view), _view(view), _numScheduledScalings(0) + : QObject(view), _view(view), _modifiers(Qt::ControlModifier), _zoom_factor_base(1.0015), + target_scene_pos(QPointF()), target_viewport_pos(QPointF()), _numScheduledScalings(0) { _view->viewport()->installEventFilter(this); _view->setMouseTracking(true); - _modifiers = Qt::ControlModifier; - _zoom_factor_base = 1.0015; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/widgets/vmaingraphicsview.h b/src/app/widgets/vmaingraphicsview.h index 810b83427..17701efb9 100644 --- a/src/app/widgets/vmaingraphicsview.h +++ b/src/app/widgets/vmaingraphicsview.h @@ -79,7 +79,7 @@ private: QGraphicsView* _view; Qt::KeyboardModifiers _modifiers; double _zoom_factor_base; - QPointF target_scene_pos; + QPointF target_scene_pos; QPointF target_viewport_pos; bool eventFilter(QObject* object, QEvent* event); diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index e55e5bd51..5816bf164 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -43,8 +43,7 @@ using namespace VPE; //--------------------------------------------------------------------------------------------------------------------- VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser(QDockWidget *parent) - :QObject(parent), - currentItem(nullptr), + :QObject(parent), PropertyModel(nullptr), formView(nullptr), currentItem(nullptr), propertyToId(QMap()), idToProperty(QMap()) { @@ -58,7 +57,7 @@ VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser(QDockWidget *parent) parent->setWidget(scroll); - connect(PropertyModel, SIGNAL(onDataChangedByEditor(VProperty*)), this, SLOT(userChangedData(VProperty*))); + connect(PropertyModel, &VPropertyModel::onDataChangedByEditor, this, &VToolOptionsPropertyBrowser::userChangedData); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/qmuparser/qmuparsertoken.h b/src/libs/qmuparser/qmuparsertoken.h index 3e5d44a62..4c40a0820 100644 --- a/src/libs/qmuparser/qmuparsertoken.h +++ b/src/libs/qmuparser/qmuparsertoken.h @@ -326,6 +326,23 @@ public: return m_pCallback->GetAssociativity(); } + //------------------------------------------------------------------------------ + template < class FunctionPtr > + FunctionPtr union_cast( void* objectPtr ) const + { + union + { + void* obj; + FunctionPtr func; + } var; + + Q_STATIC_ASSERT_X(sizeof(void *) == sizeof(void (*)(void)), + "object pointer and function pointer sizes must equal"); + + var.obj = objectPtr; + return var.func; + } + //------------------------------------------------------------------------------ /** * @brief Return the address of the callback function assoziated with function and operator tokens. @@ -343,8 +360,8 @@ public: */ generic_fun_type GetFuncAddr() const { - return ( m_pCallback.get() ) ? reinterpret_cast ( m_pCallback->GetAddr() ) : - reinterpret_cast (0); + return ( union_cast( m_pCallback.get() ) ) ? + union_cast( m_pCallback->GetAddr() ) : union_cast(0); } //------------------------------------------------------------------------------ diff --git a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h index 65e80b8bd..7b21df45b 100644 --- a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h +++ b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h @@ -32,16 +32,12 @@ struct VPROPERTYEXPLORERSHARED_EXPORT Vector3D { public: Vector3D() - { - X = Y = Z = 0; - } + :X(0), Y(0), Z(0) + {} Vector3D(const Vector3D& other) - { - X = other.X; - Y = other.Y; - Z = other.Z; - } + :X(other.X), Y(other.Y), Z(other.Z) + {} ~Vector3D() {} diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp index 83798ff47..64b945343 100644 --- a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp @@ -80,26 +80,19 @@ QVariant VIntegerProperty::getEditorData(QWidget* editor) const return QVariant(0); } -void VIntegerProperty::setSettings(int minimum, int maxiumum, int singleStep) -{ - minValue = minimum; - maxValue = maxiumum; - this->singleStep = singleStep; -} - void VIntegerProperty::setSetting(const QString& key, const QVariant& value) { if (key == QLatin1String("Min")) { - setSettings(value.toInt(), maxValue); + maxValue = value.toInt(); } else if (key == QLatin1String("Max")) { - setSettings(minValue, value.toInt()); + minValue = value.toInt(); } else if (key == QLatin1String("Step")) { - setSettings(singleStep, value.toInt()); + singleStep = value.toInt(); } } @@ -194,31 +187,23 @@ QVariant VDoubleProperty::getEditorData(QWidget* editor) const return QVariant(0); } -void VDoubleProperty::setSettings(double minimum, double maxiumum, double singleStep, int precision) -{ - minValue = minimum; - maxValue = maxiumum; - this->singleStep = singleStep; - Precision = precision; -} - void VDoubleProperty::setSetting(const QString& key, const QVariant& value) { if (key == QLatin1String("Min")) { - setSettings(value.toDouble(), maxValue, singleStep, Precision); + minValue = value.toDouble(); } else if (key == QLatin1String("Max")) { - setSettings(minValue, value.toDouble(), singleStep, Precision); + maxValue = value.toDouble(); } else if (key == QLatin1String("Step")) { - setSettings(minValue, maxValue, value.toDouble(), Precision); + singleStep = value.toDouble(); } else if (key == QLatin1String("Precision")) { - setSettings(minValue, maxValue, singleStep, value.toDouble()); + Precision = value.toDouble(); } } diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.h b/src/libs/vpropertyexplorer/plugins/vnumberproperty.h index 99814ae2c..4ccd0374a 100644 --- a/src/libs/vpropertyexplorer/plugins/vnumberproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.h @@ -48,11 +48,6 @@ public: //! Gets the data from the widget virtual QVariant getEditorData(QWidget* editor) const; - //! Sets the settings of a basic integer property - //! \param minimum The minimum value - //! \param maxiumum The maximum value - virtual void setSettings(int minimum, int maxiumum, int singleStep = 1.0); - //! Sets the settings. Available settings: //! //! key: "Min" - value: Minimum number as integer @@ -104,12 +99,6 @@ public: //! Gets the data from the widget virtual QVariant getEditorData(QWidget* editor) const; - //! Sets the settings of a double property - //! \param minimum The minimum value - //! \param maxiumum The maximum value - //! \param precision The number of decimal places - virtual void setSettings(double minimum, double maxiumum, double singleStep, int precision); - //! Sets the settings. Available settings: //! //! key: "Min" - value: Minimum number as integer diff --git a/src/libs/vpropertyexplorer/vproperty.cpp b/src/libs/vpropertyexplorer/vproperty.cpp index f1ce70acf..ed0bd6e99 100644 --- a/src/libs/vpropertyexplorer/vproperty.cpp +++ b/src/libs/vpropertyexplorer/vproperty.cpp @@ -411,5 +411,6 @@ void VProperty::UpdateParent(const QVariant &value) void VProperty::ValueChildChanged(const QVariant &value, int typeForParent) { - + Q_UNUSED(value) + Q_UNUSED(typeForParent) } diff --git a/src/libs/vpropertyexplorer/vproperty.h b/src/libs/vpropertyexplorer/vproperty.h index 06bd67a23..2a57c9d66 100644 --- a/src/libs/vpropertyexplorer/vproperty.h +++ b/src/libs/vpropertyexplorer/vproperty.h @@ -40,7 +40,7 @@ static const int MyCustomEventType = 1099; class UserChangeEvent : public QEvent { public: - UserChangeEvent() : QEvent((QEvent::Type)MyCustomEventType) {} + UserChangeEvent() : QEvent(static_cast(MyCustomEventType)) {} }; class VPropertyPrivate; @@ -210,6 +210,7 @@ protected: private: // Provide access functions for the d_ptr Q_DECLARE_PRIVATE(VProperty) + Q_DISABLE_COPY(VProperty) }; } diff --git a/src/libs/vpropertyexplorer/vproperty_p.h b/src/libs/vpropertyexplorer/vproperty_p.h index ff7fea3ca..b91fc4fc6 100644 --- a/src/libs/vpropertyexplorer/vproperty_p.h +++ b/src/libs/vpropertyexplorer/vproperty_p.h @@ -69,15 +69,19 @@ public: //! Constructor passing name and type VPropertyPrivate(const QString& name, QVariant::Type type) - : VariantValue(type), Name(name), PropertyVariantType(type), UpdateParent(false), UpdateChildren(false), - Parent(nullptr), editor(nullptr), type(Property::Simple) + : VariantValue(type), Name(name), Description(QString()), IsEmpty(false), PropertyVariantType(type), + UpdateParent(false), UpdateChildren(false), Parent(nullptr), editor(nullptr), type(Property::Simple), + Children(QList()) {} //! Constructor VPropertyPrivate() - : VariantValue(), Name(), PropertyVariantType(QVariant::Invalid), UpdateParent(false), UpdateChildren(false), - Parent(nullptr), editor(nullptr) + : VariantValue(), Name(), Description(QString()), IsEmpty(false), PropertyVariantType(QVariant::Invalid), + UpdateParent(false), UpdateChildren(false), Parent(nullptr), editor(nullptr), type(Property::Simple), + Children(QList()) {} +private: + Q_DISABLE_COPY(VPropertyPrivate) }; } diff --git a/src/libs/vpropertyexplorer/vpropertyformview.cpp b/src/libs/vpropertyexplorer/vpropertyformview.cpp index a82200d95..c76ebcfe1 100644 --- a/src/libs/vpropertyexplorer/vpropertyformview.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformview.cpp @@ -136,6 +136,8 @@ void VPropertyFormView::modelDestroyed() void VPropertyFormView::dataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right) { + Q_UNUSED(top_left) + Q_UNUSED(bottom_right) if (static_cast(d_ptr)->IgnoreDataChangedSignal) { return; diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.h b/src/libs/vpropertyexplorer/vpropertyformwidget.h index 42243112a..60749ff0a 100644 --- a/src/libs/vpropertyexplorer/vpropertyformwidget.h +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.h @@ -93,6 +93,8 @@ protected: //! Commits data of an editor void commitData(QWidget* editor); +private: + Q_DISABLE_COPY(VPropertyFormWidget) }; } // Namespace VPE diff --git a/src/libs/vpropertyexplorer/vpropertymodel.h b/src/libs/vpropertyexplorer/vpropertymodel.h index e3167a98e..615507c17 100644 --- a/src/libs/vpropertyexplorer/vpropertymodel.h +++ b/src/libs/vpropertyexplorer/vpropertymodel.h @@ -159,6 +159,9 @@ protected: //! The model data VPropertyModelPrivate* d_ptr; + +private: + Q_DISABLE_COPY(VPropertyModel) }; }