forked from len0rd/rockbox
Theme Editor: Removed markup comments from CodeEditor files (it was originally a Nokia example, so it was marked up with comments for their documentation), implemented the beginnings of drag and drop editing. Viewports are now movable, but don't invoke code generation yet
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27675 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
dad9810fe5
commit
a83adc7d6d
5 changed files with 30 additions and 35 deletions
|
@ -38,8 +38,6 @@
|
|||
|
||||
#include "codeeditor.h"
|
||||
|
||||
//![constructor]
|
||||
|
||||
CodeEditor::CodeEditor(QWidget *parent)
|
||||
: QPlainTextEdit(parent), completer(this)
|
||||
{
|
||||
|
@ -58,10 +56,6 @@ CodeEditor::CodeEditor(QWidget *parent)
|
|||
settings.beginGroup("CodeEditor");
|
||||
}
|
||||
|
||||
//![constructor]
|
||||
|
||||
//![extraAreaWidth]
|
||||
|
||||
int CodeEditor::lineNumberAreaWidth()
|
||||
{
|
||||
int digits = 1;
|
||||
|
@ -76,19 +70,12 @@ int CodeEditor::lineNumberAreaWidth()
|
|||
return space;
|
||||
}
|
||||
|
||||
//![extraAreaWidth]
|
||||
|
||||
//![slotUpdateExtraAreaWidth]
|
||||
|
||||
void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
|
||||
{
|
||||
setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
|
||||
}
|
||||
|
||||
//![slotUpdateExtraAreaWidth]
|
||||
|
||||
//![slotUpdateRequest]
|
||||
|
||||
void CodeEditor::updateLineNumberArea(const QRect &rect, int dy)
|
||||
{
|
||||
if (dy)
|
||||
|
@ -100,8 +87,6 @@ void CodeEditor::updateLineNumberArea(const QRect &rect, int dy)
|
|||
updateLineNumberAreaWidth(0);
|
||||
}
|
||||
|
||||
//![slotUpdateRequest]
|
||||
|
||||
void CodeEditor::cursorMoved()
|
||||
{
|
||||
/* Closing the completer if the cursor has moved out of its bounds */
|
||||
|
@ -138,8 +123,6 @@ void CodeEditor::insertTag()
|
|||
completer.hide();
|
||||
}
|
||||
|
||||
//![resizeEvent]
|
||||
|
||||
void CodeEditor::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QPlainTextEdit::resizeEvent(e);
|
||||
|
@ -149,8 +132,6 @@ void CodeEditor::resizeEvent(QResizeEvent *e)
|
|||
lineNumberAreaWidth(), cr.height()));
|
||||
}
|
||||
|
||||
//![resizeEvent]
|
||||
|
||||
void CodeEditor::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
|
||||
|
@ -256,23 +237,16 @@ void CodeEditor::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
}
|
||||
|
||||
//![extraAreaPaintEvent_0]
|
||||
|
||||
void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(lineNumberArea);
|
||||
painter.fillRect(event->rect(), Qt::lightGray);
|
||||
|
||||
//![extraAreaPaintEvent_0]
|
||||
|
||||
//![extraAreaPaintEvent_1]
|
||||
QTextBlock block = firstVisibleBlock();
|
||||
int blockNumber = block.blockNumber();
|
||||
int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top();
|
||||
int bottom = top + (int) blockBoundingRect(block).height();
|
||||
//![extraAreaPaintEvent_1]
|
||||
|
||||
//![extraAreaPaintEvent_2]
|
||||
while (block.isValid() && top <= event->rect().bottom()) {
|
||||
if (block.isVisible() && bottom >= event->rect().top()) {
|
||||
QString number = QString::number(blockNumber + 1);
|
||||
|
@ -293,5 +267,4 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
|
|||
++blockNumber;
|
||||
}
|
||||
}
|
||||
//![extraAreaPaintEvent_2]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue