summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-04-01 12:36:16 (GMT)
committerTobias Markmann <tm@ayena.de>2016-04-01 15:56:34 (GMT)
commiteddd92ed76ae68cb1e202602fd3ebd11b69191a2 (patch)
tree8d396e5801d77a2f0ee4ab8e4c5093d8cf8118e6 /Swift/QtUI/Whiteboard
parenta79db8d446e152b715f435550c2a6e10a36ee532 (diff)
downloadswift-eddd92ed76ae68cb1e202602fd3ebd11b69191a2.zip
swift-eddd92ed76ae68cb1e202602fd3ebd11b69191a2.tar.bz2
Modernize code to use C++11 nullptr using clang-tidy
Run 'clang-tidy -fix -checks=modernize-use-nullptr' on all source code files on OS X. This does not modernize platform specific code on Linux and Windows Test-Information: Code builds and unit tests pass on OS X 10.11.4. Change-Id: Ic43ffeb1b76c1a933a55af03db3c54977f5f60dd
Diffstat (limited to 'Swift/QtUI/Whiteboard')
-rw-r--r--Swift/QtUI/Whiteboard/ColorWidget.h8
-rw-r--r--Swift/QtUI/Whiteboard/FreehandLineItem.h4
-rw-r--r--Swift/QtUI/Whiteboard/GView.cpp28
-rw-r--r--Swift/QtUI/Whiteboard/GView.h2
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp12
-rw-r--r--Swift/QtUI/Whiteboard/TextDialog.h2
-rw-r--r--Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h2
7 files changed, 32 insertions, 26 deletions
diff --git a/Swift/QtUI/Whiteboard/ColorWidget.h b/Swift/QtUI/Whiteboard/ColorWidget.h
index 18dc73f..56ada0c 100644
--- a/Swift/QtUI/Whiteboard/ColorWidget.h
+++ b/Swift/QtUI/Whiteboard/ColorWidget.h
@@ -4,6 +4,12 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2016 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
#pragma once
#include <QWidget>
@@ -12,7 +18,7 @@ namespace Swift {
class ColorWidget : public QWidget {
Q_OBJECT
public:
- ColorWidget(QWidget* parent = 0);
+ ColorWidget(QWidget* parent = nullptr);
QSize sizeHint() const;
public slots:
diff --git a/Swift/QtUI/Whiteboard/FreehandLineItem.h b/Swift/QtUI/Whiteboard/FreehandLineItem.h
index a2dab34..5b83d95 100644
--- a/Swift/QtUI/Whiteboard/FreehandLineItem.h
+++ b/Swift/QtUI/Whiteboard/FreehandLineItem.h
@@ -21,9 +21,9 @@ namespace Swift {
class FreehandLineItem : public QGraphicsItem {
public:
enum {Type = UserType + 1};
- FreehandLineItem(QGraphicsItem* parent = 0);
+ FreehandLineItem(QGraphicsItem* parent = nullptr);
QRectF boundingRect() const;
- void paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/ = 0);
+ void paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/ = nullptr);
void setStartPoint(QPointF point);
void lineTo(QPointF point);
bool collidesWithPath(const QPainterPath& path, Qt::ItemSelectionMode /*mode*/ = Qt::IntersectsItemShape) const;
diff --git a/Swift/QtUI/Whiteboard/GView.cpp b/Swift/QtUI/Whiteboard/GView.cpp
index 4deaaf6..80061fd 100644
--- a/Swift/QtUI/Whiteboard/GView.cpp
+++ b/Swift/QtUI/Whiteboard/GView.cpp
@@ -15,7 +15,7 @@
#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
- GView::GView(QGraphicsScene* scene, QWidget* parent) : QGraphicsView(scene, parent), zValue(0), mousePressed(false), brush(QColor(Qt::white)), defaultBrush(QColor(Qt::white)), mode(GView::Select), lastItem(NULL), selectionRect(NULL), textDialog(NULL) {
+ GView::GView(QGraphicsScene* scene, QWidget* parent) : QGraphicsView(scene, parent), zValue(0), mousePressed(false), brush(QColor(Qt::white)), defaultBrush(QColor(Qt::white)), mode(GView::Select), lastItem(nullptr), selectionRect(nullptr), textDialog(nullptr) {
}
void GView::setLineWidth(int i) {
@@ -63,7 +63,7 @@ namespace Swift {
void GView::setMode(Mode mode) {
this->mode = mode;
- lastItem = 0;
+ lastItem = nullptr;
deselect();
}
@@ -86,8 +86,8 @@ namespace Swift {
scene()->clear();
items_.clear();
itemsMap_.clear();
- lastItem = 0;
- selectionRect = 0;
+ lastItem = nullptr;
+ selectionRect = nullptr;
brush = QBrush(QColor(Qt::white));
defaultBrush = QBrush(QColor(Qt::white));
pen = QPen();
@@ -123,7 +123,7 @@ namespace Swift {
if (mode == Line) {
QGraphicsLineItem* item = qgraphicsitem_cast<QGraphicsLineItem*>(lastItem);
- if(item != 0) {
+ if(item != nullptr) {
QLineF line = item->line();
line.setP1(this->mapToScene(event->pos()));
item->setLine(line);
@@ -132,7 +132,7 @@ namespace Swift {
}
else if (mode == Rect) {
QGraphicsRectItem* item = qgraphicsitem_cast<QGraphicsRectItem*>(lastItem);
- if (item != 0) {
+ if (item != nullptr) {
QPointF beginPoint = item->data(0).toPointF();
QPointF newPoint = this->mapToScene(event->pos());
QRectF rect = item->rect();
@@ -182,7 +182,7 @@ namespace Swift {
}
else if (mode == HandLine) {
FreehandLineItem* item = qgraphicsitem_cast<FreehandLineItem*>(lastItem);
- if (item != 0) {
+ if (item != nullptr) {
QPointF newPoint = this->mapToScene(event->pos());
item->lineTo(newPoint);
}
@@ -197,7 +197,7 @@ namespace Swift {
}
else if (mode == Select) {
QGraphicsItem* item = selectionRect->data(1).value<QGraphicsItem*>();
- if (item != 0) {
+ if (item != nullptr) {
QPainterPath path;
QPointF beginPoint = selectionRect->data(0).toPointF();
QPointF newPoint = this->mapToScene(event->pos());
@@ -283,7 +283,7 @@ namespace Swift {
else if (mode == Polygon) {
QPointF point = this->mapToScene(event->pos());
QGraphicsPolygonItem* item = dynamic_cast<QGraphicsPolygonItem*>(lastItem);
- if (item == 0) {
+ if (item == nullptr) {
QPolygonF polygon;
polygon.append(point);
polygon.append(point);
@@ -376,7 +376,7 @@ namespace Swift {
void GView::move(QGraphicsItem* item, int npos) {
int pos = items_.indexOf(item);
- QGraphicsItem* itemAfter = NULL;
+ QGraphicsItem* itemAfter = nullptr;
if (npos-1 > pos) {
if (npos == items_.size()) {
item->setZValue(zValue++);
@@ -473,12 +473,12 @@ namespace Swift {
}
void GView::deselect() {
- if (selectionRect != 0) {
+ if (selectionRect != nullptr) {
pen = defaultPen;
brush = defaultBrush;
scene()->removeItem(selectionRect);
delete selectionRect;
- selectionRect = 0;
+ selectionRect = nullptr;
lineWidthChanged(pen.width());
lineColorChanged(pen.color());
brushColorChanged(brush.color());
@@ -486,14 +486,14 @@ namespace Swift {
}
void GView::deselect(QString id) {
- if (selectionRect != 0) {
+ if (selectionRect != nullptr) {
QGraphicsItem* item = getItem(id);
if (item && selectionRect->data(1).value<QGraphicsItem*>() == item) {
pen = defaultPen;
brush = defaultBrush;
scene()->removeItem(selectionRect);
delete selectionRect;
- selectionRect = 0;
+ selectionRect = nullptr;
lineWidthChanged(pen.width());
lineColorChanged(pen.color());
brushColorChanged(brush.color());
diff --git a/Swift/QtUI/Whiteboard/GView.h b/Swift/QtUI/Whiteboard/GView.h
index 396e381..4af5a53 100644
--- a/Swift/QtUI/Whiteboard/GView.h
+++ b/Swift/QtUI/Whiteboard/GView.h
@@ -30,7 +30,7 @@ namespace Swift {
public:
enum Mode { Rubber, Line, Rect, Circle, HandLine, Text, Polygon, Select };
enum Type { New, Update, MoveUp, MoveDown };
- GView(QGraphicsScene* scene, QWidget* parent = 0);
+ GView(QGraphicsScene* scene, QWidget* parent = nullptr);
void setLineWidth(int i);
void setLineColor(QColor color);
QColor getLineColor();
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
index 26887e0..2eae84d 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
@@ -182,14 +182,14 @@ namespace Swift {
void QtWhiteboardWindow::showColorDialog()
{
- QColor color = QColorDialog::getColor(graphicsView->getLineColor(), 0, "Select pen color", QColorDialog::ShowAlphaChannel);
+ QColor color = QColorDialog::getColor(graphicsView->getLineColor(), nullptr, "Select pen color", QColorDialog::ShowAlphaChannel);
if(color.isValid())
graphicsView->setLineColor(color);
}
void QtWhiteboardWindow::showBrushColorDialog()
{
- QColor color = QColorDialog::getColor(graphicsView->getBrushColor(), 0, "Select brush color", QColorDialog::ShowAlphaChannel);
+ QColor color = QColorDialog::getColor(graphicsView->getBrushColor(), nullptr, "Select brush color", QColorDialog::ShowAlphaChannel);
if(color.isValid())
graphicsView->setBrushColor(color);
}
@@ -258,7 +258,7 @@ namespace Swift {
void QtWhiteboardWindow::handleLastItemChanged(QGraphicsItem* item, int pos, GView::Type type) {
WhiteboardElement::ref el;
QGraphicsLineItem* lineItem = qgraphicsitem_cast<QGraphicsLineItem*>(item);
- if (lineItem != 0) {
+ if (lineItem != nullptr) {
QLine line = lineItem->line().toLine();
QColor color = lineItem->pen().color();
WhiteboardLineElement::ref element = boost::make_shared<WhiteboardLineElement>(line.x1()+lineItem->pos().x(), line.y1()+lineItem->pos().y(), line.x2()+lineItem->pos().x(), line.y2()+lineItem->pos().y());
@@ -270,7 +270,7 @@ namespace Swift {
}
FreehandLineItem* freehandLineItem = qgraphicsitem_cast<FreehandLineItem*>(item);
- if (freehandLineItem != 0) {
+ if (freehandLineItem != nullptr) {
WhiteboardFreehandPathElement::ref element = boost::make_shared<WhiteboardFreehandPathElement>();
QColor color = freehandLineItem->pen().color();
std::vector<std::pair<int, int> > points;
@@ -290,7 +290,7 @@ namespace Swift {
}
QGraphicsRectItem* rectItem = qgraphicsitem_cast<QGraphicsRectItem*>(item);
- if (rectItem != 0) {
+ if (rectItem != nullptr) {
QRectF rect = rectItem->rect();
WhiteboardRectElement::ref element = boost::make_shared<WhiteboardRectElement>(rect.x()+item->pos().x(), rect.y()+item->pos().y(), rect.width(), rect.height());
QColor penColor = rectItem->pen().color();
@@ -305,7 +305,7 @@ namespace Swift {
}
QGraphicsTextItem* textItem = qgraphicsitem_cast<QGraphicsTextItem*>(item);
- if (textItem != 0) {
+ if (textItem != nullptr) {
QPointF point = textItem->pos();
WhiteboardTextElement::ref element = boost::make_shared<WhiteboardTextElement>(point.x(), point.y());
element->setText(textItem->toPlainText().toStdString());
diff --git a/Swift/QtUI/Whiteboard/TextDialog.h b/Swift/QtUI/Whiteboard/TextDialog.h
index 31bd096..513d381 100644
--- a/Swift/QtUI/Whiteboard/TextDialog.h
+++ b/Swift/QtUI/Whiteboard/TextDialog.h
@@ -27,7 +27,7 @@ namespace Swift {
{
Q_OBJECT
public:
- TextDialog(QGraphicsTextItem* item, QWidget* parent = 0);
+ TextDialog(QGraphicsTextItem* item, QWidget* parent = nullptr);
private:
QGraphicsTextItem* item;
diff --git a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
index 719725c..8182bcb 100644
--- a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
+++ b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
@@ -111,7 +111,7 @@ namespace Swift {
void visit(WhiteboardPolygonElement& element) {
QGraphicsPolygonItem* item = qgraphicsitem_cast<QGraphicsPolygonItem*>(graphicsView_->getItem(P2QSTRING(element.getID())));
- if (item == 0 && type_ == GView::New) {
+ if (item == nullptr && type_ == GView::New) {
item = new QGraphicsPolygonItem();
QString id = P2QSTRING(element.getID());
item->setData(100, id);