Patch for coutputwidget (again)

Roland Krause rokrau at yahoo.com
Thu Jul 18 20:51:01 UTC 2002


Works fine here with Qt-3.0.4. Allthough I have to say this really give
this function the final push over the edge. 

This code is sitting on it's knees in front of you begging for you to
finish it off. 

Roland

--- Harald Fernengel <harry at kdevelop.org> wrote:
> Hi,
> 
> This patch should fix the "jump to error/warning" problem with Qt
> 3.0.5 (which 
> took over the behaviour change from Qt 3.0.4) and the big
> lincespaces.
> 
> Hopefully, I got it right this time. Falk, Roland, is it okay to
> commit?
> 
> Best regards,
> Harry> Index: coutputwidget.cpp
> ===================================================================
> RCS file: /home/kde/kdevelop/kdevelop/coutputwidget.cpp,v
> retrieving revision 1.3.2.4.2.10.2.25
> diff -u -3 -p -r1.3.2.4.2.10.2.25 coutputwidget.cpp
> --- coutputwidget.cpp	2002/06/13 23:13:58	1.3.2.4.2.10.2.25
> +++ coutputwidget.cpp	2002/07/18 00:43:10
> @@ -25,6 +25,35 @@
>  #include <qfont.h>
>  #include <qstylesheet.h>
>  
> +#if QT_VERSION >= 300
> +
> +#include <qregexp.h>
> +
> +bool CMakeOutputWidget::isAboveQt303()
> +{
> +  static int result = -1;
> +
> +  if ( result == -1 ) {
> +    int qMajor = -1;
> +    int qMinor = -1;
> +    int qVer = -1;
> +    QRegExp verRegExp("(\\d+)\\.(\\d+)\\.(\\d+)");
> +    verRegExp.search( QString(qVersion()) );
> +    qVer = verRegExp.cap(1).toInt();
> +    qMajor = verRegExp.cap(2).toInt();
> +    qMinor = verRegExp.cap(3).toInt();
> +    //qDebug( "Qt version: %d.%d.%d", qVer, qMajor, qMinor );
> +    if ( qVer > 3 || qMajor > 0 || qMinor > 3 ) {
> +      result = 1;
> +    } else {
> +      result = 0;
> +    }
> +  }
> +
> +  return (result > 0);
> +}
> +#endif
> +
>  COutputWidget::COutputWidget(QWidget* parent, const char* name) :
>  //  KEdit(parent,name)
>    QMultiLineEdit(parent, name)
> @@ -84,8 +113,10 @@ CMakeOutputWidget::CMakeOutputWidget(QWi
>  #if QT_VERSION >= 300
>    setTextFormat(Qt::RichText);
>  
> -  // This is necessary in order to work around a bug in Qt's
> RichText widget. (Marcus Gruendler)
> -  styleSheet()->item( "font" )->setDisplayMode(
> QStyleSheetItem::DisplayBlock );
> +  if (!isAboveQt303()) {
> +    // This is necessary in order to work around a bug in Qt's
> RichText widget. (Marcus Gruendler)
> +    styleSheet()->item( "font" )->setDisplayMode(
> QStyleSheetItem::DisplayBlock );
> +  }
>  #endif
>  }
>  
> @@ -123,17 +154,12 @@ void CMakeOutputWidget::insertAtEnd(cons
>      int index;
>      getCursorPosition(&currentPara, &index);
>  
> -    bool isQt304 = false;
> -    if (QString(qVersion()) == "3.0.4") {
> -      isQt304 = true;
> -    }
> -
>      int paraCount;
> -    if (!isQt304) {
> -      paraCount = paragraphs()-1;
> +    if (isAboveQt303()) {
> +      paraCount = paragraphs();
>      }
>      else {
> -      paraCount = paragraphs();
> +      paraCount = paragraphs()-1;
>      }    
>  
>      // escape rich edit tags like "&", "<", ">"
> @@ -151,7 +177,7 @@ void CMakeOutputWidget::insertAtEnd(cons
>          break;
>        default:
>          // Runtime check for broken Qt version. Don't add empty new
> lines.
> -        if (line[0]=='\n' && !isQt304) {
> +        if (line[0]=='\n' && !(QString(qVersion())=="3.0.4")) {
>            break;
>          }
>            
> @@ -298,7 +324,7 @@ void CMakeOutputWidget::processLine(cons
>    {
>      // add the error keyed on the line number in the make output
> widget
>      ErrorDetails errorDetails(fileInErr, lineInErr, type);
> -    if (QString(qVersion()) == "3.0.4") {
> +    if (isAboveQt303()) {
>        m_errorMap.insert(numLines(), errorDetails);
>      }
>      else {
> Index: coutputwidget.h
> ===================================================================
> RCS file: /home/kde/kdevelop/kdevelop/coutputwidget.h,v
> retrieving revision 1.2.2.3.2.6.2.3
> diff -u -3 -p -r1.2.2.3.2.6.2.3 coutputwidget.h
> --- coutputwidget.h	2002/04/10 14:48:20	1.2.2.3.2.6.2.3
> +++ coutputwidget.h	2002/07/18 00:43:10
> @@ -93,6 +93,8 @@ private:
>  #if (QT_VERSION < 300)
>    void paintCell(QPainter* p, int row, int col);
>    int mapToView( int xIndex, int line );
> +#else
> +  static bool isAboveQt303();
>  #endif
>  
>    QString m_buf;
> 

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com




More information about the KDevelop-devel mailing list