summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin/scriptmanager/qworkbench_wrapper.cpp
blob: 1d22dcf2c6588de4fad20db6256e2655d5dee843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** 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, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/

#include "qworkbench_wrapper.h"

#include <wrap_helpers.h>

#include <coreplugin/messagemanager.h>

#include <utils/qtcassert.h>

#include <QtCore/QDebug>
#include <QtCore/QSettings>

#include <QtGui/QMainWindow>

#include <QtScript/QScriptEngine>

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<ICore *>(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<MessageManager *>(thisObject());
    QTC_ASSERT(mm, return);
    mm->printToOutputPane(text, bringToForeground);
}

void MessageManagerPrototype::printToOutputPanePopup(const QString &text)
{
    MessageManager *mm = qscriptvalue_cast<MessageManager *>(thisObject());
    QTC_ASSERT(mm, return);
    mm->printToOutputPanePopup(text);
}

void MessageManagerPrototype::printToOutputPane(const QString &text)
{
    MessageManager *mm = qscriptvalue_cast<MessageManager *>(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<FileManager *>(thisObject());
    QTC_ASSERT(rc, return 0);
    return rc;
}

bool FileManagerPrototype::addFiles(const QList<Core::IFile *> &files)
{
    return callee()->addFiles(files);
}

bool FileManagerPrototype::addFile(Core::IFile *file)
{
    return callee()->addFile(file);
}

bool FileManagerPrototype::removeFile(Core::IFile *file)
{
    return callee()->removeFile(file);
}

QList<Core::IFile*>
FileManagerPrototype::saveModifiedFilesSilently(const QList<Core::IFile*> &files)
{
    return callee()->saveModifiedFilesSilently(files);
}

QString FileManagerPrototype::getSaveAsFileName(Core::IFile *file)
{
    return callee()->getSaveAsFileName(file);
}

bool FileManagerPrototype::isFileManaged(const QString &fileName) const
{
    return callee()->isFileManaged(fileName);
}

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<IFile *>(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<Core::IEditor*> EditorManagerPrototype::openedEditors() const
{
    return callee()->openedEditors();
}

QList<Core::IEditor*> EditorManagerPrototype::editorsForFiles(QList<Core::IFile*> files) const
{
    return callee()->editorsForFiles(files);
}

bool EditorManagerPrototype::closeEditors(const QList<Core::IEditor*> 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<EditorManager *>(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<IEditor *>(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