aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/insight/insightview.cpp
blob: 8a4dd5d19ec2c2c73aeabec8991883003f545bcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "insightview.h"
#include "insightmodel.h"
#include "insightwidget.h"

#include <utils/qtcassert.h>

#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QTextDocument>

namespace QmlDesigner {

InsightView::InsightView(ExternalDependenciesInterface &externalDependencies,
                         QmlDesignerProjectManager &projectManager)
    : AbstractView(externalDependencies)
    , m_insightModel(std::make_unique<InsightModel>(this, externalDependencies, projectManager))
{
    Q_ASSERT(m_insightModel);
}

InsightView::~InsightView()
{
    delete m_insightWidget.data();
}

void InsightView::modelAttached(Model *model)
{
    if (model == AbstractView::model())
        return;

    QTC_ASSERT(model, return );
    AbstractView::modelAttached(model);

    m_insightModel->setup();
}

WidgetInfo InsightView::widgetInfo()
{
    if (!m_insightWidget)
        m_insightWidget = new InsightWidget(this, m_insightModel.get());

    return createWidgetInfo(m_insightWidget.data(),
                            "QtInsight",
                            WidgetInfo::RightPane,
                            tr("Qt Insight"));
}

bool InsightView::hasWidget() const
{
    return true;
}

} // namespace QmlDesigner