2010-07-20 12:54:15 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
#ifndef SCRIPTBINDINGREWRITER_H
|
|
|
|
|
#define SCRIPTBINDINGREWRITER_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QWeakPointer>
|
|
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
class QmlJSTextEditor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace QmlJSInspector {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class QmlJSLiveTextPreview : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2010-07-09 17:02:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
public:
|
2010-07-20 12:35:36 +02:00
|
|
|
explicit QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc, const QmlJS::Document::Ptr &initDoc, QObject *parent = 0);
|
2010-07-08 11:34:51 +02:00
|
|
|
static QmlJS::ModelManagerInterface *modelManager();
|
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
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
void updateDebugIds(const QDeclarativeDebugObjectReference &rootReference);
|
|
|
|
|
|
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-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-07-30 15:28:05 +02:00
|
|
|
void showSyncWarning(unsigned line, unsigned column);
|
|
|
|
|
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
|
|
|
|
2010-07-16 15:59:08 +02:00
|
|
|
QList<QWeakPointer<QmlJSEditor::Internal::QmlJSTextEditor> > 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-07-08 11:34:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlJSInspector
|
|
|
|
|
|
|
|
|
|
#endif // SCRIPTBINDINGREWRITER_H
|