From 04a974c8181a4cdab517cc33acce352ac976065d Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 16 Feb 2011 20:12:33 +0200 Subject: [PATCH] Changed: #1193 code cleanup. --- .../src/color_edit_widget.cpp | 56 +++++++++---------- .../object_viewer_qt/src/direction_widget.cpp | 54 +++++++++--------- .../src/extension_system/plugin_spec.cpp | 32 +++++------ .../src/plugins/core/core_plugin.h | 1 + 4 files changed, 71 insertions(+), 72 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.cpp index a32732133..65d9db58d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.cpp @@ -32,9 +32,9 @@ namespace NLQT { CColorEditWidget::CColorEditWidget(QWidget *parent) - : QWidget(parent), - _Wrapper(NULL), - _emit(true) + : QWidget(parent), + _Wrapper(NULL), + _emit(true) { _ui.setupUi(this); @@ -86,9 +86,9 @@ void CColorEditWidget::updateUi() void CColorEditWidget::setRed(int r) { if (_emit) - Q_EMIT colorChanged(NLMISC::CRGBA(r, _ui.gSpinBox->value(), - _ui.bSpinBox->value(), - _ui.aSpinBox->value())); + Q_EMIT colorChanged(NLMISC::CRGBA(r, _ui.gSpinBox->value(), + _ui.bSpinBox->value(), + _ui.aSpinBox->value())); _ui.graphicsWidget->repaint(); if (_Wrapper == NULL) @@ -107,10 +107,10 @@ void CColorEditWidget::setRed(int r) void CColorEditWidget::setGreen(int g) { if (_emit) - Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), - g, - _ui.bSpinBox->value(), - _ui.aSpinBox->value())); + Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), + g, + _ui.bSpinBox->value(), + _ui.aSpinBox->value())); _ui.graphicsWidget->repaint(); if (_Wrapper == NULL) return; @@ -126,10 +126,10 @@ void CColorEditWidget::setGreen(int g) void CColorEditWidget::setBlue(int b) { if (_emit) - Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), - _ui.gSpinBox->value(), - b, - _ui.aSpinBox->value())); + Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), + _ui.gSpinBox->value(), + b, + _ui.aSpinBox->value())); _ui.graphicsWidget->repaint(); if (_Wrapper == NULL) return; @@ -145,10 +145,10 @@ void CColorEditWidget::setBlue(int b) void CColorEditWidget::setAlpha(int a) { if (_emit) - Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), - _ui.gSpinBox->value(), - _ui.bSpinBox->value(), - a)); + Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), + _ui.gSpinBox->value(), + _ui.bSpinBox->value(), + a)); _ui.graphicsWidget->repaint(); if (_Wrapper == NULL) return; @@ -174,20 +174,20 @@ void CColorEditWidget::browseColor() } bool CColorEditWidget::eventFilter(QObject *object, QEvent *event) -{ - if( event->type() == QEvent::Paint ) - { - _color = QColor(_ui.rSpinBox->value(), - _ui.gSpinBox->value(), - _ui.bSpinBox->value(), - _ui.aSpinBox->value()); - +{ + if( event->type() == QEvent::Paint ) + { + _color = QColor(_ui.rSpinBox->value(), + _ui.gSpinBox->value(), + _ui.bSpinBox->value(), + _ui.aSpinBox->value()); + QPainter painter(_ui.graphicsWidget); painter.setRenderHint(QPainter::Antialiasing, true); painter.setBrush(QBrush(_color)); painter.setPen(QPen(Qt::black, 2, Qt::SolidLine)); - painter.drawRoundedRect(QRect(3, 3, _ui.graphicsWidget->width() - 6, _ui.graphicsWidget->height() - 6), 3.0, 3.0); - } + painter.drawRoundedRect(QRect(3, 3, _ui.graphicsWidget->width() - 6, _ui.graphicsWidget->height() - 6), 3.0, 3.0); + } return QWidget::eventFilter(object, event); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp index 65ae44140..2bef5e9b5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp @@ -183,17 +183,17 @@ void CDirectionWidget::setNewVecYZ(float x, float y) } bool CDirectionWidget::eventFilter(QObject *object, QEvent *event) -{ - QWidget *widget = qobject_cast(object); - switch (event->type()) - { - case QEvent::Paint: - { - float x; - if (widget->objectName() == "XZ") - x = _value.x; - else - x = _value.y; +{ + QWidget *widget = qobject_cast(object); + switch (event->type()) + { + case QEvent::Paint: + { + float x; + if (widget->objectName() == "XZ") + x = _value.x; + else + x = _value.y; QPainter painter(widget); painter.setRenderHint(QPainter::Antialiasing, true); painter.setBrush(QBrush(Qt::white)); @@ -205,23 +205,23 @@ bool CDirectionWidget::eventFilter(QObject *object, QEvent *event) painter.drawText( 10, 15, widget->objectName()); painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); painter.drawLine(widget->width() / 2, widget->height() / 2, - int((widget->width() / 2) + x * 0.9f * directionSize), int((widget->height() / 2) - _value.z * 0.9f * directionSize)); - break; - } - case QEvent::MouseButtonDblClick: - { - QMouseEvent *mouseEvent = (QMouseEvent *) event; + int((widget->width() / 2) + x * 0.9f * directionSize), int((widget->height() / 2) - _value.z * 0.9f * directionSize)); + break; + } + case QEvent::MouseButtonDblClick: + { + QMouseEvent *mouseEvent = (QMouseEvent *) event; float vx = (mouseEvent->x() - (widget->width() / 2)) / 0.9f; - float vy = ((widget->height() / 2) - mouseEvent->y()) / 0.9f; - - if (widget->objectName() == "XZ") - setNewVecXZ(vx, vy); - else - setNewVecYZ(vx, vy); - - break; - } - } + float vy = ((widget->height() / 2) - mouseEvent->y()) / 0.9f; + + if (widget->objectName() == "XZ") + setNewVecXZ(vx, vy); + else + setNewVecYZ(vx, vy); + + break; + } + } return QWidget::eventFilter(object, event); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp index c65d4f6f3..3906aafc5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp @@ -33,11 +33,19 @@ namespace ExtensionSystem { -CPluginSpec::CPluginSpec(): - _state(State::Invalid), - _hasError(false), - _plugin(NULL), - _pluginManager(NULL) +CPluginSpec::CPluginSpec() + : _location(""), + _filePath(""), + _fileName(""), + _name(""), + _version(""), + _vendor(""), + _description(""), + _state(State::Invalid), + _hasError(false), + _errorString(""), + _plugin(0), + _pluginManager(0) { } @@ -98,16 +106,6 @@ QString CPluginSpec::errorString() const bool CPluginSpec::setFileName(const QString &fileName) { - _name = _version - = _vendor - = _description - = _location - = _filePath - = _fileName - = ""; - _state = State::Invalid; - _hasError = false; - _errorString = ""; QFile file(fileName); if (!file.exists()) return reportError(QCoreApplication::translate("CPluginSpec", "File does not exist: %1").arg(file.fileName())); @@ -133,7 +131,7 @@ bool CPluginSpec::loadLibrary() return true; return reportError(QCoreApplication::translate("CPluginSpec", "Loading the library failed because state != Resolved")); } - + QPluginLoader loader(_filePath); if (!loader.load()) return reportError(loader.errorString()); @@ -209,7 +207,7 @@ void CPluginSpec::kill() if (!_plugin) return; delete _plugin; - _plugin = NULL; + _plugin = 0; _state = State::Deleted; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.h index 96cf21d30..26dae9934 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.h @@ -96,6 +96,7 @@ public: break; } } + return result; } protected: