diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index 711f8297e49..daf1faeebe7 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -56,7 +56,6 @@ SOURCES += mainwindow.cpp \ progressmanager/progressbar.cpp \ progressmanager/futureprogress.cpp \ scriptmanager/scriptmanager.cpp \ - scriptmanager/qworkbench_wrapper.cpp \ basemode.cpp \ statusbarwidget.cpp \ coreplugin.cpp \ @@ -165,7 +164,6 @@ HEADERS += mainwindow.h \ icorelistener.h \ versiondialog.h \ scriptmanager/metatypedeclarations.h \ - scriptmanager/qworkbench_wrapper.h \ scriptmanager/scriptmanager.h \ scriptmanager/scriptmanager_p.h \ core_global.h \ diff --git a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp b/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp deleted file mode 100644 index 5cd5f936cb6..00000000000 --- a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/************************************************************************** -** -** 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. -** -**************************************************************************/ - -#include "qworkbench_wrapper.h" - -#include - -#include - -#include - -#include -#include - -#include - -#include - -namespace { - enum { debugQWorkbenchWrappers = 0 }; -} - -namespace Core { -namespace Internal { - -// -- CorePrototype -CorePrototype::CorePrototype(QObject *parent) : - QObject(parent) -{ -} - -Core::MessageManager *CorePrototype::messageManager() const -{ - return callee()->messageManager(); -} - -Core::FileManager *CorePrototype::fileManager() const -{ - return callee()->fileManager(); -} - -Core::EditorManager *CorePrototype::editorManager() const -{ - return callee()->editorManager(); -} - -QMainWindow *CorePrototype::mainWindow() const -{ - return callee()->mainWindow(); -} - -QSettings *CorePrototype::settings() const -{ - return callee()->settings(); -} - -void CorePrototype::updateAdditionalContexts(const Context &remove, const Context &add) -{ - callee()->updateAdditionalContexts(remove, add); -} - -QString CorePrototype::toString() const -{ - return QLatin1String("Core"); -} - -CorePrototype::ICore *CorePrototype::callee() const -{ - ICore *rc = qscriptvalue_cast(thisObject()); - QTC_ASSERT(rc, return 0); - return rc; -} - -// -- MessageManager - -MessageManagerPrototype::MessageManagerPrototype(QObject *parent) : - QObject(parent) -{ -} - -void MessageManagerPrototype::printToOutputPane(const QString &text, bool bringToForeground) -{ - MessageManager *mm = qscriptvalue_cast(thisObject()); - QTC_ASSERT(mm, return); - mm->printToOutputPane(text, bringToForeground); -} - -void MessageManagerPrototype::printToOutputPanePopup(const QString &text) -{ - MessageManager *mm = qscriptvalue_cast(thisObject()); - QTC_ASSERT(mm, return); - mm->printToOutputPanePopup(text); -} - -void MessageManagerPrototype::printToOutputPane(const QString &text) -{ - MessageManager *mm = qscriptvalue_cast(thisObject()); - QTC_ASSERT(mm, return); - mm->printToOutputPane(text); -} - -QString MessageManagerPrototype::toString() const -{ - return QLatin1String("MessageManager"); -} - -// -- FileManagerPrototype - -FileManagerPrototype::FileManagerPrototype(QObject *parent) : - QObject(parent) -{ -} - -FileManager *FileManagerPrototype::callee() const -{ - FileManager *rc = qscriptvalue_cast(thisObject()); - QTC_ASSERT(rc, return 0); - return rc; -} - -void FileManagerPrototype::addFiles(const QList &files) -{ - callee()->addFiles(files); -} - -void FileManagerPrototype::addFile(Core::IFile *file) -{ - callee()->addFile(file); -} - -void FileManagerPrototype::removeFile(Core::IFile *file) -{ - callee()->removeFile(file); -} - -QList -FileManagerPrototype::saveModifiedFilesSilently(const QList &files) -{ - return callee()->saveModifiedFilesSilently(files); -} - -QString FileManagerPrototype::getSaveAsFileName(Core::IFile *file) -{ - return callee()->getSaveAsFileName(file); -} - -void FileManagerPrototype::blockFileChange(Core::IFile *file) -{ - callee()->blockFileChange(file); -} - -void FileManagerPrototype::unblockFileChange(Core::IFile *file) -{ - return callee()->unblockFileChange(file); -} - -void FileManagerPrototype::addToRecentFiles(const QString &fileName) -{ - return callee()->addToRecentFiles(fileName); -} - -QStringList FileManagerPrototype::recentFiles() const -{ - return callee()->recentFiles(); -} - -QString FileManagerPrototype::toString() const -{ - return QLatin1String("FileManager"); -} - -// ------- FilePrototype - -FilePrototype::FilePrototype(QObject *parent) : - QObject(parent) -{ -} - -IFile *FilePrototype::callee() const -{ - IFile *rc = qscriptvalue_cast(thisObject()); - QTC_ASSERT(rc, return 0); - return rc; -} - -QString FilePrototype::fileName () const { return callee()->fileName(); } -QString FilePrototype::defaultPath () const { return callee()->defaultPath(); } -QString FilePrototype::suggestedFileName () const { return callee()->suggestedFileName(); } - -bool FilePrototype::isModified () const { return callee()->isModified(); } -bool FilePrototype::isReadOnly () const { return callee()->isReadOnly(); } -bool FilePrototype::isSaveAsAllowed () const { return callee()->isSaveAsAllowed(); } - -QString FilePrototype::toString() const -{ - QString rc = QLatin1String("File("); - rc += fileName(); - rc += QLatin1Char(')'); - return rc; -} - -// ------------- EditorManagerPrototype - -EditorManagerPrototype::EditorManagerPrototype(QObject *parent) : - QObject(parent) -{ -} - -Core::IEditor *EditorManagerPrototype::currentEditor() const -{ - return callee()->currentEditor(); -} - -void EditorManagerPrototype::activateEditor(Core::IEditor *editor) -{ - callee()->activateEditor(editor); -} - -QList EditorManagerPrototype::openedEditors() const -{ - return callee()->openedEditors(); -} - -QList EditorManagerPrototype::editorsForFiles(QList files) const -{ - return callee()->editorsForFiles(files); -} - -bool EditorManagerPrototype::closeEditors(const QList editorsToClose, bool askAboutModifiedEditors) -{ - return callee()->closeEditors(editorsToClose, askAboutModifiedEditors); -} - -Core::IEditor *EditorManagerPrototype::openEditor(const QString &fileName, const QString &editorId) -{ - return callee()->openEditor(fileName, editorId); -} - -Core::IEditor *EditorManagerPrototype::newFile(const QString &editorId, QString titlePattern, const QString &contents) -{ - return callee()->openEditorWithContents(editorId, &titlePattern, contents); -} - -int EditorManagerPrototype::makeEditorWritable(Core::IEditor *editor) -{ - return callee()->makeEditorWritable(editor); -} - -QString EditorManagerPrototype::toString() const -{ - return QLatin1String("EditorManager"); -} - -EditorManagerPrototype::EditorManager *EditorManagerPrototype::callee() const -{ - EditorManager *rc = qscriptvalue_cast(thisObject()); - QTC_ASSERT(rc, return 0); - return rc; -} - -// ------------- EditorPrototype - -EditorPrototype::EditorPrototype(QObject *parent) - : QObject(parent) -{ -} - -QString EditorPrototype::displayName() const -{ - return callee()->displayName(); -} - -void EditorPrototype::setDisplayName(const QString &title) -{ - callee()->setDisplayName(title); -} - -QString EditorPrototype::id() const -{ - return callee()->id(); -} - -bool EditorPrototype::duplicateSupported() const -{ - return callee()->duplicateSupported(); -} - -bool EditorPrototype::createNew(const QString &contents) -{ - return callee()->createNew(contents); -} - -bool EditorPrototype::open(const QString &fileName) -{ - return callee()->open(fileName); -} - -Core::IEditor *EditorPrototype::duplicate(QWidget *parent) -{ - return callee()->duplicate(parent); -} - -Core::IFile *EditorPrototype::file() const -{ - return callee()->file(); -} - -QWidget* EditorPrototype::toolBar() const -{ - return callee()->toolBar(); -} - -Core::IEditor *EditorPrototype::callee() const -{ - IEditor *rc = qscriptvalue_cast(thisObject()); - QTC_ASSERT(rc, return 0); - return rc; -} - -QString EditorPrototype::toString() const -{ - QString rc = QLatin1String("Editor("); - rc += displayName(); - rc += QLatin1Char(')'); - return rc; -} - - -} // namespace Internal -} // namespace Core diff --git a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.h b/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.h deleted file mode 100644 index 37f92e09ba0..00000000000 --- a/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.h +++ /dev/null @@ -1,226 +0,0 @@ -/************************************************************************** -** -** 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. -** -**************************************************************************/ - -#ifndef QWORKBENCH_WRAPPER_H -#define QWORKBENCH_WRAPPER_H - -#include "metatypedeclarations.h" // required for property declarations - -#include -#include -#include -#include - -namespace Core { -namespace Internal { - -// Script prototype for the core interface. - -class CorePrototype : public QObject, public QScriptable -{ - Q_OBJECT - - Q_PROPERTY(Core::MessageManager *messageManager READ messageManager DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(Core::FileManager *fileManager READ fileManager DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(Core::EditorManager *editorManager READ editorManager DESIGNABLE false SCRIPTABLE true STORED false) - - Q_PROPERTY(QMainWindow *mainWindow READ mainWindow DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(QSettings *settings READ settings DESIGNABLE false SCRIPTABLE true STORED false) - -public: - typedef Core::ICore ICore; - - CorePrototype(QObject *parent); - - Core::MessageManager *messageManager() const; - Core::FileManager *fileManager() const; - Core::EditorManager *editorManager() const; - - QMainWindow *mainWindow() const; - QSettings *settings() const; - -public slots: - void updateAdditionalContexts(const Context &remove, const Context &add); - QString toString() const; - -private: - ICore *callee() const; -}; - -// Script prototype for the message manager. - -class MessageManagerPrototype : public QObject, public QScriptable -{ - Q_OBJECT - -public: - typedef Core::MessageManager MessageManager; - - MessageManagerPrototype(QObject *parent = 0); - -public slots: - void printToOutputPane(const QString &text, bool bringToForeground); - void printToOutputPanePopup(const QString &text); // pops up - void printToOutputPane(const QString &text); - - QString toString() const; -}; - -// Script prototype for the file manager interface. - -class FileManagerPrototype : public QObject, public QScriptable -{ - Q_OBJECT - - Q_PROPERTY(QStringList recentFiles READ recentFiles DESIGNABLE false SCRIPTABLE true STORED false) - -public: - typedef Core::FileManager FileManager; - - FileManagerPrototype(QObject *parent = 0); - QStringList recentFiles() const; - -public slots: - void addFiles(const QList &files); - void addFile(Core::IFile *file); - void removeFile(Core::IFile *file); - - QList saveModifiedFilesSilently(const QList &files); - QString getSaveAsFileName(Core::IFile *file); - - void blockFileChange(Core::IFile *file); - void unblockFileChange(Core::IFile *file); - - void addToRecentFiles(const QString &fileName); - QString toString() const; - -private: - FileManager *callee() const; -}; - -// Script prototype for the file interface. - -class FilePrototype : public QObject, public QScriptable -{ - Q_OBJECT - - Q_PROPERTY(QString fileName READ fileName DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(QString defaultPath READ defaultPath DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(QString suggestedFileName READ suggestedFileName DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(bool isModified READ isModified DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(bool isReadOnly READ isReadOnly DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(bool isSaveAsAllowed READ isSaveAsAllowed DESIGNABLE false SCRIPTABLE true STORED false) -public: - typedef Core::IFile IFile; - - FilePrototype(QObject *parent = 0); - - QString fileName() const; - QString defaultPath() const; - QString suggestedFileName() const; - - bool isModified() const; - bool isReadOnly() const; - bool isSaveAsAllowed() const; - -public slots: - QString toString() const; - -private: - IFile *callee() const; -}; - -// Script prototype for the editor manager interface. - -class EditorManagerPrototype : public QObject, public QScriptable -{ - Q_OBJECT - Q_PROPERTY(Core::IEditor* currentEditor READ currentEditor WRITE activateEditor DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(QList openedEditors READ openedEditors DESIGNABLE false SCRIPTABLE true STORED false) -public: - typedef Core::EditorManager EditorManager; - - EditorManagerPrototype(QObject *parent = 0); - - Core::IEditor *currentEditor() const; - void activateEditor(Core::IEditor *editor); - QList openedEditors() const; - QList editorHistory() const; - -public slots: - QList editorsForFiles(QList files) const; - bool closeEditors(const QList editorsToClose, bool askAboutModifiedEditors); - Core::IEditor *openEditor(const QString &fileName, const QString &editorId); - Core::IEditor *newFile(const QString &editorId, QString titlePattern, const QString &contents); - int makeEditorWritable(Core::IEditor *editor); - - QString toString() const; - -private: - EditorManager *callee() const; -}; - -// Script prototype for the editor interface. - -class EditorPrototype : public QObject, public QScriptable -{ - Q_OBJECT - Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(QString id READ id DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(bool duplicateSupported READ duplicateSupported DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(Core::IFile* file READ file DESIGNABLE false SCRIPTABLE true STORED false) - Q_PROPERTY(QWidget* toolBar READ toolBar DESIGNABLE false SCRIPTABLE true STORED false) - -public: - EditorPrototype(QObject *parent = 0); - - QString displayName() const; - void setDisplayName(const QString &title); - - QString id() const; - bool duplicateSupported() const; - - Core::IFile *file() const; - QWidget* toolBar() const; - -public slots: - bool createNew(const QString &contents); - bool open(const QString &fileName); - Core::IEditor *duplicate(QWidget *parent); - - QString toString() const; - -private: - Core::IEditor *callee() const; -}; - -} // namespace Internal -} // namespace Core - -#endif // QWORKBENCH_WRAPPER_H diff --git a/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp b/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp index ce3d887d8a3..9622c75f758 100644 --- a/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp +++ b/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp @@ -28,7 +28,6 @@ **************************************************************************/ #include "scriptmanager_p.h" -#include "qworkbench_wrapper.h" #include "metatypedeclarations.h" #include @@ -240,26 +239,11 @@ ScriptManager::QScriptEnginePtr ScriptManagerPrivate::ensureEngineInitialized() SharedTools::registerQObject(m_engine.data()); SharedTools::registerQObject(m_engine.data()); SharedTools::registerQObject(m_engine.data()); - // WB interfaces - SharedTools::registerQObjectInterface(m_engine.data()); -// SharedTools::registerQObjectInterface(m_engine); -// qScriptRegisterSequenceMetaType >(m_engine); -// SharedTools::registerQObjectInterface(m_engine); - -// SharedTools::registerQObjectInterface(m_engine); qScriptRegisterSequenceMetaType >(m_engine.data()); -// SharedTools::registerQObjectInterface(m_engine); qScriptRegisterSequenceMetaType >(m_engine.data()); - SharedTools::registerQObjectInterface(m_engine.data()); - -// SharedTools::registerQObjectInterface(m_engine); - - // Make "core" available - m_engine->globalObject().setProperty(QLatin1String("core"), qScriptValueFromValue(m_engine.data(), Core::ICore::instance())); - // CLASSIC: registerInterfaceWithDefaultPrototype(m_engine); // Message box conveniences