2010-07-20 12:54:15 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-07-20 12:54:15 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2010-07-20 12:54:15 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-07-20 12:54:15 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-07-20 12:54:15 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
#ifndef SCRIPTBINDINGREWRITER_H
|
|
|
|
|
#define SCRIPTBINDINGREWRITER_H
|
|
|
|
|
|
2011-01-24 12:29:48 +01:00
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
#include <QtCore/QWeakPointer>
|
2010-07-08 11:34:51 +02:00
|
|
|
|
|
|
|
|
#include <qmljs/parser/qmljsastfwd_p.h>
|
|
|
|
|
#include <qmljs/qmljsdocument.h>
|
2010-07-29 14:15:12 +02:00
|
|
|
#include "qmljsprivateapi.h"
|
2010-07-08 11:34:51 +02:00
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QTextDocument)
|
|
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
class IEditor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace QmlJS {
|
|
|
|
|
class ModelManagerInterface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace QmlJSEditor {
|
2011-02-21 16:02:26 +01:00
|
|
|
class QmlJSTextEditorWidget;
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace QmlJSInspector {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
class ClientProxy;
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
class QmlJSLiveTextPreview : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2010-07-09 17:02:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
public:
|
2010-08-13 14:18:10 +02:00
|
|
|
explicit QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc,
|
|
|
|
|
const QmlJS::Document::Ptr &initDoc,
|
|
|
|
|
ClientProxy *clientProxy,
|
|
|
|
|
QObject *parent = 0);
|
2010-07-16 15:59:08 +02:00
|
|
|
//void updateDocuments();
|
2010-07-08 11:34:51 +02:00
|
|
|
|
2010-07-16 15:59:08 +02:00
|
|
|
void associateEditor(Core::IEditor *editor);
|
|
|
|
|
void unassociateEditor(Core::IEditor *editor);
|
2010-07-08 11:34:51 +02:00
|
|
|
void setActiveObject(const QDeclarativeDebugObjectReference &object);
|
|
|
|
|
void mapObjectToQml(const QDeclarativeDebugObjectReference &object);
|
2010-07-20 12:35:36 +02:00
|
|
|
void resetInitialDoc(const QmlJS::Document::Ptr &doc);
|
2010-07-08 11:34:51 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void setClientProxy(ClientProxy *clientProxy);
|
|
|
|
|
|
2010-08-05 16:22:30 +02:00
|
|
|
enum UnsyncronizableChangeType {
|
|
|
|
|
NoUnsyncronizableChanges,
|
|
|
|
|
AttributeChangeWarning,
|
|
|
|
|
ElementChangeWarning
|
|
|
|
|
};
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
signals:
|
|
|
|
|
void selectedItemsChanged(const QList<QDeclarativeDebugObjectReference> &objects);
|
2010-07-30 15:28:05 +02:00
|
|
|
void reloadQmlViewerRequested();
|
|
|
|
|
void disableLivePreviewRequested();
|
2010-07-08 11:34:51 +02:00
|
|
|
|
2010-07-26 11:59:59 +02:00
|
|
|
public slots:
|
|
|
|
|
void setApplyChangesToQmlObserver(bool applyChanges);
|
2010-08-20 15:12:29 +02:00
|
|
|
void updateDebugIds();
|
2010-07-26 11:59:59 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
private slots:
|
2010-07-12 17:18:05 +02:00
|
|
|
void changeSelectedElements(QList<int> offsets, const QString &wordAtCursor);
|
2010-07-08 11:34:51 +02:00
|
|
|
void documentChanged(QmlJS::Document::Ptr doc);
|
2010-07-30 15:28:05 +02:00
|
|
|
void disableLivePreview();
|
|
|
|
|
void reloadQmlViewer();
|
2010-07-08 11:34:51 +02:00
|
|
|
|
|
|
|
|
private:
|
2010-08-05 16:22:30 +02:00
|
|
|
static QmlJS::ModelManagerInterface *modelManager();
|
2010-07-21 14:26:25 +02:00
|
|
|
QList<int> objectReferencesForOffset(quint32 offset) const;
|
2010-07-08 11:34:51 +02:00
|
|
|
QVariant castToLiteral(const QString &expression, QmlJS::AST::UiScriptBinding *scriptBinding);
|
2010-08-05 16:22:30 +02:00
|
|
|
void showSyncWarning(UnsyncronizableChangeType unsyncronizableChangeType, const QString &elementName,
|
|
|
|
|
unsigned line, unsigned column);
|
2010-07-30 15:28:05 +02:00
|
|
|
void showExperimentalWarning();
|
2010-07-08 11:34:51 +02:00
|
|
|
|
|
|
|
|
private:
|
2010-07-21 14:26:25 +02:00
|
|
|
QHash<QmlJS::AST::UiObjectMember*, QList<int> > m_debugIds;
|
2010-07-19 15:10:36 +02:00
|
|
|
QHash<QmlJS::Document::Ptr, QSet<QmlJS::AST::UiObjectMember *> > m_createdObjects;
|
2010-07-16 15:59:08 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
QmlJS::Document::Ptr m_previousDoc;
|
2010-07-16 16:37:40 +02:00
|
|
|
QmlJS::Document::Ptr m_initialDoc; //the document that was loaded by the server
|
2010-07-16 15:59:08 +02:00
|
|
|
QString m_filename;
|
2010-07-08 11:34:51 +02:00
|
|
|
|
2011-02-21 16:02:26 +01:00
|
|
|
QList<QWeakPointer<QmlJSEditor::QmlJSTextEditorWidget> > m_editors;
|
2010-07-08 11:34:51 +02:00
|
|
|
|
2010-07-26 11:59:59 +02:00
|
|
|
bool m_applyChangesToQmlObserver;
|
|
|
|
|
QmlJS::Document::Ptr m_docWithUnappliedChanges;
|
2010-08-13 14:18:10 +02:00
|
|
|
QWeakPointer<ClientProxy> m_clientProxy;
|
2010-07-26 11:59:59 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlJSInspector
|
|
|
|
|
|
|
|
|
|
#endif // SCRIPTBINDINGREWRITER_H
|