2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01: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).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** No Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** 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.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef TEXTEDITORACTIONHANDLER_H
|
|
|
|
|
#define TEXTEDITORACTIONHANDLER_H
|
|
|
|
|
|
|
|
|
|
#include "texteditor_global.h"
|
|
|
|
|
#include "basetexteditor.h"
|
|
|
|
|
|
|
|
|
|
#include "coreplugin/icontext.h"
|
|
|
|
|
|
2009-01-20 15:31:33 +01:00
|
|
|
#include <QtCore/QList>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
#include <QtCore/QPointer>
|
|
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
|
|
|
|
|
class BaseTextEditor;
|
|
|
|
|
|
|
|
|
|
// Redirects slots from global actions to the respective editor.
|
|
|
|
|
|
|
|
|
|
class TEXTEDITOR_EXPORT TextEditorActionHandler : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum OptionalActionsMask {
|
|
|
|
|
None = 0,
|
|
|
|
|
Format = 1,
|
|
|
|
|
UnCommentSelection = 2,
|
2009-09-25 10:47:04 +02:00
|
|
|
UnCollapseAll = 4
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2010-08-26 18:35:30 +02:00
|
|
|
explicit TextEditorActionHandler(const char *context, uint optionalActions = None);
|
2008-12-02 12:01:29 +01:00
|
|
|
void setupActions(BaseTextEditor *editor);
|
|
|
|
|
|
|
|
|
|
void initializeActions();
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void updateActions();
|
|
|
|
|
void updateRedoAction();
|
|
|
|
|
void updateUndoAction();
|
|
|
|
|
void updateCopyAction();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
const QPointer<BaseTextEditor> ¤tEditor() const;
|
2010-12-20 10:35:30 +01:00
|
|
|
QAction *registerNewAction(const QString &id, bool scriptable=false, const QString &title = QString());
|
|
|
|
|
QAction *registerNewAction(const QString &id, QObject *receiver, const char *slot, bool scriptable = false,
|
2008-12-02 12:01:29 +01:00
|
|
|
const QString &title = QString());
|
|
|
|
|
|
2009-02-16 12:50:15 +01:00
|
|
|
enum UpdateMode { ReadOnlyMode, WriteMode };
|
2008-12-02 12:01:29 +01:00
|
|
|
UpdateMode updateMode() const;
|
|
|
|
|
|
|
|
|
|
virtual void createActions();
|
|
|
|
|
virtual bool supportsAction(const QString &id) const;
|
|
|
|
|
virtual void updateActions(UpdateMode um);
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void undoAction();
|
|
|
|
|
void redoAction();
|
|
|
|
|
void copyAction();
|
|
|
|
|
void cutAction();
|
|
|
|
|
void pasteAction();
|
|
|
|
|
void selectAllAction();
|
|
|
|
|
void gotoAction();
|
|
|
|
|
void printAction();
|
|
|
|
|
void formatAction();
|
2009-07-21 10:37:00 +02:00
|
|
|
void rewrapParagraphAction();
|
2008-12-02 12:01:29 +01:00
|
|
|
void setVisualizeWhitespace(bool);
|
2008-12-09 17:43:31 +01:00
|
|
|
void cleanWhitespace();
|
2008-12-02 12:01:29 +01:00
|
|
|
void setTextWrapping(bool);
|
|
|
|
|
void unCommentSelection();
|
2010-05-20 15:10:26 +02:00
|
|
|
void unfoldAll();
|
|
|
|
|
void fold();
|
|
|
|
|
void unfold();
|
2009-05-14 17:24:35 +02:00
|
|
|
void cutLine();
|
2008-12-02 12:01:29 +01:00
|
|
|
void deleteLine();
|
|
|
|
|
void selectEncoding();
|
|
|
|
|
void increaseFontSize();
|
|
|
|
|
void decreaseFontSize();
|
2009-11-30 19:00:36 +01:00
|
|
|
void resetFontSize();
|
2008-12-04 18:37:02 +01:00
|
|
|
void gotoBlockStart();
|
|
|
|
|
void gotoBlockEnd();
|
|
|
|
|
void gotoBlockStartWithSelection();
|
|
|
|
|
void gotoBlockEndWithSelection();
|
2008-12-04 19:25:20 +01:00
|
|
|
void selectBlockUp();
|
|
|
|
|
void selectBlockDown();
|
2008-12-10 18:01:33 +01:00
|
|
|
void moveLineUp();
|
|
|
|
|
void moveLineDown();
|
2009-05-15 23:17:11 +02:00
|
|
|
void copyLineUp();
|
|
|
|
|
void copyLineDown();
|
2010-01-20 17:51:05 +01:00
|
|
|
void joinLines();
|
2010-05-03 17:03:11 +02:00
|
|
|
void insertLineAbove();
|
|
|
|
|
void insertLineBelow();
|
2009-02-16 12:50:15 +01:00
|
|
|
void updateCurrentEditor(Core::IEditor *editor);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-07 15:24:30 +02:00
|
|
|
void gotoLineStart();
|
|
|
|
|
void gotoLineStartWithSelection();
|
|
|
|
|
void gotoLineEnd();
|
|
|
|
|
void gotoLineEndWithSelection();
|
|
|
|
|
void gotoNextLine();
|
|
|
|
|
void gotoNextLineWithSelection();
|
|
|
|
|
void gotoPreviousLine();
|
|
|
|
|
void gotoPreviousLineWithSelection();
|
|
|
|
|
void gotoPreviousCharacter();
|
|
|
|
|
void gotoPreviousCharacterWithSelection();
|
|
|
|
|
void gotoNextCharacter();
|
|
|
|
|
void gotoNextCharacterWithSelection();
|
|
|
|
|
void gotoPreviousWord();
|
|
|
|
|
void gotoPreviousWordWithSelection();
|
|
|
|
|
void gotoNextWord();
|
|
|
|
|
void gotoNextWordWithSelection();
|
2010-11-10 12:53:45 +01:00
|
|
|
void gotoPreviousWordCamelCase();
|
|
|
|
|
void gotoPreviousWordCamelCaseWithSelection();
|
|
|
|
|
void gotoNextWordCamelCase();
|
|
|
|
|
void gotoNextWordCamelCaseWithSelection();
|
2010-05-07 15:24:30 +02:00
|
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
QAction *m_undoAction;
|
|
|
|
|
QAction *m_redoAction;
|
|
|
|
|
QAction *m_copyAction;
|
|
|
|
|
QAction *m_cutAction;
|
|
|
|
|
QAction *m_pasteAction;
|
|
|
|
|
QAction *m_selectAllAction;
|
|
|
|
|
QAction *m_gotoAction;
|
|
|
|
|
QAction *m_printAction;
|
|
|
|
|
QAction *m_formatAction;
|
2009-07-21 10:37:00 +02:00
|
|
|
QAction *m_rewrapParagraphAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *m_visualizeWhitespaceAction;
|
2008-12-09 17:43:31 +01:00
|
|
|
QAction *m_cleanWhitespaceAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *m_textWrappingAction;
|
|
|
|
|
QAction *m_unCommentSelectionAction;
|
2010-05-20 15:10:26 +02:00
|
|
|
QAction *m_unfoldAllAction;
|
|
|
|
|
QAction *m_foldAction;
|
|
|
|
|
QAction *m_unfoldAction;
|
2009-05-14 17:24:35 +02:00
|
|
|
QAction *m_cutLineAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
QAction *m_deleteLineAction;
|
|
|
|
|
QAction *m_selectEncodingAction;
|
|
|
|
|
QAction *m_increaseFontSizeAction;
|
|
|
|
|
QAction *m_decreaseFontSizeAction;
|
2009-11-30 19:00:36 +01:00
|
|
|
QAction *m_resetFontSizeAction;
|
2008-12-04 18:37:02 +01:00
|
|
|
QAction *m_gotoBlockStartAction;
|
|
|
|
|
QAction *m_gotoBlockEndAction;
|
|
|
|
|
QAction *m_gotoBlockStartWithSelectionAction;
|
|
|
|
|
QAction *m_gotoBlockEndWithSelectionAction;
|
2008-12-04 19:25:20 +01:00
|
|
|
QAction *m_selectBlockUpAction;
|
|
|
|
|
QAction *m_selectBlockDownAction;
|
2008-12-10 18:01:33 +01:00
|
|
|
QAction *m_moveLineUpAction;
|
|
|
|
|
QAction *m_moveLineDownAction;
|
2009-05-15 23:17:11 +02:00
|
|
|
QAction *m_copyLineUpAction;
|
|
|
|
|
QAction *m_copyLineDownAction;
|
2010-01-20 17:51:05 +01:00
|
|
|
QAction *m_joinLinesAction;
|
2010-05-03 17:03:11 +02:00
|
|
|
QAction *m_insertLineAboveAction;
|
|
|
|
|
QAction *m_insertLineBelowAction;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
uint m_optionalActions;
|
|
|
|
|
QPointer<BaseTextEditor> m_currentEditor;
|
2010-06-25 12:56:16 +02:00
|
|
|
Core::Context m_contextId;
|
2008-12-02 12:01:29 +01:00
|
|
|
bool m_initialized;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace TextEditor
|
|
|
|
|
|
|
|
|
|
#endif // TEXTEDITORACTIONHANDLER_H
|