1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
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.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "editorwidget.h"
34 #include "formeditorw.h"
35 #include "formeditorstack.h"
37 #include <coreplugin/editormanager/ieditor.h>
39 #include <utils/qtcassert.h>
41 #include <QtGui/QVBoxLayout>
42 #include <QtGui/QDockWidget>
43 #include <QtGui/QAbstractItemView>
45 using namespace Designer::Constants;
50 // ---------- EditorWidget
52 EditorWidget::EditorWidget(FormEditorW *few, QWidget *parent) :
53 Utils::FancyMainWindow(parent),
54 m_stack(new FormEditorStack)
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);
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);
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);
76 resetToDefaultLayout();
79 void EditorWidget::resetToDefaultLayout()
81 setTrackingEnabled(false);
82 QList<QDockWidget *> dockWidgetList = dockWidgets();
83 foreach (QDockWidget *dockWidget, dockWidgetList) {
84 dockWidget->setFloating(false);
85 removeDockWidget(dockWidget);
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]);
94 tabifyDockWidget(m_designerDockWidgets[ActionEditorSubWindow],
95 m_designerDockWidgets[SignalSlotEditorSubWindow]);
97 foreach (QDockWidget *dockWidget, dockWidgetList)
100 setTrackingEnabled(true);
103 QDockWidget* const* EditorWidget::designerDockWidgets() const
105 return m_designerDockWidgets;
108 void EditorWidget::add(const EditorData &d)
113 void EditorWidget::removeFormWindowEditor(Core::IEditor *xmlEditor)
115 m_stack->removeFormWindowEditor(xmlEditor);
118 bool EditorWidget::setVisibleEditor(Core::IEditor *xmlEditor)
120 return m_stack->setVisibleEditor(xmlEditor);
123 SharedTools::WidgetHost *EditorWidget::formWindowEditorForXmlEditor(const Core::IEditor *xmlEditor) const
125 return m_stack->formWindowEditorForXmlEditor(xmlEditor);
128 EditorData EditorWidget::activeEditor() const
130 return m_stack->activeEditor();
133 SharedTools::WidgetHost *EditorWidget::formWindowEditorForFormWindow(const QDesignerFormWindowInterface *fw) const
135 return m_stack->formWindowEditorForFormWindow(fw);
138 } // namespace Internal
139 } // namespace Designer