aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/scxmleditor
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2018-11-24 20:21:25 +0100
committerAlessandro Portale <alessandro.portale@qt.io>2018-12-10 12:03:18 +0000
commit24ecd7fe6a6ed857585cb7f6f197018dc08e2857 (patch)
tree801c67bcc64e659a100d48894a04846f736dd8a5 /src/plugins/scxmleditor
parent6474b129e61ea2a0968f4145e64bbf87d46c6ed1 (diff)
ScxmlEditor: Modernize
modernize-* Change-Id: I72a72cf5e9327956fdc0e5fc6f552bfc03d2122c Reviewed-by: Marco Benelli <marco.benelli@qt.io>
Diffstat (limited to 'src/plugins/scxmleditor')
-rw-r--r--src/plugins/scxmleditor/common/colorsettings.cpp4
-rw-r--r--src/plugins/scxmleditor/common/graphicsview.cpp2
-rw-r--r--src/plugins/scxmleditor/common/stateproperties.cpp4
-rw-r--r--src/plugins/scxmleditor/common/structure.cpp2
-rw-r--r--src/plugins/scxmleditor/common/structuremodel.cpp2
-rw-r--r--src/plugins/scxmleditor/outputpane/outputtabwidget.cpp4
-rw-r--r--src/plugins/scxmleditor/plugin_interface/attributeitemdelegate.cpp1
-rw-r--r--src/plugins/scxmleditor/plugin_interface/attributeitemmodel.cpp2
-rw-r--r--src/plugins/scxmleditor/plugin_interface/baseitem.cpp2
-rw-r--r--src/plugins/scxmleditor/plugin_interface/connectableitem.cpp7
-rw-r--r--src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp16
-rw-r--r--src/plugins/scxmleditor/plugin_interface/scattributeitemmodel.cpp2
-rw-r--r--src/plugins/scxmleditor/plugin_interface/sceneutils.cpp6
-rw-r--r--src/plugins/scxmleditor/plugin_interface/transitionitem.cpp8
-rw-r--r--src/plugins/scxmleditor/plugin_interface/warningitem.cpp4
-rw-r--r--src/plugins/scxmleditor/scxmleditorconstants.h2
-rw-r--r--src/plugins/scxmleditor/scxmleditordata.cpp6
-rw-r--r--src/plugins/scxmleditor/scxmleditorstack.cpp4
-rw-r--r--src/plugins/scxmleditor/scxmltexteditor.cpp4
19 files changed, 39 insertions, 43 deletions
diff --git a/src/plugins/scxmleditor/common/colorsettings.cpp b/src/plugins/scxmleditor/common/colorsettings.cpp
index e71b302fbd..cb3f1cee17 100644
--- a/src/plugins/scxmleditor/common/colorsettings.cpp
+++ b/src/plugins/scxmleditor/common/colorsettings.cpp
@@ -49,7 +49,7 @@ ColorSettings::ColorSettings(QWidget *parent)
m_colorThemes = s->value(Constants::C_SETTINGS_COLORSETTINGS_COLORTHEMES).toMap();
m_ui.m_comboColorThemes->clear();
- foreach (const QString &key, m_colorThemes.keys())
+ for (const auto &key : m_colorThemes.keys())
m_ui.m_comboColorThemes->addItem(key);
m_ui.m_comboColorThemes->setCurrentText(s->value(Constants::C_SETTINGS_COLORSETTINGS_CURRENTCOLORTHEME).toString());
@@ -73,7 +73,7 @@ void ColorSettings::selectTheme(const QString &name)
if (!name.isEmpty() && m_colorThemes.contains(name)) {
m_ui.m_colorThemeView->setEnabled(true);
QVariantMap colordata = m_colorThemes[name].toMap();
- foreach (const QString &index, colordata.keys())
+ for (const auto &index : colordata.keys())
m_ui.m_colorThemeView->setColor(index.toInt(), QColor(colordata[index].toString()));
} else {
m_ui.m_colorThemeView->setEnabled(false);
diff --git a/src/plugins/scxmleditor/common/graphicsview.cpp b/src/plugins/scxmleditor/common/graphicsview.cpp
index d44dd5484b..ec50c43a8d 100644
--- a/src/plugins/scxmleditor/common/graphicsview.cpp
+++ b/src/plugins/scxmleditor/common/graphicsview.cpp
@@ -231,7 +231,7 @@ void GraphicsView::dropEvent(QDropEvent *event)
QList<QGraphicsItem*> parentItems = items(event->pos());
for (int i = 0; i < parentItems.count(); ++i) {
- BaseItem *item = static_cast<BaseItem*>(parentItems[i]);
+ auto item = static_cast<const BaseItem*>(parentItems[i]);
if (item && item->type() >= StateType) {
targetPos = item->mapFromScene(targetPos);
targetTag = item->tag();
diff --git a/src/plugins/scxmleditor/common/stateproperties.cpp b/src/plugins/scxmleditor/common/stateproperties.cpp
index ca9e2e4f09..8a9d0aa3b2 100644
--- a/src/plugins/scxmleditor/common/stateproperties.cpp
+++ b/src/plugins/scxmleditor/common/stateproperties.cpp
@@ -96,14 +96,14 @@ void StateProperties::tagChange(ScxmlDocument::TagChange change, ScxmlTag *tag,
void StateProperties::setDocument(ScxmlDocument *document)
{
if (m_document)
- disconnect(m_document, 0, this, 0);
+ disconnect(m_document, nullptr, this, nullptr);
m_document = document;
if (m_document) {
m_tag = m_document->rootTag();
connect(m_document, &ScxmlDocument::endTagChange, this, &StateProperties::tagChange);
} else {
- setTag(0);
+ setTag(nullptr);
}
}
diff --git a/src/plugins/scxmleditor/common/structure.cpp b/src/plugins/scxmleditor/common/structure.cpp
index 93e5c63fa5..658032ae7a 100644
--- a/src/plugins/scxmleditor/common/structure.cpp
+++ b/src/plugins/scxmleditor/common/structure.cpp
@@ -325,7 +325,7 @@ void Structure::showMenu(const QModelIndex &index, const QPoint &globalPos)
m_currentDocument->undoStack()->beginMacro(tr("Remove items"));
m_currentDocument->setCurrentTag(tag);
m_currentDocument->removeTag(tag);
- m_currentDocument->setCurrentTag(0);
+ m_currentDocument->setCurrentTag(nullptr);
m_currentDocument->undoStack()->endMacro();
} else if (actionType == TagUtils::AddChild) {
tag->document()->undoStack()->beginMacro(tr("Add child"));
diff --git a/src/plugins/scxmleditor/common/structuremodel.cpp b/src/plugins/scxmleditor/common/structuremodel.cpp
index 6249284180..50b5298854 100644
--- a/src/plugins/scxmleditor/common/structuremodel.cpp
+++ b/src/plugins/scxmleditor/common/structuremodel.cpp
@@ -46,7 +46,7 @@ void StructureModel::setDocument(ScxmlDocument *document)
{
beginResetModel();
if (m_document)
- disconnect(m_document, 0, this, 0);
+ disconnect(m_document, nullptr, this, nullptr);
m_document = document;
if (m_document) {
diff --git a/src/plugins/scxmleditor/outputpane/outputtabwidget.cpp b/src/plugins/scxmleditor/outputpane/outputtabwidget.cpp
index 337e0fecfe..678b017be6 100644
--- a/src/plugins/scxmleditor/outputpane/outputtabwidget.cpp
+++ b/src/plugins/scxmleditor/outputpane/outputtabwidget.cpp
@@ -132,9 +132,7 @@ OutputTabWidget::OutputTabWidget(QWidget *parent)
close();
}
-OutputTabWidget::~OutputTabWidget()
-{
-}
+OutputTabWidget::~OutputTabWidget() = default;
int OutputTabWidget::addPane(OutputPane *pane)
{
diff --git a/src/plugins/scxmleditor/plugin_interface/attributeitemdelegate.cpp b/src/plugins/scxmleditor/plugin_interface/attributeitemdelegate.cpp
index 168b8b424b..ad5570441f 100644
--- a/src/plugins/scxmleditor/plugin_interface/attributeitemdelegate.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/attributeitemdelegate.cpp
@@ -29,7 +29,6 @@ using namespace ScxmlEditor::PluginInterface;
AttributeItemDelegate::AttributeItemDelegate(QObject *parent)
: QStyledItemDelegate(parent)
- , m_tag(0)
{
}
diff --git a/src/plugins/scxmleditor/plugin_interface/attributeitemmodel.cpp b/src/plugins/scxmleditor/plugin_interface/attributeitemmodel.cpp
index 8d8e63495c..47e6e8cdcd 100644
--- a/src/plugins/scxmleditor/plugin_interface/attributeitemmodel.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/attributeitemmodel.cpp
@@ -36,7 +36,7 @@ void AttributeItemModel::setTag(ScxmlTag *tag)
{
beginResetModel();
m_tag = tag;
- m_document = m_tag ? m_tag->document() : 0;
+ m_document = m_tag ? m_tag->document() : nullptr;
endResetModel();
emit layoutChanged();
emit dataChanged(QModelIndex(), QModelIndex());
diff --git a/src/plugins/scxmleditor/plugin_interface/baseitem.cpp b/src/plugins/scxmleditor/plugin_interface/baseitem.cpp
index 40bb45b5f1..f850292f43 100644
--- a/src/plugins/scxmleditor/plugin_interface/baseitem.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/baseitem.cpp
@@ -333,7 +333,7 @@ bool BaseItem::isActiveScene() const
ScxmlUiFactory *BaseItem::uiFactory() const
{
- return m_scene ? m_scene->uiFactory() : 0;
+ return m_scene ? m_scene->uiFactory() : nullptr;
}
GraphicsScene *BaseItem::graphicsScene() const
diff --git a/src/plugins/scxmleditor/plugin_interface/connectableitem.cpp b/src/plugins/scxmleditor/plugin_interface/connectableitem.cpp
index 392301e61e..90076c9eed 100644
--- a/src/plugins/scxmleditor/plugin_interface/connectableitem.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/connectableitem.cpp
@@ -451,7 +451,7 @@ void ConnectableItem::releaseFromParent()
setOpacity(0.5);
m_releasedIndex = tag()->index();
m_releasedParent = parentItem();
- tag()->document()->changeParent(tag(), 0, !m_releasedParent ? m_releasedIndex : -1);
+ tag()->document()->changeParent(tag(), nullptr, !m_releasedParent ? m_releasedIndex : -1);
setZValue(503);
for (int i = 0; i < m_quickTransitions.count(); ++i)
@@ -468,7 +468,8 @@ void ConnectableItem::connectToParent(BaseItem *parentItem)
for (int i = 0; i < m_corners.count(); ++i)
m_corners[i]->setVisible(true);
- tag()->document()->changeParent(tag(), parentItem ? parentItem->tag() : 0, parentItem == m_releasedParent ? m_releasedIndex : -1);
+ tag()->document()->changeParent(tag(), parentItem ? parentItem->tag() : nullptr,
+ parentItem == m_releasedParent ? m_releasedIndex : -1);
setZValue(0);
m_releasedIndex = -1;
@@ -564,7 +565,7 @@ void ConnectableItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
void ConnectableItem::updateUIProperties()
{
- if (tag() != 0 && isActiveScene()) {
+ if (tag() && isActiveScene()) {
Serializer s;
s.append(pos());
s.append(boundingRect());
diff --git a/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp b/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp
index e62fc096c2..c9b36ceda4 100644
--- a/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp
@@ -70,7 +70,7 @@ void GraphicsScene::unselectAll()
foreach (QGraphicsItem *it, selectedItems)
it->setSelected(false);
if (m_document)
- m_document->setCurrentTag(0);
+ m_document->setCurrentTag(nullptr);
}
void GraphicsScene::unhighlightAll()
@@ -209,7 +209,7 @@ void GraphicsScene::removeSelectedItems()
m_document->setCurrentTag(tags[i]);
m_document->removeTag(tags[i]);
}
- m_document->setCurrentTag(0);
+ m_document->setCurrentTag(nullptr);
m_document->undoStack()->endMacro();
}
}
@@ -305,7 +305,7 @@ void GraphicsScene::setEditorInfo(const QString &key, const QString &value)
void GraphicsScene::setDocument(ScxmlDocument *document)
{
if (m_document)
- disconnect(m_document, 0, this, 0);
+ disconnect(m_document, nullptr, this, nullptr);
m_document = document;
@@ -361,7 +361,7 @@ void GraphicsScene::init()
}
m_initializing = false;
- warningVisibilityChanged(0, 0);
+ warningVisibilityChanged(0, nullptr);
emit selectedStateCountChanged(0);
emit selectedBaseItemCountChanged(0);
}
@@ -556,7 +556,7 @@ void GraphicsScene::endTagChange(ScxmlDocument::TagChange change, ScxmlTag *tag,
auto transition = new TransitionItem;
addItem(transition);
transition->setStartItem(qgraphicsitem_cast<ConnectableItem*>(parentItem));
- transition->init(childTag, 0, false, false);
+ transition->init(childTag, nullptr, false, false);
transition->updateAttributes();
} else {
childItem = SceneUtils::createItemByTagType(childTag->tagType(), QPointF());
@@ -745,7 +745,7 @@ void GraphicsScene::removeItems(const ScxmlTag *tag)
// Then delete them
for (int i = items.count(); i--;) {
- items[i]->setTag(0);
+ items[i]->setTag(nullptr);
delete items[i];
}
}
@@ -911,7 +911,7 @@ void GraphicsScene::addChild(BaseItem *item)
void GraphicsScene::removeChild(BaseItem *item)
{
if (item)
- disconnect(item, 0, this, 0);
+ disconnect(item, nullptr, this, nullptr);
m_baseItems.removeAll(item);
selectionChanged(false);
@@ -943,7 +943,7 @@ void GraphicsScene::checkInitialState()
void GraphicsScene::clearAllTags()
{
foreach (BaseItem *it, m_baseItems) {
- it->setTag(0);
+ it->setTag(nullptr);
}
}
diff --git a/src/plugins/scxmleditor/plugin_interface/scattributeitemmodel.cpp b/src/plugins/scxmleditor/plugin_interface/scattributeitemmodel.cpp
index 8386a5b86b..4df2a211cc 100644
--- a/src/plugins/scxmleditor/plugin_interface/scattributeitemmodel.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/scattributeitemmodel.cpp
@@ -50,7 +50,7 @@ bool SCAttributeItemModel::setData(const QModelIndex &index, const QVariant &val
bool bEditable = m_tag->tagType() <= MetadataItem;
- if (index.row() >= 0 && m_document != 0) {
+ if (index.row() >= 0 && m_document) {
if (!bEditable) {
if (index.row() < m_tag->info()->n_attributes)
m_document->setValue(m_tag, index.row(), value.toString());
diff --git a/src/plugins/scxmleditor/plugin_interface/sceneutils.cpp b/src/plugins/scxmleditor/plugin_interface/sceneutils.cpp
index ccf8bbb15b..b5fb55aef2 100644
--- a/src/plugins/scxmleditor/plugin_interface/sceneutils.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/sceneutils.cpp
@@ -185,7 +185,7 @@ QVector<ScxmlTag*> findRemovedTags(const QVector<BaseItem*> &items)
// Find the last selected parent
BaseItem *parent = it->parentBaseItem();
BaseItem *lastSelectedParent = it;
- while (parent != 0) {
+ while (parent) {
if (parent->isSelected())
lastSelectedParent = parent;
parent = parent->parentBaseItem();
@@ -330,7 +330,7 @@ void layout(const QList<QGraphicsItem*> &items)
bool isChild(const QGraphicsItem *parent, const QGraphicsItem *child)
{
- while (child != 0) {
+ while (child) {
if (parent == child)
return true;
child = child->parentItem();
@@ -341,7 +341,7 @@ bool isChild(const QGraphicsItem *parent, const QGraphicsItem *child)
bool isSomeSelected(QGraphicsItem *item)
{
- while (item != 0) {
+ while (item) {
if (item->isSelected())
return true;
item = item->parentItem();
diff --git a/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp b/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp
index acf0116ac6..eb05ca403f 100644
--- a/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp
@@ -649,7 +649,7 @@ void TransitionItem::connectToTopItem(const QPointF &pos, TransitionPoint tp, It
removeGrabbers();
if (m_startItem == m_endItem && cornerPoints == 2) {
setTagValue("type", "internal");
- setEndItem(0);
+ setEndItem(nullptr);
m_targetType = InternalNoTarget;
}
@@ -1169,7 +1169,7 @@ void TransitionItem::storeValues(bool block)
void TransitionItem::updateUIProperties()
{
- if (tag() != 0 && isActiveScene())
+ if (tag() && isActiveScene())
storeValues();
}
@@ -1180,9 +1180,9 @@ void TransitionItem::updateTargetType()
TransitionTargetType type = ExternalTarget;
- if (m_startItem != 0 && m_startItem == m_endItem)
+ if (m_startItem && m_startItem == m_endItem)
type = InternalSameTarget;
- else if (m_startItem != 0 && !m_endItem) {
+ else if (m_startItem && !m_endItem) {
if (m_movingLastPoint) {
type = ExternalNoTarget;
} else {
diff --git a/src/plugins/scxmleditor/plugin_interface/warningitem.cpp b/src/plugins/scxmleditor/plugin_interface/warningitem.cpp
index 12c0bef594..bed6f39e29 100644
--- a/src/plugins/scxmleditor/plugin_interface/warningitem.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/warningitem.cpp
@@ -70,7 +70,7 @@ QRectF WarningItem::boundingRect() const
void WarningItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
{
- QToolTip::showText(e->screenPos(), toolTip(), 0);
+ QToolTip::showText(e->screenPos(), toolTip(), nullptr);
QGraphicsObject::mousePressEvent(e);
}
@@ -162,7 +162,7 @@ void WarningItem::setPixmap(const QPixmap &pixmap)
ScxmlTag *WarningItem::tag() const
{
- return m_parentItem ? m_parentItem->tag() : 0;
+ return m_parentItem ? m_parentItem->tag() : nullptr;
}
ScxmlEditor::OutputPane::Warning *WarningItem::warning() const
diff --git a/src/plugins/scxmleditor/scxmleditorconstants.h b/src/plugins/scxmleditor/scxmleditorconstants.h
index c503ab5f48..966d9a09f9 100644
--- a/src/plugins/scxmleditor/scxmleditorconstants.h
+++ b/src/plugins/scxmleditor/scxmleditorconstants.h
@@ -25,7 +25,7 @@
#pragma once
-#include "scxmleditor_global.h"
+#include <QtGlobal>
namespace ScxmlEditor {
namespace Constants {
diff --git a/src/plugins/scxmleditor/scxmleditordata.cpp b/src/plugins/scxmleditor/scxmleditordata.cpp
index c40639af48..205eaa8b90 100644
--- a/src/plugins/scxmleditor/scxmleditordata.cpp
+++ b/src/plugins/scxmleditor/scxmleditordata.cpp
@@ -60,11 +60,9 @@ namespace Internal {
class ScxmlTextEditorWidget : public TextEditor::TextEditorWidget
{
public:
- ScxmlTextEditorWidget()
- {
- }
+ ScxmlTextEditorWidget() = default;
- void finalizeInitialization()
+ void finalizeInitialization() override
{
setReadOnly(true);
}
diff --git a/src/plugins/scxmleditor/scxmleditorstack.cpp b/src/plugins/scxmleditor/scxmleditorstack.cpp
index bf8307a218..2861f24b50 100644
--- a/src/plugins/scxmleditor/scxmleditorstack.cpp
+++ b/src/plugins/scxmleditor/scxmleditorstack.cpp
@@ -89,8 +89,8 @@ void ScxmlEditorStack::modeAboutToChange(Core::Id m)
{
// Sync the editor when entering edit mode
if (m == Core::Constants::MODE_EDIT) {
- for (const ScxmlTextEditor *editor: m_editors)
- if (ScxmlEditorDocument *document = qobject_cast<ScxmlEditorDocument*>(editor->textDocument()))
+ for (auto editor: qAsConst(m_editors))
+ if (auto document = qobject_cast<ScxmlEditorDocument*>(editor->textDocument()))
document->syncXmlFromDesignWidget();
}
}
diff --git a/src/plugins/scxmleditor/scxmltexteditor.cpp b/src/plugins/scxmleditor/scxmltexteditor.cpp
index 1e6e2e6761..0c86cad919 100644
--- a/src/plugins/scxmleditor/scxmltexteditor.cpp
+++ b/src/plugins/scxmleditor/scxmltexteditor.cpp
@@ -49,7 +49,7 @@ ScxmlTextEditor::ScxmlTextEditor()
void ScxmlTextEditor::finalizeInitialization()
{
// Revert to saved/load externally modified files.
- ScxmlEditorDocument *document = qobject_cast<ScxmlEditorDocument*>(textDocument());
+ auto document = qobject_cast<const ScxmlEditorDocument*>(textDocument());
connect(document, &ScxmlEditorDocument::reloadRequested,
[this](QString *errorString, const QString &fileName) {
open(errorString, fileName, fileName);
@@ -58,7 +58,7 @@ void ScxmlTextEditor::finalizeInitialization()
bool ScxmlTextEditor::open(QString *errorString, const QString &fileName, const QString & /*realFileName*/)
{
- ScxmlEditorDocument *document = qobject_cast<ScxmlEditorDocument*>(textDocument());
+ auto document = qobject_cast<ScxmlEditorDocument*>(textDocument());
Common::MainWidget *designWidget = document->designWidget();
QTC_ASSERT(designWidget, return false);