Remove some useless IContext subclasses

They are only created at single places anyhow, so use the setters of
IContext instead

Change-Id: I00a089c9f1ea151c76cb6443e2a24c4a05437bbb
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2020-05-26 16:07:10 +02:00
parent e5bb7d1ffe
commit 83843fbd06
10 changed files with 10 additions and 112 deletions

View File

@@ -98,12 +98,6 @@ private:
Qt::MouseButton m_mouseButtonPressed = Qt::NoButton;
};
class TaskWindowContext : public Core::IContext
{
public:
TaskWindowContext(QWidget *widget);
};
class TaskDelegate : public QStyledItemDelegate
{
Q_OBJECT
@@ -289,7 +283,7 @@ public:
Internal::TaskModel *m_model;
Internal::TaskFilterModel *m_filter;
Internal::TaskView *m_listview;
Internal::TaskWindowContext *m_taskWindowContext;
Core::IContext *m_taskWindowContext;
QMenu *m_contextMenu;
QMap<const QAction *, ITaskHandler *> m_actionToHandlerMap;
ITaskHandler *m_defaultHandler = nullptr;
@@ -329,8 +323,9 @@ TaskWindow::TaskWindow() : d(std::make_unique<TaskWindowPrivate>())
d->m_listview->setContextMenuPolicy(Qt::ActionsContextMenu);
d->m_listview->setAttribute(Qt::WA_MacShowFocusRect, false);
d->m_taskWindowContext = new Internal::TaskWindowContext(d->m_listview);
d->m_taskWindowContext = new Core::IContext(d->m_listview);
d->m_taskWindowContext->setWidget(d->m_listview);
d->m_taskWindowContext->setContext(Core::Context(Core::Constants::C_PROBLEM_PANE));
Core::ICore::addContextObject(d->m_taskWindowContext);
connect(d->m_listview->selectionModel(), &QItemSelectionModel::currentChanged,
@@ -1018,13 +1013,6 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
painter->restore();
}
TaskWindowContext::TaskWindowContext(QWidget *widget)
: Core::IContext(widget)
{
setWidget(widget);
setContext(Core::Context(Core::Constants::C_PROBLEM_PANE));
}
} // namespace Internal
} // namespace ProjectExplorer

View File

@@ -41,8 +41,9 @@
namespace QmlDesigner {
BindingEditorWidget::BindingEditorWidget()
: m_context(new BindingEditorContext(this))
: m_context(new Core::IContext(this))
{
m_context->setWidget(this);
Core::ICore::addContextObject(m_context);
const Core::Context context(BINDINGEDITOR_CONTEXT_ID);

View File

@@ -39,18 +39,6 @@ namespace QmlDesigner {
const char BINDINGEDITOR_CONTEXT_ID[] = "BindingEditor.BindingEditorContext";
class BindingEditorContext : public Core::IContext
{
Q_OBJECT
public:
BindingEditorContext(QWidget *parent) : Core::IContext(parent)
{
setWidget(parent);
}
};
class BindingEditorWidget : public QmlJSEditor::QmlJSEditorWidget
{
Q_OBJECT
@@ -71,7 +59,7 @@ signals:
public:
QmlJSEditor::QmlJSEditorDocument *qmljsdocument = nullptr;
BindingEditorContext *m_context = nullptr;
Core::IContext *m_context = nullptr;
QAction *m_completionAction = nullptr;
};

View File

@@ -82,7 +82,6 @@ add_qtc_plugin(ScxmlEditor
plugin_interface/utilsprovider.cpp plugin_interface/utilsprovider.h
plugin_interface/warningitem.cpp plugin_interface/warningitem.h
plugin_interface/warningprovider.h
scxmlcontext.cpp scxmlcontext.h
scxmleditor_global.h
scxmleditorconstants.h
scxmleditordata.cpp scxmleditordata.h

View File

@@ -1,35 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "scxmlcontext.h"
using namespace ScxmlEditor::Internal;
ScxmlContext::ScxmlContext(const Core::Context &context, QWidget *widget, QObject *parent)
: Core::IContext(parent)
{
setContext(context);
setWidget(widget);
}

View File

@@ -1,40 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <coreplugin/icontext.h>
namespace ScxmlEditor {
namespace Internal {
class ScxmlContext : public Core::IContext
{
public:
explicit ScxmlContext(const Core::Context &contexts, QWidget *widget, QObject *parent = nullptr);
};
} // namespace Internal
} // namespace Designer

View File

@@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri)
INCLUDEPATH += $$PWD
HEADERS += \
scxmlcontext.h \
scxmleditor_global.h \
scxmleditorconstants.h \
scxmleditordata.h \
@@ -14,7 +13,6 @@ HEADERS += \
scxmltexteditor.h
SOURCES += \
scxmlcontext.cpp \
scxmleditordata.cpp \
scxmleditordocument.cpp \
scxmleditorfactory.cpp \

View File

@@ -21,7 +21,6 @@ QtcPlugin {
])
files: [
"scxmlcontext.cpp", "scxmlcontext.h",
"scxmleditor_global.h",
"scxmleditorconstants.h",
"scxmleditordata.cpp", "scxmleditordata.h",

View File

@@ -25,7 +25,6 @@
#include "scxmleditordata.h"
#include "mainwidget.h"
#include "scxmlcontext.h"
#include "scxmleditorconstants.h"
#include "scxmleditordocument.h"
#include "scxmleditorstack.h"
@@ -143,7 +142,9 @@ void ScxmlEditorData::fullInit()
Context scxmlContexts = m_contexts;
scxmlContexts.add(Core::Constants::C_EDITORMANAGER);
auto context = new ScxmlContext(scxmlContexts, m_modeWidget, this);
auto context = new IContext(this);
context->setContext(scxmlContexts);
context->setWidget(m_modeWidget);
ICore::addContextObject(context);
DesignMode::registerDesignWidget(m_modeWidget, QStringList(QLatin1String(ProjectExplorer::Constants::SCXML_MIMETYPE)), m_contexts);

View File

@@ -40,7 +40,6 @@ namespace Internal {
class ScxmlTextEditorFactory;
class ScxmlEditorWidget;
class ScxmlEditorStack;
class ScxmlContext;
class ScxmlEditorData : public QObject
{