From 6f3622e9e72e0a01763043678cf022a7c6917ffc Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 18 Jun 2009 18:55:10 -0700 Subject: Use const ref for foreach Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 5d89994..b2e424c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -725,7 +725,7 @@ void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args) const QStringList flips = flipRegexp.cap(1).split(QLatin1Char(','), QString::SkipEmptyParts); flipFlags = DSFLIP_NONE; - foreach (QString flip, flips) { + foreach(const QString &flip, flips) { if (flip == QLatin1String("wait")) flipFlags = DFBSurfaceFlipFlags(flipFlags | DSFLIP_WAIT); else if (flip == QLatin1String("blit")) -- cgit v0.12 From 70db717f8a6bbdb52ea22feacf2ced4fbea8fd1c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Sun, 21 Jun 2009 20:29:44 -0700 Subject: Bail out on invalid color in fillRect Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index e8cccfd..176c6fa 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -686,8 +686,11 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) if (!d->unsupportedCompositionMode && d->dfbCanHandleClip(rect) && !d->matrixRotShear) { switch (brush.style()) { case Qt::SolidPattern: { + const QColor color = brush.color(); + if (!color.isValid()) + return; d->unlock(); - d->setDFBColor(brush.color()); + d->setDFBColor(color); const QRect r = d->transform.mapRect(rect).toRect(); d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()); @@ -711,6 +714,8 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) { + if (!color.isValid()) + return; Q_D(QDirectFBPaintEngine); d->updateClip(); if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear) { -- cgit v0.12 From 3d0e9c521f4cdc788a7f2335a0d98a811638a9d1 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Sun, 21 Jun 2009 20:44:26 -0700 Subject: Minor optimization No need to set the pen in begin. It's always done before it's used anyway. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 176c6fa..3425d08 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -897,7 +897,6 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) setCompositionMode(q->state()->compositionMode()); dirtyClip = true; setPen(q->state()->pen); - setDFBColor(pen.color()); } void QDirectFBPaintEnginePrivate::end() -- cgit v0.12 From 0a2fa1662cf482736e8c439596d5c057f58e1454 Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Mon, 22 Jun 2009 14:33:42 +1000 Subject: task 226042 Until the PostgreSQL API has this functionality. Use a hack to find out if a transaction has failed or not. This hack is a limited to 8.x versions of PostgreSQL. Bill King --- src/sql/drivers/psql/qsql_psql.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 13cdc01..ed9b98c 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -534,7 +534,7 @@ bool QPSQLResult::prepare(const QString &query) { if (!d->preparedQueriesEnabled) return QSqlResult::prepare(query); - + cleanup(); if (!d->preparedStmtId.isEmpty()) @@ -824,7 +824,20 @@ bool QPSQLDriver::commitTransaction() return false; } PGresult* res = PQexec(d->connection, "COMMIT"); - if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { + + bool transaction_failed = false; + + // XXX + // This hack is used to tell if the transaction has succeeded for the protocol versions of + // PostgreSQL below. For 7.x and other protocol versions we are left in the dark. + // This hack can dissapear once there is an API to query this sort of information. + if (d->pro == QPSQLDriver::Version8 || + d->pro == QPSQLDriver::Version81 || + d->pro == QPSQLDriver::Version82) { + transaction_failed = QByteArray(PQcmdStatus(res)) == QByteArray("ROLLBACK")?true:false; + } + + if (!res || PQresultStatus(res) != PGRES_COMMAND_OK || transaction_failed) { PQclear(res); setLastError(qMakeError(tr("Could not commit transaction"), QSqlError::TransactionError, d)); @@ -1172,12 +1185,12 @@ bool QPSQLDriver::subscribeToNotificationImplementation(const QString &name) qPrintable(name)); return false; } - + int socket = PQsocket(d->connection); if (socket) { QString query = QString(QLatin1String("LISTEN %1")).arg(escapeIdentifier(name, QSqlDriver::TableName)); - if (PQresultStatus(PQexec(d->connection, - d->isUtf8 ? query.toUtf8().constData() + if (PQresultStatus(PQexec(d->connection, + d->isUtf8 ? query.toUtf8().constData() : query.toLocal8Bit().constData()) ) != PGRES_COMMAND_OK) { setLastError(qMakeError(tr("Unable to subscribe"), QSqlError::StatementError, d)); @@ -1208,8 +1221,8 @@ bool QPSQLDriver::unsubscribeFromNotificationImplementation(const QString &name) } QString query = QString(QLatin1String("UNLISTEN %1")).arg(escapeIdentifier(name, QSqlDriver::TableName)); - if (PQresultStatus(PQexec(d->connection, - d->isUtf8 ? query.toUtf8().constData() + if (PQresultStatus(PQexec(d->connection, + d->isUtf8 ? query.toUtf8().constData() : query.toLocal8Bit().constData()) ) != PGRES_COMMAND_OK) { setLastError(qMakeError(tr("Unable to unsubscribe"), QSqlError::StatementError, d)); @@ -1242,7 +1255,7 @@ void QPSQLDriver::_q_handleNotification(int) if (d->seid.contains(name)) emit notification(name); else - qWarning("QPSQLDriver: received notification for '%s' which isn't subscribed to.", + qWarning("QPSQLDriver: received notification for '%s' which isn't subscribed to.", qPrintable(name)); qPQfreemem(notify); -- cgit v0.12 From 1a2a6c152dbb467f31bd809098a19f4c90c6d48f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 22 Jun 2009 09:57:38 +0200 Subject: Fix crash in widget box when using load mode "LoadCustomWidgetsOnly" When loading the widget box with load mode "LoadCustomWidgetsOnly", it will create an empty category. This will indirectly cause a resize event to be posted for the tree widget of the widget box, which in turn will cause adjustSubListSize() to be called for each category item in the tree widget. Since the category has not yet been populated, the assumption in adjustSubListSize() that cat_item->child(0) is non-null would cause a crash. The fix is to return immediately if the category is empty. Reviewed-by: Friedemann Kleint --- tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp index 99dfb9c..38e3501 100644 --- a/tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp +++ b/tools/designer/src/components/widgetbox/widgetboxtreewidget.cpp @@ -664,6 +664,9 @@ WidgetBoxTreeWidget::CategoryList WidgetBoxTreeWidget::loadCustomCategoryList() void WidgetBoxTreeWidget::adjustSubListSize(QTreeWidgetItem *cat_item) { QTreeWidgetItem *embedItem = cat_item->child(0); + if (embedItem == 0) + return; + WidgetBoxCategoryListView *list_widget = static_cast(itemWidget(embedItem, 0)); list_widget->setFixedWidth(header()->width()); list_widget->doItemsLayout(); -- cgit v0.12 From 4c515cebc653e44fe6374058b205610592128ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 22 Jun 2009 10:45:48 +0200 Subject: Fixed wrong painting when doing IntersectClip after setClipping(false). The documentation is a bit ambiguous on what the expected behavior here is, but the behavior was consistent across paint engines before 4.5. QPaintEngineEx introduced inconsistencies in the raster and OpenGL paint engines, so this patch reverts the behavior back to what it was in 4.4. Task-number: 256549 Reviewed-by: Trond --- src/gui/painting/qpaintengine_raster.cpp | 2 ++ src/gui/painting/qpainter.cpp | 23 ++++++++++++----------- tests/arthur/data/qps/clipping_state.qps | 15 +++++++++++++++ tests/arthur/data/qps/clipping_state_qps.png | Bin 5089 -> 5133 bytes 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 84af880..8e91101 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1315,6 +1315,7 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) delete s->clip; s->clip = clip; + s->clip->enabled = true; s->flags.has_clip_ownership = true; } else { // intersect clip with current clip @@ -1331,6 +1332,7 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) s->clip->setClipRect(base->clipRect & clipRect); else s->clip->setClipRegion(base->clipRegion & clipRect); + s->clip->enabled = true; } else { QPaintEngineEx::clip(rect, op); return; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3a5746a..d6c1c74 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2565,6 +2565,9 @@ void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op) Q_D(QPainter); if (d->extended) { + if (!hasClipping() && (op == Qt::IntersectClip || op == Qt::UniteClip)) + op = Qt::ReplaceClip; + if (!d->engine) { qWarning("QPainter::setClipRect: Painter not active"); return; @@ -2618,6 +2621,9 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) return; } + if (!hasClipping() && (op == Qt::IntersectClip || op == Qt::UniteClip)) + op = Qt::ReplaceClip; + if (d->extended) { d->state->clipEnabled = true; d->extended->clip(rect, op); @@ -2626,9 +2632,6 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) return; } - if (!hasClipping() && (op == Qt::IntersectClip || op == Qt::UniteClip)) - op = Qt::ReplaceClip; - d->state->clipRegion = rect; d->state->clipOperation = op; if (op == Qt::NoClip || op == Qt::ReplaceClip) @@ -2671,6 +2674,9 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) return; } + if (!hasClipping() && (op == Qt::IntersectClip || op == Qt::UniteClip)) + op = Qt::ReplaceClip; + if (d->extended) { d->state->clipEnabled = true; d->extended->clip(r, op); @@ -2679,9 +2685,6 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) return; } - if (!hasClipping() && (op == Qt::IntersectClip || op == Qt::UniteClip)) - op = Qt::ReplaceClip; - d->state->clipRegion = r; d->state->clipOperation = op; if (op == Qt::NoClip || op == Qt::ReplaceClip) @@ -3068,6 +3071,9 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) return; } + if (!hasClipping() && (op == Qt::IntersectClip || op == Qt::UniteClip)) + op = Qt::ReplaceClip; + if (d->extended) { d->state->clipEnabled = true; d->extended->clip(path, op); @@ -3076,11 +3082,6 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) return; } - - - if (!hasClipping() && (op == Qt::IntersectClip || op == Qt::UniteClip)) - op = Qt::ReplaceClip; - d->state->clipPath = path; d->state->clipOperation = op; if (op == Qt::NoClip || op == Qt::ReplaceClip) diff --git a/tests/arthur/data/qps/clipping_state.qps b/tests/arthur/data/qps/clipping_state.qps index fd9a80a..3a66122 100644 --- a/tests/arthur/data/qps/clipping_state.qps +++ b/tests/arthur/data/qps/clipping_state.qps @@ -55,3 +55,18 @@ setClipping true setBrush #6300ff00 drawRect 25 25 50 50 + +# disable clipping followed by setClipRect +translate 150 0 + +setClipRect 0 0 50 50 ReplaceClip + +setClipping false + +setBrush #630000ff +drawRect 0 0 100 100 + +setClipRect 25 25 75 75 IntersectClip + +setBrush #6300ff00 +drawRect 25 25 50 50 diff --git a/tests/arthur/data/qps/clipping_state_qps.png b/tests/arthur/data/qps/clipping_state_qps.png index 9b3dee2..28bee46 100644 Binary files a/tests/arthur/data/qps/clipping_state_qps.png and b/tests/arthur/data/qps/clipping_state_qps.png differ -- cgit v0.12 From 5281f264dc605766ba82c36fc2c88055234824ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Mon, 22 Jun 2009 10:09:53 +0200 Subject: Moving a child widget right after show() does not work as expected. The problem was that we did an accelerated move, i.e. scrolled the widget's contents in the backing store and repainted the old area. We cannot do this trick when the widget has been invalidated (show(), resize()). In this case the widget had never been painted, so we basically scrolled the content of its parent and the widget itself appeared as invisible. Auto-test included. Task-number: 255117 Reviewed-by: Paul --- src/gui/painting/qbackingstore.cpp | 5 ++++- tests/auto/qwidget/tst_qwidget.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 0f7933c..3bbdf7f 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -258,7 +258,10 @@ void QWidgetBackingStore::unflushPaint(QWidget *widget, const QRegion &rgn) bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *widget) { const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft())); - return windowSurface->scroll(QRect(pos, rect.size()), dx, dy); + const QRect tlwRect(QRect(pos, rect.size())); + if (dirty.intersects(tlwRect)) + return false; // We don't want to scroll junk. + return windowSurface->scroll(tlwRect, dx, dy); } void QWidgetBackingStore::releaseBuffer() diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index a6458a5..e65fef1 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -252,6 +252,7 @@ private slots: void moveChild_data(); void moveChild(); + void showAndMoveChild(); void subtractOpaqueSiblings(); @@ -5303,6 +5304,33 @@ void tst_QWidget::moveChild() parent.color); } +void tst_QWidget::showAndMoveChild() +{ + QWidget parent(0, Qt::FramelessWindowHint); + parent.resize(300, 300); + parent.setPalette(Qt::red); + parent.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&parent); +#endif + QTest::qWait(200); + + const QPoint tlwOffset = parent.geometry().topLeft(); + QWidget child(&parent); + child.resize(100, 100); + child.setPalette(Qt::blue); + child.setAutoFillBackground(true); + + // Ensure that the child is repainted correctly when moved right after show. + // NB! Do NOT processEvents() (or qWait()) in between show() and move(). + child.show(); + child.move(150, 150); + qApp->processEvents(); + + VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue); + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); +} + void tst_QWidget::subtractOpaqueSiblings() { #ifdef QT_MAC_USE_COCOA -- cgit v0.12 From 684c43db2b5b0eda94c6893075146fa0e44f2f22 Mon Sep 17 00:00:00 2001 From: Marius Bugge Monsen Date: Mon, 22 Jun 2009 13:08:46 +0200 Subject: Check if the row larger or equal to the flowPositions vector to prevent out of bounds access. This problem is encountered if a model doesn't report it's changes correctly. Reviewed-by: Thierry Task-number: 256617 --- src/gui/itemviews/qlistview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index d2fa9a5..d410a57 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -2232,7 +2232,7 @@ QListViewItem QStaticListViewBase::indexToListViewItem(const QModelIndex &index) { if (flowPositions.isEmpty() || segmentPositions.isEmpty() - || index.row() > flowPositions.count()) + || index.row() >= flowPositions.count()) return QListViewItem(); const int segment = qBinarySearch(segmentStartRows, index.row(), -- cgit v0.12 From bbc8e0c87e0969478ad958684a4111920ccd6567 Mon Sep 17 00:00:00 2001 From: Marius Bugge Monsen Date: Mon, 22 Jun 2009 14:34:29 +0200 Subject: Check for null pointer in QGraphicsProxyWidget::event() in case there is no focusWidget(). Reviewed-by: Thierry Task-number: 255468 --- src/gui/graphicsview/qgraphicsproxywidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp index 98fe51d..65f315c 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget.cpp +++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp @@ -840,7 +840,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) // ### Qt 4.5: this code must also go into a reimplementation // of inputMethodEvent(). QWidget *focusWidget = d->widget->focusWidget(); - if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) + if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) QApplication::sendEvent(focusWidget, event); break; } -- cgit v0.12 From ab3a7760008ed6723f978a06aa52bee57b34d68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 22 Jun 2009 15:00:24 +0200 Subject: Fixed drawTiledPixmap() for the GL paint engine. The offset was completely ignored for the GL 1 paint engine. Task-number: 256608 Reviewed-by: Samuel --- src/opengl/qpaintengine_opengl.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 20d003e..84151ee 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -973,7 +973,7 @@ public: bool isFastRect(const QRectF &r); void drawImageAsPath(const QRectF &r, const QImage &img, const QRectF &sr); - void drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy); + void drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy, const QPointF &offset); void drawOffscreenPath(const QPainterPath &path); @@ -4431,7 +4431,8 @@ void QOpenGLPaintEnginePrivate::drawImageAsPath(const QRectF &r, const QImage &i brush_origin = old_brush_origin; } -void QOpenGLPaintEnginePrivate::drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy) +void QOpenGLPaintEnginePrivate::drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy, + const QPointF &offset) { QBrush old_brush = cbrush; QPointF old_brush_origin = brush_origin; @@ -4439,6 +4440,7 @@ void QOpenGLPaintEnginePrivate::drawTiledImageAsPath(const QRectF &r, const QIma QTransform brush_matrix; brush_matrix.translate(r.left(), r.top()); brush_matrix.scale(sx, sy); + brush_matrix.translate(-offset.x(), -offset.y()); cbrush = QBrush(img); cbrush.setTransform(brush_matrix); @@ -4515,7 +4517,7 @@ void QOpenGLPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QR } } -void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &) +void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &offset) { Q_D(QOpenGLPaintEngine); @@ -4525,7 +4527,7 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con int rw = qCeil(r.width()); int rh = qCeil(r.height()); if (rw < pm.width() && rh < pm.height()) { - drawTiledPixmap(r, pm.copy(0, 0, rw, rh), QPointF()); + drawTiledPixmap(r, pm.copy(0, 0, rw, rh), offset); return; } @@ -4534,11 +4536,11 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con if (d->composition_mode > QPainter::CompositionMode_Plus || (d->high_quality_antialiasing && !d->isFastRect(r))) { if (scaled.isNull()) - d->drawTiledImageAsPath(r, pm.toImage(), 1, 1); + d->drawTiledImageAsPath(r, pm.toImage(), 1, 1, offset); else { const qreal sx = pm.width() / qreal(scaled.width()); const qreal sy = pm.height() / qreal(scaled.height()); - d->drawTiledImageAsPath(r, scaled, sx, sy); + d->drawTiledImageAsPath(r, scaled, sx, sy, offset); } } else { d->flushDrawQueue(); @@ -4569,8 +4571,12 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con q_vertexType vertexArray[4*2]; q_vertexType texCoordArray[4*2]; + double offset_x = offset.x() / pm.width(); + double offset_y = offset.y() / pm.height(); + qt_add_rect_to_array(r, vertexArray); - qt_add_texcoords_to_array(0, 0, tc_w, tc_h, texCoordArray); + qt_add_texcoords_to_array(offset_x, offset_y, + tc_w + offset_x, tc_h + offset_y, texCoordArray); glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray); -- cgit v0.12 From 938592604e3689f4369d5babd2387ec8af8839bb Mon Sep 17 00:00:00 2001 From: jasplin Date: Mon, 22 Jun 2009 14:58:48 +0200 Subject: Prevented QWizard from crashing upon removing a page after deleting a field object. QWizard crashed when removing a page after deleting an object that was already registered as a field for the page. This patch prevents such a crash by doing the necessary cleanup immediately when the object is deleted. QWizard::removePage() will then see a consistent state in this case. Reviewed-by: janarve Task-number: 255350 --- src/gui/dialogs/qwizard.cpp | 25 +++++++++++++++++++++++++ src/gui/dialogs/qwizard.h | 1 + tests/auto/qwizard/tst_qwizard.cpp | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp index 2387134..6859fc9 100644 --- a/src/gui/dialogs/qwizard.cpp +++ b/src/gui/dialogs/qwizard.cpp @@ -560,6 +560,7 @@ public: void enableUpdates(); void _q_emitCustomButtonClicked(); void _q_updateButtonStates(); + void _q_handleFieldObjectDestroyed(QObject *); void setStyle(QStyle *style); #ifdef Q_WS_MAC static QPixmap findDefaultBackgroundPixmap(); @@ -731,6 +732,8 @@ void QWizardPrivate::cleanupPagesNotInHistory() void QWizardPrivate::addField(const QWizardField &field) { + Q_Q(QWizard); + QWizardField myField = field; myField.resolve(defaultPropertyTable); @@ -744,15 +747,23 @@ void QWizardPrivate::addField(const QWizardField &field) if (myField.mandatory && !myField.changedSignal.isEmpty()) QObject::connect(myField.object, myField.changedSignal, myField.page, SLOT(_q_maybeEmitCompleteChanged())); + QObject::connect( + myField.object, SIGNAL(destroyed(QObject *)), q, + SLOT(_q_handleFieldObjectDestroyed(QObject *))); } void QWizardPrivate::removeFieldAt(int index) { + Q_Q(QWizard); + const QWizardField &field = fields.at(index); fieldIndexMap.remove(field.name); if (field.mandatory && !field.changedSignal.isEmpty()) QObject::disconnect(field.object, field.changedSignal, field.page, SLOT(_q_maybeEmitCompleteChanged())); + QObject::disconnect( + field.object, SIGNAL(destroyed(QObject *)), q, + SLOT(_q_handleFieldObjectDestroyed(QObject *))); fields.remove(index); } @@ -1591,6 +1602,20 @@ void QWizardPrivate::_q_updateButtonStates() enableUpdates(); } +void QWizardPrivate::_q_handleFieldObjectDestroyed(QObject *object) +{ + QVector::iterator it = fields.begin(); + while (it != fields.end()) { + const QWizardField &field = *it; + if (field.object == object) { + fieldIndexMap.remove(field.name); + it = fields.erase(it); + } else { + ++it; + } + } +} + void QWizardPrivate::setStyle(QStyle *style) { for (int i = 0; i < QWizard::NButtons; i++) diff --git a/src/gui/dialogs/qwizard.h b/src/gui/dialogs/qwizard.h index 1d1a9b5..d1f9cf7 100644 --- a/src/gui/dialogs/qwizard.h +++ b/src/gui/dialogs/qwizard.h @@ -197,6 +197,7 @@ private: Q_DECLARE_PRIVATE(QWizard) Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked()) Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates()) + Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *)) friend class QWizardPage; }; diff --git a/tests/auto/qwizard/tst_qwizard.cpp b/tests/auto/qwizard/tst_qwizard.cpp index 71e1c3e..e5074b3 100644 --- a/tests/auto/qwizard/tst_qwizard.cpp +++ b/tests/auto/qwizard/tst_qwizard.cpp @@ -112,6 +112,7 @@ private slots: void task161658_alignments(); void task177022_setFixedSize(); void task248107_backButton(); + void task255350_fieldObjectDestroyed(); /* Things that could be added: @@ -2517,5 +2518,26 @@ void tst_QWizard::task248107_backButton() QCOMPARE(wizard.currentPage(), &page1); } +class WizardPage_task255350 : public QWizardPage +{ +public: + QLineEdit *lineEdit; + WizardPage_task255350() + : lineEdit(new QLineEdit) + { + registerField("dummy*", lineEdit); + } +}; + +void tst_QWizard::task255350_fieldObjectDestroyed() +{ + QWizard wizard; + WizardPage_task255350 *page = new WizardPage_task255350; + int id = wizard.addPage(page); + delete page->lineEdit; + wizard.removePage(id); // don't crash! + delete page; +} + QTEST_MAIN(tst_QWizard) #include "tst_qwizard.moc" -- cgit v0.12 From c5fefd136d77b4721575c59e28f38ac7d9475f23 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 23 Jun 2009 15:18:20 +1000 Subject: Fixes non-unicode strings should be strings, not bytearrays. Passes all autotests. Task-number: 251739 --- src/sql/drivers/odbc/qsql_odbc.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 3142cce..87522e0 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -90,7 +90,6 @@ public: : hEnv(0), hDbc(0), useSchema(false), disconnectCount(0), isMySqlServer(false), isMSSqlServer(false), hasSQLFetchScroll(true), hasMultiResultSets(false) { - sql_char_type = sql_varchar_type = sql_longvarchar_type = QVariant::ByteArray; unicode = false; } @@ -99,9 +98,6 @@ public: uint unicode :1; uint useSchema :1; - QVariant::Type sql_char_type; - QVariant::Type sql_varchar_type; - QVariant::Type sql_longvarchar_type; int disconnectCount; bool isMySqlServer; bool isMSSqlServer; @@ -125,7 +121,6 @@ public: QODBCPrivate() : hEnv(0), hDbc(0), hStmt(0), useSchema(false), hasSQLFetchScroll(true), precisionPolicy(QSql::HighPrecision) { - sql_char_type = sql_varchar_type = sql_longvarchar_type = QVariant::ByteArray; unicode = false; } @@ -138,9 +133,6 @@ public: uint unicode :1; uint useSchema :1; - QVariant::Type sql_char_type; - QVariant::Type sql_varchar_type; - QVariant::Type sql_longvarchar_type; QSqlRecord rInf; QVector fieldCache; @@ -291,14 +283,10 @@ static QVariant::Type qDecodeODBCType(SQLSMALLINT sqltype, const T* p, bool isSi break; #endif case SQL_CHAR: - type = p->sql_char_type; - break; case SQL_VARCHAR: case SQL_GUID: - type = p->sql_varchar_type; - break; case SQL_LONGVARCHAR: - type = p->sql_longvarchar_type; + type = QVariant::String; break; default: type = QVariant::ByteArray; @@ -713,9 +701,6 @@ QODBCResult::QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p) d->hDbc = p->hDbc; d->unicode = p->unicode; d->useSchema = p->useSchema; - d->sql_char_type = p->sql_char_type; - d->sql_varchar_type = p->sql_varchar_type; - d->sql_longvarchar_type = p->sql_longvarchar_type; d->disconnectCount = p->disconnectCount; d->hasSQLFetchScroll = p->hasSQLFetchScroll; } @@ -1782,7 +1767,6 @@ void QODBCDriverPrivate::checkUnicode() sizeof(fFunc), NULL); if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WCHAR)) { - sql_char_type = QVariant::String; unicode = true; } -- cgit v0.12 From af6fb86be2fc711cbaf10a482ad84d6f207f5d27 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 23 Jun 2009 15:51:07 +1000 Subject: make the last checkin compile. --- src/sql/drivers/odbc/qsql_odbc.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 87522e0..e0aa9b5 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -1776,7 +1776,6 @@ void QODBCDriverPrivate::checkUnicode() sizeof(fFunc), NULL); if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WVARCHAR)) { - sql_varchar_type = QVariant::String; unicode = true; } @@ -1786,7 +1785,6 @@ void QODBCDriverPrivate::checkUnicode() sizeof(fFunc), NULL); if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WLONGVARCHAR)) { - sql_longvarchar_type = QVariant::String; unicode = true; } } -- cgit v0.12 From 764a3dd99072cde27fdf7887cd40f4db54796781 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Tue, 23 Jun 2009 10:33:05 +0200 Subject: Doc - Adding Pierre Rossi's frozen column example Reviewed-By: TrustMe --- .../diagrams/frozencolumn/tableview-overlay.svg | 240 +++++++++++++++++++++ doc/src/examples/frozencolumn.qdoc | 147 +++++++++++++ doc/src/images/frozencolumn-example.png | Bin 0 -> 41102 bytes doc/src/images/frozencolumn-tableview.png | Bin 0 -> 22942 bytes .../itemviews/frozencolumn/freezetablewidget.cpp | 159 ++++++++++++++ .../itemviews/frozencolumn/freezetablewidget.h | 73 +++++++ examples/itemviews/frozencolumn/frozencolumn.pro | 9 + examples/itemviews/frozencolumn/grades.qrc | 5 + examples/itemviews/frozencolumn/grades.txt | 35 +++ examples/itemviews/frozencolumn/main.cpp | 90 ++++++++ 10 files changed, 758 insertions(+) create mode 100644 doc/src/diagrams/frozencolumn/tableview-overlay.svg create mode 100644 doc/src/examples/frozencolumn.qdoc create mode 100644 doc/src/images/frozencolumn-example.png create mode 100644 doc/src/images/frozencolumn-tableview.png create mode 100644 examples/itemviews/frozencolumn/freezetablewidget.cpp create mode 100644 examples/itemviews/frozencolumn/freezetablewidget.h create mode 100644 examples/itemviews/frozencolumn/frozencolumn.pro create mode 100644 examples/itemviews/frozencolumn/grades.qrc create mode 100644 examples/itemviews/frozencolumn/grades.txt create mode 100644 examples/itemviews/frozencolumn/main.cpp diff --git a/doc/src/diagrams/frozencolumn/tableview-overlay.svg b/doc/src/diagrams/frozencolumn/tableview-overlay.svg new file mode 100644 index 0000000..fafdc23 --- /dev/null +++ b/doc/src/diagrams/frozencolumn/tableview-overlay.svg @@ -0,0 +1,240 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + horizontal header + + viewport + + + + vertical header + + + + + + scrollbars + + + + second QTableView + + diff --git a/doc/src/examples/frozencolumn.qdoc b/doc/src/examples/frozencolumn.qdoc new file mode 100644 index 0000000..e5a3b59 --- /dev/null +++ b/doc/src/examples/frozencolumn.qdoc @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example itemviews/frozencolumn + \title Frozen Column Example + + This example demonstrates how to freeze a column within a QTableView. + + \image frozencolumn-example.png "Screenshot of the example" + + We use Qt's model/view framework to implement a table with its first + column frozen. This technique can be aplied to several columns or rows, + as long as they are on the edge of the table. + + The model/view framework allows for one model to be displayed in different + ways using multiple views. For this example, we use two views on the same + model - two \l {QTableView}{table views} sharing one model. The frozen + column is a child of the main tableview, and we provide the desired visual + effect using an overlay technique which will be described step by step in + the coming sections. + + \image frozencolumn-tableview.png + + + \section1 FreezeTableWidget Class Definition + + The \c FreezeTableWidget class has a constructor and a destructor. Also, it + has two private members: the table view that we will use as an overlay, and + the shared model for both table views. Two slots are added to help keep the + section sizes in sync, as well as a function to readjust the frozen + column's geometry. In addition, we reimplement two functions: + \l{QAbstractItemView::}{resizeEvent()} and \l{QTableView::}{moveCursor()}. + + \snippet examples/itemviews/frozencolumn/freezetablewidget.h Widget definition + + \note QAbstractItemView is \l{QTableView}'s ancestor. + + + \section1 FreezeTableWidget Class Implementation + + The constructor takes \a model as an argument and creates a table view that + we will use to display the frozen column. Then, within the constructor, we + invoke the \c init() function to set up the frozen column. Finally, we + connect the \l{QHeaderView::sectionResized()} signals (for horizontal and + vertical headers) to the appropriate slots. This ensures that our frozen + column's sections are in sync with the headers. We also connect the + vertical scrollbars together so that the frozen column scrolls vertically + with the rest of our table. + + \snippet examples/itemviews/frozencolumn/freezetablewidget.cpp constructor + + + In the \c init() function, we ensure that the overlay table view + responsible for displaying the frozen column, is set up properly. This + means that this table view, \c frozenTableView, has to have the same model + as the main table view. However, the difference here is: \c frozenTableView's + only visible column is its first column; we hide the others using + \l{QTableView::}{setColumnHidden()} + + \snippet examples/itemviews/frozencolumn/freezetablewidget.cpp init part1 + + + In terms of the frozen column's z-order, we stack it on top of the + viewport. This is achieved by calling \l{QWidget::}{stackUnder()} on the + viewport. For appearance's sake, we prevent the column from stealing focus + from the main tableview. Also, we make sure that both views share the same + selection model, so only one cell can be selected at a time. A few other + tweaks are done to make our application look good and behave consistently + with the main tableview. Note that we called \c updateFrozenTableGeometry() + to make the column occupy the correct spot. + + \snippet examples/itemviews/frozencolumn/freezetablewidget.cpp init part2 + + When you resize the frozen column, the same column on the main table view + must resize accordingly, to provide seamless integration. This is + accomplished by getting the new size of the column from the \c newSize + value from the \l{QHeaderView::}{sectionResized()} signal, emitted by both + the horizontal and vertical header. + + \snippet examples/itemviews/frozencolumn/freezetablewidget.cpp sections + + Since the width of the frozen column is modified, we adjust the geometry of + the widget accordingly by invoking \c updateFrozenTableGeometry(). This + function is further explained below. + + In our reimplementation of QTableView::resizeEvent(), we call + \c updateFrozenTableGeometry() after invoking the base class + implementation. + + \snippet examples/itemviews/frozencolumn/freezetablewidget.cpp resize + + When navigating around the table with the keyboard, we need to ensure that + the current selection does not disappear behind the frozen column. To + synchronize this, we reimplement QTableView::moveCursor() and adjust the + scrollbar positions if needed, after calling the base class implementation. + + \snippet examples/itemviews/frozencolumn/freezetablewidget.cpp navigate + + The frozen column's geometry calculation is based on the geometry of the + table underneath, so it always appears in the right place. Using the + QFrame::frameWidth() function helps to calculate this geometry correctly, + no matter which style is used. We rely on the geometry of the viewport and + headers to set the boundaries for the frozen column. + + \snippet examples/itemviews/frozencolumn/freezetablewidget.cpp geometry + +*/ + diff --git a/doc/src/images/frozencolumn-example.png b/doc/src/images/frozencolumn-example.png new file mode 100644 index 0000000..66b5c10 Binary files /dev/null and b/doc/src/images/frozencolumn-example.png differ diff --git a/doc/src/images/frozencolumn-tableview.png b/doc/src/images/frozencolumn-tableview.png new file mode 100644 index 0000000..d829ff5 Binary files /dev/null and b/doc/src/images/frozencolumn-tableview.png differ diff --git a/examples/itemviews/frozencolumn/freezetablewidget.cpp b/examples/itemviews/frozencolumn/freezetablewidget.cpp new file mode 100644 index 0000000..7a9a8df --- /dev/null +++ b/examples/itemviews/frozencolumn/freezetablewidget.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "freezetablewidget.h" + +//! [constructor] +FreezeTableWidget::FreezeTableWidget(QAbstractItemModel * model) +{ + setModel(model); + frozenTableView = new QTableView(this); + + init(); + + //connect the headers and scrollbars of both tableviews together + connect(horizontalHeader(),SIGNAL(sectionResized ( int ,int,int )), this, + SLOT(updateSectionWidth(int, int, int))); + connect(verticalHeader(),SIGNAL(sectionResized ( int ,int,int )), this, + SLOT(updateSectionHeight(int, int, int))); + + connect(frozenTableView->verticalScrollBar(), SIGNAL(valueChanged(int)), + verticalScrollBar(), SLOT(setValue(int))); + connect(verticalScrollBar(), SIGNAL(valueChanged(int)), + frozenTableView->verticalScrollBar(), SLOT(setValue(int))); + + +} +//! [constructor] + +FreezeTableWidget::~FreezeTableWidget() +{ + delete frozenTableView; +} + +//! [init part1] +void FreezeTableWidget::init() +{ + frozenTableView->setModel(model()); + frozenTableView->setFocusPolicy(Qt::NoFocus); + frozenTableView->verticalHeader()->hide(); + frozenTableView->horizontalHeader()->setResizeMode(QHeaderView::Fixed); + + viewport()->stackUnder(frozenTableView); +//! [init part1] + +//! [init part2] + frozenTableView->setStyleSheet("QTableView { border: none;" + "background-color: #8EDE21;}"); //for demo purposes + frozenTableView->setSelectionModel(selectionModel()); + for(int col=1; colcolumnCount(); col++) + frozenTableView->setColumnHidden(col, true); + + frozenTableView->setColumnWidth(0, columnWidth(0) ); + + frozenTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + frozenTableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + frozenTableView->show(); + + updateFrozenTableGeometry(); + + setHorizontalScrollMode(ScrollPerPixel); + setVerticalScrollMode(ScrollPerPixel); + frozenTableView->setVerticalScrollMode(ScrollPerPixel); +} +//! [init part2] + + +//! [sections] +void FreezeTableWidget::updateSectionWidth(int logicalIndex, int, int newSize) +{ + if(logicalIndex==0){ + frozenTableView->setColumnWidth(0,newSize); + updateFrozenTableGeometry(); + } +} + +void FreezeTableWidget::updateSectionHeight(int logicalIndex, int, int newSize) +{ + frozenTableView->setRowHeight(logicalIndex, newSize); +} +//! [sections] + + +//! [resize] +void FreezeTableWidget::resizeEvent(QResizeEvent * event) +{ + QTableView::resizeEvent(event); + updateFrozenTableGeometry(); + } +//! [resize] + + +//! [navigate] +QModelIndex FreezeTableWidget::moveCursor(CursorAction cursorAction, + Qt::KeyboardModifiers modifiers) +{ + QModelIndex current = QTableView::moveCursor(cursorAction, modifiers); + + if(cursorAction == MoveLeft && current.column()>0 + && visualRect(current).topLeft().x() < frozenTableView->columnWidth(0) ){ + + const int newValue = horizontalScrollBar()->value() + visualRect(current).topLeft().x() + - frozenTableView->columnWidth(0); + horizontalScrollBar()->setValue(newValue); + } + return current; +} +//! [navigate] + + +//! [geometry] +void FreezeTableWidget::updateFrozenTableGeometry() +{ + frozenTableView->setGeometry( verticalHeader()->width()+frameWidth(), + frameWidth(), columnWidth(0), + viewport()->height()+horizontalHeader()->height()); +} +//! [geometry] + + diff --git a/examples/itemviews/frozencolumn/freezetablewidget.h b/examples/itemviews/frozencolumn/freezetablewidget.h new file mode 100644 index 0000000..2abae47 --- /dev/null +++ b/examples/itemviews/frozencolumn/freezetablewidget.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef FREEZETABLEWIDGET_H +#define FREEZETABLEWIDGET_H + +#include + +//! [Widget definition] +class FreezeTableWidget : public QTableView { + Q_OBJECT + +public: + FreezeTableWidget(QAbstractItemModel * model); + ~FreezeTableWidget(); + + +protected: + virtual void resizeEvent(QResizeEvent *event); + virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers); + +private: + QTableView *frozenTableView; + void init(); + void updateFrozenTableGeometry(); + + +private slots: + void updateSectionWidth(int logicalIndex,int, int newSize); + void updateSectionHeight(int logicalIndex, int, int newSize); + +}; +//! [Widget definition] +#endif diff --git a/examples/itemviews/frozencolumn/frozencolumn.pro b/examples/itemviews/frozencolumn/frozencolumn.pro new file mode 100644 index 0000000..361de5b --- /dev/null +++ b/examples/itemviews/frozencolumn/frozencolumn.pro @@ -0,0 +1,9 @@ +HEADERS += freezetablewidget.h +SOURCES += main.cpp freezetablewidget.cpp +RESOURCES += grades.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/frozencolumn +sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/frozencolumn +INSTALLS += target sources diff --git a/examples/itemviews/frozencolumn/grades.qrc b/examples/itemviews/frozencolumn/grades.qrc new file mode 100644 index 0000000..5f16d56 --- /dev/null +++ b/examples/itemviews/frozencolumn/grades.qrc @@ -0,0 +1,5 @@ + + + grades.txt + + diff --git a/examples/itemviews/frozencolumn/grades.txt b/examples/itemviews/frozencolumn/grades.txt new file mode 100644 index 0000000..4b55b473 --- /dev/null +++ b/examples/itemviews/frozencolumn/grades.txt @@ -0,0 +1,35 @@ + France , Norway , YDS , UK(tech.), UK(adj.) , UIAA , Ger , Australia , Finland , Brazil + +1, , 5.2, , , I , I , , , Isup +2, , 5.3, , , II , II , 11, , II +3, 3, 5.4, , , III , III , 12, , IIsup +4, 4, 5.5, 4a , VD , IV , IV , 12, , III +5a , 5-, 5.6, , S , V- , V , 13, 5-, IIIsup +5b , 5, 5.7, 4b , HS , V , VI , 14, 5, IV + , , , 4c , , V+ , , 15, , +5c , 5+, 5.8, , VS , VI- , VIIa , 16, 5, IVsup +6a , 6-, 5.9, 5a , HVS , VI , VIIb , 17, , V +6a+ , 6-/6 , 5.10a , , E1 , VI+ , VIIc , 18, 6-, VI +6b , , 5.10b , 5b , , , , 19, , VI/VI+ +6b+ , 6, 5.10c , , E2 , VII- , VIIIa , 20, 6, VIsup/VI+ +6c , 6+, 5.10d , 5c , , VII , VIIIb , 21, , VIsup +6c+ , 7-, 5.11a , , E3 , VII+ , VIIIc , 22, 6, 7a +6c+ , 7, 5.11b , , , , , 23, , 7b +7a , 7+, 5.11c , 6a , E4 , VIII- , IXa , 24, 7-, 7c +7a , 7+/8- , 5.11d , , , VIII , IXb , , , 7c +7a+ , 8-, 5.12a , , E5 , VIII+ , IXc , 25, 7, 8a +7b , 8, 5.12b , 6b , , , , 26, 8-, 8b +7b+ , 8/8+ , 5.12c , , E6 , IX- , Xa , 27, 8, 8c +7c , 8+, 5.12d , 6c , , IX , Xb , 28, 8, 9a +7c+ , 9-, 5.13a , , E7 , IX+ , Xc , 29, 9-, 9b +8a , , 5.13b , , , , , , 9, 9c +8a+ , 9-/9 , 5.13c , 7a , , X- , , 30, 9, 10a +8b , 9, 5.13d , , E8 , X , , 31, 10-, 10b +8b+ , 9/9+ , 5.14a , , , X+ , , 32, 10, 10c +8c , 9+, 5.14b , 7b , , , , 33, 10, 11a +8c+ , 10-, 5.14c , , E9 , XI- , , 34, 11-, 11b +9a , 10, 5.14d , 7c , , XI , , 35, 11, 11c +9a+ , , 5.15a , , , XI+ , , , , 12a +9b , , 5.15b , , , , , , , 12b + +# Wikipedia contributors. Grade (climbing). Wikipedia, The Free Encyclopedia. May 15, 2009, 20:42 UTC. Available at: http://en.wikipedia.org/w/index.php?title=Grade_(climbing)&oldid=290165724. Accessed May 28, 2009. diff --git a/examples/itemviews/frozencolumn/main.cpp b/examples/itemviews/frozencolumn/main.cpp new file mode 100644 index 0000000..fdefd73 --- /dev/null +++ b/examples/itemviews/frozencolumn/main.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include + +#include "freezetablewidget.h" + +int main( int argc, char** argv ) +{ + + Q_INIT_RESOURCE(grades); + + + QApplication app( argc, argv ); + QStandardItemModel *model=new QStandardItemModel(); + + + QFile file(":/grades.txt"); + QString line; + QStringList list; + if (file.open(QFile::ReadOnly)) { + line = file.readLine(200); + list= line.simplified().split(","); + model->setHorizontalHeaderLabels(list); + + int row=0; + QStandardItem *newItem=0; + while(file.canReadLine()){ + line = file.readLine(200); + if(!line.startsWith("#") && line.contains(",")){ + list= line.simplified().split(","); + for(int col=0; colsetItem(row ,col, newItem); + } + row++; + } + } + } + file.close(); + + FreezeTableWidget *tableView = new FreezeTableWidget(model); + + tableView->setWindowTitle(QObject::tr("Frozen Column Example")); + tableView->resize(560,680); + tableView->show(); + return app.exec(); +} + -- cgit v0.12 From adf322c514a5781dcb9ec304d44229fa47d5e8b3 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 23 Jun 2009 10:35:02 +0200 Subject: Improve text drawing quality with Carbon Re-enable fractional coordinates for text output, to produce the same output as regular Carbon/ATSUI applications. Reviewed-by: Norwegian Rock Cat --- src/gui/text/qfontengine_mac.mm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index d43ef15..327df45 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -1019,11 +1019,6 @@ bool QFontEngineMacMulti::stringToCMapInternal(const QChar *str, int len, QGlyph | kATSLineDisableAllJustification ; - if (!(flags & QTextEngine::DesignMetrics)) { - layopts |= kATSLineFractDisable | kATSLineUseDeviceMetrics - | kATSLineDisableAutoAdjustDisplayPos; - } - if (fontDef.styleStrategy & QFont::NoAntialias) layopts |= kATSLineNoAntiAliasing; -- cgit v0.12 From 380ffdefaf4a3c2e25992b193e78ffd207fc2a1c Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Tue, 23 Jun 2009 10:50:26 +0200 Subject: Doc - Adding the new Frozen Column Example by Pierre Rossi into our list of examples Reviewed-By: TrustMe --- doc/src/examples.qdoc | 1 + examples/itemviews/itemviews.pro | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/src/examples.qdoc b/doc/src/examples.qdoc index 667f9b7..5329c78 100644 --- a/doc/src/examples.qdoc +++ b/doc/src/examples.qdoc @@ -166,6 +166,7 @@ \o \l{itemviews/dirview}{Dir View} \o \l{itemviews/editabletreemodel}{Editable Tree Model}\raisedaster \o \l{itemviews/fetchmore}{Fetch More}\raisedaster + \o \l{itemviews/frozencolumn}{Frozen Column}\raisedaster \o \l{itemviews/pixelator}{Pixelator}\raisedaster \o \l{itemviews/puzzle}{Puzzle} \o \l{itemviews/simpledommodel}{Simple DOM Model}\raisedaster diff --git a/examples/itemviews/itemviews.pro b/examples/itemviews/itemviews.pro index 6202bbc..7dcf0f6 100644 --- a/examples/itemviews/itemviews.pro +++ b/examples/itemviews/itemviews.pro @@ -8,6 +8,7 @@ SUBDIRS = addressbook \ dirview \ editabletreemodel \ fetchmore \ + frozencolumn \ pixelator \ puzzle \ simpledommodel \ -- cgit v0.12 From 929c5160fd4ff9dc3601e1a6391bea4806d38730 Mon Sep 17 00:00:00 2001 From: kh Date: Tue, 23 Jun 2009 11:22:41 +0200 Subject: Fix missing member initialization. Reviewed-by: ossi --- tools/assistant/lib/fulltextsearch/qanalyzer.cpp | 1 + tools/assistant/lib/fulltextsearch/qdocument.cpp | 1 + tools/assistant/lib/fulltextsearch/qfield.cpp | 1 + tools/assistant/lib/fulltextsearch/qfilter.cpp | 1 + tools/assistant/lib/fulltextsearch/qhits.cpp | 1 + tools/assistant/lib/fulltextsearch/qindexreader.cpp | 1 + tools/assistant/lib/fulltextsearch/qindexwriter.cpp | 1 + tools/assistant/lib/fulltextsearch/qquery.cpp | 1 + tools/assistant/lib/fulltextsearch/qqueryparser.cpp | 1 + tools/assistant/lib/fulltextsearch/qreader.cpp | 3 ++- tools/assistant/lib/fulltextsearch/qsearchable.cpp | 1 + tools/assistant/lib/fulltextsearch/qsort.cpp | 1 + tools/assistant/lib/fulltextsearch/qterm.cpp | 1 + tools/assistant/lib/fulltextsearch/qtoken.cpp | 1 + tools/assistant/lib/fulltextsearch/qtokenstream.cpp | 1 + 15 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/assistant/lib/fulltextsearch/qanalyzer.cpp b/tools/assistant/lib/fulltextsearch/qanalyzer.cpp index 9c380ae..ed018bf 100644 --- a/tools/assistant/lib/fulltextsearch/qanalyzer.cpp +++ b/tools/assistant/lib/fulltextsearch/qanalyzer.cpp @@ -27,6 +27,7 @@ QCLuceneAnalyzerPrivate::QCLuceneAnalyzerPrivate(const QCLuceneAnalyzerPrivate & : QSharedData() { analyzer = _CL_POINTER(other.analyzer); + deleteCLuceneAnalyzer = other.deleteCLuceneAnalyzer; } QCLuceneAnalyzerPrivate::~QCLuceneAnalyzerPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qdocument.cpp b/tools/assistant/lib/fulltextsearch/qdocument.cpp index c2aae98..bad8ea9 100644 --- a/tools/assistant/lib/fulltextsearch/qdocument.cpp +++ b/tools/assistant/lib/fulltextsearch/qdocument.cpp @@ -29,6 +29,7 @@ QCLuceneDocumentPrivate::QCLuceneDocumentPrivate(const QCLuceneDocumentPrivate & : QSharedData() { document = _CL_POINTER(other.document); + deleteCLuceneDocument = other.deleteCLuceneDocument; } QCLuceneDocumentPrivate::~QCLuceneDocumentPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qfield.cpp b/tools/assistant/lib/fulltextsearch/qfield.cpp index 496622d..dc878f3 100644 --- a/tools/assistant/lib/fulltextsearch/qfield.cpp +++ b/tools/assistant/lib/fulltextsearch/qfield.cpp @@ -28,6 +28,7 @@ QCLuceneFieldPrivate::QCLuceneFieldPrivate(const QCLuceneFieldPrivate &other) : QSharedData() { field = _CL_POINTER(other.field); + deleteCLuceneField = other.deleteCLuceneField; } QCLuceneFieldPrivate::~QCLuceneFieldPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qfilter.cpp b/tools/assistant/lib/fulltextsearch/qfilter.cpp index 60a2a1d..837f590 100644 --- a/tools/assistant/lib/fulltextsearch/qfilter.cpp +++ b/tools/assistant/lib/fulltextsearch/qfilter.cpp @@ -26,6 +26,7 @@ QCLuceneFilterPrivate::QCLuceneFilterPrivate(const QCLuceneFilterPrivate &other) : QSharedData() { filter = _CL_POINTER(other.filter); + deleteCLuceneFilter = other.deleteCLuceneFilter; } QCLuceneFilterPrivate::~QCLuceneFilterPrivate () diff --git a/tools/assistant/lib/fulltextsearch/qhits.cpp b/tools/assistant/lib/fulltextsearch/qhits.cpp index 003db17..c2fbf1b 100644 --- a/tools/assistant/lib/fulltextsearch/qhits.cpp +++ b/tools/assistant/lib/fulltextsearch/qhits.cpp @@ -27,6 +27,7 @@ QCLuceneHitsPrivate::QCLuceneHitsPrivate(const QCLuceneHitsPrivate &other) : QSharedData() { hits = _CL_POINTER(other.hits); + deleteCLuceneHits = other.deleteCLuceneHits; } QCLuceneHitsPrivate::~QCLuceneHitsPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qindexreader.cpp b/tools/assistant/lib/fulltextsearch/qindexreader.cpp index a755eae..fc1a3bb 100644 --- a/tools/assistant/lib/fulltextsearch/qindexreader.cpp +++ b/tools/assistant/lib/fulltextsearch/qindexreader.cpp @@ -27,6 +27,7 @@ QCLuceneIndexReaderPrivate::QCLuceneIndexReaderPrivate(const QCLuceneIndexReader : QSharedData() { reader = _CL_POINTER(other.reader); + deleteCLuceneIndexReader = other.deleteCLuceneIndexReader; } QCLuceneIndexReaderPrivate::~QCLuceneIndexReaderPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qindexwriter.cpp b/tools/assistant/lib/fulltextsearch/qindexwriter.cpp index af5a7bb..93e23e7 100644 --- a/tools/assistant/lib/fulltextsearch/qindexwriter.cpp +++ b/tools/assistant/lib/fulltextsearch/qindexwriter.cpp @@ -27,6 +27,7 @@ QCLuceneIndexWriterPrivate::QCLuceneIndexWriterPrivate(const QCLuceneIndexWriter : QSharedData() { writer = _CL_POINTER(other.writer); + deleteCLuceneIndexWriter = other.deleteCLuceneIndexWriter; } QCLuceneIndexWriterPrivate::~QCLuceneIndexWriterPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qquery.cpp b/tools/assistant/lib/fulltextsearch/qquery.cpp index 8bc9607..1760b05 100644 --- a/tools/assistant/lib/fulltextsearch/qquery.cpp +++ b/tools/assistant/lib/fulltextsearch/qquery.cpp @@ -28,6 +28,7 @@ QCLuceneQueryPrivate::QCLuceneQueryPrivate(const QCLuceneQueryPrivate &other) : QSharedData() { query = _CL_POINTER(other.query); + deleteCLuceneQuery = other.deleteCLuceneQuery; } QCLuceneQueryPrivate::~QCLuceneQueryPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qqueryparser.cpp b/tools/assistant/lib/fulltextsearch/qqueryparser.cpp index cbe0147..6f546be 100644 --- a/tools/assistant/lib/fulltextsearch/qqueryparser.cpp +++ b/tools/assistant/lib/fulltextsearch/qqueryparser.cpp @@ -28,6 +28,7 @@ QCLuceneQueryParserPrivate::QCLuceneQueryParserPrivate(const QCLuceneQueryParser : QSharedData() { queryParser = _CL_POINTER(other.queryParser); + deleteCLuceneQueryParser = other.deleteCLuceneQueryParser; } QCLuceneQueryParserPrivate::~QCLuceneQueryParserPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qreader.cpp b/tools/assistant/lib/fulltextsearch/qreader.cpp index fe079a9..3b2d6f5 100644 --- a/tools/assistant/lib/fulltextsearch/qreader.cpp +++ b/tools/assistant/lib/fulltextsearch/qreader.cpp @@ -25,8 +25,9 @@ QCLuceneReaderPrivate::QCLuceneReaderPrivate() QCLuceneReaderPrivate::QCLuceneReaderPrivate(const QCLuceneReaderPrivate &other) : QSharedData() -{ +{ reader = _CL_POINTER(other.reader); + deleteCLuceneReader = other.deleteCLuceneReader; } QCLuceneReaderPrivate::~QCLuceneReaderPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qsearchable.cpp b/tools/assistant/lib/fulltextsearch/qsearchable.cpp index c26868c..70cae91 100644 --- a/tools/assistant/lib/fulltextsearch/qsearchable.cpp +++ b/tools/assistant/lib/fulltextsearch/qsearchable.cpp @@ -26,6 +26,7 @@ QCLuceneSearchablePrivate::QCLuceneSearchablePrivate(const QCLuceneSearchablePri : QSharedData() { searchable = _CL_POINTER(other.searchable); + deleteCLuceneSearchable = other.deleteCLuceneSearchable; } QCLuceneSearchablePrivate::~QCLuceneSearchablePrivate() diff --git a/tools/assistant/lib/fulltextsearch/qsort.cpp b/tools/assistant/lib/fulltextsearch/qsort.cpp index 9c1e902..97ed128 100644 --- a/tools/assistant/lib/fulltextsearch/qsort.cpp +++ b/tools/assistant/lib/fulltextsearch/qsort.cpp @@ -27,6 +27,7 @@ QCLuceneSortPrivate::QCLuceneSortPrivate (const QCLuceneSortPrivate &other) : QSharedData() { sort = _CL_POINTER(other.sort); + deleteCLuceneSort = other.deleteCLuceneSort; } QCLuceneSortPrivate::~QCLuceneSortPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qterm.cpp b/tools/assistant/lib/fulltextsearch/qterm.cpp index 58d5c4d..10a2f3a 100644 --- a/tools/assistant/lib/fulltextsearch/qterm.cpp +++ b/tools/assistant/lib/fulltextsearch/qterm.cpp @@ -27,6 +27,7 @@ QCLuceneTermPrivate::QCLuceneTermPrivate(const QCLuceneTermPrivate &other) : QSharedData() { term = _CL_POINTER(other.term); + deleteCLuceneTerm = other.deleteCLuceneTerm; } QCLuceneTermPrivate::~QCLuceneTermPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qtoken.cpp b/tools/assistant/lib/fulltextsearch/qtoken.cpp index cc5296a..9056a7c 100644 --- a/tools/assistant/lib/fulltextsearch/qtoken.cpp +++ b/tools/assistant/lib/fulltextsearch/qtoken.cpp @@ -27,6 +27,7 @@ QCLuceneTokenPrivate::QCLuceneTokenPrivate(const QCLuceneTokenPrivate &other) : QSharedData() { token = _CL_POINTER(other.token); + deleteCLuceneToken = other.deleteCLuceneToken; } QCLuceneTokenPrivate::~QCLuceneTokenPrivate() diff --git a/tools/assistant/lib/fulltextsearch/qtokenstream.cpp b/tools/assistant/lib/fulltextsearch/qtokenstream.cpp index 8a98c08..0f4ab95 100644 --- a/tools/assistant/lib/fulltextsearch/qtokenstream.cpp +++ b/tools/assistant/lib/fulltextsearch/qtokenstream.cpp @@ -26,6 +26,7 @@ QCLuceneTokenStreamPrivate::QCLuceneTokenStreamPrivate(const QCLuceneTokenStream : QSharedData() { tokenStream = _CL_POINTER(other.tokenStream); + deleteCLuceneTokenStream = other.deleteCLuceneTokenStream; } QCLuceneTokenStreamPrivate::~QCLuceneTokenStreamPrivate() -- cgit v0.12 From 59725e0074541ae18868cc9a9922f8a2e1a8b8df Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Tue, 23 Jun 2009 11:32:28 +0200 Subject: Fix the dash pattern examples in the documentation of QPen The custom dash pattern must have an even number of entries. Our examples were using an odd number. --- doc/src/snippets/code/src_gui_painting_qpen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/snippets/code/src_gui_painting_qpen.cpp b/doc/src/snippets/code/src_gui_painting_qpen.cpp index 538fa09..b5995f7 100644 --- a/doc/src/snippets/code/src_gui_painting_qpen.cpp +++ b/doc/src/snippets/code/src_gui_painting_qpen.cpp @@ -25,7 +25,7 @@ QVector dashes; qreal space = 4; dashes << 1 << space << 3 << space << 9 << space - << 27 << space << 9; + << 27 << space << 9 << space; pen.setDashPattern(dashes); //! [2] @@ -36,6 +36,6 @@ QPen pen; QVector dashes; qreal space = 4; dashes << 1 << space << 3 << space << 9 << space - << 27 << space << 9; + << 27 << space << 9 << space; pen.setDashPattern(dashes); //! [3] -- cgit v0.12 From 29f5f6eeae00fc0890a171398f6717bc543dff38 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 23 Jun 2009 11:36:03 +0200 Subject: add -input-codec option for qm reader basing the input codec on the locale was broken by design and didn't really work anyway. so adding this option really is a bugfix, kind of. --- tools/linguist/lconvert/main.cpp | 8 ++++++++ tools/linguist/shared/qm.cpp | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 336bf31..ddde578 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -85,6 +85,9 @@ static int usage(const QStringList &args) " -of \n" " --output-format \n" " Specify output format. See -if.\n\n" + " --input-codec \n" + " Specify encoding for .qm input files. Default is 'Latin1'.\n" + " UTF-8 is always tried as well, corresponding to the trUtf8() function.\n\n" " --drop-tags \n" " Drop named extra tags when writing 'ts' or 'xlf' files.\n" " May be specified repeatedly.\n\n" @@ -136,6 +139,7 @@ int main(int argc, char *argv[]) bool verbose = false; ConversionData cd; + cd.m_codecForSource = "Latin1"; Translator tr; for (int i = 1; i < args.size(); ++i) { @@ -164,6 +168,10 @@ int main(int argc, char *argv[]) if (++i >= args.size()) return usage(args); inFormat = args[i]; + } else if (args[i] == QLatin1String("-input-codec")) { + if (++i >= args.size()) + return usage(args); + cd.m_codecForSource = args[i].toLatin1(); } else if (args[i] == QLatin1String("-drop-tag")) { if (++i >= args.size()) return usage(args); diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index 14f4c2c..c6f3602 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -545,8 +545,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) size_t numItems = offsetLength / (2 * sizeof(quint32)); //qDebug() << "NUMITEMS: " << numItems; - // FIXME: that's just a guess, the original locale data is lost... - QTextCodec *codec = QTextCodec::codecForLocale(); + QTextCodec *codec = QTextCodec::codecForName(cd.m_codecForSource); QTextCodec *utf8Codec = 0; if (codec->name() != "UTF-8") utf8Codec = QTextCodec::codecForName("UTF-8"); @@ -649,7 +648,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) } if (!(contextIsSystem && sourcetextIsSystem && commentIsSystem)) { cd.appendError(QLatin1String( - "Cannot read file with current system character codec")); + "Cannot read file with specified input codec")); return false; } // The message is 8-bit in the file's encoding (utf-8 or not). -- cgit v0.12 From d710a09bd26728a78963e6ad464540daea46f6a4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 23 Jun 2009 11:37:48 +0200 Subject: mark plural messages as such in the qm reader this contains both a "clean" code path based on translation count and a fallback path based on looking for "%n" (for languages with only one form). --- tools/linguist/shared/qm.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index c6f3602..323bd29 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -550,6 +550,15 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) if (codec->name() != "UTF-8") utf8Codec = QTextCodec::codecForName("UTF-8"); + QString strProN = QLatin1String("%n"); + QLocale::Language l; + QLocale::Country c; + Translator::languageAndCountry(translator.languageCode(), &l, &c); + QStringList numerusForms; + bool guessPlurals = true; + if (getNumerusInfo(l, c, 0, &numerusForms)) + guessPlurals = (numerusForms.count() == 1); + QString context, contextUtf8; bool contextIsSystem, contextIsUtf8, contextNeeds8Bit; QString sourcetext, sourcetextUtf8; @@ -634,6 +643,15 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) end:; TranslatorMessage msg; msg.setType(TranslatorMessage::Finished); + if (translations.count() > 1) { + // If guessPlurals is not false here, plural form discard messages + // will be spewn out later. + msg.setPlural(true); + } else if (guessPlurals) { + // This might cause false positives, so it is a fallback only. + if (sourcetext.contains(strProN)) + msg.setPlural(true); + } msg.setTranslations(translations); translations.clear(); if (contextNeeds8Bit || sourcetextNeeds8Bit || commentNeeds8Bit) { -- cgit v0.12 From 4b43263b870c17fd813d1d34f97146f4c725083e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 12 Jun 2009 14:27:54 +0200 Subject: Attempt to fix header installation for Phonon. This is the long-standing issue of whether Phonon headers should be written with a capital P or a lowercase one. KDE releases of Phonon had whereas Qt 4.4 had . I tried to solve this before by adding a Phonon subdir next to phonon in include/, but that only compounded the error: the presence of two dirs caused problems and the installation wasn't fixed. So instead try to place Phonon/ClassName inside include/phonon. And fix the installation to do it properly: just copy the include/$lib dir into the target, then overwrite the .h files with the sources from src/$lib. Reviewed-by: Marius Storm-Olsen --- bin/syncqt | 46 ++++++++++++++++++++++------------------------ src/qt_install.pri | 16 ++++++++++++---- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index f58a4d1..d6d3c57 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -308,8 +308,6 @@ sub syncHeader { $header =~ s=\\=/=g; return copyFile($iheader, $header) if($copy); - my $iheader_no_basedir = $iheader; - $iheader_no_basedir =~ s,^$basedir/?,,; unless(-e "$header") { my $header_dir = dirname($header); mkpath $header_dir, 0777; @@ -798,10 +796,9 @@ foreach (@modules_to_sync) { my $class = $_; if ($class =~ m/::/) { $class =~ s,::,/,g; - $class = "../" . $class; } $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n"; - $header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", $header, 0)); + $header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0)); } } else { @headers = ( "$out_basedir/include/$lib/private/$header" ); @@ -823,7 +820,6 @@ foreach (@modules_to_sync) { my $class = $_; if ($class =~ m/::/) { $class =~ s,::,/,g; - $class = "../" . $class; } my $class_header = fixPaths("$out_basedir/include/$lib/$class", $current_dir) . " "; @@ -844,25 +840,27 @@ foreach (@modules_to_sync) { $master_contents .= "#endif\n"; unless($showonly) { - #generate the "master" include file - my $master_include = "$out_basedir/include/$lib/$lib"; - $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too - if(-e "$master_include") { - open MASTERINCLUDE, "<$master_include"; - local $/; - binmode MASTERINCLUDE; - my $oldmaster = ; - close MASTERINCLUDE; - $oldmaster =~ s/\r//g; # remove \r's , so comparison is ok on all platforms - $master_include = 0 if($oldmaster eq $master_contents); - } - if($master_include && $master_contents) { - my $master_dir = dirname($master_include); - mkpath $master_dir, 0777; - print "header (master) created for $lib\n"; - open MASTERINCLUDE, ">$master_include"; - print MASTERINCLUDE "$master_contents"; - close MASTERINCLUDE; + unless ($lib eq "phonon") { + #generate the "master" include file + my $master_include = "$out_basedir/include/$lib/$lib"; + $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too + if($master_include && -e "$master_include") { + open MASTERINCLUDE, "<$master_include"; + local $/; + binmode MASTERINCLUDE; + my $oldmaster = ; + close MASTERINCLUDE; + $oldmaster =~ s/\r//g; # remove \r's , so comparison is ok on all platforms + $master_include = 0 if($oldmaster eq $master_contents); + } + if($master_include && $master_contents) { + my $master_dir = dirname($master_include); + mkpath $master_dir, 0777; + print "header (master) created for $lib\n"; + open MASTERINCLUDE, ">$master_include"; + print MASTERINCLUDE "$master_contents"; + close MASTERINCLUDE; + } } #handle the headers.pri for each module diff --git a/src/qt_install.pri b/src/qt_install.pri index 6dd2074..ebeac8d 100644 --- a/src/qt_install.pri +++ b/src/qt_install.pri @@ -15,11 +15,19 @@ qt_install_headers { $$QT_SOURCE_TREE/src/corelib/arch/$$QT_ARCH/arch } - flat_headers.files = $$INSTALL_HEADERS - flat_headers.path = $$[QT_INSTALL_HEADERS]/Qt - INSTALLS += flat_headers + equals(TARGET, phonon) { + class_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET/Phonon + } else { + flat_headers.files = $$INSTALL_HEADERS + flat_headers.path = $$[QT_INSTALL_HEADERS]/Qt + INSTALLS += flat_headers - targ_headers.files = $$INSTALL_HEADERS $$SYNCQT.HEADER_CLASSES + class_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET + } + class_headers.files = $$SYNCQT.HEADER_CLASSES + INSTALLS += class_headers + + targ_headers.files = $$INSTALL_HEADERS targ_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET INSTALLS += targ_headers } -- cgit v0.12 From 71be46c61c582d2f4635a1e420e44d57ddb5857a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 12 Jun 2009 15:06:29 +0200 Subject: Fix compilation after the last change. The #include header no longer exists. And the or headers have never existed (neither for us nor for the Phonon sources). You have to select each and every header that you do want now. Reviewed-By: Marius Storm-Olsen --- .../webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp | 5 ++++- tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp index b1a48fb..2e01100 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp @@ -35,7 +35,10 @@ #include #include #include -#include + +#include +#include +#include using namespace Phonon; diff --git a/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.h b/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.h index 0887a7c..8c54492 100644 --- a/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.h +++ b/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.h @@ -47,7 +47,8 @@ #include #include -#include +#include +#include QT_BEGIN_NAMESPACE -- cgit v0.12