texteditoractionhandler.cpp 19 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** 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.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
31
32
33
34
35
#include "texteditoractionhandler.h"
#include "texteditorconstants.h"
#include "basetexteditor.h"
#include "texteditorplugin.h"
#include "linenumberfilter.h"

con's avatar
con committed
36
#include <quickopen/locatormanager.h>
37
#include <coreplugin/icore.h>
con's avatar
con committed
38
39
#include <coreplugin/coreconstants.h>
#include <coreplugin/uniqueidmanager.h>
40
#include <coreplugin/actionmanager/actionmanager.h>
con's avatar
con committed
41
#include <coreplugin/editormanager/editormanager.h>
hjk's avatar
hjk committed
42
#include <utils/qtcassert.h>
con's avatar
con committed
43
44
45
46
47
48
49
50
51

#include <QtCore/QSet>
#include <QtCore/QtDebug>
#include <QtGui/QAction>
#include <QtGui/QTextCursor>

using namespace TextEditor;
using namespace TextEditor::Internal;

52
TextEditorActionHandler::TextEditorActionHandler(const QString &context,
53
                                                 uint optionalActions)
54
  : QObject(Core::ICore::instance()),
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
    m_undoAction(0),
    m_redoAction(0),
    m_copyAction(0),
    m_cutAction(0),
    m_pasteAction(0),
    m_selectAllAction(0),
    m_gotoAction(0),
    m_printAction(0),
    m_formatAction(0),
    m_visualizeWhitespaceAction(0),
    m_cleanWhitespaceAction(0),
    m_textWrappingAction(0),
    m_unCommentSelectionAction(0),
    m_unCollapseAllAction(0),
    m_collapseAction(0),
    m_expandAction(0),
    m_cutLineAction(0),
    m_deleteLineAction(0),
    m_selectEncodingAction(0),
    m_increaseFontSizeAction(0),
    m_decreaseFontSizeAction(0),
    m_gotoBlockStartAction(0),
    m_gotoBlockEndAction(0),
    m_gotoBlockStartWithSelectionAction(0),
    m_gotoBlockEndWithSelectionAction(0),
    m_selectBlockUpAction(0),
    m_selectBlockDownAction(0),
    m_moveLineUpAction(0),
    m_moveLineDownAction(0),
    m_copyLineUpAction(0),
    m_copyLineDownAction(0),
con's avatar
con committed
86
87
88
89
    m_optionalActions(optionalActions),
    m_currentEditor(0),
    m_initialized(false)
{
90
    m_contextId << Core::UniqueIDManager::instance()->uniqueIdentifier(context);
91

92
    connect(Core::ICore::instance()->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
93
        this, SLOT(updateCurrentEditor(Core::IEditor*)));
con's avatar
con committed
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
}

void TextEditorActionHandler::setupActions(BaseTextEditor *editor)
{
    initializeActions();
    editor->setActionHack(this);
    QObject::connect(editor, SIGNAL(undoAvailable(bool)), this, SLOT(updateUndoAction()));
    QObject::connect(editor, SIGNAL(redoAvailable(bool)), this, SLOT(updateRedoAction()));
    QObject::connect(editor, SIGNAL(copyAvailable(bool)), this, SLOT(updateCopyAction()));
}


void TextEditorActionHandler::initializeActions()
{
    if (!m_initialized) {
        createActions();
        m_initialized = true;
    }
}

void TextEditorActionHandler::createActions()
{
    m_undoAction      = registerNewAction(QLatin1String(Core::Constants::UNDO),      this, SLOT(undoAction()),
                                          tr("&Undo"));
    m_redoAction      = registerNewAction(QLatin1String(Core::Constants::REDO),      this, SLOT(redoAction()),
                                          tr("&Redo"));
    m_copyAction      = registerNewAction(QLatin1String(Core::Constants::COPY),      this, SLOT(copyAction()));
    m_cutAction       = registerNewAction(QLatin1String(Core::Constants::CUT),       this, SLOT(cutAction()));
    m_pasteAction     = registerNewAction(QLatin1String(Core::Constants::PASTE),     this, SLOT(pasteAction()));
    m_selectAllAction = registerNewAction(QLatin1String(Core::Constants::SELECTALL), this, SLOT(selectAllAction()));
    m_gotoAction      = registerNewAction(QLatin1String(Core::Constants::GOTO),      this, SLOT(gotoAction()));
    m_printAction     = registerNewAction(QLatin1String(Core::Constants::PRINT),     this, SLOT(printAction()));

127
    Core::ActionManager *am = Core::ICore::instance()->actionManager();
con's avatar
con committed
128

129
130
    Core::ActionContainer *medit = am->actionContainer(Core::Constants::M_EDIT);
    Core::ActionContainer *advancedMenu = am->actionContainer(Core::Constants::M_EDIT_ADVANCED);
con's avatar
con committed
131
132

    m_selectEncodingAction = new QAction(tr("Select Encoding..."), this);
con's avatar
con committed
133
    Core::Command *command = am->registerAction(m_selectEncodingAction, Constants::SELECT_ENCODING, m_contextId);
con's avatar
con committed
134
135
136
137
138
139
140
    connect(m_selectEncodingAction, SIGNAL(triggered()), this, SLOT(selectEncoding()));
    medit->addAction(command, Core::Constants::G_EDIT_OTHER);


    m_formatAction = new QAction(tr("Auto-&indent Selection"), this);
    command = am->registerAction(m_formatAction, TextEditor::Constants::AUTO_INDENT_SELECTION, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+I")));
141
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
con's avatar
con committed
142
143
    connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction()));

con's avatar
con committed
144
145
146
147
148
149
#ifdef Q_WS_MAC
    QString modifier = tr("Meta");
#else
    QString modifier = tr("Ctrl");
#endif

150
151
    m_rewrapParagraphAction = new QAction(tr("&Rewrap Paragraph"), this);
    command = am->registerAction(m_rewrapParagraphAction, TextEditor::Constants::REWRAP_PARAGRAPH, m_contextId);
con's avatar
con committed
152
    command->setDefaultKeySequence(QKeySequence(tr("%1+E, R").arg(modifier)));
153
154
155
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
    connect(m_rewrapParagraphAction, SIGNAL(triggered(bool)), this, SLOT(rewrapParagraphAction()));

con's avatar
con committed
156

157
    m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this);
con's avatar
con committed
158
159
    m_visualizeWhitespaceAction->setCheckable(true);
    command = am->registerAction(m_visualizeWhitespaceAction,
160
                                 TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId);
con's avatar
con committed
161
    command->setDefaultKeySequence(QKeySequence(tr("%1+E, %2+V").arg(modifier, modifier)));
162
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
con's avatar
con committed
163
164
    connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool)));

165
166
167
168
    m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this);
    command = am->registerAction(m_cleanWhitespaceAction,
                                 TextEditor::Constants::CLEAN_WHITESPACE, m_contextId);

169
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
170
171
    connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace()));

con's avatar
con committed
172
173
    m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this);
    m_textWrappingAction->setCheckable(true);
174
    command = am->registerAction(m_textWrappingAction, TextEditor::Constants::TEXT_WRAPPING, m_contextId);
con's avatar
con committed
175
    command->setDefaultKeySequence(QKeySequence(tr("%1+E, %2+W").arg(modifier, modifier)));
176
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
con's avatar
con committed
177
178
179
180
181
182
183
    connect(m_textWrappingAction, SIGNAL(triggered(bool)), this, SLOT(setTextWrapping(bool)));


    m_unCommentSelectionAction = new QAction(tr("(Un)Comment &Selection"), this);
    command = am->registerAction(m_unCommentSelectionAction, Constants::UN_COMMENT_SELECTION, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+/")));
    connect(m_unCommentSelectionAction, SIGNAL(triggered()), this, SLOT(unCommentSelection()));
184
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
con's avatar
con committed
185

186
187
188
189
190
    m_cutLineAction = new QAction(tr("Cut &Line"), this);
    command = am->registerAction(m_cutLineAction, Constants::CUT_LINE, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Shift+Del")));
    connect(m_cutLineAction, SIGNAL(triggered()), this, SLOT(cutLine()));

con's avatar
con committed
191
192
193
194
195
196
197
198
    m_deleteLineAction = new QAction(tr("Delete &Line"), this);
    command = am->registerAction(m_deleteLineAction, Constants::DELETE_LINE, m_contextId);
    connect(m_deleteLineAction, SIGNAL(triggered()), this, SLOT(deleteLine()));

    m_collapseAction = new QAction(tr("Collapse"), this);
    command = am->registerAction(m_collapseAction, Constants::COLLAPSE, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+<")));
    connect(m_collapseAction, SIGNAL(triggered()), this, SLOT(collapse()));
199
    advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
con's avatar
con committed
200
201
202
203
204

    m_expandAction = new QAction(tr("Expand"), this);
    command = am->registerAction(m_expandAction, Constants::EXPAND, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+>")));
    connect(m_expandAction, SIGNAL(triggered()), this, SLOT(expand()));
205
    advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
con's avatar
con committed
206
207
208
209

    m_unCollapseAllAction = new QAction(tr("(Un)&Collapse All"), this);
    command = am->registerAction(m_unCollapseAllAction, Constants::UN_COLLAPSE_ALL, m_contextId);
    connect(m_unCollapseAllAction, SIGNAL(triggered()), this, SLOT(unCollapseAll()));
210
    advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
con's avatar
con committed
211
212
213
214
215

    m_increaseFontSizeAction = new QAction(tr("Increase Font Size"), this);
    command = am->registerAction(m_increaseFontSizeAction, Constants::INCREASE_FONT_SIZE, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl++")));
    connect(m_increaseFontSizeAction, SIGNAL(triggered()), this, SLOT(increaseFontSize()));
216
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT);
217

con's avatar
con committed
218
219
220
221
    m_decreaseFontSizeAction = new QAction(tr("Decrease Font Size"), this);
    command = am->registerAction(m_decreaseFontSizeAction, Constants::DECREASE_FONT_SIZE, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+-")));
    connect(m_decreaseFontSizeAction, SIGNAL(triggered()), this, SLOT(decreaseFontSize()));
222
    advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT);
223
224
225
226
227

    m_gotoBlockStartAction = new QAction(tr("Goto Block Start"), this);
    command = am->registerAction(m_gotoBlockStartAction, Constants::GOTO_BLOCK_START, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+[")));
    connect(m_gotoBlockStartAction, SIGNAL(triggered()), this, SLOT(gotoBlockStart()));
mae's avatar
mae committed
228
    advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
229
230
231
232
233

    m_gotoBlockEndAction = new QAction(tr("Goto Block End"), this);
    command = am->registerAction(m_gotoBlockEndAction, Constants::GOTO_BLOCK_END, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+]")));
    connect(m_gotoBlockEndAction, SIGNAL(triggered()), this, SLOT(gotoBlockEnd()));
mae's avatar
mae committed
234
    advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
235
236
237
238
239
240
241
242
243
244
245

    m_gotoBlockStartWithSelectionAction = new QAction(tr("Goto Block Start With Selection"), this);
    command = am->registerAction(m_gotoBlockStartWithSelectionAction, Constants::GOTO_BLOCK_START_WITH_SELECTION, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+{")));
    connect(m_gotoBlockStartWithSelectionAction, SIGNAL(triggered()), this, SLOT(gotoBlockStartWithSelection()));

    m_gotoBlockEndWithSelectionAction = new QAction(tr("Goto Block End With Selection"), this);
    command = am->registerAction(m_gotoBlockEndWithSelectionAction, Constants::GOTO_BLOCK_END_WITH_SELECTION, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+}")));
    connect(m_gotoBlockEndWithSelectionAction, SIGNAL(triggered()), this, SLOT(gotoBlockEndWithSelection()));

246
247
248
249
    m_selectBlockUpAction= new QAction(tr("Select Block Up"), this);
    command = am->registerAction(m_selectBlockUpAction, Constants::SELECT_BLOCK_UP, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+U")));
    connect(m_selectBlockUpAction, SIGNAL(triggered()), this, SLOT(selectBlockUp()));
mae's avatar
mae committed
250
    advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
251
252
253
254

    m_selectBlockDownAction= new QAction(tr("Select Block Down"), this);
    command = am->registerAction(m_selectBlockDownAction, Constants::SELECT_BLOCK_DOWN, m_contextId);
    connect(m_selectBlockDownAction, SIGNAL(triggered()), this, SLOT(selectBlockDown()));
mae's avatar
mae committed
255
    advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
256
257
258
259
260
261
262
263
264
265

    m_moveLineUpAction= new QAction(tr("Move Line Up"), this);
    command = am->registerAction(m_moveLineUpAction, Constants::MOVE_LINE_UP, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Up")));
    connect(m_moveLineUpAction, SIGNAL(triggered()), this, SLOT(moveLineUp()));

    m_moveLineDownAction= new QAction(tr("Move Line Down"), this);
    command = am->registerAction(m_moveLineDownAction, Constants::MOVE_LINE_DOWN, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Down")));
    connect(m_moveLineDownAction, SIGNAL(triggered()), this, SLOT(moveLineDown()));
266
267
268
269
270
271
272
273
274
275

    m_copyLineUpAction= new QAction(tr("Copy Line Up"), this);
    command = am->registerAction(m_copyLineUpAction, Constants::COPY_LINE_UP, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Up")));
    connect(m_copyLineUpAction, SIGNAL(triggered()), this, SLOT(copyLineUp()));

    m_copyLineDownAction= new QAction(tr("Copy Line Down"), this);
    command = am->registerAction(m_copyLineDownAction, Constants::COPY_LINE_DOWN, m_contextId);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Down")));
    connect(m_copyLineDownAction, SIGNAL(triggered()), this, SLOT(copyLineDown()));
con's avatar
con committed
276
277
278
279
280
281
282
283
284
285
286
287
288
}

bool TextEditorActionHandler::supportsAction(const QString & /*id */) const
{
    return true;
}

QAction *TextEditorActionHandler::registerNewAction(const QString &id, const QString &title)
{
    if (!supportsAction(id))
        return 0;

    QAction *result = new QAction(title, this);
289
    Core::ICore::instance()->actionManager()->registerAction(result, id, m_contextId);
con's avatar
con committed
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
    return result;
}

QAction *TextEditorActionHandler::registerNewAction(const QString &id,
                                                    QObject *receiver,
                                                    const char *slot,
                                                    const QString &title)
{
    QAction *rc = registerNewAction(id, title);
    if (!rc)
        return 0;

    connect(rc, SIGNAL(triggered()), receiver, slot);
    return rc;
}

TextEditorActionHandler::UpdateMode TextEditorActionHandler::updateMode() const
{
308
    Q_ASSERT(m_currentEditor != 0);
con's avatar
con committed
309
310
311
312
313
    return m_currentEditor->file()->isReadOnly() ? ReadOnlyMode : WriteMode;
}

void TextEditorActionHandler::updateActions()
{
314
315
    if (!m_currentEditor || !m_initialized)
        return;
con's avatar
con committed
316
317
318
319
320
    updateActions(updateMode());
}

void TextEditorActionHandler::updateActions(UpdateMode um)
{
321
322
323
324
325
326
327
328
329
    m_pasteAction->setEnabled(um != ReadOnlyMode);
    m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode);
    m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode);
    m_moveLineUpAction->setEnabled(um != ReadOnlyMode);
    m_moveLineDownAction->setEnabled(um != ReadOnlyMode);

    m_formatAction->setEnabled((m_optionalActions & Format));
    m_unCollapseAllAction->setEnabled((m_optionalActions & UnCollapseAll));
    m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
con's avatar
con committed
330
    if (m_textWrappingAction) {
331
        m_textWrappingAction->setChecked(m_currentEditor->displaySettings().m_textWrapping);
con's avatar
con committed
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
    }

    updateRedoAction();
    updateUndoAction();
    updateCopyAction();
}

void TextEditorActionHandler::updateRedoAction()
{
    if (m_redoAction)
        m_redoAction->setEnabled(m_currentEditor && m_currentEditor->document()->isRedoAvailable());
}

void TextEditorActionHandler::updateUndoAction()
{
    if (m_undoAction)
        m_undoAction->setEnabled(m_currentEditor && m_currentEditor->document()->isUndoAvailable());
}

void TextEditorActionHandler::updateCopyAction()
{
353
    const bool hasCopyableText = m_currentEditor && m_currentEditor->textCursor().hasSelection();
con's avatar
con committed
354
355
    if (m_cutAction)
        m_cutAction->setEnabled(hasCopyableText && updateMode() == WriteMode);
356
    if (m_copyAction) {
con's avatar
con committed
357
        m_copyAction->setEnabled(hasCopyableText);
358
    }
con's avatar
con committed
359
360
361
362
}

void TextEditorActionHandler::gotoAction()
{
con's avatar
con committed
363
    QuickOpen::LocatorManager *quickopen = QuickOpen::LocatorManager::instance();
hjk's avatar
hjk committed
364
    QTC_ASSERT(quickopen, return);
365
366
367
    const QString shortcut = TextEditorPlugin::instance()->lineNumberFilter()->shortcutString();
    const QString text = tr(" <line number>");
    quickopen->show(shortcut + text, 2, text.length()-1);
con's avatar
con committed
368
369
370
371
372
}

void TextEditorActionHandler::printAction()
{
    if (m_currentEditor)
373
        m_currentEditor->print(Core::ICore::instance()->printer());
con's avatar
con committed
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
}

void TextEditorActionHandler::setVisualizeWhitespace(bool checked)
{
    if (m_currentEditor) {
        DisplaySettings ds = m_currentEditor->displaySettings();
        ds.m_visualizeWhitespace = checked;
        m_currentEditor->setDisplaySettings(ds);
    }
}

void TextEditorActionHandler::setTextWrapping(bool checked)
{
    if (m_currentEditor) {
        DisplaySettings ds = m_currentEditor->displaySettings();
        ds.m_textWrapping = checked;
        m_currentEditor->setDisplaySettings(ds);
    }
}

394
395
396
397
398
399
400
401
402
403
404
#define FUNCTION(funcname) void TextEditorActionHandler::funcname ()\
{\
    if (m_currentEditor)\
        m_currentEditor->funcname ();\
}
#define FUNCTION2(funcname, funcname2) void TextEditorActionHandler::funcname ()\
{\
    if (m_currentEditor)\
        m_currentEditor->funcname2 ();\
}

405
406
407
408
409
410
411

FUNCTION2(undoAction, undo)
FUNCTION2(redoAction, redo)
FUNCTION2(copyAction, copy)
FUNCTION2(cutAction, cut)
FUNCTION2(pasteAction, paste)
FUNCTION2(formatAction, format)
412
FUNCTION2(rewrapParagraphAction, rewrapParagraph)
413
414
FUNCTION2(selectAllAction, selectAll)
FUNCTION(cleanWhitespace)
415
FUNCTION(unCommentSelection)
416
FUNCTION(cutLine)
417
418
419
420
421
422
423
424
425
426
427
FUNCTION(deleteLine)
FUNCTION(unCollapseAll)
FUNCTION(collapse)
FUNCTION(expand)
FUNCTION2(increaseFontSize, zoomIn)
FUNCTION2(decreaseFontSize, zoomOut)
FUNCTION(selectEncoding)
FUNCTION(gotoBlockStart)
FUNCTION(gotoBlockEnd)
FUNCTION(gotoBlockStartWithSelection)
FUNCTION(gotoBlockEndWithSelection)
428
429
FUNCTION(selectBlockUp)
FUNCTION(selectBlockDown)
430
431
FUNCTION(moveLineUp)
FUNCTION(moveLineDown)
432
433
FUNCTION(copyLineUp)
FUNCTION(copyLineDown)
con's avatar
con committed
434

435
void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor)
con's avatar
con committed
436
{
437
438
439
440
441
442
443
444
445
446
447
    m_currentEditor = 0;

    if (!editor)
        return;

    BaseTextEditor *baseEditor = qobject_cast<BaseTextEditor *>(editor->widget());

    if (baseEditor && baseEditor->actionHack() == this) {
        m_currentEditor = baseEditor;
        updateActions();
    }
con's avatar
con committed
448
449
450
451
452
453
}

const QPointer<BaseTextEditor> &TextEditorActionHandler::currentEditor() const
{
    return m_currentEditor;
}