Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
5208444d
Commit
5208444d
authored
May 18, 2009
by
Thorbjørn Lindeijer
Browse files
Merge branch 'copylines'
Conflicts: src/plugins/texteditor/texteditorconstants.h
parents
9a79a069
2dd04664
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
5208444d
...
...
@@ -694,6 +694,66 @@ void BaseTextEditor::selectBlockDown()
_q_matchParentheses
();
}
void
BaseTextEditor
::
copyLineUp
()
{
copyLineUpDown
(
true
);
}
void
BaseTextEditor
::
copyLineDown
()
{
copyLineUpDown
(
false
);
}
void
BaseTextEditor
::
copyLineUpDown
(
bool
up
)
{
QTextCursor
cursor
=
textCursor
();
QTextCursor
move
=
cursor
;
move
.
beginEditBlock
();
bool
hasSelection
=
cursor
.
hasSelection
();
if
(
hasSelection
)
{
move
.
setPosition
(
cursor
.
selectionStart
());
move
.
movePosition
(
QTextCursor
::
StartOfBlock
);
move
.
setPosition
(
cursor
.
selectionEnd
(),
QTextCursor
::
KeepAnchor
);
move
.
movePosition
(
QTextCursor
::
EndOfBlock
,
QTextCursor
::
KeepAnchor
);
}
else
{
move
.
movePosition
(
QTextCursor
::
StartOfBlock
);
move
.
movePosition
(
QTextCursor
::
EndOfBlock
,
QTextCursor
::
KeepAnchor
);
}
QString
text
=
move
.
selectedText
();
if
(
up
)
{
move
.
setPosition
(
cursor
.
selectionStart
());
move
.
movePosition
(
QTextCursor
::
StartOfBlock
);
move
.
insertBlock
();
move
.
movePosition
(
QTextCursor
::
Left
);
}
else
{
move
.
movePosition
(
QTextCursor
::
EndOfBlock
);
if
(
move
.
atBlockStart
())
{
move
.
movePosition
(
QTextCursor
::
NextBlock
);
move
.
insertBlock
();
move
.
movePosition
(
QTextCursor
::
Left
);
}
else
{
move
.
insertBlock
();
}
}
int
start
=
move
.
position
();
move
.
clearSelection
();
move
.
insertText
(
text
);
int
end
=
move
.
position
();
move
.
setPosition
(
start
);
move
.
setPosition
(
end
,
QTextCursor
::
KeepAnchor
);
indent
(
document
(),
move
,
QChar
::
Null
);
move
.
endEditBlock
();
setTextCursor
(
move
);
}
void
BaseTextEditor
::
moveLineUp
()
{
moveLineUpDown
(
true
);
...
...
src/plugins/texteditor/basetexteditor.h
View file @
5208444d
...
...
@@ -388,6 +388,9 @@ public slots:
void
moveLineUp
();
void
moveLineDown
();
void
copyLineUp
();
void
copyLineDown
();
void
cleanWhitespace
();
signals:
...
...
@@ -513,6 +516,7 @@ private:
void
handleHomeKey
(
bool
anchor
);
void
handleBackspaceKey
();
void
moveLineUpDown
(
bool
up
);
void
copyLineUpDown
(
bool
up
);
void
saveCurrentCursorPositionForNavigation
();
void
drawFoldingMarker
(
QPainter
*
painter
,
const
QPalette
&
pal
,
...
...
src/plugins/texteditor/texteditoractionhandler.cpp
View file @
5208444d
...
...
@@ -85,6 +85,8 @@ TextEditorActionHandler::TextEditorActionHandler(const QString &context,
m_selectBlockDownAction
=
0
;
m_moveLineUpAction
=
0
;
m_moveLineDownAction
=
0
;
m_copyLineUpAction
=
0
;
m_copyLineDownAction
=
0
;
m_contextId
<<
Core
::
UniqueIDManager
::
instance
()
->
uniqueIdentifier
(
context
);
...
...
@@ -251,6 +253,16 @@ void TextEditorActionHandler::createActions()
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
()));
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
()));
}
bool
TextEditorActionHandler
::
supportsAction
(
const
QString
&
/*id */
)
const
...
...
@@ -406,6 +418,8 @@ FUNCTION(selectBlockUp)
FUNCTION
(
selectBlockDown
)
FUNCTION
(
moveLineUp
)
FUNCTION
(
moveLineDown
)
FUNCTION
(
copyLineUp
)
FUNCTION
(
copyLineDown
)
void
TextEditorActionHandler
::
updateCurrentEditor
(
Core
::
IEditor
*
editor
)
{
...
...
src/plugins/texteditor/texteditoractionhandler.h
View file @
5208444d
...
...
@@ -111,6 +111,8 @@ private slots:
void
selectBlockDown
();
void
moveLineUp
();
void
moveLineDown
();
void
copyLineUp
();
void
copyLineDown
();
void
updateCurrentEditor
(
Core
::
IEditor
*
editor
);
private:
...
...
@@ -143,6 +145,8 @@ private:
QAction
*
m_selectBlockDownAction
;
QAction
*
m_moveLineUpAction
;
QAction
*
m_moveLineDownAction
;
QAction
*
m_copyLineUpAction
;
QAction
*
m_copyLineDownAction
;
uint
m_optionalActions
;
QPointer
<
BaseTextEditor
>
m_currentEditor
;
...
...
src/plugins/texteditor/texteditorconstants.h
View file @
5208444d
...
...
@@ -53,6 +53,8 @@ const char * const SELECT_BLOCK_UP = "TextEditor.SelectBlockUp";
const
char
*
const
SELECT_BLOCK_DOWN
=
"TextEditor.SelectBlockDown"
;
const
char
*
const
MOVE_LINE_UP
=
"TextEditor.MoveLineUp"
;
const
char
*
const
MOVE_LINE_DOWN
=
"TextEditor.MoveLineDown"
;
const
char
*
const
COPY_LINE_UP
=
"TextEditor.CopyLineUp"
;
const
char
*
const
COPY_LINE_DOWN
=
"TextEditor.CopyLineDown"
;
const
char
*
const
CUT_LINE
=
"TextEditor.CutLine"
;
const
char
*
const
DELETE_LINE
=
"TextEditor.DeleteLine"
;
const
char
*
const
DELETE_WORD
=
"TextEditor.DeleteWord"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment