formeditorstack.h 2.67 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
Lasse Holmstedt's avatar
Lasse Holmstedt committed
2
**
3 4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
Lasse Holmstedt's avatar
Lasse Holmstedt committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
Lasse Holmstedt's avatar
Lasse Holmstedt committed
7
**
hjk's avatar
hjk committed
8 9 10 11
** 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
12 13 14
** 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.
Lasse Holmstedt's avatar
Lasse Holmstedt committed
15
**
16 17 18 19 20 21 22
** 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.
con's avatar
con committed
23
**
hjk's avatar
hjk committed
24
****************************************************************************/
Lasse Holmstedt's avatar
Lasse Holmstedt committed
25

hjk's avatar
hjk committed
26
#pragma once
Lasse Holmstedt's avatar
Lasse Holmstedt committed
27

28 29
#include "editordata.h"

hjk's avatar
hjk committed
30 31
#include <coreplugin/id.h>

32 33
#include <QStackedWidget>
#include <QList>
Lasse Holmstedt's avatar
Lasse Holmstedt committed
34

35 36 37 38 39
QT_BEGIN_NAMESPACE
class QDesignerFormWindowInterface;
class QDesignerFormEditorInterface;
QT_END_NAMESPACE

hjk's avatar
hjk committed
40
namespace Core { class IEditor; }
Lasse Holmstedt's avatar
Lasse Holmstedt committed
41 42 43 44

namespace Designer {
namespace Internal {

45 46 47 48 49
/* FormEditorStack: Maintains a stack of Qt Designer form windows embedded
 * into a scrollarea and their associated XML editors.
 * Takes care of updating the XML editor once design mode is left.
 * Also updates the maincontainer resize handles when the active form
 * window changes. */
Lasse Holmstedt's avatar
Lasse Holmstedt committed
50 51 52
class FormEditorStack : public QStackedWidget
{
    Q_OBJECT
hjk's avatar
hjk committed
53

Lasse Holmstedt's avatar
Lasse Holmstedt committed
54
public:
55 56
    explicit FormEditorStack(QWidget *parent = 0);

57 58
    void add(const EditorData &d);

Lasse Holmstedt's avatar
Lasse Holmstedt committed
59
    bool setVisibleEditor(Core::IEditor *xmlEditor);
60 61
    SharedTools::WidgetHost *formWindowEditorForXmlEditor(const Core::IEditor *xmlEditor) const;
    SharedTools::WidgetHost *formWindowEditorForFormWindow(const QDesignerFormWindowInterface *fw) const;
62 63

    EditorData activeEditor() const;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
64

65 66 67
public slots:
    void removeFormWindowEditor(QObject *);

Lasse Holmstedt's avatar
Lasse Holmstedt committed
68
private slots:
69
    void updateFormWindowSelectionHandles();
hjk's avatar
hjk committed
70
    void modeAboutToChange(Core::Id mode);
71
    void formSizeChanged(int w, int h);
Lasse Holmstedt's avatar
Lasse Holmstedt committed
72 73

private:
74 75
    inline int indexOfFormWindow(const QDesignerFormWindowInterface *) const;
    inline int indexOfFormEditor(const QObject *xmlEditor) const;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
76

77
    QList<EditorData> m_formEditors;
78
    QDesignerFormEditorInterface *m_designerCore;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
79 80
};

81 82
} // namespace Internal
} // namespace Designer