コード例 #1
0
QTextParagraph *QTextDocument::paragAt( int i ) const
{
    QTextParagraph* p = curParag;
    if ( !p || p->paragId() > i )
	p = fParag;
    while ( p && p->paragId() != i )
	p = p->next();
    ((QTextDocument*)this)->curParag = p;
    return p;
}
コード例 #2
0
ファイル: cppbrowser.cpp プロジェクト: serghei/kde3-qt
void CppEditorBrowser::showHelp( const QString &w )
{
    QString word( w );
    if ( word[ 0 ] == 'Q' ) {
        if ( word[ (int)word.length() - 1 ] == '&' ||
                word[ (int)word.length() - 1 ] == '*' )
            word.remove( word.length() - 1, 1 );
        word = word.lower() + ".html";
        QStringList lst;
        lst << "assistant" << "-file" << word;
        QProcess proc( lst );
        proc.start();
        return;
    }

    if ( word.find( '(' ) != -1 ) {
        QString txt = "::" + word.left( word.find( '(' ) );
        QTextDocument *doc = curEditor->document();
        QTextParagraph *p = doc->firstParagraph();
        while ( p ) {
            if ( p->string()->toString().find( txt ) != -1 ) {
                curEditor->setCursorPosition( p->paragId(), 0 );
                return;
            }
            p = p->next();
        }
    }

    QMainWindow *mw = ::qt_cast<QMainWindow*>(curEditor->topLevelWidget());
    if ( mw )
        mw->statusBar()->message( tr( "Nothing available for '%1'" ).arg( w ), 1500 );
}
コード例 #3
0
ファイル: markerwidget.cpp プロジェクト: aroraujjwal/qt3
void MarkerWidget::contextMenuEvent( QContextMenuEvent *e )
{
    QPopupMenu m( 0, "editor_breakpointsmenu" );

    int toggleBreakPoint = 0;
//    int editBreakpoints = 0;

    QTextParagraph *p = ( (Editor*)viewManager->currentView() )->document()->firstParagraph();
    int yOffset = ( (Editor*)viewManager->currentView() )->contentsY();
    bool supports = ( (Editor*)viewManager->currentView() )->supportsBreakPoints();
    while ( p && supports ) {
	if ( e->y() >= p->rect().y() - yOffset && e->y() <= p->rect().y() + p->rect().height() - yOffset ) {
	    if ( ( (ParagData*)p->extraData() )->marker == ParagData::Breakpoint )
		toggleBreakPoint = m.insertItem( tr( "Clear Breakpoint\tF9" ) );
	    else
		toggleBreakPoint = m.insertItem( tr( "Set Breakpoint\tF9" ) );
// 	    editBreakpoints = m.insertItem( tr( "Edit Breakpoints..." ) );
	    m.insertSeparator();
	    break;
	}
	p = p->next();
    }

    const int collapseAll = m.insertItem( tr( "Collapse All" ) );
    const int expandAll = m.insertItem( tr( "Expand All" ) );
    const int collapseFunctions = m.insertItem( tr( "Collapse all Functions" ) );
    const int expandFunctions = m.insertItem( tr( "Expand all Functions" ) );

    int res = m.exec( e->globalPos() );
    if ( res == -1)
	return;

    if ( res == collapseAll ) {
	emit collapse( TRUE );
    } else if ( res == collapseFunctions ) {
	emit collapse( FALSE );
    } else if ( res == expandAll ) {
	emit expand( TRUE );
    } else if ( res == expandFunctions ) {
	emit expand( FALSE );
    } else if ( res == toggleBreakPoint ) {
	if ( ( (ParagData*)p->extraData() )->marker == ParagData::Breakpoint ) {
	    ( (ParagData*)p->extraData() )->marker = ParagData::NoMarker;
	} else {
	    bool ok;
	    isBreakpointPossible( ok, ( (Editor*)viewManager->currentView() )->text(), p->paragId() );
	    if ( ok )
		( (ParagData*)p->extraData() )->marker = ParagData::Breakpoint;
	    else
		emit showMessage( tr( "<font color=red>Can't set breakpoint here!</font>" ) );
	}
//    } else if ( res == editBreakpoints ) {
//	emit editBreakPoints();
    }
    doRepaint();
    emit markersChanged();
}
コード例 #4
0
void EditorInterfaceImpl::scrollTo( const QString &txt, const QString & )
{
    if ( !viewManager || !viewManager->currentView() )
	return;
    ( (CppEditor*)viewManager->currentView() )->sync();
    QTextDocument *doc = ( (CppEditor*)viewManager->currentView() )->document();
    QTextParagraph *p = doc->firstParagraph();
    while ( p ) {
	if ( p->string()->toString().find( txt ) != -1 ) {
	    ( (CppEditor*)viewManager->currentView() )->setCursorPosition( p->paragId() + 2, 0 );
	    break;
	}
	p = p->next();
    }
    ( (CppEditor*)viewManager->currentView() )->setFocus();
}
コード例 #5
0
ファイル: markerwidget.cpp プロジェクト: aroraujjwal/qt3
void MarkerWidget::mousePressEvent( QMouseEvent *e )
{
    if ( e->button() != LeftButton )
	return;
    bool supports = ( (Editor*)viewManager->currentView() )->supportsBreakPoints();
    QTextParagraph *p = ( (Editor*)viewManager->currentView() )->document()->firstParagraph();
    int yOffset = ( (Editor*)viewManager->currentView() )->contentsY();
    while ( p ) {
	if ( e->y() >= p->rect().y() - yOffset && e->y() <= p->rect().y() + p->rect().height() - yOffset ) {
	    QTextParagraphData *d = p->extraData();
	    if ( !d )
		return;
	    ParagData *data = (ParagData*)d;
	    if ( supports && ( e->x() < width() - 15 ) ) {
		if ( data->marker == ParagData::Breakpoint ) {
		    data->marker = ParagData::NoMarker;
		} else {
		    bool ok = TRUE;
		    isBreakpointPossible( ok, ( (Editor*)viewManager->currentView() )->text(), p->paragId() );
		    if ( ok )
			data->marker = ParagData::Breakpoint;
		    else
			emit showMessage( tr( "<font color=red>Can't set breakpoint here!</font>" ) );
		}
	    } else {
		if ( data->lineState == ParagData::FunctionStart ) {
		    if ( data->functionOpen )
			emit collapseFunction( p );
		    else
			emit expandFunction( p );
		}
	    }
	    break;
	}
	p = p->next();
    }
    doRepaint();
    emit markersChanged();
}
コード例 #6
0
ファイル: markerwidget.cpp プロジェクト: aroraujjwal/qt3
void MarkerWidget::paintEvent( QPaintEvent * )
{
    buffer.fill( backgroundColor() );

    QTextParagraph *p = ( (Editor*)viewManager->currentView() )->document()->firstParagraph();
    QPainter painter( &buffer );
    int yOffset = ( (Editor*)viewManager->currentView() )->contentsY();
    while ( p ) {
	if ( !p->isVisible() ) {
	    p = p->next();
	    continue;
	}
	if ( p->rect().y() + p->rect().height() - yOffset < 0 ) {
	    p = p->next();
	    continue;
	}
	if ( p->rect().y() - yOffset > height() )
	    break;
	if ( !((p->paragId() + 1) % 10) ) {
	    painter.save();
	    painter.setPen( colorGroup().dark() );
	    painter.drawText( 0, p->rect().y() - yOffset, width() - 20, p->rect().height(),
			      Qt::AlignRight | Qt::AlignTop, QString::number( p->paragId() + 1 ) );
	    painter.restore();
	}
	ParagData *paragData = (ParagData*)p->extraData();
	if ( paragData ) {
	    switch ( paragData->marker ) {
	    case ParagData::Error:
		painter.drawPixmap( 3, p->rect().y() +
				    ( p->rect().height() - errorPixmap->height() ) / 2 -
				    yOffset, *errorPixmap );
		break;
	    case ParagData::Breakpoint:
		painter.drawPixmap( 3, p->rect().y() +
				    ( p->rect().height() - breakpointPixmap->height() ) / 2 -
				    yOffset, *breakpointPixmap );
		break;
	    default:
		break;
	    }
	    switch ( paragData->lineState ) {
	    case ParagData::FunctionStart:
		painter.setPen( colorGroup().foreground() );
		painter.setBrush( colorGroup().base() );
		painter.drawLine( width() - 11, p->rect().y() - yOffset,
				  width() - 11, p->rect().y() + p->rect().height() - yOffset );
		painter.drawRect( width() - 15, p->rect().y() + ( p->rect().height() - 9 ) / 2 - yOffset, 9, 9 );
		painter.drawLine( width() - 13, p->rect().y() + ( p->rect().height() - 9 ) / 2 - yOffset + 4,
				  width() - 9, p->rect().y() +
				  ( p->rect().height() - 9 ) / 2 - yOffset + 4 );
		if ( !paragData->functionOpen )
		    painter.drawLine( width() - 11,
				      p->rect().y() + ( p->rect().height() - 9 ) / 2 - yOffset + 2,
				      width() - 11,
				      p->rect().y() +
				      ( p->rect().height() - 9 ) / 2 - yOffset + 6 );
		break;
	    case ParagData::InFunction:
		painter.setPen( colorGroup().foreground() );
		painter.drawLine( width() - 11, p->rect().y() - yOffset,
				  width() - 11, p->rect().y() + p->rect().height() - yOffset );
		break;
	    case ParagData::FunctionEnd:
		painter.setPen( colorGroup().foreground() );
		painter.drawLine( width() - 11, p->rect().y() - yOffset,
				  width() - 11, p->rect().y() + p->rect().height() - yOffset );
		painter.drawLine( width() - 11, p->rect().y() + p->rect().height() - yOffset,
				  width() - 7, p->rect().y() + p->rect().height() - yOffset );
		break;
	    default:
		break;
	    }
	    if ( paragData->step )
		painter.drawPixmap( 3, p->rect().y() +
				    ( p->rect().height() - stepPixmap->height() ) / 2 -
				    yOffset, *stepPixmap );
	    if ( paragData->stackFrame )
		painter.drawPixmap( 3, p->rect().y() +
				    ( p->rect().height() - stackFrame->height() ) / 2 -
				    yOffset, *stackFrame );
	}
	p = p->next();
    }
    painter.end();

    bitBlt( this, 0, 0, &buffer );
}