From ff35fc61cc8d6b103da4f079fce170d82406cea0 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 2 Jun 2010 09:21:35 +0200 Subject: Doc: Removed a link to Qt3 support in QSlider Task-number: QTBUG-6394 --- src/gui/widgets/qslider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qslider.cpp b/src/gui/widgets/qslider.cpp index a5e62cf..5755202 100644 --- a/src/gui/widgets/qslider.cpp +++ b/src/gui/widgets/qslider.cpp @@ -621,7 +621,7 @@ QSlider::TickPosition QSlider::tickPosition() const \brief the interval between tickmarks This is a value interval, not a pixel interval. If it is 0, the - slider will choose between lineStep() and pageStep(). + slider will choose between singleStep() and pageStep(). The default value is 0. -- cgit v0.12 From af8b034e2886ecb11db51d4fecc29177595b86ab Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 4 Jun 2010 13:50:36 +0200 Subject: Doc: QTreeWidgetItems remove themselves from views when deleted. Task-number: QTBUG-10640 --- src/gui/itemviews/qtreewidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 0e06f34..8f55734 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -1472,6 +1472,10 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after /*! Destroys this tree widget item. + + The item will be removed from \l{QTreeWidget}s to which it has + been added. This makes it safe to delete an item at any time. + */ QTreeWidgetItem::~QTreeWidgetItem() -- cgit v0.12 From 7ffb1c2e821cc4d508dcedcdb7363756f9f693ff Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 4 Jun 2010 15:06:45 +0200 Subject: Doc: Said to not access events after they are posted(postEvent). Task-number: QTBUG-10210 --- src/corelib/kernel/qcoreapplication.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 4e6e6b9..0a5e06e 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1073,7 +1073,7 @@ void QCoreApplication::exit(int returnCode) The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been - posted. It is \e {not safe} to modify or delete the event after + posted. It is \e {not safe} to access the event after it has been posted. When control returns to the main event loop, all events that are @@ -1104,7 +1104,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event) The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been - posted. It is \e {not safe} to modify or delete the event after + posted. It is \e {not safe} to access the event after it has been posted. When control returns to the main event loop, all events that are -- cgit v0.12 From f96d6a5d7d422847d302f4ed1180b66436683191 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 11 Jun 2010 15:21:14 +0300 Subject: Stylus menu for Share (QT app) is different from native S60 apps First part of corrections to make menu items more native like. This fixes: - In Sym^3 "separator items" are drawn automatically between items, using a simple line graphic with theme color and alpha values - highlight for menu item is positioned better - menu items themselves are better positioned - the corners of highlight are now more rounded for Sym^3 devices Task-number: QT-3295 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 76 +++++++++++++++++++++++++++++++--------- src/gui/styles/qs60style_s60.cpp | 10 ++++-- 2 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 91d3fa6..9745d9c 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1762,40 +1762,64 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) text_flags |= Qt::TextHideMnemonic; - const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); - if (selected) - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); - QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); //todo: move the vertical spacing stuff into subElementRect const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); + QStyleOptionMenuItem optionCheckBox; if (checkable){ const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); - QStyleOptionMenuItem optionCheckBox; optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); optionCheckBox.rect.moveCenter(QPoint( optionCheckBox.rect.center().x(), menuItem->rect.center().y())); - const int moveByX = optionCheckBox.rect.width() + vSpacing; + const int moveByX = optionCheckBox.rect.width() + vSpacing + + pixelMetric(PM_DefaultFrameWidth) + 1; if (optionMenuItem.direction == Qt::LeftToRight) { - textRect.translate(moveByX, 0); - iconRect.translate(moveByX, 0); - iconRect.setWidth(iconRect.width() + vSpacing); - textRect.setWidth(textRect.width() - moveByX - vSpacing); + if (iconRect.isValid()) { + iconRect.translate(moveByX, 0); + iconRect.setWidth(iconRect.width() + vSpacing); + } + if (textRect.isValid()) { + textRect.translate(moveByX, 0); + textRect.setWidth(textRect.width() - moveByX - vSpacing); + } optionCheckBox.rect.translate(vSpacing >> 1, hSpacing >> 1); } else { - textRect.setWidth(textRect.width() - moveByX); - iconRect.setWidth(iconRect.width() + vSpacing); - iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); + if (textRect.isValid()) + textRect.setWidth(textRect.width() - moveByX); + if (iconRect.isValid()) { + iconRect.setWidth(iconRect.width() + vSpacing); + iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); + } optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); } - if (!ignoreCheckMark) - drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); } + + const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); + const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2; + if (selected) { + int start; int end; + if (QApplication::layoutDirection() == Qt::LeftToRight) { + start = optionMenuItem.rect.left() + spacing; + end = qMax(textRect.right(), iconRect.right() + spacing); + } else { + start = qMax(spacing, qMin(textRect.left(), iconRect.left() - spacing)); + end = optionMenuItem.rect.right() - spacing; + } + //-1 adjustment to avoid highlight being on top of possible separator item + const QRect highlightRect = QRect( + QPoint(start, option->rect.top()), + QPoint(end, option->rect.bottom() - 1)); + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); + } + + if (checkable && !ignoreCheckMark) + drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); + //draw icon and/or checkState QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), enabled ? QIcon::Normal : QIcon::Disabled); @@ -1806,7 +1830,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, textRect.translate(vSpacing, 0); else textRect.translate(-vSpacing, 0); - textRect.setWidth(textRect.width()-vSpacing); + textRect.setWidth(textRect.width() - vSpacing); } //draw indicators @@ -1844,6 +1868,23 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QCommonStyle::drawItemText(painter, textRect, text_flags, optionMenuItem.palette, enabled, optionMenuItem.text, QPalette::Text); + + //In Sym^3, native menu items have "lines" between them + if (QS60StylePrivate::isSingleClickUi()) { + const QColor lineColorAlpha = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 15, 0); + //native platform sets each color byte to same value for "line 16" which just defines alpha for + //menuitem lines; lets use first byte "red". + QColor lineColor = optionMenuItem.palette.text().color(); + if (lineColorAlpha.isValid()) + lineColor.setAlpha(lineColorAlpha.red()); + painter->save(); + painter->setPen(lineColor); + + const int lineStartX = optionMenuItem.rect.left() + (QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) - 2) + spacing; + const int lineEndX = optionMenuItem.rect.right() - (QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) - 2) - spacing; + painter->drawLine(QPoint(lineStartX, optionMenuItem.rect.bottom()), QPoint(lineEndX, optionMenuItem.rect.bottom())); + painter->restore(); + } if (!enabled) painter->restore(); } @@ -2555,6 +2596,8 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, } } sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); + //native items have small empty areas at the beginning and end of menu item + sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin)); if (QS60StylePrivate::isTouchSupported()) //Make itemview easier to use in touch devices //QCommonStyle does not adjust height with horizontal margin, it only adjusts width @@ -2996,7 +3039,6 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con ret.setWidth(indicatorWidth); } } else { - ret = menuItem->rect; if (!menuItem->icon.isNull()) if (menuItem->direction == Qt::LeftToRight) ret.adjust(indicatorWidth, 0, 0, 0); diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index e5c74ad..4bb2ea8 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1023,8 +1023,14 @@ TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameEl heightShrink = heightShrink >> 1; break; case QS60StylePrivate::SF_ListHighlight: - widthShrink = widthShrink - 2; - heightShrink = heightShrink - 2; + //In Sym^3 devices highlights are less blocky + if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) { + widthShrink += 2; + heightShrink += 2; + } else { + widthShrink -= 2; + heightShrink -= 2; + } break; case QS60StylePrivate::SF_PopupBackground: widthShrink = widthShrink + 5; -- cgit v0.12 From 104fac002e228fb17304ec76d57febe33f8e8e7f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 14 Jun 2010 12:45:10 +0200 Subject: Add QTextOption API to QStaticText To allow more control over the layout process for a QStaticText, introduce a QTextOption API. This will allow you to, e.g., set an alignment for the text layout. Patch also contains a couple of bug fixes to make right alignment work correctly when you set a text width on the QStaticText. Task-number: QTBUG-9031 Reviewed-by: Samuel --- src/gui/text/qstatictext.cpp | 34 ++++++++++++++++++++++++++++++---- src/gui/text/qstatictext.h | 5 ++++- src/gui/text/qstatictext_p.h | 6 +++++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 10870aa..c742455 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -324,6 +324,26 @@ QStaticText::PerformanceHint QStaticText::performanceHint() const } /*! + Sets the text option structure that controls the layout process to the given \a textOption. + + \sa textOption() +*/ +void QStaticText::setTextOption(const QTextOption &textOption) +{ + detach(); + data->textOption = textOption; + data->invalidate(); +} + +/*! + Returns the current text option used to control the layout process. +*/ +QTextOption QStaticText::textOption() const +{ + return data->textOption; +} + +/*! Sets the preferred width for this QStaticText. If the text is wider than the specified width, it will be broken into multiple lines and grow vertically. If the text cannot be split into multiple lines, it will be larger than the specified \a textWidth. @@ -580,6 +600,7 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p) QTextLayout textLayout; textLayout.setText(text); textLayout.setFont(font); + textLayout.setTextOption(textOption); qreal leading = QFontMetricsF(font).leading(); qreal height = -leading; @@ -610,21 +631,26 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p) .arg(QString::number(color.blue(), 16), 2, QLatin1Char('0'))); #endif document.setDefaultFont(font); - document.setDocumentMargin(0.0); - if (textWidth >= 0.0) - document.setTextWidth(textWidth); + document.setDocumentMargin(0.0); #ifndef QT_NO_TEXTHTMLPARSER document.setHtml(text); #else document.setPlainText(text); #endif + if (textWidth >= 0.0) + document.setTextWidth(textWidth); + else + document.adjustSize(); + document.setDefaultTextOption(textOption); - document.adjustSize(); p->save(); p->translate(topLeftPosition); document.drawContents(p); p->restore(); + if (textWidth >= 0.0) + document.adjustSize(); // Find optimal size + actualSize = document.size(); } } diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h index f3bef93..4febde2 100644 --- a/src/gui/text/qstatictext.h +++ b/src/gui/text/qstatictext.h @@ -48,7 +48,7 @@ #include #include - +#include QT_BEGIN_HEADER @@ -79,6 +79,9 @@ public: void setTextWidth(qreal textWidth); qreal textWidth() const; + void setTextOption(const QTextOption &textOption); + QTextOption textOption() const; + QSizeF size() const; void prepare(const QTransform &matrix = QTransform(), const QFont &font = QFont()); diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index 1a96291..cb60626 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -53,6 +53,8 @@ // We mean it. // +#include "qstatictext.h" + #include #include @@ -148,12 +150,14 @@ public: QFixedPoint *positionPool; // 4 bytes per text QChar *charPool; // 4 bytes per text + QTextOption textOption; // 28 bytes per text + unsigned char needsRelayout : 1; // 1 byte per text unsigned char useBackendOptimizations : 1; unsigned char textFormat : 2; unsigned char untransformedCoordinates : 1; // ================ - // 167 bytes per text + // 195 bytes per text static QStaticTextPrivate *get(const QStaticText *q); }; -- cgit v0.12 From 44af23156fac578543e6d17c67d739e75e51c972 Mon Sep 17 00:00:00 2001 From: Carolina Gomes Date: Mon, 14 Jun 2010 13:23:48 +0200 Subject: Fixed error reporting in grayraster and reduced default pool size. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-10471 Merge-request: 642 Reviewed-by: Samuel Rødal --- src/gui/painting/qgrayraster.c | 35 +++++++++++++++++++------------- src/gui/painting/qgrayraster_p.h | 4 ++++ src/gui/painting/qpaintengine_raster.cpp | 12 +++++++---- src/gui/painting/qrasterdefs_p.h | 6 ++---- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c index ff2469c..5e7c67a 100644 --- a/src/gui/painting/qgrayraster.c +++ b/src/gui/painting/qgrayraster.c @@ -156,6 +156,7 @@ #define ErrRaster_Invalid_Outline -1 #define ErrRaster_Invalid_Argument -3 #define ErrRaster_Memory_Overflow -4 +#define ErrRaster_OutOfMemory -6 #define QT_FT_BEGIN_HEADER #define QT_FT_END_HEADER @@ -222,7 +223,6 @@ #define DOWNSCALE( x ) ( (x) << ( 6 - PIXEL_BITS ) ) #endif - /*************************************************************************/ /* */ /* TYPE DEFINITIONS */ @@ -1757,8 +1757,7 @@ #ifdef DEBUG_GRAYS fprintf( stderr, "Rotten glyph!\n" ); #endif - /* == Raster_Err_OutOfMemory in qblackraster.c */ - return -6; + return ErrRaster_OutOfMemory; } if ( bottom-top >= ras.band_size ) @@ -1784,7 +1783,7 @@ static int - gray_raster_render( PRaster raster, + gray_raster_render( QT_FT_Raster raster, const QT_FT_Raster_Params* params ) { const QT_FT_Outline* outline = (const QT_FT_Outline*)params->source; @@ -1795,6 +1794,12 @@ if ( !raster || !raster->buffer || !raster->buffer_size ) return ErrRaster_Invalid_Argument; + // If raster object and raster buffer are allocated, but + // raster size isn't of the minimum size, indicate out of + // memory. + if (raster && raster->buffer && raster->buffer_size < MINIMUM_POOL_SIZE ) + return ErrRaster_OutOfMemory; + /* return immediately if the outline is empty */ if ( outline->n_points == 0 || outline->n_contours <= 0 ) return 0; @@ -1874,19 +1879,15 @@ /**** a static object. *****/ static int - gray_raster_new( void * memory, - QT_FT_Raster* araster ) + gray_raster_new( QT_FT_Raster* araster ) { - if (memory) - fprintf(stderr, "gray_raster_new(), memory ignored"); - memory = malloc(sizeof(TRaster)); - if (!memory) { + *araster = malloc(sizeof(TRaster)); + if (!*araster) { *araster = 0; return ErrRaster_Memory_Overflow; } - QT_FT_MEM_ZERO(memory, sizeof(TRaster)); + QT_FT_MEM_ZERO(*araster, sizeof(TRaster)); - *araster = (QT_FT_Raster) memory; return 0; } @@ -1905,10 +1906,9 @@ { PRaster rast = (PRaster)raster; - if ( raster ) { - if ( pool_base && pool_size >= (long)sizeof ( TWorker ) + 2048 ) + if ( pool_base && ( pool_size >= MINIMUM_POOL_SIZE ) ) { PWorker worker = (PWorker)pool_base; @@ -1923,6 +1923,13 @@ rast->band_size = (int)( rast->buffer_size / ( sizeof ( TCell ) * 8 ) ); } + else if ( pool_base) + { // Case when there is a raster pool allocated, but it + // doesn't have the minimum size (and so memory will be reallocated) + rast->buffer = pool_base; + rast->worker = NULL; + rast->buffer_size = pool_size; + } else { rast->buffer = NULL; diff --git a/src/gui/painting/qgrayraster_p.h b/src/gui/painting/qgrayraster_p.h index 4463fc9..ad595b8 100644 --- a/src/gui/painting/qgrayraster_p.h +++ b/src/gui/painting/qgrayraster_p.h @@ -89,6 +89,10 @@ #define QT_FT_EXPORT_VAR( x ) extern x #endif +/* Minimum buffer size for raster object, that accounts + for TWorker and TCell sizes.*/ +#define MINIMUM_POOL_SIZE 4096 + QT_FT_EXPORT_VAR( const QT_FT_Raster_Funcs ) qt_ft_grays_raster; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 08e14fb..9f1128b 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -345,7 +345,7 @@ void QRasterPaintEngine::init() // The antialiasing raster. d->grayRaster.reset(new QT_FT_Raster); Q_CHECK_PTR(d->grayRaster.data()); - if (qt_ft_grays_raster.raster_new(0, d->grayRaster.data())) + if (qt_ft_grays_raster.raster_new(d->grayRaster.data())) QT_THROW(std::bad_alloc()); // an error creating the raster is caused by a bad malloc @@ -4185,7 +4185,11 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, return; } - const int rasterPoolInitialSize = 8192; + // Initial size for raster pool is MINIMUM_POOL_SIZE so as to + // minimize memory reallocations. However if initial size for + // raster pool is changed for lower value, reallocations will + // occur normally. + const int rasterPoolInitialSize = MINIMUM_POOL_SIZE; int rasterPoolSize = rasterPoolInitialSize; unsigned char *rasterPoolBase; #if defined(Q_WS_WIN64) @@ -4229,7 +4233,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, error = qt_ft_grays_raster.raster_render(*grayRaster.data(), &rasterParams); // Out of memory, reallocate some more and try again... - if (error == -6) { // -6 is Result_err_OutOfMemory + if (error == -6) { // ErrRaster_OutOfMemory from qgrayraster.c int new_size = rasterPoolSize * 2; if (new_size > 1024 * 1024) { qWarning("QPainter: Rasterization of primitive failed"); @@ -4255,7 +4259,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, Q_CHECK_PTR(rasterPoolBase); // note: we just freed the old rasterPoolBase. I hope it's not fatal. qt_ft_grays_raster.raster_done(*grayRaster.data()); - qt_ft_grays_raster.raster_new(0, grayRaster.data()); + qt_ft_grays_raster.raster_new(grayRaster.data()); qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); } else { done = true; diff --git a/src/gui/painting/qrasterdefs_p.h b/src/gui/painting/qrasterdefs_p.h index c33fa57..19a0b16 100644 --- a/src/gui/painting/qrasterdefs_p.h +++ b/src/gui/painting/qrasterdefs_p.h @@ -81,7 +81,6 @@ QT_FT_BEGIN_HEADER - /*************************************************************************/ /* */ /*
*/ @@ -837,7 +836,7 @@ QT_FT_BEGIN_HEADER /* A handle (pointer) to a raster object. Each object can be used */ /* independently to convert an outline into a bitmap or pixmap. */ /* */ - typedef struct QT_FT_RasterRec_* QT_FT_Raster; + typedef struct TRaster_ *QT_FT_Raster; /*************************************************************************/ @@ -1118,8 +1117,7 @@ QT_FT_BEGIN_HEADER /* ignored by a given raster implementation. */ /* */ typedef int - (*QT_FT_Raster_NewFunc)( void* memory, - QT_FT_Raster* raster ); + (*QT_FT_Raster_NewFunc)( QT_FT_Raster* raster ); #define QT_FT_Raster_New_Func QT_FT_Raster_NewFunc -- cgit v0.12 From b18a343cc63f93a8e97a8c6c623e56a666775b57 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 15 Jun 2010 15:23:28 +1000 Subject: Fix bug with childrenRect resizing on startup. This also optimizes the implementation. Task-number: QTBUG-11383 --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 28 ++++++++++------------ src/declarative/graphicsitems/qdeclarativeitem_p.h | 7 +++--- .../qdeclarativeitem/data/childrenRectBug.qml | 23 ++++++++++++++++++ .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 17 +++++++++++++ 4 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 18806e7..42b370b 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -231,9 +231,10 @@ QT_BEGIN_NAMESPACE \brief The QDeclarativeContents class gives access to the height and width of an item's contents. */ - -QDeclarativeContents::QDeclarativeContents() : m_x(0), m_y(0), m_width(0), m_height(0) +QDeclarativeContents::QDeclarativeContents(QDeclarativeItem *item) : m_item(item), m_x(0), m_y(0), m_width(0), m_height(0) { + //### optimize + connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF))); } QDeclarativeContents::~QDeclarativeContents() @@ -328,12 +329,8 @@ void QDeclarativeContents::calcWidth(QDeclarativeItem *changed) emit rectChanged(rectF()); } -void QDeclarativeContents::setItem(QDeclarativeItem *item) +void QDeclarativeContents::complete() { - m_item = item; - //### optimize - connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF))); - QList children = m_item->childItems(); for (int i = 0; i < children.count(); ++i) { QDeclarativeItem *child = qobject_cast(children.at(i)); @@ -343,9 +340,7 @@ void QDeclarativeContents::setItem(QDeclarativeItem *item) //###what about changes to visibility? } - //### defer until componentComplete - calcHeight(); - calcWidth(); + calcGeometry(); } void QDeclarativeContents::itemGeometryChanged(QDeclarativeItem *changed, const QRectF &newGeometry, const QRectF &oldGeometry) @@ -360,16 +355,14 @@ void QDeclarativeContents::itemDestroyed(QDeclarativeItem *item) { if (item) QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); - calcWidth(); - calcHeight(); + calcGeometry(); } void QDeclarativeContents::childRemoved(QDeclarativeItem *item) { if (item) QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); - calcWidth(); - calcHeight(); + calcGeometry(); } void QDeclarativeContents::childAdded(QDeclarativeItem *item) @@ -1752,8 +1745,9 @@ QRectF QDeclarativeItem::childrenRect() { Q_D(QDeclarativeItem); if (!d->_contents) { - d->_contents = new QDeclarativeContents; - d->_contents->setItem(this); + d->_contents = new QDeclarativeContents(this); + if (d->_componentComplete) + d->_contents->complete(); } return d->_contents->rectF(); } @@ -2619,6 +2613,8 @@ void QDeclarativeItem::componentComplete() } if (d->keyHandler) d->keyHandler->componentComplete(); + if (d->_contents) + d->_contents->complete(); } QDeclarativeStateGroup *QDeclarativeItemPrivate::_states() diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 184d6f1..fb416c2 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -83,16 +83,17 @@ class QDeclarativeContents : public QObject, public QDeclarativeItemChangeListen { Q_OBJECT public: - QDeclarativeContents(); + QDeclarativeContents(QDeclarativeItem *item); ~QDeclarativeContents(); QRectF rectF() const; - void setItem(QDeclarativeItem *item); - void childRemoved(QDeclarativeItem *item); void childAdded(QDeclarativeItem *item); + void calcGeometry() { calcWidth(); calcHeight(); } + void complete(); + Q_SIGNALS: void rectChanged(QRectF); diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml new file mode 100644 index 0000000..4a2f056 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml @@ -0,0 +1,23 @@ +import Qt 4.7 + +Rectangle { + width: 400 + height: 200 + + Item { + objectName: "theItem" + anchors.centerIn: parent + width: childrenRect.width + height: childrenRect.height + Rectangle { + id: text1 + anchors.verticalCenter: parent.verticalCenter + width: 100; height: 100; color: "green" + } + Rectangle { + anchors.left: text1.right + anchors.verticalCenter: parent.verticalCenter + width: 100; height: 100; color: "green" + } + } +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index c2d3660..0a66245 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -72,6 +72,7 @@ private slots: void transforms(); void transforms_data(); void childrenRect(); + void childrenRectBug(); void childrenProperty(); void resourcesProperty(); @@ -736,6 +737,22 @@ void tst_QDeclarativeItem::childrenRect() delete o; } +// QTBUG-11383 +void tst_QDeclarativeItem::childrenRectBug() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug.qml")); + canvas->show(); + + QGraphicsObject *o = canvas->rootObject(); + QDeclarativeItem *item = o->findChild("theItem"); + QCOMPARE(item->width(), qreal(200)); + QCOMPARE(item->height(), qreal(100)); + QCOMPARE(item->x(), qreal(100)); + + delete canvas; +} + template T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) { -- cgit v0.12 From c1e6d97b9476c859abc3927046144b4006fcf735 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 15 Jun 2010 15:49:08 +1000 Subject: Remove duplicated code. --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 8 +------- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 3b4f2a7..3106daf 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1113,13 +1113,7 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) Q_D(QDeclarativeTextEdit); if (d->focusOnPress){ bool hadFocus = hasFocus(); - QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? - while(p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) - p->setFocus(); - p = p->parentItem(); - } - setFocus(true); + forceFocus(); if (d->showInputPanelOnFocus) { if (hasFocus() && hadFocus && !isReadOnly()) { // re-open input panel on press if already focused diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 633c01e..cba01ef 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -924,13 +924,7 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) Q_D(QDeclarativeTextInput); if(d->focusOnPress){ bool hadFocus = hasFocus(); - QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? - while(p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) - p->setFocus(); - p = p->parentItem(); - } - setFocus(true); + forceFocus(); if (d->showInputPanelOnFocus) { if (hasFocus() && hadFocus && !isReadOnly()) { // re-open input panel on press if already focused -- cgit v0.12 From 37ed99a30839696a95c498f7d99a3505936ac29c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 15 Jun 2010 10:25:24 +0200 Subject: Updated WebKit to 40c2d6907ef75288b4f15e7fad334b9138acdbbf Integrated fix: || || [Qt] The qt_webkit_version.pri file gets overwritten on install || --- mkspecs/modules/qt_webkit_version.pri | 6 ++++-- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 13 +++++++++++++ src/3rdparty/webkit/WebCore/WebCore.pri | 2 +- src/3rdparty/webkit/WebCore/WebCore.pro | 7 +------ 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/mkspecs/modules/qt_webkit_version.pri b/mkspecs/modules/qt_webkit_version.pri index 0370720..ffd192c 100644 --- a/mkspecs/modules/qt_webkit_version.pri +++ b/mkspecs/modules/qt_webkit_version.pri @@ -1,2 +1,4 @@ -# The version information comes from our copy of -include($$PWD/../../src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri) +QT_WEBKIT_VERSION = 4.7.0 +QT_WEBKIT_MAJOR_VERSION = 4 +QT_WEBKIT_MINOR_VERSION = 7 +QT_WEBKIT_PATCH_VERSION = 0 diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 125e175..07a02d7 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -0f8941d0dd5f947530e1dc55b859d810bba14764 +40c2d6907ef75288b4f15e7fad334b9138acdbbf diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 6aaae4f..b648b94 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - f943ead2759537527faa7f3cb057d995291663b9 + 40c2d6907ef75288b4f15e7fad334b9138acdbbf diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index e04729d..6a7da30 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,16 @@ +2010-06-15 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] The qt_webkit_version.pri file gets overwritten on install + https://bugs.webkit.org/show_bug.cgi?id=40487 + + Don't install qt_webkit_version.pri when building WebKit inside of Qt. + The import of WebKit into Qt will take care of providing the file + in mkspecs/modules and it'll be installed through projects.pro. + + * WebCore.pro: + 2010-06-13 Noam Rosenthal Reviewed by Eric Seidel. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pri b/src/3rdparty/webkit/WebCore/WebCore.pri index 9debd6a..97ae526 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pri +++ b/src/3rdparty/webkit/WebCore/WebCore.pri @@ -107,7 +107,7 @@ greaterThan(QT_MINOR_VERSION, 5) { !lessThan(QT_MINOR_VERSION, 7) { DEFINES += ENABLE_QT_BEARER=1 } else { - load(mobilityconfig) + load(mobilityconfig, true) contains(MOBILITY_CONFIG, bearer) { DEFINES += ENABLE_QT_BEARER=1 } diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 048fc93..07ef474 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2845,12 +2845,7 @@ contains(DEFINES, ENABLE_SYMBIAN_DIALOG_PROVIDERS) { include($$PWD/../WebKit/qt/Api/headers.pri) HEADERS += $$WEBKIT_API_HEADERS -CONFIG(QTDIR_build) { - modfile.files = $$moduleFile - modfile.path = $$[QMAKE_MKSPECS]/modules - - INSTALLS += modfile -} else { +!CONFIG(QTDIR_build) { exists($$OUTPUT_DIR/include/QtWebKit/classheaders.pri): include($$OUTPUT_DIR/include/QtWebKit/classheaders.pri) WEBKIT_INSTALL_HEADERS = $$WEBKIT_API_HEADERS $$WEBKIT_CLASS_HEADERS -- cgit v0.12 From d6bcab9e1cfb3a3b91b45269d68a594f6f079914 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 15 Jun 2010 10:14:18 +0200 Subject: Fix regression, remove artificial emboldening of monospaced fonts In change 889e13652e00ba64060e7b62ed3377ea04d44faa we employed usage of artificial emboldening of fonts with FreeType when a bold variant of the font does not exist. This introduced a regression for monospaced fonts, where the contract says that all glyphs must be the same width. Since the artificial emboldening algorithm does not support this contract, it has been turned off for monospaced fonts, reverting to the old behavior for this particular class of fonts. Task-number: QTBUG-11353 Reviewed-by: Paul --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 9056012..2c4fbab 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -690,7 +690,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) if (fake_oblique) transform = true; // fake bold - if ((fontDef.weight == QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD)) + if ((fontDef.weight == QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) embolden = true; // underline metrics line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); -- cgit v0.12 From a041e4eca3467c1baa6245b6fb47def127f30f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 15 Jun 2010 10:45:23 +0200 Subject: Added missing sanity checks in qimage.cpp We should be consistent and do sanity checks whenever we allocate new images. Task-number: QTBUG-1985 Reviewed-by: Eskil --- src/gui/image/qimage.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d89ffe6..adc2632 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4210,6 +4210,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const int w = width(); int h = height(); QImage m(w, h, Format_MonoLSB); + QIMAGE_SANITYCHECK_MEMORY(m); m.setColorCount(2); m.setColor(0, QColor(Qt::color0).rgba()); m.setColor(1, QColor(Qt::color1).rgba()); @@ -4302,6 +4303,7 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const if (!d) return QImage(); QImage maskImage(size(), QImage::Format_MonoLSB); + QIMAGE_SANITYCHECK_MEMORY(maskImage); maskImage.fill(0); uchar *s = maskImage.bits(); @@ -4362,6 +4364,7 @@ QImage QImage::mirrored(bool horizontal, bool vertical) const int h = d->height; // Create result image, copy colormap QImage result(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(result); // check if we ran out of of memory.. if (!result.d) @@ -4499,6 +4502,7 @@ QImage QImage::rgbSwapped() const case Format_ARGB32: case Format_ARGB32_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { uint *q = (uint*)res.scanLine(i); uint *p = (uint*)scanLine(i); @@ -4512,6 +4516,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB16: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { ushort *q = (ushort*)res.scanLine(i); const ushort *p = (const ushort*)scanLine(i); @@ -4525,6 +4530,7 @@ QImage QImage::rgbSwapped() const break; case Format_ARGB8565_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *p = (quint8*)scanLine(i); const quint8 *end = p + d->width * sizeof(qargb8565); @@ -4537,6 +4543,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB666: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { qrgb666 *q = reinterpret_cast(res.scanLine(i)); const qrgb666 *p = reinterpret_cast(scanLine(i)); @@ -4549,6 +4556,7 @@ QImage QImage::rgbSwapped() const break; case Format_ARGB6666_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { qargb6666 *q = reinterpret_cast(res.scanLine(i)); const qargb6666 *p = reinterpret_cast(scanLine(i)); @@ -4561,6 +4569,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB555: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { ushort *q = (ushort*)res.scanLine(i); const ushort *p = (const ushort*)scanLine(i); @@ -4574,6 +4583,7 @@ QImage QImage::rgbSwapped() const break; case Format_ARGB8555_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *p = (quint8*)scanLine(i); const quint8 *end = p + d->width * sizeof(qargb8555); @@ -4586,6 +4596,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB888: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *q = reinterpret_cast(res.scanLine(i)); const quint8 *p = reinterpret_cast(scanLine(i)); @@ -4601,6 +4612,7 @@ QImage QImage::rgbSwapped() const break; case Format_RGB444: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *q = reinterpret_cast(res.scanLine(i)); const quint8 *p = reinterpret_cast(scanLine(i)); @@ -4615,6 +4627,7 @@ QImage QImage::rgbSwapped() const break; case Format_ARGB4444_Premultiplied: res = QImage(d->width, d->height, d->format); + QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { quint8 *q = reinterpret_cast(res.scanLine(i)); const quint8 *p = reinterpret_cast(scanLine(i)); -- cgit v0.12 From 78560390b948127262a9ebb5f4dd355b6c517e94 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 15 Jun 2010 13:49:26 +0300 Subject: Change $${EPOCROOT} to also have drive if EPOCROOT env variable has it Since sbsv2 toolchain supports having sources and SDK on different drives, $${EPOCROOT} needs to contain drive letter to make it work. Reviewed-by: Jason Barron --- qmake/generators/symbian/symbiancommon.cpp | 3 --- qmake/generators/symbian/symmake_sbsv2.cpp | 4 +++- src/s60installs/s60installs.pro | 4 ++-- tools/shared/symbian/epocroot.cpp | 4 ---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index 58729d2..3a4bdbc 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -433,9 +433,6 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB if (from.size() > 1 && from.at(1) == QLatin1Char(':')) from = from.mid(2); from.prepend(zDir); - } else { - if (from.size() > 1 && from.at(1) == QLatin1Char(':')) - from = from.mid(2); } } diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index c2f1d1a..78f6f85 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -99,7 +99,9 @@ void SymbianSbsv2MakefileGenerator::writeSbsDeploymentList(const DeploymentList& fromItem.replace("\\", "/"); toItem.replace("\\", "/"); #if defined(Q_OS_WIN) - toItem.prepend(QDir::current().absolutePath().left(2)); // add drive + // add drive if it doesn't have one yet + if (toItem.size() > 1 && toItem[1] != QLatin1Char(':')) + toItem.prepend(QDir::current().absolutePath().left(2)); #endif t << "OPTION DEPLOY_SOURCE " << fromItem << endl; t << "OPTION DEPLOY_TARGET " << toItem << endl; diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index d751134..ce0f4f1 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -16,8 +16,8 @@ symbian: { # It is also expected that devices newer than those based on S60 5.0 all have sqlite3.dll. contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { BLD_INF_RULES.prj_exports += \ - "sqlite3.sis $${EPOCROOT}epoc32/data/qt/sis/sqlite3.sis" \ - "sqlite3_selfsigned.sis $${EPOCROOT}epoc32/data/qt/sis/sqlite3_selfsigned.sis" + "sqlite3.sis /epoc32/data/qt/sis/sqlite3.sis" \ + "sqlite3_selfsigned.sis /epoc32/data/qt/sis/sqlite3_selfsigned.sis" symbian-abld|symbian-sbsv2 { sqlitedeployment = \ "; Deploy sqlite onto phone that does not have it already" \ diff --git a/tools/shared/symbian/epocroot.cpp b/tools/shared/symbian/epocroot.cpp index 064e056..ae1dcb1 100644 --- a/tools/shared/symbian/epocroot.cpp +++ b/tools/shared/symbian/epocroot.cpp @@ -105,10 +105,6 @@ static void fixEpocRoot(QString &path) { path.replace("\\", "/"); - if (path.size() > 1 && path[1] == QChar(':')) { - path = path.mid(2); - } - if (!path.size() || path[path.size()-1] != QChar('/')) { path += QChar('/'); } -- cgit v0.12 From c5b06919a8fb5d20aae41f0edf9e2ffa99eb1a8a Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 15 Jun 2010 13:59:41 +0200 Subject: Doc: Documented qputenv and qgetenv Task-number: QTBUG-4041 Reviewed-by: Morten Engvoldsen --- src/corelib/global/qglobal.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 373c0b4..b31c83b 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2503,6 +2503,19 @@ void qFatal(const char *msg, ...) // getenv is declared as deprecated in VS2005. This function // makes use of the new secure getenv function. +/*! + \relates + + Returns the value of the environment variable with name \a + varName. To get the variable string, use QByteArray::constData(). + + \note qgetenv() was introduced because getenv() from the standard + C library was deprecated in VC2005 (and later versions). qgetenv() + uses the new replacement function in VC, and calls the standard C + library's implementation on all other platforms. + + \sa qputenv() +*/ QByteArray qgetenv(const char *varName) { #if defined(_MSC_VER) && _MSC_VER >= 1400 @@ -2522,6 +2535,20 @@ QByteArray qgetenv(const char *varName) #endif } +/*! + \relates + + This function sets the \a value of the environment variable named + \a varName. It will create the variable if it does not exist. It + returns 0 if the variable could not be set. + + \note qputenv() was introduced because putenv() from the standard + C library was deprecated in VC2005 (and later versions). qputenv() + uses the replacement function in VC, and calls the standard C + library's implementation on all other platforms. + + \sa qgetenv() +*/ bool qputenv(const char *varName, const QByteArray& value) { #if defined(_MSC_VER) && _MSC_VER >= 1400 -- cgit v0.12 From c28efecdcfdd5fa0049bf482cb102814338c0d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 15 Jun 2010 12:33:39 +0200 Subject: Fixed missing stroke for flat ellipses. The behavior should be the same as for arcs and rects. Task-number: QTBUG-2743 Reviewed-by: Eskil --- src/gui/painting/qpaintengine_raster.cpp | 1 + src/gui/painting/qpaintengine_x11.cpp | 5 +++++ src/gui/painting/qpainter.cpp | 4 ---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9f1128b..f10f12f 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3789,6 +3789,7 @@ void QRasterPaintEngine::drawEllipse(const QRectF &rect) if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen) || (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased)) && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT + && !rect.isEmpty() && s->matrix.type() <= QTransform::TxScale) // no shear { ensureBrush(); diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index b8ad9b3..910b2df 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -1453,6 +1453,11 @@ void QX11PaintEngine::drawEllipse(const QRectF &rect) void QX11PaintEngine::drawEllipse(const QRect &rect) { + if (rect.isEmpty()) { + drawRects(&rect, 1); + return; + } + Q_D(QX11PaintEngine); QRect devclip(SHRT_MIN, SHRT_MIN, SHRT_MAX*2 - 1, SHRT_MAX*2 - 1); QRect r(rect); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index e8c4599..d17c711 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -4238,8 +4238,6 @@ void QPainter::drawEllipse(const QRectF &r) return; QRectF rect(r.normalized()); - if (rect.isEmpty()) - return; if (d->extended) { d->extended->drawEllipse(rect); @@ -4281,8 +4279,6 @@ void QPainter::drawEllipse(const QRect &r) return; QRect rect(r.normalized()); - if (rect.isEmpty()) - return; if (d->extended) { d->extended->drawEllipse(rect); -- cgit v0.12 From df55141aa260c8a10c06aa990b6f20d6fb4718f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 15 Jun 2010 13:06:19 +0200 Subject: Fixed QImageReader::format() inconsistency. If state is set to ReadHeader before canRead() then setFormat("png") never gets called. We should make sure that setFormat() gets set whenever canRead() returns true. Task-number: QTBUG-2263 Reviewed-by: Kent Hansen --- src/gui/image/qbmphandler.cpp | 10 +++++---- src/gui/image/qpnghandler.cpp | 10 +++++---- src/gui/image/qppmhandler.cpp | 10 +++++---- src/gui/image/qxbmhandler.cpp | 10 +++++---- src/gui/image/qxpmhandler.cpp | 8 ++++++-- src/plugins/imageformats/gif/qgifhandler.cpp | 4 ++-- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 10 +++++---- src/plugins/imageformats/mng/qmnghandler.cpp | 8 ++++---- tests/auto/qimagereader/tst_qimagereader.cpp | 28 ++++++++++++++++++++++++++ 9 files changed, 70 insertions(+), 28 deletions(-) diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 42e19b8..074b8f0 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -674,13 +674,15 @@ bool QBmpHandler::readHeader() bool QBmpHandler::canRead() const { - if (state == Ready) { - if (!canRead(device())) - return false; + if (state == Ready && !canRead(device())) + return false; + + if (state != Error) { setFormat("bmp"); return true; } - return state != Error; + + return false; } bool QBmpHandler::canRead(QIODevice *device) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index dd31834..2cf8222 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -892,13 +892,15 @@ QPngHandler::~QPngHandler() bool QPngHandler::canRead() const { - if (d->state == QPngHandlerPrivate::Ready) { - if (!canRead(device())) - return false; + if (d->state == QPngHandlerPrivate::Ready && !canRead(device())) + return false; + + if (d->state != QPngHandlerPrivate::Error) { setFormat("png"); return true; } - return d->state != QPngHandlerPrivate::Error; + + return false; } bool QPngHandler::canRead(QIODevice *device) diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index cbbbef4..a9e796c 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -409,13 +409,15 @@ bool QPpmHandler::readHeader() bool QPpmHandler::canRead() const { - if (state == Ready) { - if (!canRead(device(), &subType)) - return false; + if (state == Ready && !canRead(device(), &subType)) + return false; + + if (state != Error) { setFormat(subType); return true; } - return state != Error; + + return false; } bool QPpmHandler::canRead(QIODevice *device, QByteArray *subType) diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 385340a..0dd4e99 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -261,13 +261,15 @@ bool QXbmHandler::readHeader() bool QXbmHandler::canRead() const { - if (state == Ready) { - if (!canRead(device())) - return false; + if (state == Ready && !canRead(device())) + return false; + + if (state != Error) { setFormat("xbm"); return true; } - return state != Error; + + return false; } bool QXbmHandler::canRead(QIODevice *device) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index a475cd0..b97afd3 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1225,11 +1225,15 @@ bool QXpmHandler::readImage(QImage *image) bool QXpmHandler::canRead() const { - if (state == Ready && canRead(device())) { + if (state == Ready && !canRead(device())) + return false; + + if (state != Error) { setFormat("xpm"); return true; } - return state != Error; + + return false; } bool QXpmHandler::canRead(QIODevice *device) diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index 8abc2d1..5e2157e 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -1061,12 +1061,12 @@ bool QGifHandler::imageIsComing() const bool QGifHandler::canRead() const { - if (!nextDelay && canRead(device())) { + if (!nextDelay && canRead(device()) || imageIsComing()) { setFormat("gif"); return true; } - return imageIsComing(); + return false; } bool QGifHandler::canRead(QIODevice *device) diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 72dde15..60e7cce 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -802,13 +802,15 @@ QJpegHandler::~QJpegHandler() bool QJpegHandler::canRead() const { - if(d->state == QJpegHandlerPrivate::Ready) { - if (!canRead(device())) - return false; + if(d->state == QJpegHandlerPrivate::Ready && !canRead(device())) + return false; + + if (d->state != QJpegHandlerPrivate::Error) { setFormat("jpeg"); return true; } - return d->state != QJpegHandlerPrivate::Error; + + return false; } bool QJpegHandler::canRead(QIODevice *device) diff --git a/src/plugins/imageformats/mng/qmnghandler.cpp b/src/plugins/imageformats/mng/qmnghandler.cpp index d408e6c..c134fd6 100644 --- a/src/plugins/imageformats/mng/qmnghandler.cpp +++ b/src/plugins/imageformats/mng/qmnghandler.cpp @@ -381,10 +381,10 @@ QMngHandler::~QMngHandler() bool QMngHandler::canRead() const { Q_D(const QMngHandler); - if (!d->haveReadNone) - return (!d->haveReadAll || (d->haveReadAll && (d->nextIndex < d->frameCount))); - - if (canRead(device())) { + if ((!d->haveReadNone + && (!d->haveReadAll || (d->haveReadAll && (d->nextIndex < d->frameCount)))) + || canRead(device())) + { setFormat("mng"); return true; } diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index aadee5b..7e57973 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -138,6 +138,9 @@ private slots: void sizeBeforeRead_data(); void sizeBeforeRead(); + void sizeBeforeFormat_data(); + void sizeBeforeFormat(); + void imageFormatBeforeRead_data(); void imageFormatBeforeRead(); @@ -706,6 +709,31 @@ void tst_QImageReader::sizeBeforeRead() QCOMPARE(size, image.size()); } +void tst_QImageReader::sizeBeforeFormat_data() +{ + imageFormat_data(); +} + +void tst_QImageReader::sizeBeforeFormat() +{ + QFETCH(QString, fileName); + + QByteArray formatA, formatB; + + { + QImageReader reader(prefix + fileName); + formatA = reader.format(); + } + + { + QImageReader reader(prefix + fileName); + QSize size = reader.size(); + formatB = reader.format(); + } + + QCOMPARE(formatA, formatB); +} + void tst_QImageReader::imageFormatBeforeRead_data() { imageFormat_data(); -- cgit v0.12 From 86b13101afe31934eddb0c904ac6d2815cd39e5e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 15 Jun 2010 15:34:01 +0300 Subject: Stylus menu for Share (QT app) is different from native S60 apps This is part two of the fix. This fix makes the menu item to be layoutted always with space reserved for checkbox indicator, even if the menu item is not having one (just like native side). Also, the right and left "gap areas" (between menu border and menu item highlight) match the native side more closely now. There is still some difference if using QMenu (instead of QComboBoxListView), since we can't just ignore margin set from widget. Also, the Sym^3 "separator lines" are now started from correct position. Finally, the menu item height now matches the native side. Task-number: QT-3295 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 66 +++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 9745d9c..1a8dd78 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1768,40 +1768,41 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, //todo: move the vertical spacing stuff into subElementRect const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); QStyleOptionMenuItem optionCheckBox; - if (checkable){ - const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); - optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); - optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); - optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); - optionCheckBox.rect.moveCenter(QPoint( - optionCheckBox.rect.center().x(), - menuItem->rect.center().y())); - const int moveByX = optionCheckBox.rect.width() + vSpacing + - pixelMetric(PM_DefaultFrameWidth) + 1; - if (optionMenuItem.direction == Qt::LeftToRight) { - if (iconRect.isValid()) { - iconRect.translate(moveByX, 0); - iconRect.setWidth(iconRect.width() + vSpacing); - } - if (textRect.isValid()) { - textRect.translate(moveByX, 0); - textRect.setWidth(textRect.width() - moveByX - vSpacing); - } - optionCheckBox.rect.translate(vSpacing >> 1, hSpacing >> 1); - } else { - if (textRect.isValid()) - textRect.setWidth(textRect.width() - moveByX); - if (iconRect.isValid()) { - iconRect.setWidth(iconRect.width() + vSpacing); - iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); - } - optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); + + //Regardless of checkbox visibility, make room for it, this mirrors native implementation, + //where text and icon placement is static regardless of content of menu item. + const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); + optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); + optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); + optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); + optionCheckBox.rect.moveCenter(QPoint( + optionCheckBox.rect.center().x(), + menuItem->rect.center().y())); + const int moveByX = optionCheckBox.rect.width() + vSpacing + + pixelMetric(PM_DefaultFrameWidth); + if (optionMenuItem.direction == Qt::LeftToRight) { + if (iconRect.isValid()) { + iconRect.translate(moveByX, 0); + iconRect.setWidth(iconRect.width() + vSpacing); + } + if (textRect.isValid()) { + textRect.translate(moveByX, 0); + textRect.setWidth(textRect.width() - moveByX - vSpacing); + } + optionCheckBox.rect.translate(vSpacing + pixelMetric(PM_DefaultFrameWidth), hSpacing >> 1); + } else { + if (textRect.isValid()) + textRect.setWidth(textRect.width() - moveByX); + if (iconRect.isValid()) { + iconRect.setWidth(iconRect.width() + vSpacing); + iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); } + optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); } const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); - const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2; if (selected) { + const int spacing = pixelMetric(PM_DefaultFrameWidth) * 2; int start; int end; if (QApplication::layoutDirection() == Qt::LeftToRight) { start = optionMenuItem.rect.left() + spacing; @@ -1872,6 +1873,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, //In Sym^3, native menu items have "lines" between them if (QS60StylePrivate::isSingleClickUi()) { const QColor lineColorAlpha = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 15, 0); + const int spacing = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); //native platform sets each color byte to same value for "line 16" which just defines alpha for //menuitem lines; lets use first byte "red". QColor lineColor = optionMenuItem.palette.text().color(); @@ -2281,6 +2283,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && option->palette.window().texture().cacheKey() == QS60StylePrivate::m_themePalette->window().texture().cacheKey()) + //todo: for combobox listviews, the background should include area for menu scrollers, + //but this produces drawing issues as we need to turn clipping off. QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, option->rect, flags); else commonStyleDraws = true; @@ -2597,11 +2601,11 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, } sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); //native items have small empty areas at the beginning and end of menu item - sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin)); + sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin) + 2 * QS60StylePrivate::pixelMetric(PM_FrameCornerWidth)); if (QS60StylePrivate::isTouchSupported()) //Make itemview easier to use in touch devices //QCommonStyle does not adjust height with horizontal margin, it only adjusts width - sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); + sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin) - 8); //QCommonstyle adds 8 to height that this style handles through PM values break; #ifndef QT_NO_COMBOBOX case CT_ComboBox: { -- cgit v0.12 From 20a39c16f236f999cd1694cdc47a3739efcbbfe4 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Tue, 15 Jun 2010 13:39:25 +0200 Subject: Temporary fix for regression in QSslCertificate::fromPath() The regression was introduced with 164f347aba7287407615223dc2219a016ebc8248. As soon as possible we should probably rewrite the fromPath() function, to have a proper solution. Nevertheless this might be a bigger change and should not be done so late in release cycle. Reviewed-by: TrustMe --- src/network/ssl/qsslcertificate.cpp | 11 ++++++++--- tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index ed12e00..a3ea555 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -537,7 +537,7 @@ QList QSslCertificate::fromPath(const QString &path, // $, (,), *, +, ., ?, [, ,], ^, {, | and }. int pos = -1; if (syntax == QRegExp::Wildcard) - pos = path.indexOf(QRegExp(QLatin1String("[\\*\\?\\[]"))); + pos = path.indexOf(QRegExp(QLatin1String("[^\\][\\*\\?\\[\\]]"))); else if (syntax != QRegExp::FixedString) pos = path.indexOf(QRegExp(QLatin1String("[^\\][\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]"))); QString pathPrefix = path.left(pos); // == path if pos < 0 @@ -548,8 +548,13 @@ QList QSslCertificate::fromPath(const QString &path, // chop off the first two characters from the glob'ed paths. int startIndex = 0; if (pathPrefix.trimmed().isEmpty()) { - startIndex = 2; - pathPrefix = QLatin1String("."); + if(path.startsWith(QLatin1Char('/'))) { + pathPrefix = path.left(path.indexOf(QRegExp(QLatin1String("[\\*\\?\\[]")))); + pathPrefix = path.left(path.lastIndexOf(QLatin1Char('/'))); + } else { + startIndex = 2; + pathPrefix = QLatin1String("."); + } } // The path is a file. diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 505b867..d0509bb 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -542,6 +542,9 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"d.*/c.*.pem\" regexp der") << QString("d.*/c.*.pem") << int(QRegExp::RegExp) << false << 0; QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0; QTest::newRow("\"d.*/c.*.pem\" wildcard der") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0; +#ifdef Q_OS_LINUX + QTest::newRow("absolute path wildcard pem") << QString(QDir::currentPath() + "/certificates/*.pem") << int(QRegExp::Wildcard) << true << 4; +#endif QTest::newRow("trailing-whitespace") << QString("more-certificates/trailing-whitespace.pem") << int(QRegExp::FixedString) << true << 1; QTest::newRow("no-ending-newline") << QString("more-certificates/no-ending-newline.pem") << int(QRegExp::FixedString) << true << 1; -- cgit v0.12 From 28ce5c1f2c0dbbfe45b5c3744bf03a2548c12223 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 15 Jun 2010 16:09:41 +0300 Subject: ComboBox popuplist is not correctly layouted in fullscreen mode This is part two of the fix for issue QTBUG-9913. This corrects the left margin of the ComboBox menu to start from the left screen border (for LetToRight UI Layout), instead of having small margin. Task-number: QTBUG-9913 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 1a8dd78..45bcc00 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2870,16 +2870,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple } break; case SC_ComboBoxListBoxPopup: { - const QRect desktopContent = QApplication::desktop()->availableGeometry(); - - // take the size of this and position bottom above available area - QRect popupRect; - const int width = desktopContent.width() - pixelMetric(PM_LayoutRightMargin) - pixelMetric(PM_LayoutLeftMargin); - popupRect.setWidth(width); - popupRect.setHeight(desktopContent.height()); //combobox resets height anyway based on content - popupRect.setBottom(desktopContent.bottom()); - popupRect.translate(pixelMetric(PM_LayoutLeftMargin), 0); - ret = popupRect; + ret = QApplication::desktop()->availableGeometry(); } break; default: -- cgit v0.12 From 0e0e74f23566de7ae408a2e7091001941508b694 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 14 Jun 2010 10:12:07 +0200 Subject: Use native locale aware string comparison on Symbian. Fix to use the native CompareC function instead. Task-number: QTBUG-11350 Reviewed-by: Miikka Heikkinen --- src/corelib/tools/qstring.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 1d5fab3..57f79a0 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4768,6 +4768,10 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, CFRelease(thisString); CFRelease(otherString); return result; +#elif defined(Q_OS_SYMBIAN) + TPtrC p1 = TPtrC16(reinterpret_cast(data1), length1); + TPtrC p2 = TPtrC16(reinterpret_cast(data2), length2); + return p1.CompareC(p2); #elif defined(Q_OS_UNIX) // declared in int delta = strcoll(toLocal8Bit_helper(data1, length1), toLocal8Bit_helper(data2, length2)); -- cgit v0.12 From 0ee0c77738faaeced93980dab33867d42efcf2cc Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 15 Jun 2010 10:57:28 +1000 Subject: Document section.delegate --- src/declarative/graphicsitems/qdeclarativelistview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index dcf18af..48ac4a4 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1936,6 +1936,8 @@ void QDeclarativeListView::setCacheBuffer(int b) /*! \qmlproperty string ListView::section.property \qmlproperty enumeration ListView::section.criteria + \qmlproperty Component ListView::section.delegate + These properties hold the expression to be evaluated for the \l section attached property. \c section.property hold the name of the property to use to determine @@ -1949,6 +1951,8 @@ void QDeclarativeListView::setCacheBuffer(int b) \o ViewSection.FirstCharacter - section is the first character of the property value. \endlist + \c section.delegate holds the delegate component for each section. + Each item in the list has attached properties named \c ListView.section and \c ListView.prevSection. These may be used to place a section header for related items. The example below assumes that the model is sorted by size of @@ -1985,7 +1989,7 @@ QString QDeclarativeListView::currentSection() const These properties hold the move and resize animation speed of the highlight delegate. - \c highlightFollowsCurrentItem must be true for these properties + \l highlightFollowsCurrentItem must be true for these properties to have effect. The default value for the speed properties is 400 pixels/second. -- cgit v0.12 From cbc1541ecf32ef0c52086b0fc83e1bca70a668ba Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 15 Jun 2010 14:46:37 +1000 Subject: Document QML_IMPORT_TRACE --- doc/src/declarative/qdeclarativedebugging.qdoc | 31 ++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/qdeclarativedebugging.qdoc b/doc/src/declarative/qdeclarativedebugging.qdoc index 4ff7fde..99dd2d2 100644 --- a/doc/src/declarative/qdeclarativedebugging.qdoc +++ b/doc/src/declarative/qdeclarativedebugging.qdoc @@ -60,8 +60,35 @@ Rectangle { \section1 Debugging Transitions When a transition doesn't look quite right, it can be helpful to view it in slow -motion to see what is happening more clearly. The \l {Qt Declarative UI Runtime}{qml} tool provides a -"Slow Down Animations" menu option to facilitate this. +motion to see what is happening more clearly. This functionality is supported +in the \l {Qt Declarative UI Runtime}{qmlviewer} tool: to enable this, +click on the "Debugging" menu, then "Slow Down Animations". + + +\section1 Debugging module imports + +The \c QML_IMPORT_TRACE environment variable can be set to enable debug output +from QML's import loading mechanisms. + +For example, for a simple QML file like this: + +\qml +import Qt 4.7 + +Rectangle { width: 100; height: 100 } +\endqml + +If you set \c {QML_IMPORT_TRACE=1} before running the \l {Qt Declarative UI Runtime}{qmlviewer} +(or your QML C++ application), you will see output similar to this: + +\code +QDeclarativeImportDatabase::addImportPath "/qt-sdk/imports" +QDeclarativeImportDatabase::addImportPath "/qt-sdk/bin/QMLViewer.app/Contents/MacOS" +QDeclarativeImportDatabase::addToImport 0x106237370 "." -1.-1 File as "" +QDeclarativeImportDatabase::addToImport 0x106237370 "Qt" 4.7 Library as "" +QDeclarativeImportDatabase::resolveType "Rectangle" = "QDeclarativeRectangle" +\endcode + \section1 Debugging with Qt Creator -- cgit v0.12 From eb05fde709f958a0a67f83455c02dcde3dfc1493 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 15 Jun 2010 15:55:58 +1000 Subject: Clean up list examples --- .../declarative/modelviews/listview/PetsModel.qml | 101 +++++++++ .../modelviews/listview/RecipesModel.qml | 130 +++++++++++ .../listview/content/ClickAutoRepeating.qml | 71 ------ .../modelviews/listview/content/MediaButton.qml | 75 ------- .../listview/content/PressAndHoldButton.qml | 79 +++++++ .../modelviews/listview/content/TextButton.qml | 78 +++++++ .../modelviews/listview/dummydata/MyPetsModel.qml | 101 --------- .../modelviews/listview/dummydata/Recipes.qml | 130 ----------- .../modelviews/listview/dynamiclist.qml | 244 +++++++-------------- .../modelviews/listview/expandingdelegates.qml | 74 ++++--- .../declarative/modelviews/listview/highlight.qml | 34 ++- .../modelviews/listview/highlightranges.qml | 70 +++--- .../declarative/modelviews/listview/sections.qml | 77 +++---- 13 files changed, 578 insertions(+), 686 deletions(-) create mode 100644 examples/declarative/modelviews/listview/PetsModel.qml create mode 100644 examples/declarative/modelviews/listview/RecipesModel.qml delete mode 100644 examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml delete mode 100644 examples/declarative/modelviews/listview/content/MediaButton.qml create mode 100644 examples/declarative/modelviews/listview/content/PressAndHoldButton.qml create mode 100644 examples/declarative/modelviews/listview/content/TextButton.qml delete mode 100644 examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml delete mode 100644 examples/declarative/modelviews/listview/dummydata/Recipes.qml diff --git a/examples/declarative/modelviews/listview/PetsModel.qml b/examples/declarative/modelviews/listview/PetsModel.qml new file mode 100644 index 0000000..70cdcdd --- /dev/null +++ b/examples/declarative/modelviews/listview/PetsModel.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +// ListModel allows free form list models to be defined and populated. + +ListModel { + id: petsModel + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/declarative/modelviews/listview/RecipesModel.qml b/examples/declarative/modelviews/listview/RecipesModel.qml new file mode 100644 index 0000000..03ab961 --- /dev/null +++ b/examples/declarative/modelviews/listview/RecipesModel.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +ListModel { + id: recipesModel + ListElement { + title: "Pancakes" + picture: "content/pics/pancakes.jpg" + ingredients: " +
    +
  • 1 cup (150g) self-raising flour +
  • 1 tbs caster sugar +
  • 3/4 cup (185ml) milk +
  • 1 egg +
+ " + method: " +
    +
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
  4. Turn over and cook other side until golden. +
+ " + } + ListElement { + title: "Fruit Salad" + picture: "content/pics/fruit-salad.jpg" + ingredients: "* Seasonal Fruit" + method: "* Chop fruit and place in a bowl." + } + ListElement { + title: "Vegetable Soup" + picture: "content/pics/vegetable-soup.jpg" + ingredients: " +
    +
  • 1 onion +
  • 1 turnip +
  • 1 potato +
  • 1 carrot +
  • 1 head of celery +
  • 1 1/2 litres of water +
+ " + method: " +
    +
  1. Chop vegetables. +
  2. Boil in water until vegetables soften. +
  3. Season with salt and pepper to taste. +
+ " + } + ListElement { + title: "Hamburger" + picture: "content/pics/hamburger.jpg" + ingredients: " +
    +
  • 500g minced beef +
  • Seasoning +
  • lettuce, tomato, onion, cheese +
  • 1 hamburger bun for each burger +
+ " + method: " +
    +
  1. Mix the beef, together with seasoning, in a food processor. +
  2. Shape the beef into burgers. +
  3. Grill the burgers for about 5 mins on each side (until cooked through) +
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
+ " + } + ListElement { + title: "Lemonade" + picture: "content/pics/lemonade.jpg" + ingredients: " +
    +
  • 1 cup Lemon Juice +
  • 1 cup Sugar +
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
+ " + method: " +
    +
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
  3. Chill or serve over ice cubes. +
+ " + } +} diff --git a/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml b/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml deleted file mode 100644 index dc23b78..0000000 --- a/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -Item { - id: page - property int repeatdelay: 300 - property int repeatperiod: 75 - property bool isPressed: false - - signal pressed - signal released - signal clicked - - SequentialAnimation on isPressed { - running: false - id: autoRepeat - PropertyAction { target: page; property: "isPressed"; value: true } - ScriptAction { script: page.pressed() } - ScriptAction { script: page.clicked() } - PauseAnimation { duration: repeatdelay } - SequentialAnimation { - loops: Animation.Infinite - ScriptAction { script: page.clicked() } - PauseAnimation { duration: repeatperiod } - } - } - MouseArea { - anchors.fill: parent - onPressed: autoRepeat.start() - onReleased: { autoRepeat.stop(); parent.isPressed = false; page.released() } - } -} diff --git a/examples/declarative/modelviews/listview/content/MediaButton.qml b/examples/declarative/modelviews/listview/content/MediaButton.qml deleted file mode 100644 index 2aed6e0..0000000 --- a/examples/declarative/modelviews/listview/content/MediaButton.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -Item { - property variant text - signal clicked - - id: container - Image { - id: normal - source: "pics/button.png" - } - Image { - id: pressed - source: "pics/button-pressed.png" - opacity: 0 - } - MouseArea { - id: clickRegion - anchors.fill: normal - onClicked: { container.clicked(); } - } - Text { - font.bold: true - color: "white" - anchors.centerIn: normal - text: container.text - } - width: normal.width - - states: State { - name: "Pressed" - when: clickRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - } -} diff --git a/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml b/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml new file mode 100644 index 0000000..7c174e3 --- /dev/null +++ b/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +Image { + id: container + + property int repeatDelay: 300 + property int repeatDuration: 75 + property bool pressed: false + + signal clicked + + scale: pressed ? 0.9 : 1 + + SequentialAnimation on pressed { + id: autoRepeatClicks + running: false + + PropertyAction { target: container; property: "pressed"; value: true } + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDelay } + + SequentialAnimation { + loops: Animation.Infinite + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDuration } + } + } + + MouseArea { + anchors.fill: parent + + onPressed: autoRepeatClicks.start() + onReleased: { + autoRepeatClicks.stop() + container.pressed = false + } + } +} + diff --git a/examples/declarative/modelviews/listview/content/TextButton.qml b/examples/declarative/modelviews/listview/content/TextButton.qml new file mode 100644 index 0000000..ded7a11 --- /dev/null +++ b/examples/declarative/modelviews/listview/content/TextButton.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +Rectangle { + id: container + + property alias text: label.text + + signal clicked + + width: label.width + 20; height: label.height + 6 + smooth: true + radius: 10 + + gradient: Gradient { + GradientStop { id: gradientStop; position: 0.0; color: palette.light } + GradientStop { position: 1.0; color: palette.button } + } + + SystemPalette { id: palette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { container.clicked() } + } + + Text { + id: label + anchors.centerIn: parent + } + + states: State { + name: "pressed" + when: mouseArea.pressed + PropertyChanges { target: gradientStop; color: palette.dark } + } +} + diff --git a/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml b/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml deleted file mode 100644 index 70cdcdd..0000000 --- a/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -// ListModel allows free form list models to be defined and populated. - -ListModel { - id: petsModel - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/modelviews/listview/dummydata/Recipes.qml b/examples/declarative/modelviews/listview/dummydata/Recipes.qml deleted file mode 100644 index 03ab961..0000000 --- a/examples/declarative/modelviews/listview/dummydata/Recipes.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -ListModel { - id: recipesModel - ListElement { - title: "Pancakes" - picture: "content/pics/pancakes.jpg" - ingredients: " -
    -
  • 1 cup (150g) self-raising flour -
  • 1 tbs caster sugar -
  • 3/4 cup (185ml) milk -
  • 1 egg -
- " - method: " -
    -
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
  4. Turn over and cook other side until golden. -
- " - } - ListElement { - title: "Fruit Salad" - picture: "content/pics/fruit-salad.jpg" - ingredients: "* Seasonal Fruit" - method: "* Chop fruit and place in a bowl." - } - ListElement { - title: "Vegetable Soup" - picture: "content/pics/vegetable-soup.jpg" - ingredients: " -
    -
  • 1 onion -
  • 1 turnip -
  • 1 potato -
  • 1 carrot -
  • 1 head of celery -
  • 1 1/2 litres of water -
- " - method: " -
    -
  1. Chop vegetables. -
  2. Boil in water until vegetables soften. -
  3. Season with salt and pepper to taste. -
- " - } - ListElement { - title: "Hamburger" - picture: "content/pics/hamburger.jpg" - ingredients: " -
    -
  • 500g minced beef -
  • Seasoning -
  • lettuce, tomato, onion, cheese -
  • 1 hamburger bun for each burger -
- " - method: " -
    -
  1. Mix the beef, together with seasoning, in a food processor. -
  2. Shape the beef into burgers. -
  3. Grill the burgers for about 5 mins on each side (until cooked through) -
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
- " - } - ListElement { - title: "Lemonade" - picture: "content/pics/lemonade.jpg" - ingredients: " -
    -
  • 1 cup Lemon Juice -
  • 1 cup Sugar -
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
- " - method: " -
    -
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
  3. Chill or serve over ice cubes. -
- " - } -} diff --git a/examples/declarative/modelviews/listview/dynamiclist.qml b/examples/declarative/modelviews/listview/dynamiclist.qml index df2e094..0e290f5 100644 --- a/examples/declarative/modelviews/listview/dynamiclist.qml +++ b/examples/declarative/modelviews/listview/dynamiclist.qml @@ -37,16 +37,18 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - import Qt 4.7 import "content" -import "../../ui-components/scrollbar" + +// This example shows how items can be dynamically added to and removed from +// a ListModel, and how these list modifications can be animated. Rectangle { id: container width: 640; height: 480 color: "#343434" + // The model: ListModel { id: fruitModel @@ -77,55 +79,43 @@ Rectangle { ListElement { description: "Smelly" } ] } - ListElement { - name: "Elderberry"; cost: 0.05 - attributes: [ - ListElement { description: "Berry" } - ] - } - ListElement { - name: "Fig"; cost: 0.25 - attributes: [ - ListElement { description: "Flower" } - ] - } } + // The delegate for each fruit in the model: Component { - id: fruitDelegate - + id: listDelegate + Item { - id: wrapper - width: container.width; height: 55 + id: delegateItem + width: listView.width; height: 55 + clip: true - Column { - id: moveButtons - x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter + Row { + anchors.verticalCenter: parent.verticalCenter + spacing: 10 - Image { - source: "content/pics/go-up.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) } - } - Image { source: "content/pics/go-down.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) } + Column { + Image { + source: "content/pics/go-up.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) } + } + Image { source: "content/pics/go-down.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) } + } } - } - Column { - anchors { right: itemButtons.left; verticalCenter: parent.verticalCenter; left: moveButtons.right; leftMargin: 10 } + Column { + anchors.verticalCenter: parent.verticalCenter - Text { - id: label - width: parent.width - color: "White" - font.bold: true; font.pixelSize: 15 - text: name; elide: Text.ElideRight - } - Row { - spacing: 5 - Repeater { - model: attributes - Component { + Text { + text: name + font.pixelSize: 15 + color: "white" + } + Row { + spacing: 5 + Repeater { + model: attributes Text { text: description; color: "White" } } } @@ -133,149 +123,81 @@ Rectangle { } Row { - id: itemButtons - - anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter } - width: childrenRect.width + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right spacing: 10 - Image { + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter source: "content/pics/list-add.png" - scale: clickUp.isPressed ? 0.9 : 1 - - ClickAutoRepeating { - id: clickUp - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", cost+0.25) - } + onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) } - Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } + Text { + id: costText + anchors.verticalCenter: parent.verticalCenter + text: '$' + Number(cost).toFixed(2) + font.pixelSize: 15 + color: "white" + font.bold: true + } - Image { + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter source: "content/pics/list-remove.png" - scale: clickDown.isPressed ? 0.9 : 1 + onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + } - ClickAutoRepeating { - id: clickDown - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) - } + Image { + source: "content/pics/archive-remove.png" + MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } } } - Image { - id: removeButton - anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 } - source: "content/pics/archive-remove.png" - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + // Animate adding and removing of items: + + ListView.onAdd: SequentialAnimation { + PropertyAction { target: delegateItem; property: "height"; value: 0 } + NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } } - // Animate adding and removing items - ListView.delayRemove: true // so that the item is not destroyed immediately - ListView.onAdd: state = "add" - ListView.onRemove: state = "remove" - states: [ - State { - name: "add" - PropertyChanges { target: wrapper; height: 55; clip: true } - }, - State { - name: "remove" - PropertyChanges { target: wrapper; height: 0; clip: true } - } - ] - transitions: [ - Transition { - to: "add" - SequentialAnimation { - NumberAnimation { properties: "height"; from: 0; to: 55 } - PropertyAction { target: wrapper; property: "state"; value: "" } - } - }, - Transition { - to: "remove" - SequentialAnimation { - NumberAnimation { properties: "height" } - // Make sure delayRemove is set back to false so that the item can be destroyed - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - } - } - ] + ListView.onRemove: SequentialAnimation { + PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + + // Make sure delayRemove is set back to false so that the item can be destroyed + PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } + } } } + // The view: ListView { - id: view - anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top } + id: listView + anchors.fill: parent; anchors.margins: 20 model: fruitModel - delegate: fruitDelegate - } - - // Attach scrollbar to the right edge of the view. - ScrollBar { - id: verticalScrollBar - - width: 8; height: view.height; anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - - // Only show the scrollbar when the view is moving. - states: State { - name: "ShowBars"; when: view.movingVertically - PropertyChanges { target: verticalScrollBar; opacity: 1 } - } - transitions: Transition { - NumberAnimation { properties: "opacity"; duration: 400 } - } + delegate: listDelegate } Row { - id: buttons - - x: 8; width: childrenRect.width; height: childrenRect.height - anchors { bottom: parent.bottom; bottomMargin: 8 } - spacing: 8 - - Image { - source: "content/pics/archive-insert.png" - - MouseArea { - anchors.fill: parent - onClicked: { - fruitModel.append({ - "name": "Pizza Margarita", - "cost": 5.95, - "attributes": [{"description": "Cheese"},{"description": "Tomato"}] - }) - } - } - } - - Image { - source: "content/pics/archive-insert.png" - - MouseArea { - anchors.fill: parent; - onClicked: { - fruitModel.insert(0, { - "name": "Pizza Supreme", - "cost": 9.95, - "attributes": [{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}] - }) - } + anchors { left: parent.left; bottom: parent.bottom; margins: 20 } + spacing: 10 + + TextButton { + text: "Add an item" + onClicked: { + fruitModel.append({ + "name": "Pizza Margarita", + "cost": 5.95, + "attributes": [{"description": "Cheese"}, {"description": "Tomato"}] + }) } } - Image { - source: "content/pics/archive-remove.png" - - MouseArea { - anchors.fill: parent - onClicked: fruitModel.clear() - } + TextButton { + text: "Remove all items" + onClicked: fruitModel.clear() } } } + diff --git a/examples/declarative/modelviews/listview/expandingdelegates.qml b/examples/declarative/modelviews/listview/expandingdelegates.qml index f4b97ea..94ea48f 100644 --- a/examples/declarative/modelviews/listview/expandingdelegates.qml +++ b/examples/declarative/modelviews/listview/expandingdelegates.qml @@ -41,7 +41,7 @@ import Qt 4.7 import "content" -// This example illustrates expanding a list item to show a more detailed view +// This example illustrates expanding a list item to show a more detailed view. Rectangle { id: page @@ -49,13 +49,13 @@ Rectangle { color: "black" // Delegate for the recipes. This delegate has two modes: - // 1. the list mode (default), which just shows the picture and title of the recipe. - // 2. the details mode, which also shows the ingredients and method. + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. Component { id: recipeDelegate Item { - id: wrapper + id: recipe // Create a property to contain the visibility of the details. // We can bind multiple element's opacity to this one property, @@ -63,14 +63,15 @@ Rectangle { // want to fade. property real detailsOpacity : 0 - width: list.width + width: listView.width + height: 70 // A simple rounded rectangle for the background Rectangle { id: background - x: 1; y: 2; width: parent.width - 2; height: parent.height - 4 - color: "#FEFFEE" - border.color: "#FFBE4F" + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" radius: 5 } @@ -78,50 +79,53 @@ Rectangle { // When clicked it changes mode to 'Details'. If we are already // in Details mode, then no change will happen. MouseArea { - id: pageMouse anchors.fill: parent - onClicked: wrapper.state = 'Details'; + onClicked: recipe.state = 'Details'; } - // Layout the page. Picture, title and ingredients at the top, method at the + // Lay out the page: picture, title and ingredients at the top, and method at the // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to wrapper.detailsOpacity. + // mode have their opacity set to recipe.detailsOpacity. Row { id: topLayout - x: 10; y: 10; height: recipePic.height; width: parent.width + x: 10; y: 10; height: recipeImage.height; width: parent.width spacing: 10 Image { - id: recipePic - source: picture; width: 48; height: 48 + id: recipeImage + width: 50; height: 50 + source: picture } Column { - width: background.width-recipePic.width-20; height: recipePic.height; + width: background.width - recipeImage.width - 20; height: recipeImage.height spacing: 5 - Text { id: name; text: title; font.bold: true; font.pointSize: 16 } + Text { + text: title + font.bold: true; font.pointSize: 16 + } Text { text: "Ingredients" font.pointSize: 12; font.bold: true - opacity: wrapper.detailsOpacity + opacity: recipe.detailsOpacity } Text { text: ingredients wrapMode: Text.WordWrap width: parent.width - opacity: wrapper.detailsOpacity + opacity: recipe.detailsOpacity } } } Item { id: details - x: 10; width: parent.width-20 + x: 10; width: parent.width - 20 anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: wrapper.detailsOpacity + opacity: recipe.detailsOpacity Text { id: methodTitle @@ -153,30 +157,28 @@ Rectangle { } // A button to close the detailed view, i.e. set the state back to default (''). - MediaButton { - y: 10; anchors { right: background.right; rightMargin: 5 } - opacity: wrapper.detailsOpacity + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity text: "Close" - onClicked: wrapper.state = ''; + onClicked: recipe.state = ''; } - // Set the default height to the height of the picture, plus margin. - height: 68 - states: State { name: "Details" PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipePic; width: 128; height: 128 } // Make picture bigger - PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 } // Make details visible - PropertyChanges { target: wrapper; height: list.height } // Fill the entire list area with the detailed view + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible + PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view // Move the list so that this item is at the top. - PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y } + PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } // Disallow flicking while we're in detailed view - PropertyChanges { target: wrapper.ListView.view; interactive: false } + PropertyChanges { target: recipe.ListView.view; interactive: false } } transitions: Transition { @@ -191,10 +193,10 @@ Rectangle { // The actual list ListView { - id: list + id: listView anchors.fill: parent - clip: true - model: Recipes + model: RecipesModel {} delegate: recipeDelegate + clip: true } } diff --git a/examples/declarative/modelviews/listview/highlight.qml b/examples/declarative/modelviews/listview/highlight.qml index 239272a..5748974 100644 --- a/examples/declarative/modelviews/listview/highlight.qml +++ b/examples/declarative/modelviews/listview/highlight.qml @@ -41,12 +41,7 @@ import Qt 4.7 Rectangle { - width: 400; height: 300 - - // MyPets model is defined in dummydata/MyPetsModel.qml - // The launcher automatically loads files in dummydata/* to assist - // development without a real data source. - // This one contains my pets. + width: 200; height: 300 // Define a delegate component. A component will be // instantiated for each visible item in the list. @@ -54,42 +49,45 @@ Rectangle { id: petDelegate Item { id: wrapper - width: 200; height: 50 + width: 200; height: 55 Column { Text { text: 'Name: ' + name } Text { text: 'Type: ' + type } Text { text: 'Age: ' + age } } - // Use the ListView.isCurrentItem attached property to - // indent the item if it is the current item. + // indent the item if it is the current item states: State { name: "Current" when: wrapper.ListView.isCurrentItem - PropertyChanges { target: wrapper; x: 10 } + PropertyChanges { target: wrapper; x: 20 } } transitions: Transition { NumberAnimation { properties: "x"; duration: 200 } } } } - // Specify a highlight with custom movement. Note that highlightFollowsCurrentItem - // is set to false in the ListView so that we can control how the - // highlight moves to the current item. + + // Define a highlight with customised movement between items. Component { - id: petHighlight + id: highlightBar Rectangle { width: 200; height: 50 color: "#FFFF88" - SpringFollow on y { to: list1.currentItem.y; spring: 3; damping: 0.1 } + SpringFollow on y { to: listView.currentItem.y; spring: 3; damping: 0.1 } } } ListView { - id: list1 + id: listView width: 200; height: parent.height - model: MyPetsModel + + model: PetsModel {} delegate: petDelegate - highlight: petHighlight; highlightFollowsCurrentItem: false focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false } } diff --git a/examples/declarative/modelviews/listview/highlightranges.qml b/examples/declarative/modelviews/listview/highlightranges.qml index a8a95c4..162d8b7 100644 --- a/examples/declarative/modelviews/listview/highlightranges.qml +++ b/examples/declarative/modelviews/listview/highlightranges.qml @@ -43,46 +43,20 @@ import Qt 4.7 Rectangle { width: 600; height: 300 - // MyPets model is defined in dummydata/MyPetsModel.qml - // The viewer automatically loads files in dummydata/* to assist - // development without a real data source. - // This one contains my pets. - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - width: 200; height: 50 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - } - } - - // Define a highlight component. Just one of these will be instantiated - // by each ListView and placed behind the current item. - Component { - id: petHighlight - Rectangle { color: "#FFFF88" } - } - // Show the model in three lists, with different highlight ranges. // preferredHighlightBegin and preferredHighlightEnd set the // range in which to attempt to maintain the highlight. // - // Note that the second and third ListView - // set their currentIndex to be the same as the first, and that - // the first ListView is given keyboard focus. + // The second and third ListView set their currentIndex to be the + // same as the first, and the first ListView is given keyboard focus. // - // The default mode allows the currentItem to move freely - // within the visible area. If it would move outside the visible - // area, the view is scrolled to keep it visible. + // The first list does not set a highlight range, so its currentItem + // can move freely within the visible area. If it moves outside the + // visible area, the view is automatically scrolled to keep the current + // item visible. // // The second list sets a highlight range which attempts to keep the - // current item within the the bounds of the range, however + // current item within the the bounds of the range. However, // items will not scroll beyond the beginning or end of the view, // forcing the highlight to move outside the range at the ends. // @@ -98,21 +72,22 @@ Rectangle { ListView { id: list1 width: 200; height: parent.height - model: MyPetsModel + model: PetsModel {} delegate: petDelegate - highlight: petHighlight + highlight: Rectangle { color: "lightsteelblue" } currentIndex: list3.currentIndex focus: true } ListView { id: list2 - x: 200; width: 200; height: parent.height - model: MyPetsModel + x: list1.width + width: 200; height: parent.height + model: PetsModel {} delegate: petDelegate - highlight: petHighlight + highlight: Rectangle { color: "yellow" } currentIndex: list1.currentIndex preferredHighlightBegin: 80; preferredHighlightEnd: 220 highlightRangeMode: ListView.ApplyRange @@ -120,14 +95,25 @@ Rectangle { ListView { id: list3 - x: 400; width: 200; height: parent.height - model: MyPetsModel + x: list1.width + list2.width + width: 200; height: parent.height + model: PetsModel {} delegate: petDelegate - highlight: Rectangle { color: "lightsteelblue" } + highlight: Rectangle { color: "yellow" } currentIndex: list1.currentIndex preferredHighlightBegin: 125; preferredHighlightEnd: 125 highlightRangeMode: ListView.StrictlyEnforceRange - flickDeceleration: 1000 + } + + // The delegate for each list + Component { + id: petDelegate + Column { + width: 200 + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } } } diff --git a/examples/declarative/modelviews/listview/sections.qml b/examples/declarative/modelviews/listview/sections.qml index d2f9aba..8c038a0 100644 --- a/examples/declarative/modelviews/listview/sections.qml +++ b/examples/declarative/modelviews/listview/sections.qml @@ -42,70 +42,43 @@ import Qt 4.7 //! [0] Rectangle { + id: container width: 200 - height: 240 + height: 250 - // MyPets model is defined in dummydata/MyPetsModel.qml - // The viewer automatically loads files in dummydata/* to assist - // development without a real data source. - // This one contains my pets. - - // Define a delegate component that includes a separator for sections. - Component { - id: petDelegate - - Item { - id: wrapper - width: 200 - height: desc.height // height is the combined height of the description and the section separator + ListModel { + id: animalsModel + ListElement { name: "Parrot"; size: "Small" } + ListElement { name: "Guinea pig"; size: "Small" } + ListElement { name: "Dog"; size: "Medium" } + ListElement { name: "Cat"; size: "Medium" } + ListElement { name: "Elephant"; size: "Large" } + } - Item { - id: desc - x: 5; height: layout.height + 4 + // The delegate for each section header + Component { + id: sectionHeading + Rectangle { + width: container.width + height: childrenRect.height + color: "lightsteelblue" - Column { - id: layout - y: 2 - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } + Text { + text: section + font.bold: true } } } - // Define a highlight component. Just one of these will be instantiated - // by each ListView and placed behind the current item. - Component { - id: petHighlight - Rectangle { color: "#FFFF88" } - } - - // The list ListView { - id: myList + anchors.fill: parent + model: animalsModel + delegate: Text { text: name } - width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - highlight: petHighlight - focus: true - - // The sectionExpression is simply the size of the pet. - // We use this to determine which section we are in above. section.property: "size" section.criteria: ViewSection.FullString - section.delegate: Rectangle { - color: "lightsteelblue" - width: 200 - height: 20 - Text { - x: 2; height: parent.height - verticalAlignment: Text.AlignVCenter - text: section - font.bold: true - } - } + section.delegate: sectionHeading } } //! [0] + -- cgit v0.12 From 71ba2b0973d291e991e1498c266e69d6640c8531 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Wed, 16 Jun 2010 10:01:42 +0200 Subject: Reduce the memory consumption of QtFontStyle QtFontSize::pixelSize() was allocating 8 slots for QtFontSize while most fonts only require one. This patch add a special case for the first QtFontSize in order to reduce memory consumption. The size of QtFontSize in memory has also been reduced. Overall, the memory consumtion of QtFontStyle instances go down from 100kb to 10kb. Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontdatabase.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index ff29462..4c058ce 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -145,18 +145,18 @@ struct QtFontEncoding struct QtFontSize { - unsigned short pixelSize; - #ifdef Q_WS_X11 - int count; QtFontEncoding *encodings; QtFontEncoding *encodingID(int id, uint xpoint = 0, uint xres = 0, uint yres = 0, uint avgwidth = 0, bool add = false); + unsigned short count : 16; #endif // Q_WS_X11 #if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) QByteArray fileName; int fileIndex; #endif // defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) + + unsigned short pixelSize : 16; }; @@ -284,7 +284,12 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add) if (!add) return 0; - if (!(count % 8)) { + if (!pixelSizes) { + // Most style have only one font size, we avoid waisting memory + QtFontSize *newPixelSizes = (QtFontSize *)malloc(sizeof(QtFontSize)); + Q_CHECK_PTR(newPixelSizes); + pixelSizes = newPixelSizes; + } else if (!(count % 8)) { QtFontSize *newPixelSizes = (QtFontSize *) realloc(pixelSizes, (((count+8) >> 3) << 3) * sizeof(QtFontSize)); -- cgit v0.12 From 7b0f85f91c7bf51b98e96621312a0f5e86349461 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 29 May 2010 20:34:46 +0200 Subject: Work around ICE in Intel C++ Compiler 11.1.072 qml/qdeclarativecompiledbindings.cpp(1141) (col. 11): internal error: 0_1855 Intel reports that this bug has been fixed with release 12 of ICC Reviewed-By: Alan Alpert --- src/declarative/qml/qdeclarativecompiledbindings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp index ad05e80..507e47b 100644 --- a/src/declarative/qml/qdeclarativecompiledbindings.cpp +++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp @@ -64,7 +64,7 @@ DEFINE_BOOL_CONFIG_OPTION(bindingsDump, QML_BINDINGS_DUMP); Q_GLOBAL_STATIC(QDeclarativeFastProperties, fastProperties); -#ifdef __GNUC__ +#if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200) # define QML_THREADED_INTERPRETER #endif -- cgit v0.12 From 5b5785bc564ccea9f6868d02be3d1080cb5039b9 Mon Sep 17 00:00:00 2001 From: kh1 Date: Wed, 16 Jun 2010 12:24:12 +0200 Subject: Fix some kind of race condition while using remote commands. Please do not merge to master, we had to fix it different there. Because of async content loading, we have to cache the url to load. A combination of SetSource and SyncContents would have lead to sync to the old url till loading was finished. So return the cached during loading. Task-number: QTBUG-11342 Reviewed-by: ck --- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 23 +++++++++++++++++++++- tools/assistant/tools/assistant/helpviewer_qwv.h | 3 ++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index 244d091..dcbbf2c 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -172,6 +172,7 @@ private: bool closeNewTabIfNeeded; friend class HelpViewer; + QUrl m_loadingUrl; Qt::MouseButtons m_pressedButtons; Qt::KeyboardModifiers m_keyboardModifiers; }; @@ -232,6 +233,11 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, return false; } + m_loadingUrl = url; // because of async page loading, we will hit some kind + // of race condition while using a remote command, like a combination of + // SetSource; SyncContent. SetSource would be called and SyncContents shortly + // afterwards, but the page might not have finished loading and the old url + // would be returned. return true; } @@ -268,6 +274,7 @@ HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this, SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); + connect(this, SIGNAL(loadStarted()), this, SLOT(setLoadStarted())); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SIGNAL(printRequested())); @@ -333,10 +340,19 @@ bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e) return false; } +QUrl HelpViewer::source() const +{ + HelpPage *currentPage = static_cast (page()); + if (currentPage && !hasLoadFinished()) { + // see HelpPage::acceptNavigationRequest(...) + return currentPage->m_loadingUrl; + } + return url(); +} + void HelpViewer::setSource(const QUrl &url) { TRACE_OBJ - loadFinished = false; load(url.toString() == QLatin1String("help") ? LocalHelpFile : url); } @@ -396,6 +412,11 @@ void HelpViewer::mousePressEvent(QMouseEvent *event) QWebView::mousePressEvent(event); } +void HelpViewer::setLoadStarted() +{ + loadFinished = false; +} + void HelpViewer::setLoadFinished(bool ok) { TRACE_OBJ diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h index 2577828..1897e3e 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -71,8 +71,8 @@ public: bool handleForwardBackwardMouseButtons(QMouseEvent *e); + QUrl source() const; void setSource(const QUrl &url); - inline QUrl source() const { return url(); } inline QString documentTitle() const { return title(); } @@ -109,6 +109,7 @@ protected: private Q_SLOTS: void actionChanged(); + void setLoadStarted(); void setLoadFinished(bool ok); private: -- cgit v0.12 From 73fa311f67b21c9b897de0196d3b8227f27d828f Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 15 Jun 2010 14:44:17 +0200 Subject: qmake: Fix CONFIG += exceptions_off with the MSVC project generator. cl.exe default exception handling (when not specified on the command line) is to disable exceptions. In vcproj files however, if the ExceptionHandling option is not specified, the default behavior is to enable exceptions without SEH (/EHsh). This patch makes sure that ExceptionHandling is disabled when /EHsc is not fed to parseOption (which happens when the exceptions_off config is encountered). For VS2003 the values are a bit different where "false"==ehNone, "true"==ehNoSEH and ehSEH is not available. The default is "true" if not specified thus why we set it to "false" when exceptions_off is given. Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msbuild_objectmodel.cpp | 1 + qmake/generators/win32/msvc_objectmodel.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 75fc910..bf874b2 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -385,6 +385,7 @@ VCXCLCompilerTool::VCXCLCompilerTool() DisableLanguageExtensions(unset), EnableFiberSafeOptimizations(unset), EnablePREfast(unset), + ExceptionHandling("false"), ExpandAttributedSource(unset), FloatingPointExceptions(unset), ForceConformanceInForLoopScope(unset), diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 1e060a0..e23e119 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -360,8 +360,11 @@ inline XmlOutput::xml_output xformUsePrecompiledHeaderForNET2005(pchOption whatP inline XmlOutput::xml_output xformExceptionHandlingNET2005(exceptionHandling eh, DotNET compilerVersion) { - if (eh == ehDefault) - return noxml(); + if (eh == ehDefault) { + if (compilerVersion >= NET2005) + return attrE(_ExceptionHandling, ehNone); + return attrS(_ExceptionHandling, "false"); + } if (compilerVersion >= NET2005) return attrE(_ExceptionHandling, eh); -- cgit v0.12 From 7e08ce215763475c5933d2f035687e5db3d5295d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 16 Jun 2010 14:14:06 +0200 Subject: Updated JavaScriptCore from /home/khansen/dev/qtwebkit-qtscript-integration to javascriptcore-snapshot-16062010 ( 8b2d3443afca194f8ac50a63151dc9d19a150582 ) Integrated changes: || || JSC's currentThreadStackBase is not reentrant on some platforms --- src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog | 17 +++++++++++++++++ .../JavaScriptCore/runtime/Collector.cpp | 18 ++++++++++-------- src/3rdparty/javascriptcore/VERSION | 4 ++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog index fd6125f..b0873ab 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog +++ b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog @@ -12,6 +12,23 @@ * wtf/Platform.h: +2010-04-28 Simon Hausmann , Kent Hansen + + Reviewed by Darin Adler. + + JSC's currentThreadStackBase is not reentrant on some platforms + https://bugs.webkit.org/show_bug.cgi?id=37195 + + This function needs to be reentrant to avoid memory corruption on platforms where + the implementation uses global variables. + + This patch adds a mutex lock where necessary and makes the Symbian implementation + reentrant. + + * runtime/Collector.cpp: + (JSC::currentThreadStackBaseMutex): + (JSC::currentThreadStackBase): + 2010-04-14 Kent Hansen Reviewed by Maciej Stachowiak. diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp index 57f2a92..eafcc23 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp @@ -637,6 +637,8 @@ static inline void* currentThreadStackBase() #elif OS(HPUX) return hpux_get_stack_base(); #elif OS(QNX) + AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); + MutexLocker locker(mutex); return currentThreadStackBaseQNX(); #elif OS(SOLARIS) stack_t s; @@ -660,19 +662,17 @@ static inline void* currentThreadStackBase() pthread_stackseg_np(thread, &stack); return stack.ss_sp; #elif OS(SYMBIAN) - static void* stackBase = 0; - if (stackBase == 0) { - TThreadStackInfo info; - RThread thread; - thread.StackInfo(info); - stackBase = (void*)info.iBase; - } - return (void*)stackBase; + TThreadStackInfo info; + RThread thread; + thread.StackInfo(info); + return (void*)info.iBase; #elif OS(HAIKU) thread_info threadInfo; get_thread_info(find_thread(NULL), &threadInfo); return threadInfo.stack_end; #elif OS(UNIX) + AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); + MutexLocker locker(mutex); static void* stackBase = 0; static size_t stackSize = 0; static pthread_t stackThread; @@ -695,6 +695,8 @@ static inline void* currentThreadStackBase() } return static_cast(stackBase) + stackSize; #elif OS(WINCE) + AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); + MutexLocker locker(mutex); if (g_stackBase) return g_stackBase; else { diff --git a/src/3rdparty/javascriptcore/VERSION b/src/3rdparty/javascriptcore/VERSION index 1b5109a..daecc37 100644 --- a/src/3rdparty/javascriptcore/VERSION +++ b/src/3rdparty/javascriptcore/VERSION @@ -4,8 +4,8 @@ This is a snapshot of JavaScriptCore from The commit imported was from the - javascriptcore-snapshot-19052010 branch/tag + javascriptcore-snapshot-16062010 branch/tag and has the sha1 checksum - 8039ba79702d6516cf6841c9f15b324ec499bbf3 + 8b2d3443afca194f8ac50a63151dc9d19a150582 -- cgit v0.12 From 47d3d5569e25d0e88259e1f0448d87325da0ab6a Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 16 Jun 2010 13:54:56 +0200 Subject: Make sure only started gestures can cause cancellations The design is that calling setGestureCancelPolicy on the gesture that is in starting state, and is accepted can cause other gestures to be cancelled. So change the logic to follow this, which means we won't try to execute the cancel strategy if the gesture was never accepted and avoid the crash detailed in the task. Reviewed-by: Denis Task-number: QTBUG-9771 --- src/gui/graphicsview/qgraphicsscene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 6c5623e..ca3b56f 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -6277,7 +6277,8 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original) { Q_ASSERT(original); QGraphicsItem *originalItem = gestureTargets.value(original); - Q_ASSERT(originalItem); + if (originalItem == 0) // we only act on accepted gestures, which implies it has a target. + return; // iterate over all active gestures and for each find the owner // if the owner is part of our sub-hierarchy, cancel it. -- cgit v0.12 From 3d03e0a1fdd04e1ab97ba0f95a3a934c879d047e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 16 Jun 2010 05:00:47 +0200 Subject: Defer allocation of GIF decoding tables/stack. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WebKit creates many image readers but will only retrieve the dimensions until the image itself is actually needed (i.e appears in the viewport.) This avoids allocating 16kB per GIF image until it's time to actually decode it. Reviewed-by: Samuel Rødal --- src/plugins/imageformats/gif/qgifhandler.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index 5e2157e..58093aa 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -132,8 +132,8 @@ private: int code_size, clear_code, end_code, max_code_size, max_code; int firstcode, oldcode, incode; - short table[2][1<< max_lzw_bits]; - short stack[(1<<(max_lzw_bits))*2]; + short* table[2]; + short* stack; short *sp; bool needfirst; int x, y; @@ -162,6 +162,9 @@ QGIFFormat::QGIFFormat() lcmap = false; newFrame = false; partialNewFrame = false; + table[0] = 0; + table[1] = 0; + stack = 0; } /*! @@ -171,6 +174,7 @@ QGIFFormat::~QGIFFormat() { if (globalcmap) delete[] globalcmap; if (localcmap) delete[] localcmap; + delete [] stack; } void QGIFFormat::disposePrevious(QImage *image) @@ -237,6 +241,12 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, // CompuServe Incorporated. GIF(sm) is a Service Mark property of // CompuServe Incorporated." + if (!stack) { + stack = new short[(1 << max_lzw_bits) * 4]; + table[0] = &stack[(1 << max_lzw_bits) * 2]; + table[1] = &stack[(1 << max_lzw_bits) * 3]; + } + image->detach(); int bpl = image->bytesPerLine(); unsigned char *bits = image->bits(); -- cgit v0.12