Skip to content
GitLab
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
c4532125
Commit
c4532125
authored
Feb 03, 2010
by
Erik Verbruggen
Browse files
Added indenting of dirty areas.
parent
3efdb876
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/core/include/componenttextmodifier.h
View file @
c4532125
...
...
@@ -43,6 +43,8 @@ public:
virtual
void
replace
(
int
offset
,
int
length
,
const
QString
&
replacement
);
virtual
void
move
(
const
MoveInfo
&
moveInfo
);
virtual
void
indent
(
int
offset
,
int
length
);
virtual
void
startGroup
();
virtual
void
flushGroup
();
virtual
void
commitGroup
();
...
...
src/plugins/qmldesigner/core/include/plaintexteditmodifier.h
View file @
c4532125
...
...
@@ -64,6 +64,8 @@ public:
virtual
void
replace
(
int
offset
,
int
length
,
const
QString
&
replacement
);
virtual
void
move
(
const
MoveInfo
&
moveInfo
);
virtual
void
indent
(
int
offset
,
int
length
);
virtual
void
startGroup
();
virtual
void
flushGroup
();
virtual
void
commitGroup
();
...
...
src/plugins/qmldesigner/core/include/textmodifier.h
View file @
c4532125
...
...
@@ -68,6 +68,8 @@ public:
virtual
void
replace
(
int
offset
,
int
length
,
const
QString
&
replacement
)
=
0
;
virtual
void
move
(
const
MoveInfo
&
moveInfo
)
=
0
;
virtual
void
indent
(
int
offset
,
int
length
)
=
0
;
virtual
void
startGroup
()
=
0
;
virtual
void
flushGroup
()
=
0
;
virtual
void
commitGroup
()
=
0
;
...
...
src/plugins/qmldesigner/core/model/componenttextmodifier.cpp
View file @
c4532125
...
...
@@ -58,6 +58,11 @@ void ComponentTextModifier::move(const MoveInfo &moveInfo)
m_originalModifier
->
move
(
moveInfo
);
}
void
ComponentTextModifier
::
indent
(
int
offset
,
int
length
)
{
m_originalModifier
->
indent
(
offset
,
length
);
}
void
ComponentTextModifier
::
startGroup
()
{
m_originalModifier
->
startGroup
();
...
...
src/plugins/qmldesigner/core/model/modeltotextmerger.cpp
View file @
c4532125
...
...
@@ -287,15 +287,16 @@ void ModelToTextMerger::applyChanges()
}
}
void
ModelToTextMerger
::
reindent
(
const
QMap
<
int
,
int
>
&
/*
dirtyAreas
*/
)
const
void
ModelToTextMerger
::
reindent
(
const
QMap
<
int
,
int
>
&
dirtyAreas
)
const
{
// QList<int> offsets = dirtyAreas.keys();
// qSort(offsets);
//
// foreach (const int offset, offsets) {
// const int length = dirtyAreas[offset];
// xxxx
// }
QList
<
int
>
offsets
=
dirtyAreas
.
keys
();
qSort
(
offsets
);
TextModifier
*
textModifier
=
m_rewriterView
->
textModifier
();
foreach
(
const
int
offset
,
offsets
)
{
const
int
length
=
dirtyAreas
[
offset
];
textModifier
->
indent
(
offset
,
length
);
}
}
void
ModelToTextMerger
::
schedule
(
RewriteAction
*
action
)
...
...
src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp
View file @
c4532125
...
...
@@ -27,14 +27,15 @@
**
**************************************************************************/
#include
<QtCore/QDebug>
#include
"plaintexteditmodifier.h"
#include
<texteditor/basetexteditor.h>
#include
<utils/changeset.h>
#include
<QtGui/QPlainTextEdit>
#include
<QtGui/QUndoStack>
#include
<utils/changeset.h>
#include
"plaintexteditmodifier.h"
#include
<QtCore/QDebug>
using
namespace
Utils
;
using
namespace
QmlDesigner
;
...
...
@@ -112,6 +113,27 @@ void PlainTextEditModifier::move(const MoveInfo &moveInfo)
}
}
void
PlainTextEditModifier
::
indent
(
int
offset
,
int
length
)
{
if
(
length
==
0
||
offset
<
0
||
offset
+
length
>=
text
().
length
())
return
;
// qDebug() << "PlainTextEditModifier::indent(" << offset << "," << length << ")";
if
(
TextEditor
::
BaseTextEditor
*
bte
=
dynamic_cast
<
TextEditor
::
BaseTextEditor
*>
(
m_textEdit
))
{
// qDebug() << "**** Doing indentation";
// find the applicable block:
QTextDocument
*
doc
=
bte
->
document
();
QTextCursor
tc
(
doc
);
tc
.
beginEditBlock
();
tc
.
setPosition
(
offset
);
tc
.
setPosition
(
offset
+
length
,
QTextCursor
::
KeepAnchor
);
bte
->
indentInsertedText
(
tc
);
tc
.
endEditBlock
();
}
else
{
// qDebug() << "**** Skipping indentation";
}
}
void
PlainTextEditModifier
::
startGroup
()
{
if
(
!
m_changeSet
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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