OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / designer / editorwidget.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #include "editorwidget.h"
34 #include "formeditorw.h"
35 #include "formeditorstack.h"
36
37 #include <coreplugin/editormanager/ieditor.h>
38
39 #include <utils/qtcassert.h>
40
41 #include <QtGui/QVBoxLayout>
42 #include <QtGui/QDockWidget>
43 #include <QtGui/QAbstractItemView>
44
45 using namespace Designer::Constants;
46
47 namespace Designer {
48 namespace Internal {
49
50 // ---------- EditorWidget
51
52 EditorWidget::EditorWidget(FormEditorW *few, QWidget *parent) :
53     Utils::FancyMainWindow(parent),
54     m_stack(new FormEditorStack)
55 {
56     setObjectName(QLatin1String("EditorWidget"));
57     setCentralWidget(m_stack);
58     setDocumentMode(true);
59     setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South);
60     setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
61     setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
62
63     QWidget * const*subs = few->designerSubWindows();
64     for (int i = 0; i < DesignerSubWindowCount; i++) {
65         QWidget *subWindow = subs[i];
66         subWindow->setWindowTitle(subs[i]->windowTitle());
67         m_designerDockWidgets[i] = addDockForWidget(subWindow);
68
69         // Since we have 1-pixel splitters, we generally want to remove
70         // frames around item views. So we apply this hack for now.
71         QList<QAbstractItemView*> frames = subWindow->findChildren<QAbstractItemView*>();
72         for (int i = 0 ; i< frames.count(); ++i)
73             frames[i]->setFrameStyle(QFrame::NoFrame);
74
75     }
76     resetToDefaultLayout();
77 }
78
79 void EditorWidget::resetToDefaultLayout()
80 {
81     setTrackingEnabled(false);
82     QList<QDockWidget *> dockWidgetList = dockWidgets();
83     foreach (QDockWidget *dockWidget, dockWidgetList) {
84         dockWidget->setFloating(false);
85         removeDockWidget(dockWidget);
86     }
87
88     addDockWidget(Qt::LeftDockWidgetArea, m_designerDockWidgets[WidgetBoxSubWindow]);
89     addDockWidget(Qt::RightDockWidgetArea, m_designerDockWidgets[ObjectInspectorSubWindow]);
90     addDockWidget(Qt::RightDockWidgetArea, m_designerDockWidgets[PropertyEditorSubWindow]);
91     addDockWidget(Qt::BottomDockWidgetArea, m_designerDockWidgets[ActionEditorSubWindow]);
92     addDockWidget(Qt::BottomDockWidgetArea, m_designerDockWidgets[SignalSlotEditorSubWindow]);
93
94     tabifyDockWidget(m_designerDockWidgets[ActionEditorSubWindow],
95                      m_designerDockWidgets[SignalSlotEditorSubWindow]);
96
97     foreach (QDockWidget *dockWidget, dockWidgetList)
98         dockWidget->show();
99
100     setTrackingEnabled(true);
101 }
102
103 QDockWidget* const* EditorWidget::designerDockWidgets() const
104 {
105     return m_designerDockWidgets;
106 }
107
108 void EditorWidget::add(const EditorData &d)
109 {
110     m_stack->add(d);
111 }
112
113 void EditorWidget::removeFormWindowEditor(Core::IEditor *xmlEditor)
114 {
115     m_stack->removeFormWindowEditor(xmlEditor);
116 }
117
118 bool EditorWidget::setVisibleEditor(Core::IEditor *xmlEditor)
119 {
120     return m_stack->setVisibleEditor(xmlEditor);
121 }
122
123 SharedTools::WidgetHost *EditorWidget::formWindowEditorForXmlEditor(const Core::IEditor *xmlEditor) const
124 {
125     return m_stack->formWindowEditorForXmlEditor(xmlEditor);
126 }
127
128 EditorData EditorWidget::activeEditor() const
129 {
130     return m_stack->activeEditor();
131 }
132
133 SharedTools::WidgetHost *EditorWidget::formWindowEditorForFormWindow(const QDesignerFormWindowInterface *fw) const
134 {
135     return m_stack->formWindowEditorForFormWindow(fw);
136 }
137
138 } // namespace Internal
139 } // namespace Designer