summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/documentmanager.cpp
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@digia.com>2013-01-23 12:31:22 +0100
committerMarco Bubke <marco.bubke@digia.com>2013-01-23 14:53:28 +0100
commit8d9710c0747a68f9938c8e7d32110f67ba64cc1e (patch)
treefda8332d2625520be7d282dcdbe20f48ad10f3ed /src/plugins/qmldesigner/documentmanager.cpp
parenta4455f37110f09e326b984977baae286082366ad (diff)
downloadqt-creator-8d9710c0747a68f9938c8e7d32110f67ba64cc1e.tar.gz
Refactoring document handling
The document handling in the qml designer was complicated source code, which was initially intended for a non creator application. To integrate new views it has to be changed and cleaned up. This is the first major step in that direction. Change-Id: Ie26f0aad7a03946d18bdb4c0759b246c5439d922 Reviewed-by: Tim Jenssen <tim.jenssen@digia.com> Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
Diffstat (limited to 'src/plugins/qmldesigner/documentmanager.cpp')
-rw-r--r--src/plugins/qmldesigner/documentmanager.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/plugins/qmldesigner/documentmanager.cpp b/src/plugins/qmldesigner/documentmanager.cpp
new file mode 100644
index 0000000000..4a7af81f42
--- /dev/null
+++ b/src/plugins/qmldesigner/documentmanager.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** 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
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "documentmanager.h"
+
+#include <coreplugin/designmode.h>
+#include <coreplugin/modemanager.h>
+#include <qmljseditor/qmljseditorconstants.h>
+
+namespace QmlDesigner {
+
+DocumentManager::DocumentManager()
+ : QObject()
+{
+}
+
+DocumentManager::~DocumentManager()
+{
+ foreach (const QWeakPointer<DesignDocument> &designDocument, m_designDocumentHash)
+ delete designDocument.data();
+}
+
+void DocumentManager::setCurrentDesignDocument(Core::IEditor *editor)
+{
+ if (editor) {
+ m_currentDesignDocument = m_designDocumentHash.value(editor);
+ if (m_currentDesignDocument == 0) {
+ m_currentDesignDocument = new DesignDocument;
+ m_designDocumentHash.insert(editor, m_currentDesignDocument);
+ m_currentDesignDocument->setEditor(editor);
+ }
+ } else {
+ m_currentDesignDocument->resetToDocumentModel();
+ m_currentDesignDocument.clear();
+ }
+}
+
+DesignDocument *DocumentManager::currentDesignDocument() const
+{
+ return m_currentDesignDocument.data();
+}
+
+bool DocumentManager::hasCurrentDesignDocument() const
+{
+ return m_currentDesignDocument.data();
+}
+
+void DocumentManager::removeEditors(QList<Core::IEditor *> editors)
+{
+ foreach (Core::IEditor *editor, editors)
+ delete m_designDocumentHash.take(editor).data();
+}
+
+} // namespace QmlDesigner