forked from qt-creator/qt-creator
ScxmlEditor: Modernize
modernize-* Change-Id: I72a72cf5e9327956fdc0e5fc6f552bfc03d2122c Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
@@ -49,7 +49,7 @@ ColorSettings::ColorSettings(QWidget *parent)
|
|||||||
m_colorThemes = s->value(Constants::C_SETTINGS_COLORSETTINGS_COLORTHEMES).toMap();
|
m_colorThemes = s->value(Constants::C_SETTINGS_COLORSETTINGS_COLORTHEMES).toMap();
|
||||||
|
|
||||||
m_ui.m_comboColorThemes->clear();
|
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->addItem(key);
|
||||||
|
|
||||||
m_ui.m_comboColorThemes->setCurrentText(s->value(Constants::C_SETTINGS_COLORSETTINGS_CURRENTCOLORTHEME).toString());
|
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)) {
|
if (!name.isEmpty() && m_colorThemes.contains(name)) {
|
||||||
m_ui.m_colorThemeView->setEnabled(true);
|
m_ui.m_colorThemeView->setEnabled(true);
|
||||||
QVariantMap colordata = m_colorThemes[name].toMap();
|
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()));
|
m_ui.m_colorThemeView->setColor(index.toInt(), QColor(colordata[index].toString()));
|
||||||
} else {
|
} else {
|
||||||
m_ui.m_colorThemeView->setEnabled(false);
|
m_ui.m_colorThemeView->setEnabled(false);
|
||||||
|
@@ -231,7 +231,7 @@ void GraphicsView::dropEvent(QDropEvent *event)
|
|||||||
|
|
||||||
QList<QGraphicsItem*> parentItems = items(event->pos());
|
QList<QGraphicsItem*> parentItems = items(event->pos());
|
||||||
for (int i = 0; i < parentItems.count(); ++i) {
|
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) {
|
if (item && item->type() >= StateType) {
|
||||||
targetPos = item->mapFromScene(targetPos);
|
targetPos = item->mapFromScene(targetPos);
|
||||||
targetTag = item->tag();
|
targetTag = item->tag();
|
||||||
|
@@ -96,14 +96,14 @@ void StateProperties::tagChange(ScxmlDocument::TagChange change, ScxmlTag *tag,
|
|||||||
void StateProperties::setDocument(ScxmlDocument *document)
|
void StateProperties::setDocument(ScxmlDocument *document)
|
||||||
{
|
{
|
||||||
if (m_document)
|
if (m_document)
|
||||||
disconnect(m_document, 0, this, 0);
|
disconnect(m_document, nullptr, this, nullptr);
|
||||||
|
|
||||||
m_document = document;
|
m_document = document;
|
||||||
if (m_document) {
|
if (m_document) {
|
||||||
m_tag = m_document->rootTag();
|
m_tag = m_document->rootTag();
|
||||||
connect(m_document, &ScxmlDocument::endTagChange, this, &StateProperties::tagChange);
|
connect(m_document, &ScxmlDocument::endTagChange, this, &StateProperties::tagChange);
|
||||||
} else {
|
} else {
|
||||||
setTag(0);
|
setTag(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -325,7 +325,7 @@ void Structure::showMenu(const QModelIndex &index, const QPoint &globalPos)
|
|||||||
m_currentDocument->undoStack()->beginMacro(tr("Remove items"));
|
m_currentDocument->undoStack()->beginMacro(tr("Remove items"));
|
||||||
m_currentDocument->setCurrentTag(tag);
|
m_currentDocument->setCurrentTag(tag);
|
||||||
m_currentDocument->removeTag(tag);
|
m_currentDocument->removeTag(tag);
|
||||||
m_currentDocument->setCurrentTag(0);
|
m_currentDocument->setCurrentTag(nullptr);
|
||||||
m_currentDocument->undoStack()->endMacro();
|
m_currentDocument->undoStack()->endMacro();
|
||||||
} else if (actionType == TagUtils::AddChild) {
|
} else if (actionType == TagUtils::AddChild) {
|
||||||
tag->document()->undoStack()->beginMacro(tr("Add child"));
|
tag->document()->undoStack()->beginMacro(tr("Add child"));
|
||||||
|
@@ -46,7 +46,7 @@ void StructureModel::setDocument(ScxmlDocument *document)
|
|||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
if (m_document)
|
if (m_document)
|
||||||
disconnect(m_document, 0, this, 0);
|
disconnect(m_document, nullptr, this, nullptr);
|
||||||
|
|
||||||
m_document = document;
|
m_document = document;
|
||||||
if (m_document) {
|
if (m_document) {
|
||||||
|
@@ -132,9 +132,7 @@ OutputTabWidget::OutputTabWidget(QWidget *parent)
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputTabWidget::~OutputTabWidget()
|
OutputTabWidget::~OutputTabWidget() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int OutputTabWidget::addPane(OutputPane *pane)
|
int OutputTabWidget::addPane(OutputPane *pane)
|
||||||
{
|
{
|
||||||
|
@@ -29,7 +29,6 @@ using namespace ScxmlEditor::PluginInterface;
|
|||||||
|
|
||||||
AttributeItemDelegate::AttributeItemDelegate(QObject *parent)
|
AttributeItemDelegate::AttributeItemDelegate(QObject *parent)
|
||||||
: QStyledItemDelegate(parent)
|
: QStyledItemDelegate(parent)
|
||||||
, m_tag(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ void AttributeItemModel::setTag(ScxmlTag *tag)
|
|||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_tag = tag;
|
m_tag = tag;
|
||||||
m_document = m_tag ? m_tag->document() : 0;
|
m_document = m_tag ? m_tag->document() : nullptr;
|
||||||
endResetModel();
|
endResetModel();
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
emit dataChanged(QModelIndex(), QModelIndex());
|
emit dataChanged(QModelIndex(), QModelIndex());
|
||||||
|
@@ -333,7 +333,7 @@ bool BaseItem::isActiveScene() const
|
|||||||
|
|
||||||
ScxmlUiFactory *BaseItem::uiFactory() const
|
ScxmlUiFactory *BaseItem::uiFactory() const
|
||||||
{
|
{
|
||||||
return m_scene ? m_scene->uiFactory() : 0;
|
return m_scene ? m_scene->uiFactory() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsScene *BaseItem::graphicsScene() const
|
GraphicsScene *BaseItem::graphicsScene() const
|
||||||
|
@@ -451,7 +451,7 @@ void ConnectableItem::releaseFromParent()
|
|||||||
setOpacity(0.5);
|
setOpacity(0.5);
|
||||||
m_releasedIndex = tag()->index();
|
m_releasedIndex = tag()->index();
|
||||||
m_releasedParent = parentItem();
|
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);
|
setZValue(503);
|
||||||
|
|
||||||
for (int i = 0; i < m_quickTransitions.count(); ++i)
|
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)
|
for (int i = 0; i < m_corners.count(); ++i)
|
||||||
m_corners[i]->setVisible(true);
|
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);
|
setZValue(0);
|
||||||
m_releasedIndex = -1;
|
m_releasedIndex = -1;
|
||||||
@@ -564,7 +565,7 @@ void ConnectableItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
|||||||
|
|
||||||
void ConnectableItem::updateUIProperties()
|
void ConnectableItem::updateUIProperties()
|
||||||
{
|
{
|
||||||
if (tag() != 0 && isActiveScene()) {
|
if (tag() && isActiveScene()) {
|
||||||
Serializer s;
|
Serializer s;
|
||||||
s.append(pos());
|
s.append(pos());
|
||||||
s.append(boundingRect());
|
s.append(boundingRect());
|
||||||
|
@@ -70,7 +70,7 @@ void GraphicsScene::unselectAll()
|
|||||||
foreach (QGraphicsItem *it, selectedItems)
|
foreach (QGraphicsItem *it, selectedItems)
|
||||||
it->setSelected(false);
|
it->setSelected(false);
|
||||||
if (m_document)
|
if (m_document)
|
||||||
m_document->setCurrentTag(0);
|
m_document->setCurrentTag(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsScene::unhighlightAll()
|
void GraphicsScene::unhighlightAll()
|
||||||
@@ -209,7 +209,7 @@ void GraphicsScene::removeSelectedItems()
|
|||||||
m_document->setCurrentTag(tags[i]);
|
m_document->setCurrentTag(tags[i]);
|
||||||
m_document->removeTag(tags[i]);
|
m_document->removeTag(tags[i]);
|
||||||
}
|
}
|
||||||
m_document->setCurrentTag(0);
|
m_document->setCurrentTag(nullptr);
|
||||||
m_document->undoStack()->endMacro();
|
m_document->undoStack()->endMacro();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,7 +305,7 @@ void GraphicsScene::setEditorInfo(const QString &key, const QString &value)
|
|||||||
void GraphicsScene::setDocument(ScxmlDocument *document)
|
void GraphicsScene::setDocument(ScxmlDocument *document)
|
||||||
{
|
{
|
||||||
if (m_document)
|
if (m_document)
|
||||||
disconnect(m_document, 0, this, 0);
|
disconnect(m_document, nullptr, this, nullptr);
|
||||||
|
|
||||||
m_document = document;
|
m_document = document;
|
||||||
|
|
||||||
@@ -361,7 +361,7 @@ void GraphicsScene::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_initializing = false;
|
m_initializing = false;
|
||||||
warningVisibilityChanged(0, 0);
|
warningVisibilityChanged(0, nullptr);
|
||||||
emit selectedStateCountChanged(0);
|
emit selectedStateCountChanged(0);
|
||||||
emit selectedBaseItemCountChanged(0);
|
emit selectedBaseItemCountChanged(0);
|
||||||
}
|
}
|
||||||
@@ -556,7 +556,7 @@ void GraphicsScene::endTagChange(ScxmlDocument::TagChange change, ScxmlTag *tag,
|
|||||||
auto transition = new TransitionItem;
|
auto transition = new TransitionItem;
|
||||||
addItem(transition);
|
addItem(transition);
|
||||||
transition->setStartItem(qgraphicsitem_cast<ConnectableItem*>(parentItem));
|
transition->setStartItem(qgraphicsitem_cast<ConnectableItem*>(parentItem));
|
||||||
transition->init(childTag, 0, false, false);
|
transition->init(childTag, nullptr, false, false);
|
||||||
transition->updateAttributes();
|
transition->updateAttributes();
|
||||||
} else {
|
} else {
|
||||||
childItem = SceneUtils::createItemByTagType(childTag->tagType(), QPointF());
|
childItem = SceneUtils::createItemByTagType(childTag->tagType(), QPointF());
|
||||||
@@ -745,7 +745,7 @@ void GraphicsScene::removeItems(const ScxmlTag *tag)
|
|||||||
|
|
||||||
// Then delete them
|
// Then delete them
|
||||||
for (int i = items.count(); i--;) {
|
for (int i = items.count(); i--;) {
|
||||||
items[i]->setTag(0);
|
items[i]->setTag(nullptr);
|
||||||
delete items[i];
|
delete items[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -911,7 +911,7 @@ void GraphicsScene::addChild(BaseItem *item)
|
|||||||
void GraphicsScene::removeChild(BaseItem *item)
|
void GraphicsScene::removeChild(BaseItem *item)
|
||||||
{
|
{
|
||||||
if (item)
|
if (item)
|
||||||
disconnect(item, 0, this, 0);
|
disconnect(item, nullptr, this, nullptr);
|
||||||
m_baseItems.removeAll(item);
|
m_baseItems.removeAll(item);
|
||||||
|
|
||||||
selectionChanged(false);
|
selectionChanged(false);
|
||||||
@@ -943,7 +943,7 @@ void GraphicsScene::checkInitialState()
|
|||||||
void GraphicsScene::clearAllTags()
|
void GraphicsScene::clearAllTags()
|
||||||
{
|
{
|
||||||
foreach (BaseItem *it, m_baseItems) {
|
foreach (BaseItem *it, m_baseItems) {
|
||||||
it->setTag(0);
|
it->setTag(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ bool SCAttributeItemModel::setData(const QModelIndex &index, const QVariant &val
|
|||||||
|
|
||||||
bool bEditable = m_tag->tagType() <= MetadataItem;
|
bool bEditable = m_tag->tagType() <= MetadataItem;
|
||||||
|
|
||||||
if (index.row() >= 0 && m_document != 0) {
|
if (index.row() >= 0 && m_document) {
|
||||||
if (!bEditable) {
|
if (!bEditable) {
|
||||||
if (index.row() < m_tag->info()->n_attributes)
|
if (index.row() < m_tag->info()->n_attributes)
|
||||||
m_document->setValue(m_tag, index.row(), value.toString());
|
m_document->setValue(m_tag, index.row(), value.toString());
|
||||||
|
@@ -185,7 +185,7 @@ QVector<ScxmlTag*> findRemovedTags(const QVector<BaseItem*> &items)
|
|||||||
// Find the last selected parent
|
// Find the last selected parent
|
||||||
BaseItem *parent = it->parentBaseItem();
|
BaseItem *parent = it->parentBaseItem();
|
||||||
BaseItem *lastSelectedParent = it;
|
BaseItem *lastSelectedParent = it;
|
||||||
while (parent != 0) {
|
while (parent) {
|
||||||
if (parent->isSelected())
|
if (parent->isSelected())
|
||||||
lastSelectedParent = parent;
|
lastSelectedParent = parent;
|
||||||
parent = parent->parentBaseItem();
|
parent = parent->parentBaseItem();
|
||||||
@@ -330,7 +330,7 @@ void layout(const QList<QGraphicsItem*> &items)
|
|||||||
|
|
||||||
bool isChild(const QGraphicsItem *parent, const QGraphicsItem *child)
|
bool isChild(const QGraphicsItem *parent, const QGraphicsItem *child)
|
||||||
{
|
{
|
||||||
while (child != 0) {
|
while (child) {
|
||||||
if (parent == child)
|
if (parent == child)
|
||||||
return true;
|
return true;
|
||||||
child = child->parentItem();
|
child = child->parentItem();
|
||||||
@@ -341,7 +341,7 @@ bool isChild(const QGraphicsItem *parent, const QGraphicsItem *child)
|
|||||||
|
|
||||||
bool isSomeSelected(QGraphicsItem *item)
|
bool isSomeSelected(QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
while (item != 0) {
|
while (item) {
|
||||||
if (item->isSelected())
|
if (item->isSelected())
|
||||||
return true;
|
return true;
|
||||||
item = item->parentItem();
|
item = item->parentItem();
|
||||||
|
@@ -649,7 +649,7 @@ void TransitionItem::connectToTopItem(const QPointF &pos, TransitionPoint tp, It
|
|||||||
removeGrabbers();
|
removeGrabbers();
|
||||||
if (m_startItem == m_endItem && cornerPoints == 2) {
|
if (m_startItem == m_endItem && cornerPoints == 2) {
|
||||||
setTagValue("type", "internal");
|
setTagValue("type", "internal");
|
||||||
setEndItem(0);
|
setEndItem(nullptr);
|
||||||
m_targetType = InternalNoTarget;
|
m_targetType = InternalNoTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1169,7 +1169,7 @@ void TransitionItem::storeValues(bool block)
|
|||||||
|
|
||||||
void TransitionItem::updateUIProperties()
|
void TransitionItem::updateUIProperties()
|
||||||
{
|
{
|
||||||
if (tag() != 0 && isActiveScene())
|
if (tag() && isActiveScene())
|
||||||
storeValues();
|
storeValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1180,9 +1180,9 @@ void TransitionItem::updateTargetType()
|
|||||||
|
|
||||||
TransitionTargetType type = ExternalTarget;
|
TransitionTargetType type = ExternalTarget;
|
||||||
|
|
||||||
if (m_startItem != 0 && m_startItem == m_endItem)
|
if (m_startItem && m_startItem == m_endItem)
|
||||||
type = InternalSameTarget;
|
type = InternalSameTarget;
|
||||||
else if (m_startItem != 0 && !m_endItem) {
|
else if (m_startItem && !m_endItem) {
|
||||||
if (m_movingLastPoint) {
|
if (m_movingLastPoint) {
|
||||||
type = ExternalNoTarget;
|
type = ExternalNoTarget;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -70,7 +70,7 @@ QRectF WarningItem::boundingRect() const
|
|||||||
|
|
||||||
void WarningItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
void WarningItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
||||||
{
|
{
|
||||||
QToolTip::showText(e->screenPos(), toolTip(), 0);
|
QToolTip::showText(e->screenPos(), toolTip(), nullptr);
|
||||||
QGraphicsObject::mousePressEvent(e);
|
QGraphicsObject::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ void WarningItem::setPixmap(const QPixmap &pixmap)
|
|||||||
|
|
||||||
ScxmlTag *WarningItem::tag() const
|
ScxmlTag *WarningItem::tag() const
|
||||||
{
|
{
|
||||||
return m_parentItem ? m_parentItem->tag() : 0;
|
return m_parentItem ? m_parentItem->tag() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScxmlEditor::OutputPane::Warning *WarningItem::warning() const
|
ScxmlEditor::OutputPane::Warning *WarningItem::warning() const
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "scxmleditor_global.h"
|
#include <QtGlobal>
|
||||||
|
|
||||||
namespace ScxmlEditor {
|
namespace ScxmlEditor {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
@@ -60,11 +60,9 @@ namespace Internal {
|
|||||||
class ScxmlTextEditorWidget : public TextEditor::TextEditorWidget
|
class ScxmlTextEditorWidget : public TextEditor::TextEditorWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScxmlTextEditorWidget()
|
ScxmlTextEditorWidget() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void finalizeInitialization()
|
void finalizeInitialization() override
|
||||||
{
|
{
|
||||||
setReadOnly(true);
|
setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
@@ -89,8 +89,8 @@ void ScxmlEditorStack::modeAboutToChange(Core::Id m)
|
|||||||
{
|
{
|
||||||
// Sync the editor when entering edit mode
|
// Sync the editor when entering edit mode
|
||||||
if (m == Core::Constants::MODE_EDIT) {
|
if (m == Core::Constants::MODE_EDIT) {
|
||||||
for (const ScxmlTextEditor *editor: m_editors)
|
for (auto editor: qAsConst(m_editors))
|
||||||
if (ScxmlEditorDocument *document = qobject_cast<ScxmlEditorDocument*>(editor->textDocument()))
|
if (auto document = qobject_cast<ScxmlEditorDocument*>(editor->textDocument()))
|
||||||
document->syncXmlFromDesignWidget();
|
document->syncXmlFromDesignWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ ScxmlTextEditor::ScxmlTextEditor()
|
|||||||
void ScxmlTextEditor::finalizeInitialization()
|
void ScxmlTextEditor::finalizeInitialization()
|
||||||
{
|
{
|
||||||
// Revert to saved/load externally modified files.
|
// Revert to saved/load externally modified files.
|
||||||
ScxmlEditorDocument *document = qobject_cast<ScxmlEditorDocument*>(textDocument());
|
auto document = qobject_cast<const ScxmlEditorDocument*>(textDocument());
|
||||||
connect(document, &ScxmlEditorDocument::reloadRequested,
|
connect(document, &ScxmlEditorDocument::reloadRequested,
|
||||||
[this](QString *errorString, const QString &fileName) {
|
[this](QString *errorString, const QString &fileName) {
|
||||||
open(errorString, fileName, fileName);
|
open(errorString, fileName, fileName);
|
||||||
@@ -58,7 +58,7 @@ void ScxmlTextEditor::finalizeInitialization()
|
|||||||
|
|
||||||
bool ScxmlTextEditor::open(QString *errorString, const QString &fileName, const QString & /*realFileName*/)
|
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();
|
Common::MainWidget *designWidget = document->designWidget();
|
||||||
QTC_ASSERT(designWidget, return false);
|
QTC_ASSERT(designWidget, return false);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user