editors/qeditor/linenumberwidget.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
#include "linenumberwidget.h"
00043
#include "qeditor.h"
00044
#include "paragdata.h"
00045
00046
#include <private/qrichtext_p.h>
00047
00048 LineNumberWidget::LineNumberWidget(
QEditor* editor,
QWidget* parent,
const char* name )
00049 :
QWidget( parent, name, WRepaintNoErase | WStaticContents | WResizeNoErase ),
00050 m_editor( editor )
00051 {
00052 setFixedWidth( 50 );
00053
00054 connect(
m_editor->verticalScrollBar(), SIGNAL( valueChanged(
int ) ),
00055
this, SLOT(
doRepaint() ) );
00056 connect(
m_editor, SIGNAL( textChanged() ),
00057
this, SLOT(
doRepaint() ) );
00058
doRepaint();
00059 }
00060
00061 LineNumberWidget::~LineNumberWidget()
00062 {
00063 }
00064
00065 void LineNumberWidget::paintEvent(
QPaintEvent* )
00066 {
00067
buffer.fill();
00068
00069 QTextParagraph *p =
m_editor->
document()->firstParagraph();
00070
QPainter painter( &
buffer );
00071
int yOffset =
m_editor->contentsY();
00072
while ( p ) {
00073
if ( !p->isVisible() ) {
00074 p = p->next();
00075
continue;
00076 }
00077
if ( p->rect().y() + p->rect().height() - yOffset < 0 ) {
00078 p = p->next();
00079
continue;
00080 }
00081
if ( p->rect().y() - yOffset > height() )
00082
break;
00083
00084
00085 painter.drawText( 0, p->rect().y() - yOffset,
00086
buffer.width() - 10, p->rect().height(),
00087 AlignRight | AlignBottom,
00088 QString::number(p->paragId()+1) );
00089 p = p->next();
00090 }
00091
00092 painter.end();
00093 bitBlt(
this, 0, 0, &
buffer );
00094 }
00095
00096 void LineNumberWidget::resizeEvent(
QResizeEvent *e )
00097 {
00098
buffer.resize( e->size() );
00099 QWidget::resizeEvent( e );
00100 }
00101
00102
#include "linenumberwidget.moc"
This file is part of the documentation for KDevelop Version 3.0.4.