summaryrefslogtreecommitdiff
path: root/src/plugins/designer/formeditorw.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-03-09 15:48:01 +0100
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-03-09 15:48:01 +0100
commit1c78e200c261f6a8d6561a00b190d36f4aada74b (patch)
tree2653812fec9a8376aa1e4d0327fccd821f36d947 /src/plugins/designer/formeditorw.cpp
parent403d755855d1c1951e846be5fbe6b06463b6b4d2 (diff)
downloadqt-creator-1c78e200c261f6a8d6561a00b190d36f4aada74b.tar.gz
Design mode/Qt Designer: clean-up Part II: Fix undo.
Re-introduce FormEditorFile that delegates dirty handling to the form window. Change DesignerXmlEditable to be an IEditor that embeds TextEditable so that the PlainTextEditor can work with it, but delegates relevant functionality to FormEditorFile. Centralize all form window creation code that was scattered around in FormEditorW::createEditor() and have that return a struct Editor data, which is passed to FormEditorStack. Update the text editor only on open/createNew/switch away from design mode.
Diffstat (limited to 'src/plugins/designer/formeditorw.cpp')
-rw-r--r--src/plugins/designer/formeditorw.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp
index 98c2ea295b..320be347a6 100644
--- a/src/plugins/designer/formeditorw.cpp
+++ b/src/plugins/designer/formeditorw.cpp
@@ -34,12 +34,12 @@
#include "settingsmanager.h"
#include "settingspage.h"
#include "editorwidget.h"
+#include "editordata.h"
#include "qtcreatorintegration.h"
#include "designerxmleditor.h"
#include "designercontext.h"
#include "editorwidget.h"
-#include <texteditor/basetextdocument.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/designmode.h>
#include <coreplugin/coreconstants.h>
@@ -47,6 +47,7 @@
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <texteditor/texteditorsettings.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
@@ -213,7 +214,7 @@ FormEditorW::~FormEditorW()
m_self = 0;
}
-// Add an action to toggle the view state of a dock window
+// Add an actioon to toggle the view state of a dock window
void FormEditorW::addDockViewAction(Core::ActionManager *am,
int index, const QList<int> &context,
const QString &title, const QString &id)
@@ -651,13 +652,27 @@ void FormEditorW::addToolAction(QAction *a,
c1->addAction(command);
}
-FormWindowEditor *FormEditorW::createFormWindowEditor(QWidget* parentWidget)
+EditorData FormEditorW::createEditor(QWidget *parent)
{
+ if (Designer::Constants::Internal::debug)
+ qDebug() << "FormEditorW::createEditor";
+ // Create and associate form and text editor.
+ EditorData data;
m_fwm->closeAllPreviews();
- QDesignerFormWindowInterface *form = m_fwm->createFormWindow(0);
+ qdesigner_internal::FormWindowBase *form = qobject_cast<qdesigner_internal::FormWindowBase *>(m_fwm->createFormWindow(0));
+ QTC_ASSERT(form, return data);
connect(form, SIGNAL(toolChanged(int)), this, SLOT(toolChanged(int)));
+ form->setDesignerGrid(qdesigner_internal::FormWindowBase::defaultDesignerGrid());
qdesigner_internal::FormWindowBase::setupDefaultAction(form);
- return new FormWindowEditor(form, parentWidget);
+ data.formEditor = new FormWindowEditor(form);
+ DesignerXmlEditor *xmlEditor = new DesignerXmlEditor(form, parent);
+ TextEditor::TextEditorSettings::instance()->initializeEditor(xmlEditor);
+ data.xmlEditor = xmlEditor->designerEditable();
+ data.formEditor->setFile(data.xmlEditor->file());
+ connect(data.formEditor, SIGNAL(formWindowSizeChanged(int,int)),
+ xmlEditor, SIGNAL(changed()));
+ m_editorWidget->add(data);
+ return data;
}
void FormEditorW::updateShortcut(QObject *command)
@@ -681,11 +696,8 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
QTC_ASSERT(xmlEditor, return);
ensureInitStage(FullyInitialized);
FormWindowEditor *fw = m_editorWidget->formWindowEditorForXmlEditor(xmlEditor);
- if (fw) {
- m_editorWidget->setVisibleEditor(xmlEditor);
- } else {
- fw = m_editorWidget->createFormWindowEditor(xmlEditor);
- }
+ QTC_ASSERT(fw, return)
+ m_editorWidget->setVisibleEditor(xmlEditor);
m_fwm->setActiveFormWindow(fw->formWindow());
m_actionGroupEditMode->setVisible(true);
m_modeActionSeparator->setVisible(true);