After cppcheck.

--HG--
branch : develop
This commit is contained in:
dismine 2014-01-27 17:48:11 +02:00
parent b4841c1f25
commit 68b443fc7f
14 changed files with 46 additions and 27 deletions

View File

@ -158,6 +158,7 @@ private:
* @brief serror report an error
* @param error error code
*/
// cppcheck-suppress functionStatic
void serror(qint32 error);
/**
* @brief look_up finding the internal format for the current token in the token table.

View File

@ -215,7 +215,7 @@ void VContainer::UpdateId(qint64 newId)
}
}
QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &points) const
QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &points)
{
QVector<QPointF> correctPoints;
if(points.size()<4)//Better don't check if only three points. We can destroy equidistant.
@ -387,7 +387,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
return path;
}
QVector<QPointF> VContainer::biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const
QVector<QPointF> VContainer::biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my)
{
QVector<QPointF> p;
for (qint32 i = 0; i < points.size(); ++i)
@ -400,7 +400,7 @@ QVector<QPointF> VContainer::biasPoints(const QVector<QPointF> &points, const qr
return p;
}
QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width) const
QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width)
{
QPainterPath ekv;
QVector<QPointF> ekvPoints;
@ -483,7 +483,7 @@ QPointF VContainer::SingleParallelPoint(const QLineF &line, const qreal &angle,
return pLine.p2();
}
QVector<QPointF> VContainer::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width) const
QVector<QPointF> VContainer::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)
{
Q_ASSERT(width > 0);
QVector<QPointF> points;
@ -533,7 +533,7 @@ QVector<QPointF> VContainer::EkvPoint(const QLineF &line1, const QLineF &line2,
return points;
}
QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const
QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points)
{
QVector<QPointF> ekvPoints;
/*If we got less than 4 points no need seek loops.*/
@ -848,7 +848,7 @@ void VContainer::CreateManTableIGroup ()
AddStandardTableCell("Sb", VStandardTableRow(492, 15, 5));
}
QVector<QPointF> VContainer::GetReversePoint(const QVector<QPointF> &points) const
QVector<QPointF> VContainer::GetReversePoint(const QVector<QPointF> &points)
{
Q_ASSERT(points.size() > 0);
QVector<QPointF> reversePoints;
@ -859,7 +859,7 @@ QVector<QPointF> VContainer::GetReversePoint(const QVector<QPointF> &points) con
return reversePoints;
}
qreal VContainer::GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints) const
qreal VContainer::GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints)
{
qreal length = 0;
QVector<QPointF> points;

View File

@ -204,6 +204,7 @@ public:
* @param secondPoint id of second point of line
* @return name of line
*/
// cppcheck-suppress functionStatic
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const;
/**
* @brief GetNameLineAngle return name of line angle
@ -211,6 +212,7 @@ public:
* @param secondPoint id of second point of line
* @return name of angle of line
*/
// cppcheck-suppress functionStatic
QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const;
/**
* @brief UpdatePoint update point by id
@ -373,7 +375,12 @@ public:
* @param newId id
*/
static void UpdateId(qint64 newId);
QVector<QPointF> CorrectEquidistantPoints(const QVector<QPointF> &points) const;
/**
* @brief CorrectEquidistantPoints clear equivalent points and remove point on line from equdistant.
* @param points list of points equdistant.
* @return corrected list.
*/
static QVector<QPointF> CorrectEquidistantPoints(const QVector<QPointF> &points);
/**
* @brief ContourPath create painter path for detail
* @param idDetail id of detail
@ -387,7 +394,7 @@ public:
* @param my offset respect to y
* @return new vector biased points
*/
QVector<QPointF> biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const;
static QVector<QPointF> biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my);
/**
* @brief Equidistant create equidistant painter path for detail
* @param points vector of points
@ -395,7 +402,7 @@ public:
* @param width width of equidistant
* @return return painter path of equidistant
*/
QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width)const;
static QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width);
/**
* @brief ParallelLine create parallel line
* @param line starting line
@ -418,13 +425,13 @@ public:
* @param width width of equidistant
* @return vector of points
*/
QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)const;
static QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width);
/**
* @brief CheckLoops seek and delete loops in equidistant
* @param points vector of points of equidistant
* @return vector of points of equidistant
*/
QVector<QPointF> CheckLoops(const QVector<QPointF> &points) const;
static QVector<QPointF> CheckLoops(const QVector<QPointF> &points);
/**
* @brief PrepareDetails prepare detail for creation layout
* @param list list of details
@ -480,14 +487,14 @@ private:
* @param points container with points
* @return reverced points
*/
QVector<QPointF> GetReversePoint(const QVector<QPointF> &points)const;
static QVector<QPointF> GetReversePoint(const QVector<QPointF> &points);
/**
* @brief GetLengthContour return length of contour
* @param contour container with points of contour
* @param newPoints point whos we try to add to contour
* @return length length of contour
*/
qreal GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints)const;
static qreal GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints);
template <typename key, typename val>
/**
* @brief GetObject return object from container
@ -495,6 +502,7 @@ private:
* @param id id of object
* @return Object
*/
// cppcheck-suppress functionStatic
const val GetObject(const QHash<key, val> &obj, key id) const;
template <typename key, typename val>
/**
@ -503,6 +511,7 @@ private:
* @param id id of object
* @return Object
*/
// cppcheck-suppress functionStatic
val GetVariable(const QHash<key, val> &obj, key id) const;
template <typename val>
/**

View File

@ -268,7 +268,7 @@ QVector<VNodeDetail> VDetail::listNodePoint() const
return list;
}
ptrdiff_t VDetail::indexOfNode(const QVector<VNodeDetail> &list, const qint64 &id) const
ptrdiff_t VDetail::indexOfNode(const QVector<VNodeDetail> &list, const qint64 &id)
{
for (ptrdiff_t i = 0; i < list.size(); ++i)
{

View File

@ -282,7 +282,7 @@ private:
* @param id object (arc, point, spline, splinePath) id.
* @return index in list or -1 id can't find.
*/
ptrdiff_t indexOfNode(const QVector<VNodeDetail> &list, const qint64 &id) const;
static ptrdiff_t indexOfNode(const QVector<VNodeDetail> &list, const qint64 &id);
};
#endif // VDETAIL_H

View File

@ -326,6 +326,7 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
da1 = x3 - x1;
da2 = y3 - y1;
d3 = k * (da1*dx + da2*dy);
// cppcheck-suppress incorrectLogicOperator
if (d2 > 0 && d2 < 1 && d3 > 0 && d3 < 1)
{
// Simple collinear case, 1---2---3---4

View File

@ -93,13 +93,12 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);
static const char * GENERIC_ICON_TO_CHECK = "document-open";
static const char * FALLBACK_ICON_THEME = "win.icon.theme";
if (!QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK)) {
//If there is no default working icon theme then we should
//use an icon theme that we provide via a .qrc file
//This case happens under Windows and Mac OS X
//This does not happen under GNOME or KDE
QIcon::setThemeName(FALLBACK_ICON_THEME);
QIcon::setThemeName("win.icon.theme");
ui->actionNew->setIcon(QIcon::fromTheme("document-new"));
ui->actionOpen->setIcon(QIcon::fromTheme("document-open"));
ui->actionSave->setIcon(QIcon::fromTheme("document-save"));

View File

@ -86,6 +86,7 @@ void VToolAlongLine::SetFactor(qreal factor)
RefreshGeometry();
}
//cppcheck-suppress unusedFunction
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogAlongLine, this, event);

View File

@ -226,12 +226,14 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsItem::mouseReleaseEvent(event);
}
//cppcheck-suppress unusedFunction
void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine/factor));
}
//cppcheck-suppress unusedFunction
void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);

View File

@ -35,7 +35,7 @@ VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, co
const QString &radius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
: VToolPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId),
: VToolPoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId),
secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>())
{
if (typeCreation == Tool::FromGui)
@ -52,7 +52,7 @@ void VToolPointOfContact::setDialog()
{
Q_ASSERT(dialogPointOfContact.isNull() == false);
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
dialogPointOfContact->setRadius(radius);
dialogPointOfContact->setRadius(arcRadius);
dialogPointOfContact->setCenter(center, id);
dialogPointOfContact->setFirstPoint(firstPointId, id);
dialogPointOfContact->setSecondPoint(secondPointId, id);
@ -154,7 +154,7 @@ void VToolPointOfContact::FullUpdateFromFile()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
radius = domElement.attribute(AttrRadius, "");
arcRadius = domElement.attribute(AttrRadius, "");
center = domElement.attribute(AttrCenter, "").toLongLong();
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
@ -207,7 +207,7 @@ void VToolPointOfContact::AddToFile()
SetAttribute(domElement, AttrMx, toMM(point->mx()));
SetAttribute(domElement, AttrMy, toMM(point->my()));
SetAttribute(domElement, AttrRadius, radius);
SetAttribute(domElement, AttrRadius, arcRadius);
SetAttribute(domElement, AttrCenter, center);
SetAttribute(domElement, AttrFirstPoint, firstPointId);
SetAttribute(domElement, AttrSecondPoint, secondPointId);
@ -224,7 +224,7 @@ void VToolPointOfContact::RefreshDataInFile()
SetAttribute(domElement, AttrName, point->name());
SetAttribute(domElement, AttrMx, toMM(point->mx()));
SetAttribute(domElement, AttrMy, toMM(point->my()));
SetAttribute(domElement, AttrRadius, radius);
SetAttribute(domElement, AttrRadius, arcRadius);
SetAttribute(domElement, AttrCenter, center);
SetAttribute(domElement, AttrFirstPoint, firstPointId);
SetAttribute(domElement, AttrSecondPoint, secondPointId);

View File

@ -51,7 +51,7 @@ public:
* @param parent parent object.
*/
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &radius, const qint64 &center,
const QString &arcRadius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
@ -66,7 +66,7 @@ public:
* @param secondPoint second line point.
* @return point intersection.
*/
static QPointF FindPoint(const qreal &radius, const QPointF &center, const QPointF &firstPoint,
static QPointF FindPoint(const qreal &arcRadius, const QPointF &center, const QPointF &firstPoint,
const QPointF &secondPoint);
/**
* @brief Create help create tool from GUI.
@ -93,7 +93,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const qint64 _id, const QString &radius, const qint64 &center,
static void Create(const qint64 _id, const QString &arcRadius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation);
@ -140,7 +140,7 @@ private:
/**
* @brief radius string with formula radius arc.
*/
QString radius;
QString arcRadius;
/**
* @brief center id center arc point.
*/

View File

@ -385,6 +385,7 @@ void VToolDetail::RefreshGeometry()
}
template <typename Tool>
//cppcheck-suppress unusedFunction
void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
{
QHash<qint64, VDataTool*>* tools = doc->getTools();

View File

@ -30,6 +30,7 @@
#include <QDoubleSpinBox>
//cppcheck-suppress unusedFunction
QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
@ -43,6 +44,7 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption
return editor;
}
//cppcheck-suppress unusedFunction
void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
qreal value = index.model()->data(index, Qt::EditRole).toDouble();
@ -52,6 +54,7 @@ void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &in
spinBox->setValue(value);
}
//cppcheck-suppress unusedFunction
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor);
@ -62,6 +65,7 @@ void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *mo
model->setData(index, value, Qt::EditRole);
}
//cppcheck-suppress unusedFunction
void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{

View File

@ -42,6 +42,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
this->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
}
//cppcheck-suppress unusedFunction
void VMainGraphicsView::wheelEvent(QWheelEvent *event)
{
int numSteps = event->delta() / 8 / 15; // see QWheelEvent documentation