COutputWidget revisited
Roland Krause
rokrau at yahoo.com
Wed Jun 19 19:26:02 UTC 2002
Grrr....
I'll put it on the backburner, i am cramped with other stuff and I dont
have 3.0.5 yet. Is it officially out?
Roland
--- Harald Fernengel <harry at kdevelop.org> wrote:
> Hi,
>
> in Qt 3.0.5 the behaviour of QTextEdit changed again a little bit.
> BlockMode
> now uses paragraph linespacing, so each output line has too much
> space above
> and below.
>
> The attached patch fixes this, I tested it on an unchanged SuSE 8.0
> and a self
> compiled CVS HEAD.
>
> Since KDevelop 2.1.2 gets delayed for one week, I'd really get that
> patch in.
>
> Falk, Roland, Kuba and the other 2.x users, can you please test and
> review it?
>
> 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/06/19 11:27:02
> @@ -25,6 +25,10 @@
> #include <qfont.h>
> #include <qstylesheet.h>
>
> +#if QT_VERSION >= 300
> +#include <qregexp.h>
> +#endif
> +
> COutputWidget::COutputWidget(QWidget* parent, const char* name) :
> // KEdit(parent,name)
> QMultiLineEdit(parent, name)
> @@ -71,6 +75,32 @@ void COutputWidget::insertAtEnd(const QS
> // I'm sure it is possible but I gave in...
> //
>
---------------------------------------------------------------------------
>
> +#if QT_VERSION >= 300
> +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 > 2 && qMajor >= 0 && qMinor > 3) {
> + result = 1;
> + } else {
> + result = 0;
> + }
> + }
> +
> + return (result > 0);
> +}
> +#endif
> +
> CMakeOutputWidget::CMakeOutputWidget(QWidget* parent, const char*
> name) :
> QMultiLineEdit(parent, name),
> m_buf(),
> @@ -85,7 +115,9 @@ CMakeOutputWidget::CMakeOutputWidget(QWi
> 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() ) {
> + styleSheet()->item( "font" )->setDisplayMode(
> QStyleSheetItem::DisplayBlock );
> + }
> #endif
> }
>
> @@ -123,13 +155,8 @@ void CMakeOutputWidget::insertAtEnd(cons
> int index;
> getCursorPosition(¤tPara, &index);
>
> - bool isQt304 = false;
> - if (QString(qVersion()) == "3.0.4") {
> - isQt304 = true;
> - }
> -
> int paraCount;
> - if (!isQt304) {
> + if (isAboveQt303()) {
> paraCount = paragraphs()-1;
> }
> else {
> @@ -151,7 +178,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' && !isAboveQt303()) {
> break;
> }
>
> @@ -298,7 +325,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/06/19 11:27:02
> @@ -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!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
More information about the KDevelop-devel
mailing list