Fix some random deprecation warning

if QT_DEPRECATED_SINCE(6, 0)
    QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()")
    inline QPoint pos() const { return position().toPoint(); }
    ...

Change-Id: If885b26c8e5f4d68ca1c5c7e4ffc495b0701b210
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2024-06-05 17:27:14 +02:00
parent a05b0a7829
commit f64232f77b
11 changed files with 22 additions and 23 deletions

View File

@@ -289,7 +289,7 @@ void WorkspaceView::keyPressEvent(QKeyEvent *event)
void WorkspaceView::dropEvent(QDropEvent *event)
{
const QModelIndex dropIndex = indexAt(event->pos());
const QModelIndex dropIndex = indexAt(event->position().toPoint());
const DropIndicatorPosition dropIndicator = dropIndicatorPosition();
const auto droppedWorkspaces = selectedWorkspaces();

View File

@@ -38,7 +38,7 @@ private:
InvokerBase(const InvokerBase &); // Unimplemented.
template <class T> const char *typeName()
{
return QMetaType::typeName(qMetaTypeId<T>());
return QMetaType(qMetaTypeId<T>()).name();
}
QObject *target;
QGenericArgument arg[10];

View File

@@ -112,7 +112,7 @@ void DiagramView::dropEvent(QDropEvent *event)
if (diagramSceneController->isAddingAllowed(Uid(QUuid(key)),
m_diagramSceneModel->diagram())) {
diagramSceneController->addExistingModelElement(Uid(QUuid(key)),
mapToScene(event->pos()),
mapToScene(event->position().toPoint()),
m_diagramSceneModel->diagram());
}
}
@@ -126,10 +126,10 @@ void DiagramView::dropEvent(QDropEvent *event)
QString stereotype;
dataStream >> newElementId >> name >> stereotype;
if (!newElementId.isEmpty()) {
QPointF pos = mapToScene(event->pos());
QPointF pos = mapToScene(event->position().toPoint());
diagramSceneController->dropNewElement(
newElementId, name, stereotype, m_diagramSceneModel->findTopmostElement(pos),
pos, m_diagramSceneModel->diagram(), event->pos(), size());
pos, m_diagramSceneModel->diagram(), event->position().toPoint(), size());
}
}
event->accept();

View File

@@ -184,7 +184,7 @@ void ModelTreeView::dragMoveEvent(QDragMoveEvent *event)
{
QTreeView::dragMoveEvent(event);
bool accept = false;
QModelIndex dropIndex = indexAt(event->pos());
QModelIndex dropIndex = indexAt(event->position().toPoint());
QModelIndex dropSourceModelIndex = m_sortedTreeModel->mapToSource(dropIndex);
if (dropSourceModelIndex.isValid()) {
TreeModel *treeModel = m_sortedTreeModel->treeModel();
@@ -215,7 +215,7 @@ void ModelTreeView::dropEvent(QDropEvent *event)
bool accept = false;
event->setDropAction(Qt::MoveAction);
if (event->mimeData()->hasFormat("text/model-elements")) {
QModelIndex dropIndex = indexAt(event->pos());
QModelIndex dropIndex = indexAt(event->position().toPoint());
QModelIndex dropSourceModelIndex = m_sortedTreeModel->mapToSource(dropIndex);
if (dropSourceModelIndex.isValid()) {
TreeModel *treeModel = m_sortedTreeModel->treeModel();

View File

@@ -108,7 +108,7 @@ bool DropSupport::eventFilter(QObject *obj, QEvent *event)
de->acceptProposedAction();
bool needToScheduleEmit = m_files.isEmpty();
m_files.append(tempFiles);
m_dropPos = de->pos();
m_dropPos = de->position().toPoint();
if (needToScheduleEmit) { // otherwise we already have a timer pending
// Delay the actual drop, to avoid conflict between
// actions that happen when opening files, and actions that the item views do
@@ -122,7 +122,7 @@ bool DropSupport::eventFilter(QObject *obj, QEvent *event)
accepted = true;
bool needToScheduleEmit = m_values.isEmpty();
m_values.append(fileDropMimeData->values());
m_dropPos = de->pos();
m_dropPos = de->position().toPoint();
if (needToScheduleEmit)
QTimer::singleShot(100, this, &DropSupport::emitValuesDropped);
}

View File

@@ -707,7 +707,7 @@ ActionContainer *FormEditorData::createPreviewStyleMenu(QActionGroup *actionGrou
QString name = menuId;
name += dot;
const QVariant data = a->data();
const bool isDeviceProfile = data.typeId() == QVariant::Int;
const bool isDeviceProfile = data.typeId() == QMetaType::Int;
if (isDeviceProfile) {
name += deviceProfilePrefix;
name += dot;

View File

@@ -29,7 +29,7 @@ public:
QVariant maybeConvertToNumber(const QVariant &value)
{
if (value.typeId() == QVariant::Bool)
if (value.typeId() == QMetaType::Bool)
return value;
if (value.typeId() == QMetaType::QString) {

View File

@@ -265,7 +265,7 @@ void TextEditorWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
void TextEditorWidget::dragMoveEvent(QDragMoveEvent *dragMoveEvent)
{
QTextCursor cursor = m_textEditor->editorWidget()->cursorForPosition(dragMoveEvent->pos());
QTextCursor cursor = m_textEditor->editorWidget()->cursorForPosition(dragMoveEvent->position().toPoint());
const int cursorPosition = cursor.position();
RewriterView *rewriterView = m_textEditorView->model()->rewriterView();
@@ -279,7 +279,7 @@ void TextEditorWidget::dragMoveEvent(QDragMoveEvent *dragMoveEvent)
void TextEditorWidget::dropEvent(QDropEvent *dropEvent)
{
QTextCursor cursor = m_textEditor->editorWidget()->cursorForPosition(dropEvent->pos());
QTextCursor cursor = m_textEditor->editorWidget()->cursorForPosition(dropEvent->position().toPoint());
const int cursorPosition = cursor.position();
RewriterView *rewriterView = m_textEditorView->model()->rewriterView();

View File

@@ -201,7 +201,7 @@ QVariant read(const QString &typeStr, const QString &str, const MetaInfo &)
QVariant read(const QString &typeStr, const QString &str)
{
int type = QMetaType::type(typeStr.toUtf8().constData());
int type = QMetaType::fromName(typeStr.toUtf8().constData()).id();
if (type == 0) {
if (typeStr != "binding"_L1 && typeStr != "enum"_L1) {
qWarning() << "Type " << typeStr
@@ -270,15 +270,14 @@ QVariant read(int variantType, const QString &str)
value = QVariant::fromValue<Enumeration>(enumerationFromString(str, &conversionOk));
} else {
value = QVariant(str);
value.convert(static_cast<QVariant::Type>(variantType));
value.convert(QMetaType(variantType));
}
break;
}
}
if (!conversionOk) {
qWarning() << "Could not convert" << str
<< "to" << QMetaType::typeName(variantType);
qWarning() << "Could not convert" << str << "to" << QMetaType(variantType).name();
value = QVariant(str);
}

View File

@@ -175,8 +175,8 @@ void GraphicsView::dragMoveEvent(QDragMoveEvent *event)
ScxmlTag *targetTag = nullptr;
QList<QGraphicsItem*> parentItems = items(event->pos());
QPointF sceneP = mapToScene(event->pos());
QList<QGraphicsItem*> parentItems = items(event->position().toPoint());
QPointF sceneP = mapToScene(event->position().toPoint());
for (int i = 0; i < parentItems.count(); ++i) {
auto item = static_cast<BaseItem*>(parentItems[i]);
if (item && item->type() >= TransitionType && item->containsScenePoint(sceneP)) {
@@ -206,9 +206,9 @@ void GraphicsView::dropEvent(QDropEvent *event)
int shapeIndex = event->mimeData()->data("shapeIndex").toInt();
ScxmlTag *targetTag = nullptr;
QPointF targetPos = mapToScene(event->pos());
QPointF targetPos = mapToScene(event->position().toPoint());
QList<QGraphicsItem*> parentItems = items(event->pos());
QList<QGraphicsItem*> parentItems = items(event->position().toPoint());
for (int i = 0; i < parentItems.count(); ++i) {
auto item = static_cast<const BaseItem*>(parentItems[i]);
if (item && item->type() >= StateType) {

View File

@@ -9232,7 +9232,7 @@ void TextEditorWidget::dragLeaveEvent(QDragLeaveEvent *)
void TextEditorWidget::dragMoveEvent(QDragMoveEvent *e)
{
const QRect rect = cursorRect(d->m_dndCursor);
d->m_dndCursor = cursorForPosition(e->pos());
d->m_dndCursor = cursorForPosition(e->position().toPoint());
if (!rect.isNull())
viewport()->update(rect);
viewport()->update(cursorRect(d->m_dndCursor));
@@ -9250,7 +9250,7 @@ void TextEditorWidget::dropEvent(QDropEvent *e)
// Update multi text cursor before inserting data
MultiTextCursor cursor = multiTextCursor();
cursor.beginEditBlock();
const QTextCursor eventCursor = cursorForPosition(e->pos());
const QTextCursor eventCursor = cursorForPosition(e->position().toPoint());
if (e->dropAction() == Qt::MoveAction && e->source() == viewport())
cursor.removeSelectedText();
cursor.setCursors({eventCursor});