From 995afbfc2ca81960ca840f50b2a837938a4f1d52 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Sun, 14 Feb 2010 12:16:00 +0200 Subject: Change a name of a variable to be more descriptive Currently when calculating a button content size, QS60Style has a variable called buttonWidth, which actually is the width of the content, not the button itself. Change this to buttonContentWidth. Reviewed-by: TrustMe --- src/gui/styles/qs60style.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 9025e5b..14e9b95 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2559,11 +2559,11 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) { const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; const int buttonMargin = spinbox->frame ? 2 : 0; - const int buttonWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; + const int buttonContentWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; QSize buttonSize; buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); //width should at least be equal to height - buttonSize.setWidth(qMax(buttonSize.height(), buttonWidth)); + buttonSize.setWidth(qMax(buttonSize.height(), buttonContentWidth)); buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); const int y = frameThickness + spinbox->rect.y(); -- cgit v0.12 From 35f993eaa233f4729118eb796554b0ccce85b67e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 15 Feb 2010 08:46:25 +0200 Subject: Remove scrollbar context menu from QS60Style Currently style does not forbid scrollbar context menu, so by default long pressing over the scrollbar widget shows the context menu. This is not according to 'S60-style', so from now on the stylehint SH_ScrollBar_ContextMenu returns false. Task-number: QTBUG-8194 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 14e9b95..7372c3c 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2481,6 +2481,9 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_FormLayoutWrapPolicy: retValue = QFormLayout::WrapLongRows; break; + case SH_ScrollBar_ContextMenu: + retValue = false; + break; default: retValue = QCommonStyle::styleHint(sh, opt, widget, hret); break; -- cgit v0.12 From b92b103d1b88760ff5b05163865593be6e937b07 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 15 Feb 2010 08:55:42 +0200 Subject: QS60Style draws drop area as a black rect When Drag-n-Dropping elements in itemviews QS60Style draws drop area as a black rect. Change this so that native graphics are used instead. This change only affects touch-devices as non-touch 3.x devices do not have the native graphics defined. In 3.x non-touch devices, style still uses QCommonStyle to draw the DropArea. Task-number: QTBUG-8193 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 11 +++++++++-- src/gui/styles/qs60style_p.h | 2 ++ src/gui/styles/qs60style_s60.cpp | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 7372c3c..8f253cd 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -289,6 +289,9 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, case SE_Editor: drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); break; + case SE_DropArea: + drawPart(QS60StyleEnums::SP_QgnGrafOrgBgGrid, painter, rect, flags | SF_PointNorth); + break; default: break; } @@ -2302,7 +2305,12 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti break; case PE_PanelScrollAreaCorner: break; - + case PE_IndicatorItemViewItemDrop: + if (QS60StylePrivate::isTouchSupported()) + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_DropArea, painter, option->rect, flags); + else + commonStyleDraws = true; + break; // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases case PE_FrameLineEdit: case PE_IndicatorDockWidgetResizeHandle: @@ -2323,7 +2331,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif //QT_NO_TOOLBAR #ifndef QT_NO_COLUMNVIEW case PE_IndicatorColumnViewArrow: - case PE_IndicatorItemViewItemDrop: #endif //QT_NO_COLUMNVIEW case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. default: diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index eae2291..0119398 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -131,6 +131,7 @@ public: SP_QgnGrafBarFrameSideL, SP_QgnGrafBarFrameSideR, SP_QgnGrafBarProgress, + SP_QgnGrafOrgBgGrid SP_QgnGrafScrollArrowDown, SP_QgnGrafScrollArrowLeft, SP_QgnGrafScrollArrowRight, @@ -428,6 +429,7 @@ public: SE_ScrollBarHandlePressedVertical, SE_ButtonInactive, SE_Editor, + SE_DropArea }; enum SkinFrameElements { diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 872bc2b..e9b2da8 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -178,6 +178,7 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafOrgBgGrid */ {KAknsIIDQgnGrafOrgBgGrid, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawGulIcon, ES60_All, -1,-1}, /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawGulIcon, ES60_All, -1,-1}, /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawGulIcon, ES60_All, -1,-1}, -- cgit v0.12 From a4fdbdca6d55fa9e569a446c0f161a72205a0a4e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 15 Feb 2010 08:58:54 +0200 Subject: Scroll bar handle/groove ends are squeezed (in nHD resolution) QS60Style uses non-square area for scrollbar end graphics areas. It then tries to scale the areas to make them look like native graphics (and keeps the width-height ratio), thus squeezing them. Change style so that scrollbar end areas are squares, just like in native graphics they are. Task-number: QTBUG-7996 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 8f253cd..dd1489f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -847,15 +847,18 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); break; - case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: - case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: case QS60StyleEnums::SP_QsnCpScrollBgBottom: - case QS60StyleEnums::SP_QsnCpScrollBgMiddle: case QS60StyleEnums::SP_QsnCpScrollBgTop: case QS60StyleEnums::SP_QsnCpScrollHandleBottom: - case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: case QS60StyleEnums::SP_QsnCpScrollHandleTop: + case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: + result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); + result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent)); + break; + case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: + case QS60StyleEnums::SP_QsnCpScrollBgMiddle: + case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); result.setWidth(pixelMetric(QStyle::PM_ScrollBarSliderMin)); break; -- cgit v0.12 From 12bbcde642ed81c574b8f8d7af1d15885e998582 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 15 Feb 2010 09:11:09 +0200 Subject: Compilation error fix: missing comma in enum list in QS60Style Fix for QTBUG-8193 introduced a new enum value into s60style. Unfortunately, the comma after the value didn't make it into the fix itself. Adding the comma to allow compilation of style. Task-number: QTBUG-8193 Reviewed-by: TrustMe --- src/gui/styles/qs60style_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 0119398..ea30b81 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -131,7 +131,7 @@ public: SP_QgnGrafBarFrameSideL, SP_QgnGrafBarFrameSideR, SP_QgnGrafBarProgress, - SP_QgnGrafOrgBgGrid + SP_QgnGrafOrgBgGrid, SP_QgnGrafScrollArrowDown, SP_QgnGrafScrollArrowLeft, SP_QgnGrafScrollArrowRight, -- cgit v0.12 From 6e88bdd8012b54549a22e22da4c35215bbc67917 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 15 Feb 2010 09:13:38 +0200 Subject: QS60Style: Branch indicator in tree view is misplaced Fix for QTBUG-7258 make itemview margins larger. This broke the treeviews visually, as indicators are not shown in correct places. Now, indocators are placed correctly for treeviews as well. Task-number: QTBUG-7995 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index dd1489f..ea7399f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2277,14 +2277,16 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti QS60StyleEnums::SkinParts skinPart = (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; int minDimension = qMin(option->rect.width(), option->rect.height()); - const int resizeValue = minDimension >> 1; - minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); - int verticalMagic(0); - // magic values for positioning svg icon. - if (option->rect.width() <= option->rect.height()) - verticalMagic = 3; - iconRect.translate(3, verticalMagic - resizeValue); + const int magicTweak = 3; + int resizeValue = minDimension >> 1; + if (!QS60StylePrivate::isTouchSupported()) { + minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. + iconRect.setSize(QSize(minDimension, minDimension)); + const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; + resizeValue = verticalMagic - resizeValue; + } + iconRect.translate(magicTweak, resizeValue); QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); } } -- cgit v0.12 From 60db3752fbbf6453ae935798d149986fb64e0507 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 15 Feb 2010 11:45:02 +0200 Subject: Build break fix for QS60Style. Very recent change for QS60Style breaks compilation of the style for 3.1. This is due to that style refers to a skin item ID that is not existing on 3.1 environment. Fixed by referring to the skin ID with its internal values. Task-number: QTBUG-8193 Reviewed-by: TrustMe --- src/gui/styles/qs60style_s60.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index e9b2da8..d57b187 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -178,7 +178,8 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_All, -1,-1}, - /* SP_QgnGrafOrgBgGrid */ {KAknsIIDQgnGrafOrgBgGrid, EDrawIcon, ES60_All, -1,-1}, + // No drop area for 3.x non-touch devices + /* SP_QgnGrafOrgBgGrid */ {KAknsIIDNone, EDrawIcon, ES60_3_X, EAknsMajorGeneric ,0x1eba}, //KAknsIIDQgnGrafOrgBgGrid /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawGulIcon, ES60_All, -1,-1}, /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawGulIcon, ES60_All, -1,-1}, /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawGulIcon, ES60_All, -1,-1}, -- cgit v0.12 From 12180c397a2007970978033928b4b5b12efad7c6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 15 Feb 2010 14:55:59 +0100 Subject: Prepare translations of the declarative module. Add to translations profile. move stuff out of QObject-context, correct spelling and contractions, correct usage of tr(). --- .../graphicsitems/qmlgraphicsanchors.cpp | 26 +++++++++++----------- src/declarative/qml/qmlcompiler.cpp | 12 +++++----- src/declarative/qml/qmlobjectscriptclass.cpp | 6 ++--- src/declarative/util/qmlanimation.cpp | 14 ++++++------ src/declarative/util/qmlbehavior.cpp | 2 +- src/declarative/util/qmlpropertychanges.cpp | 2 +- src/declarative/util/qmlstateoperations.cpp | 8 +++---- src/declarative/util/qmlxmllistmodel.cpp | 4 ++-- translations/translations.pri | 1 + 9 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp index 93055fc..945e7d3 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp @@ -366,7 +366,7 @@ void QmlGraphicsAnchors::setFill(QmlGraphicsItem *f) return; } if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << tr("Can't anchor to an item that isn't a parent or sibling."); + qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); return; } d->remDepend(d->fill); @@ -400,7 +400,7 @@ void QmlGraphicsAnchors::setCenterIn(QmlGraphicsItem* c) return; } if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << tr("Can't anchor to an item that isn't a parent or sibling."); + qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); return; } @@ -991,7 +991,7 @@ bool QmlGraphicsAnchorsPrivate::checkHValid() const if (usedAnchors & QmlGraphicsAnchors::HasLeftAnchor && usedAnchors & QmlGraphicsAnchors::HasRightAnchor && usedAnchors & QmlGraphicsAnchors::HasHCenterAnchor) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't specify left, right, and hcenter anchors."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot specify left, right, and hcenter anchors."); return false; } @@ -1001,16 +1001,16 @@ bool QmlGraphicsAnchorsPrivate::checkHValid() const bool QmlGraphicsAnchorsPrivate::checkHAnchorValid(QmlGraphicsAnchorLine anchor) const { if (!anchor.item) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor to a null item."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to a null item."); return false; } else if (anchor.anchorLine & QmlGraphicsAnchorLine::Vertical_Mask) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor a horizontal edge to a vertical edge."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor a horizontal edge to a vertical edge."); return false; } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor to an item that isn't a parent or sibling."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to an item that isn't a parent or sibling."); return false; } else if (anchor.item == item) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor item to self."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor item to self."); return false; } @@ -1022,13 +1022,13 @@ bool QmlGraphicsAnchorsPrivate::checkVValid() const if (usedAnchors & QmlGraphicsAnchors::HasTopAnchor && usedAnchors & QmlGraphicsAnchors::HasBottomAnchor && usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't specify top, bottom, and vcenter anchors."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot specify top, bottom, and vcenter anchors."); return false; } else if (usedAnchors & QmlGraphicsAnchors::HasBaselineAnchor && (usedAnchors & QmlGraphicsAnchors::HasTopAnchor || usedAnchors & QmlGraphicsAnchors::HasBottomAnchor || usedAnchors & QmlGraphicsAnchors::HasVCenterAnchor)) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."); return false; } @@ -1038,16 +1038,16 @@ bool QmlGraphicsAnchorsPrivate::checkVValid() const bool QmlGraphicsAnchorsPrivate::checkVAnchorValid(QmlGraphicsAnchorLine anchor) const { if (!anchor.item) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor to a null item."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to a null item."); return false; } else if (anchor.anchorLine & QmlGraphicsAnchorLine::Horizontal_Mask) { - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor a vertical edge to a horizontal edge."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor a vertical edge to a horizontal edge."); return false; } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor to an item that isn't a parent or sibling."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor to an item that isn't a parent or sibling."); return false; } else if (anchor.item == item){ - qmlInfo(item) << QmlGraphicsAnchors::tr("Can't anchor item to self."); + qmlInfo(item) << QmlGraphicsAnchors::tr("Cannot anchor item to self."); return false; } diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 10150de..9990c06 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -730,7 +730,7 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) compileState.parserStatusCount++; // Check if this is a custom parser type. Custom parser types allow - // assignments to non-existant properties. These assignments are then + // assignments to non-existent properties. These assignments are then // compiled by the type. bool isCustomParser = output->types.at(obj->type).type && output->types.at(obj->type).type->customParser() != 0; @@ -1429,7 +1429,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, ctxt)); return true; } else if (!type || !type->attachedPropertiesType()) { - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existant attached object")); + COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existent attached object")); } if (!prop->value) @@ -1486,9 +1486,9 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, } else if (prop->index == -1) { if (prop->isDefault) { - COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QmlCompiler","Cannot assign to non-existant default property")); + COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent default property")); } else { - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(prop->name))); } } else if (prop->value) { @@ -1534,7 +1534,7 @@ QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns, &type, 0, 0, 0); if (!type || !type->attachedPropertiesType()) - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existant attached object")); + COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Non-existent attached object")); if (!prop->value) COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Invalid attached object assignment")); @@ -1841,7 +1841,7 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, foreach (Property *prop, obj->properties) { int idx = type->metaObject()->indexOfProperty(prop->name.constData()); if (idx == -1) - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, QCoreApplication::translate("QmlCompiler","Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(prop->name))); QMetaProperty p = type->metaObject()->property(idx); prop->index = idx; prop->type = p.userType(); diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 1c41d46..c373a8e 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -313,7 +313,7 @@ void QmlObjectScriptClass::setProperty(QObject *obj, Q_ASSERT(lastData); if (!lastData->isValid()) { - QString error = QLatin1String("Cannot assign to non-existant property \"") + + QString error = QLatin1String("Cannot assign to non-existent property \"") + toString(name) + QLatin1Char('\"'); if (context()) context()->throwError(error); @@ -628,11 +628,11 @@ QmlObjectMethodScriptClass::Value QmlObjectMethodScriptClass::call(Object *o, QS for (int ii = 0; ii < argTypeNames.count(); ++ii) { argTypes[ii] = QMetaType::type(argTypeNames.at(ii)); if (argTypes[ii] == QVariant::Invalid) - return Value(ctxt, ctxt->throwError(QString(QLatin1String("Unknown method parameter type: %1")).arg(QLatin1String(argTypeNames.at(ii))))); + return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii))))); } if (argTypes.count() > ctxt->argumentCount()) - return Value(ctxt, ctxt->throwError("Insufficient arguments")); + return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments"))); QVarLengthArray args(argTypes.count() + 1); args[0].initAsType(method->data.propType, engine); diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index abffefe..6609c73 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -77,7 +77,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) if (hasParams) { QString easeName = curve.trimmed(); if (!easeName.endsWith(QLatin1Char(')'))) { - qmlInfo(obj) << obj->tr("Unmatched parenthesis in easing function \"%1\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Unmatched parenthesis in easing function \"%1\"").arg(curve); return easingCurve; } @@ -86,7 +86,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) easeName.mid(idx + 1, easeName.length() - 1 - idx - 1); normalizedCurve = easeName.left(idx); if (!normalizedCurve.startsWith(QLatin1String("ease"))) { - qmlInfo(obj) << obj->tr("Easing function \"%1\" must start with \"ease\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Easing function \"%1\" must start with \"ease\"").arg(curve); return easingCurve; } @@ -101,7 +101,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) int value = me.keyToValue(normalizedCurve.toUtf8().constData()); if (value < 0) { - qmlInfo(obj) << obj->tr("Unknown easing curve \"%1\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing curve \"%1\"").arg(curve); return easingCurve; } easingCurve.setType((QEasingCurve::Type)value); @@ -111,7 +111,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) int sep = str.indexOf(QLatin1Char(':')); if (sep == -1) { - qmlInfo(obj) << obj->tr("Improperly specified parameter in easing function \"%1\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve); continue; } @@ -120,7 +120,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk); if (propName.isEmpty() || !isOk) { - qmlInfo(obj) << obj->tr("Improperly specified parameter in easing function \"%1\"").arg(curve); + qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve); continue; } @@ -131,7 +131,7 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) } else if (propName == QLatin1String("overshoot")) { easingCurve.setOvershoot(propValue); } else { - qmlInfo(obj) << obj->tr("Unknown easing parameter \"%1\"").arg(propName); + qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing parameter \"%1\"").arg(propName); continue; } } @@ -226,7 +226,7 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const { QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str, qmlContext(infoObj)); if (!prop.isValid()) { - qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existant property \"%1\"").arg(str); + qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str); return QmlMetaProperty(); } else if (!prop.isWritable()) { qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp index b9c77f5..e8feeaa 100644 --- a/src/declarative/util/qmlbehavior.cpp +++ b/src/declarative/util/qmlbehavior.cpp @@ -119,7 +119,7 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation) { Q_D(QmlBehavior); if (d->animation) { - qmlInfo(this) << tr("Can't change the animation assigned to a Behavior."); + qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior."); return; } diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index 68fc5cc..f1f39da 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -357,7 +357,7 @@ QmlPropertyChangesPrivate::property(const QByteArray &property) Q_Q(QmlPropertyChanges); QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromUtf8(property)); if (!prop.isValid()) { - qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(property)); + qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(property)); return QmlMetaProperty(); } else if (!(prop.type() & QmlMetaProperty::SignalProperty) && !prop.isWritable()) { qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property)); diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 35c8f7d..cefe2bc 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -82,7 +82,7 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics bool ok; const QTransform &transform = target->itemTransform(targetParent, &ok); if (transform.type() >= QTransform::TxShear || !ok) { - qmlInfo(q) << QObject::tr("Unable to preserve appearance under complex transform"); + qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under complex transform"); ok = false; } @@ -92,21 +92,21 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics if (transform.m11() == transform.m22()) scale = transform.m11(); else { - qmlInfo(q) << QObject::tr("Unable to preserve appearance under non-uniform scale"); + qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale"); ok = false; } } else if (ok && transform.type() == QTransform::TxRotate) { if (transform.m11() == transform.m22()) scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); else { - qmlInfo(q) << QObject::tr("Unable to preserve appearance under non-uniform scale"); + qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale"); ok = false; } if (scale != 0) rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI; else { - qmlInfo(q) << QObject::tr("Unable to preserve appearance under scale of 0"); + qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under scale of 0"); ok = false; } } diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp index d31fadf..d586792 100644 --- a/src/declarative/util/qmlxmllistmodel.cpp +++ b/src/declarative/util/qmlxmllistmodel.cpp @@ -391,7 +391,7 @@ void QmlXmlRoleList::insert(int i, QmlXmlListModelRole *role) { QmlConcreteList::insert(i, role); if (model->roleNames.contains(role->name())) { - qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name()); + qmlInfo(role) << QCoreApplication::translate("QmlXmlRoleList", "\"%1\" duplicates a previous role name and will be disabled.").arg(role->name()); return; } model->roles.insert(i, model->highestRole); @@ -551,7 +551,7 @@ void QmlXmlListModel::setQuery(const QString &query) { Q_D(QmlXmlListModel); if (!query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << tr("An XmlListModel query must start with '/' or \"//\""); + qmlInfo(this) << QCoreApplication::translate("QmlXmlRoleList", "An XmlListModel query must start with '/' or \"//\""); return; } diff --git a/translations/translations.pri b/translations/translations.pri index 808dc4f..a8fb7ee 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -25,6 +25,7 @@ ts-qt.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ 3rdparty/webkit \ activeqt \ corelib \ + declarative \ gui \ multimedia \ network \ -- cgit v0.12 From e024cc10a97b9518b2dd577175feb66258d7ac05 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 15 Feb 2010 17:04:03 +0100 Subject: Fixed missing repaints on S60 3.1. The bug happened when a paint event came in from Symbian, but the painted area was bigger than the exposed rect being passed in by Symbian. In these cases we would lose updates to the area outside. Fixed by calling Draw() once more if we detect that we painted a larger area to the backing store. It is still a mystery why this worked on 5.0 though... :-P AutoTest: QWidget passed RevBy: Jason Barron Task: QTBUG-8200 --- src/gui/painting/qwindowsurface_s60.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 6cbf3d9..028ec48 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -149,11 +149,19 @@ void QS60WindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_ASSERT(window); QTLWExtra *topExtra = window->d_func()->maybeTopData(); Q_ASSERT(topExtra); + QRect qr = region.boundingRect(); if (!topExtra->inExpose) { topExtra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again - TRect tr = qt_QRect2TRect(region.boundingRect()); + TRect tr = qt_QRect2TRect(qr); widget->winId()->DrawNow(tr); topExtra->inExpose = false; + } else { + // This handles the case when syncBackingStore updates content outside of the + // original drawing rectangle. This might happen if there are pending update() + // events at the same time as we get a Draw() from Symbian. + QRect drawRect = qt_TRect2QRect(widget->winId()->DrawableWindow()->GetDrawRect()); + if (!drawRect.contains(qr)) + widget->winId()->DrawDeferred(); } } -- cgit v0.12 From e885e8123fbe0d57a0d8a4c8115ea43dde31b05d Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 15 Feb 2010 17:16:53 +0100 Subject: Assistant: Rebuild search index at most once at start-up. Reviewed-by: kh1 --- .../tools/assistant/helpenginewrapper.cpp | 28 +++++++++++++++++++++- .../assistant/tools/assistant/helpenginewrapper.h | 6 +++++ tools/assistant/tools/assistant/mainwindow.cpp | 3 +-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index 76211c5..a181c71 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -112,6 +112,7 @@ private: QFileSystemWatcher * const m_qchWatcher; typedef QPair > RecentSignal; QMap m_recentQchUpdates; + bool m_initialReindexingNeeded; }; const QString HelpEngineWrapper::TrUnfiltered = tr("Unfiltered"); @@ -141,6 +142,18 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) : d(new HelpEngineWrapperPrivate(collectionFile)) { TRACE_OBJ + + /* + * Otherwise we will waste time if several new docs are found, + * because we will start to index them, only to be interupted + * by the next request. Also, there is a nasty SQLITE bug that will + * cause the application to hang for minutes in that case. + * This call is reverted by initalDocSetupDone(), which must be + * called after the new docs have been installed. + */ + disconnect(d->m_helpEngine, SIGNAL(setupFinished()), + searchEngine(), SLOT(indexDocumentation())); + connect(d, SIGNAL(documentationRemoved(QString)), this, SIGNAL(documentationRemoved(QString))); connect(d, SIGNAL(documentationUpdated(QString)), @@ -157,6 +170,15 @@ HelpEngineWrapper::~HelpEngineWrapper() delete d; } +void HelpEngineWrapper::initialDocSetupDone() +{ + TRACE_OBJ + connect(d->m_helpEngine, SIGNAL(setupFinished()), + searchEngine(), SLOT(indexDocumentation())); + if (d->m_initialReindexingNeeded) + setupData(); +} + QHelpSearchEngine *HelpEngineWrapper::searchEngine() const { TRACE_OBJ @@ -207,6 +229,7 @@ bool HelpEngineWrapper::registerDocumentation(const QString &docFile) return false; d->m_qchWatcher->addPath(docFile); d->checkDocFilesWatched(); + d->m_initialReindexingNeeded = true; return true; } @@ -219,6 +242,7 @@ bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) return false; d->m_qchWatcher->removePath(file); d->checkDocFilesWatched(); + d->m_initialReindexingNeeded = true; return true; } @@ -698,7 +722,8 @@ void TimeoutForwarder::forward() HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile) : m_helpEngine(new QHelpEngine(collectionFile, this)), - m_qchWatcher(new QFileSystemWatcher(this)) + m_qchWatcher(new QFileSystemWatcher(this)), + m_initialReindexingNeeded(false) { TRACE_OBJ if (!m_helpEngine->customFilters().contains(Unfiltered)) @@ -797,6 +822,7 @@ void HelpEngineWrapperPrivate::qchFileChanged(const QString &fileName, } else { emit documentationUpdated(ns); } + m_initialReindexingNeeded = true; m_helpEngine->setupData(); } m_recentQchUpdates.erase(it); diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h index a30fab8..8d95273 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.h +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -101,6 +101,12 @@ public: const QStringList filterAttributes(const QString &filterName) const; QString error() const; + /* + * To be called after assistant has finished looking for new documentation. + * This will mainly cause the search index to be updated, if necessary. + */ + void initialDocSetupDone(); + const QStringList qtDocInfo(const QString &component) const; void setQtDocInfo(const QString &component, const QStringList &doc); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 4115d39..8096218 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -354,8 +354,6 @@ void MainWindow::lookForNewQtDocumentation() void MainWindow::qtDocumentationInstalled(bool newDocsInstalled) { TRACE_OBJ - if (newDocsInstalled) - HelpEngineWrapper::instance().setupData(); statusBar()->clearMessage(); checkInitState(); } @@ -383,6 +381,7 @@ void MainWindow::checkInitState() } emit initDone(); } + HelpEngineWrapper::instance().initialDocSetupDone(); } void MainWindow::insertLastPages() -- cgit v0.12 From d813575790f94fc4f98abcb45ad47248cdd8b2d8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Feb 2010 08:35:10 +0100 Subject: Fix qml test breakage of 12180c397a2007970978033928b4b5b12efad7c6 Fix messages in test data. --- .../qmlanimations/tst_qmlanimations.cpp | 6 +++--- .../declarative/qmlbehaviors/tst_qmlbehaviors.cpp | 2 +- tests/auto/declarative/qmldom/tst_qmldom.cpp | 2 +- .../qmlecmascript/tst_qmlecmascript.cpp | 12 +++++------ .../qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp | 24 +++++++++++----------- .../data/invalidAttachedProperty.1.errors.txt | 2 +- .../data/invalidAttachedProperty.10.errors.txt | 2 +- .../data/invalidAttachedProperty.2.errors.txt | 2 +- .../data/invalidAttachedProperty.6.errors.txt | 2 +- .../data/invalidAttachedProperty.7.errors.txt | 2 +- .../data/invalidAttachedProperty.8.errors.txt | 2 +- .../data/invalidAttachedProperty.9.errors.txt | 2 +- .../data/invalidGroupedProperty.4.errors.txt | 2 +- .../qmllanguage/data/missingSignal.errors.txt | 2 +- .../data/missingValueTypeProperty.errors.txt | 2 +- .../data/nonexistantProperty.1.errors.txt | 2 +- .../data/nonexistantProperty.2.errors.txt | 2 +- .../data/nonexistantProperty.3.errors.txt | 2 +- .../data/nonexistantProperty.4.errors.txt | 2 +- .../data/nonexistantProperty.6.errors.txt | 2 +- tests/auto/declarative/qmlstates/tst_qmlstates.cpp | 4 ++-- 21 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 17a1453..a00e911 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -308,7 +308,7 @@ void tst_animations::badProperties() QmlEngine engine; QmlComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml")); - QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existant property \"border.colr\""; + QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\""; QTest::ignoreMessage(QtWarningMsg, message); QTest::ignoreMessage(QtWarningMsg, message); // why twice? QmlGraphicsRectangle *rect = qobject_cast(c1.create()); @@ -546,8 +546,8 @@ void tst_animations::easingStringConversion() QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic); QVERIFY(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude() != qreal(5)); - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistantproperty\""); - animation->setEasing("easeOutQuad(nonexistantproperty: 12)"); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistentproperty\""); + animation->setEasing("easeOutQuad(nonexistentproperty: 12)"); QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutQuad); delete animation; diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp index 61023a2..73ab35e 100644 --- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -254,7 +254,7 @@ void tst_behaviors::reassignedAnimation() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); - QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Can't change the animation assigned to a Behavior.").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Cannot change the animation assigned to a Behavior.").toUtf8().constData()); QmlGraphicsRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QCOMPARE(qobject_cast( diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp index ce35130..eb4d419 100644 --- a/tests/auto/declarative/qmldom/tst_qmldom.cpp +++ b/tests/auto/declarative/qmldom/tst_qmldom.cpp @@ -394,7 +394,7 @@ void tst_qmldom::loadErrors() QCOMPARE(error.url(), QUrl()); QCOMPARE(error.line(), 3); QCOMPARE(error.column(), 3); - QCOMPARE(error.description(), QString("Cannot assign to non-existant property \"foo\"")); + QCOMPARE(error.description(), QString("Cannot assign to non-existent property \"foo\"")); } // Test loading a file with syntax errors diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index e5472bb..a6baf10 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -572,7 +572,7 @@ void tst_qmlecmascript::enums() QCOMPARE(object->property("i").toInt(), 19); QCOMPARE(object->property("j").toInt(), 19); } - // Non-existant enums + // Non-existent enums { QmlComponent component(&engine, TEST_FILE("enums.2.qml")); @@ -680,7 +680,7 @@ void tst_qmlecmascript::outerBindingOverridesInnerBinding() } /* -Access a non-existant attached object. +Access a non-existent attached object. Tests for a regression where this used to crash. */ @@ -928,7 +928,7 @@ void tst_qmlecmascript::scriptErrors() QString warning5 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object."; QString warning6 = url + ":9: Unable to assign [undefined] to int"; QString warning7 = url + ":14: Error: Cannot assign to read-only property \"trueProperty\""; - QString warning8 = url + ":15: Error: Cannot assign to non-existant property \"fakeProperty\""; + QString warning8 = url + ":15: Error: Cannot assign to non-existent property \"fakeProperty\""; QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); @@ -1207,15 +1207,15 @@ void tst_qmlecmascript::callQtInvokables() QScriptEngine *engine = &ep->scriptEngine; ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o)); - // Non-existant methods + // Non-existent methods o.reset(); - QCOMPARE(engine->evaluate("object.method_nonexistant()").isError(), true); + QCOMPARE(engine->evaluate("object.method_nonexistent()").isError(), true); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), -1); QCOMPARE(o.actuals().count(), 0); o.reset(); - QCOMPARE(engine->evaluate("object.method_nonexistant(10, 11)").isError(), true); + QCOMPARE(engine->evaluate("object.method_nonexistent(10, 11)").isError(), true); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), -1); QCOMPARE(o.actuals().count(), 0); diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp index 5850cf0..70e70d0 100644 --- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp +++ b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp @@ -223,55 +223,55 @@ void tst_anchors::illegalSets_data() QTest::newRow("H - too many anchors") << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }" - << "QML Rectangle (file::2:23) Can't specify left, right, and hcenter anchors."; + << "QML Rectangle (file::2:23) Cannot specify left, right, and hcenter anchors."; foreach (const QString &side, QStringList() << "left" << "right") { QTest::newRow("H - anchor to V") << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side) - << "QML Rectangle (file::2:13) Can't anchor a horizontal edge to a vertical edge."; + << "QML Rectangle (file::2:13) Cannot anchor a horizontal edge to a vertical edge."; QTest::newRow("H - anchor to non parent/sibling") << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("H - anchor to self") << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "QML Rectangle (file::2:1) Can't anchor item to self."; + << "QML Rectangle (file::2:1) Cannot anchor item to self."; } QTest::newRow("V - too many anchors") << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }" - << "QML Rectangle (file::2:23) Can't specify top, bottom, and vcenter anchors."; + << "QML Rectangle (file::2:23) Cannot specify top, bottom, and vcenter anchors."; QTest::newRow("V - too many anchors with baseline") << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }" - << "QML Text (file::2:47) Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."; + << "QML Text (file::2:47) Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."; foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") { QTest::newRow("V - anchor to H") << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side) - << "QML Rectangle (file::2:13) Can't anchor a vertical edge to a horizontal edge."; + << "QML Rectangle (file::2:13) Cannot anchor a vertical edge to a horizontal edge."; QTest::newRow("V - anchor to non parent/sibling") << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("V - anchor to self") << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "QML Rectangle (file::2:1) Can't anchor item to self."; + << "QML Rectangle (file::2:1) Cannot anchor item to self."; } QTest::newRow("centerIn - anchor to non parent/sibling") << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }" - << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; QTest::newRow("fill - anchor to non parent/sibling") << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }" - << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; + << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling."; } void tst_anchors::reset() @@ -348,7 +348,7 @@ void tst_anchors::nullItem() const QMetaObject *meta = item->anchors()->metaObject(); QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Can't anchor to a null item."); + QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Cannot anchor to a null item."); QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); delete item; diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt index 68fe671..492bbb4 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt @@ -1 +1 @@ -5:17:Cannot assign to non-existant property "foo" +5:17:Cannot assign to non-existent property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt index 7f630f4..ff2409b 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt @@ -1 +1 @@ -5:15:Non-existant attached object +5:15:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt index 9f06e07..34de769 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt @@ -1 +1 @@ -5:27:Cannot assign to non-existant property "foo" +5:27:Cannot assign to non-existent property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt index e232b23..6770e1f 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt @@ -1 +1 @@ -5:5:Non-existant attached object +5:5:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt index e232b23..6770e1f 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt @@ -1 +1 @@ -5:5:Non-existant attached object +5:5:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt index 7f630f4..ff2409b 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt @@ -1 +1 @@ -5:15:Non-existant attached object +5:15:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt index e232b23..6770e1f 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt @@ -1 +1 @@ -5:5:Non-existant attached object +5:5:Non-existent attached object diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt index 19934fa..69c6871 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt @@ -1 +1 @@ -4:5:Cannot assign to non-existant property "foo" +4:5:Cannot assign to non-existent property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt b/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt index e243ae5..f562246 100644 --- a/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt @@ -1 +1 @@ -4:5:Cannot assign to non-existant property "onClicked" +4:5:Cannot assign to non-existent property "onClicked" diff --git a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt b/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt index dfaa218..caf7e55 100644 --- a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt @@ -1 +1 @@ -4:18:Cannot assign to non-existant property "foo" +4:18:Cannot assign to non-existent property "foo" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt index cfc6fc8..6bfce9a 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt @@ -1 +1 @@ -2:15:Cannot assign to non-existant property "something" +2:15:Cannot assign to non-existent property "something" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt index 8b13585..4b30056 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt @@ -1 +1 @@ -3:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt index 8b13585..4b30056 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt @@ -1 +1 @@ -3:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt index 8b13585..4b30056 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt @@ -1 +1 @@ -3:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt index c02d7bd..89925b7 100644 --- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt @@ -1 +1 @@ -3:5:Cannot assign to non-existant default property +3:5:Cannot assign to non-existent default property diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp index fc348a5..4e4f3fb 100644 --- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp +++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp @@ -731,7 +731,7 @@ void tst_states::propertyErrors() QCOMPARE(rect->color(),QColor("red")); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existant property \"colr\"").constData()); + QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existent property \"colr\"").constData()); QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to read-only property \"wantsFocus\"").constData()); rect->setState("blue"); } @@ -877,7 +877,7 @@ void tst_states::nonExistantProperty() QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existant property \"colr\"").constData()); + QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existent property \"colr\"").constData()); rect->setState("blue"); QCOMPARE(rect->state(), QLatin1String("blue")); } -- cgit v0.12 From 4790ab735f96a13027e7292ff5b49195224f0af9 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 16 Feb 2010 09:19:20 +0100 Subject: Enabled commit 2b60b542a for all platforms. Task: QTBUG-5892 RevBy: Trust me --- src/gui/widgets/qlineedit.cpp | 12 ++---------- src/gui/widgets/qtextedit.cpp | 13 +++---------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 141f844..0ba8b9f 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1637,12 +1637,8 @@ void QLineEdit::keyPressEvent(QKeyEvent *event) if (!hasEditFocus() && !(event->modifiers() & Qt::ControlModifier)) { if (!event->text().isEmpty() && event->text().at(0).isPrint() && !isReadOnly()) - { setEditFocus(true); -#ifndef Q_OS_SYMBIAN - clear(); -#endif - } else { + else { event->ignore(); return; } @@ -1698,12 +1694,8 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e) // commit text as they focus out without interfering with focus if (QApplication::keypadNavigationEnabled() && hasFocus() && !hasEditFocus() - && !e->preeditString().isEmpty()) { + && !e->preeditString().isEmpty()) setEditFocus(true); -#ifndef Q_OS_SYMBIAN - selectAll(); // so text is replaced rather than appended to -#endif - } #endif d->control->processInputMethodEvent(e); diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index b6886b4..4541730 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -1212,12 +1212,9 @@ void QTextEdit::keyPressEvent(QKeyEvent *e) default: if (QApplication::keypadNavigationEnabled()) { if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) { - if (e->text()[0].isPrint()) { + if (e->text()[0].isPrint()) setEditFocus(true); -#ifndef Q_OS_SYMBIAN - clear(); -#endif - } else { + else { e->ignore(); return; } @@ -1677,12 +1674,8 @@ void QTextEdit::inputMethodEvent(QInputMethodEvent *e) #ifdef QT_KEYPAD_NAVIGATION if (d->control->textInteractionFlags() & Qt::TextEditable && QApplication::keypadNavigationEnabled() - && !hasEditFocus()) { + && !hasEditFocus()) setEditFocus(true); -#ifndef Q_OS_SYMBIAN - selectAll(); // so text is replaced rather than appended to -#endif - } #endif d->sendControlEvent(e); ensureCursorVisible(); -- cgit v0.12 From 96be992ccdc7a9aaf02672234be7bd341be105e7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Feb 2010 10:12:11 +0100 Subject: Designer:Fix undo crash caused by special handling of key move. Remove special handling and storing of commands. Customize SetPropertyCommand such that it is able to perform a transformation of the new value., thus, the same (relative) distance can be used on all widgets and the normal command merging mechanism can be used to merge subsequent moves correctly. Task-number: QTBUG-8213 --- .../src/components/formeditor/formwindow.cpp | 172 ++++++++++++++------- .../src/components/formeditor/formwindow.h | 3 - .../src/lib/shared/qdesigner_formwindowcommand.cpp | 6 +- .../src/lib/shared/qdesigner_formwindowcommand_p.h | 4 +- .../src/lib/shared/qdesigner_propertycommand.cpp | 54 +++++-- .../src/lib/shared/qdesigner_propertycommand_p.h | 28 +++- 6 files changed, 177 insertions(+), 90 deletions(-) diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 3a7cd83..8b8351d 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -1428,26 +1428,123 @@ int FormWindow::calcValue(int val, bool forward, bool snap, int snapOffset) cons return (forward ? val + 1 : val - 1); } -QRect FormWindow::applyValue(const QRect &rect, int val, int key, bool size) const +// ArrowKeyOperation: Stores a keyboard move or resize (Shift pressed) +// operation. +struct ArrowKeyOperation { + ArrowKeyOperation() : resize(false), distance(0), arrowKey(Qt::Key_Left) {} + + QRect apply(const QRect &in) const; + + bool resize; // Resize: Shift-Key->drag bottom/right corner, else just move + int distance; + int arrowKey; +}; + +QRect ArrowKeyOperation::apply(const QRect &rect) const { QRect r = rect; - if (size) { - if (key == Qt::Key_Left || key == Qt::Key_Right) - r.setWidth(val); + if (resize) { + if (arrowKey == Qt::Key_Left || arrowKey == Qt::Key_Right) + r.setWidth(r.width() + distance); else - r.setHeight(val); + r.setHeight(r.height() + distance); } else { - if (key == Qt::Key_Left || key == Qt::Key_Right) - r.moveLeft(val); + if (arrowKey == Qt::Key_Left || arrowKey == Qt::Key_Right) + r.moveLeft(r.x() + distance); else - r.moveTop(val); + r.moveTop(r.y() + distance); } return r; } +QDebug operator<<(QDebug in, const ArrowKeyOperation &op) +{ + in.nospace() << "Resize=" << op.resize << " dist=" << op.distance << " Key=" << op.arrowKey << ' '; + return in; +} + +} // namespace qdesigner_internal + +Q_DECLARE_METATYPE(qdesigner_internal::ArrowKeyOperation) + +namespace qdesigner_internal { + +// ArrowKeyPropertyHelper: Applies a struct ArrowKeyOperation +// (stored as new value) to a list of widgets using to calculate the +// changed geometry of the widget in setValue(). Thus, the 'newValue' +// of the property command is the relative move distance, which is the same +// for all widgets (although resulting in different geometries for the widgets). +// The command merging can then work as it would when applying the same text +// to all QLabels. + +class ArrowKeyPropertyHelper : public PropertyHelper { +public: + ArrowKeyPropertyHelper(QObject* o, SpecialProperty sp, + QDesignerPropertySheetExtension *s, int i) : + PropertyHelper(o, sp, s, i) {} + + virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask); +}; + +PropertyHelper::Value ArrowKeyPropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask) +{ + // Apply operation to obtain the new geometry value. + QWidget *w = qobject_cast(object()); + const ArrowKeyOperation operation = qvariant_cast(value); + const QRect newGeom = operation.apply(w->geometry()); + return PropertyHelper::setValue(fw, QVariant(newGeom), changed, subPropertyMask); +} + +// ArrowKeyPropertyCommand: Helper factory overwritten to create +// ArrowKeyPropertyHelper and a merge operation that merges values of +// the same direction. +class ArrowKeyPropertyCommand: public SetPropertyCommand { +public: + explicit ArrowKeyPropertyCommand(QDesignerFormWindowInterface *fw, + QUndoCommand *p = 0); + + void init(QWidgetList &l, const ArrowKeyOperation &op); + +protected: + virtual PropertyHelper *createPropertyHelper(QObject *o, SpecialProperty sp, + QDesignerPropertySheetExtension *s, int i) const + { return new ArrowKeyPropertyHelper(o, sp, s, i); } + virtual QVariant mergeValue(const QVariant &newValue); +}; + +ArrowKeyPropertyCommand::ArrowKeyPropertyCommand(QDesignerFormWindowInterface *fw, + QUndoCommand *p) : + SetPropertyCommand(fw, p) +{ + static const int mid = qRegisterMetaType(); + Q_UNUSED(mid) +} + +void ArrowKeyPropertyCommand::init(QWidgetList &l, const ArrowKeyOperation &op) +{ + QObjectList ol; + foreach(QWidget *w, l) + ol.push_back(w); + SetPropertyCommand::init(ol, QLatin1String("geometry"), qVariantFromValue(op)); + + setText(op.resize ? FormWindow::tr("Key Resize") : FormWindow::tr("Key Move")); +} + +QVariant ArrowKeyPropertyCommand::mergeValue(const QVariant &newMergeValue) +{ + // Merge move operations of the same arrow key + if (!qVariantCanConvert(newMergeValue)) + return QVariant(); + ArrowKeyOperation mergedOperation = qvariant_cast(newValue()); + const ArrowKeyOperation newMergeOperation = qvariant_cast(newMergeValue); + if (mergedOperation.resize != newMergeOperation.resize || mergedOperation.arrowKey != newMergeOperation.arrowKey) + return QVariant(); + mergedOperation.distance += newMergeOperation.distance; + return qVariantFromValue(mergedOperation); +} + void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers) { - bool startMacro = false; const QDesignerFormWindowCursorInterface *c = cursor(); if (!c->hasSelection()) return; @@ -1480,57 +1577,14 @@ void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers) const int newValue = calcValue(oldValue, forward, snap, snapPoint); - const int offset = newValue - oldValue; + ArrowKeyOperation operation; + operation.resize = modifiers & Qt::ShiftModifier; + operation.distance = newValue - oldValue; + operation.arrowKey = key; - const int selCount = selection.count(); - // check if selection is the same as last time - if (selCount != m_moveSelection.count() || - m_lastUndoIndex != m_commandHistory->index()) { - m_moveSelection.clear(); - startMacro = true; - } else { - for (int index = 0; index < selCount; ++index) { - if (m_moveSelection[index]->object() != selection.at(index)) { - m_moveSelection.clear(); - startMacro = true; - break; - } - } - } - - if (startMacro) - beginCommand(tr("Key Move")); - - for (int index = 0; index < selCount; ++index) { - QWidget *w = selection.at(index); - const QRect oldGeom = w->geometry(); - const QRect geom = applyValue(oldGeom, getValue(oldGeom, key, size) + offset, key, size); - - SetPropertyCommand *cmd = 0; - - if (m_moveSelection.count() > index) - cmd = m_moveSelection[index]; - - if (!cmd) { - cmd = new SetPropertyCommand(this); - cmd->init(w, QLatin1String("geometry"), geom); - cmd->setText(tr("Key Move")); - m_commandHistory->push(cmd); - - if (m_moveSelection.count() > index) - m_moveSelection.replace(index, cmd); - else - m_moveSelection.append(cmd); - } else { - cmd->setNewValue(geom); - cmd->redo(); - } - } - - if (startMacro) { - endCommand(); - m_lastUndoIndex = m_commandHistory->index(); - } + ArrowKeyPropertyCommand *cmd = new ArrowKeyPropertyCommand(this); + cmd->init(selection, operation); + m_commandHistory->push(cmd); } bool FormWindow::handleKeyReleaseEvent(QWidget *, QWidget *, QKeyEvent *e) diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index 3eee476..1b2916c 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -263,7 +263,6 @@ private: int getValue(const QRect &rect, int key, bool size) const; int calcValue(int val, bool forward, bool snap, int snapOffset) const; - QRect applyValue(const QRect &rect, int val, int key, bool size) const; void handleClickSelection(QWidget *managedWidget, unsigned mouseFlags); bool frameNeeded(QWidget *w) const; @@ -368,8 +367,6 @@ private: QString m_exportMacro; QStringList m_includeHints; - QList m_moveSelection; - int m_lastUndoIndex; QPoint m_contextMenuPosition; private: diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp index 8c55d26..490373e 100644 --- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp +++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp @@ -62,8 +62,10 @@ QT_BEGIN_NAMESPACE namespace qdesigner_internal { // ---- QDesignerFormWindowCommand ---- -QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow) - : QUndoCommand(description), +QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description, + QDesignerFormWindowInterface *formWindow, + QUndoCommand *parent) + : QUndoCommand(description, parent), m_formWindow(formWindow) { } diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h b/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h index d8cd018..d73d70c 100644 --- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h +++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h @@ -70,7 +70,9 @@ class QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand: public QUndoCommand { public: - QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow); + QDesignerFormWindowCommand(const QString &description, + QDesignerFormWindowInterface *formWindow, + QUndoCommand *parent = 0); virtual void undo(); virtual void redo(); diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp index 822c14b..6cc054c 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -926,8 +926,9 @@ bool PropertyListCommand::PropertyDescription::equals(const PropertyDescription // ---- PropertyListCommand -PropertyListCommand::PropertyListCommand(QDesignerFormWindowInterface *formWindow) : - QDesignerFormWindowCommand(QString(), formWindow) +PropertyListCommand::PropertyListCommand(QDesignerFormWindowInterface *formWindow, + QUndoCommand *parent) : + QDesignerFormWindowCommand(QString(), formWindow, parent) { } @@ -966,10 +967,17 @@ bool PropertyListCommand::add(QObject *object, const QString &propertyName) if (!match || m_propertyDescription.m_specialProperty == SP_ObjectName) return false; } - m_propertyHelperList.push_back(PropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index)); + + const PropertyHelperPtr ph(createPropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index)); + m_propertyHelperList.push_back(ph); return true; } +PropertyHelper *PropertyListCommand::createPropertyHelper(QObject *object, SpecialProperty sp, + QDesignerPropertySheetExtension *sheet, int sheetIndex) const +{ + return new PropertyHelper(object, sp, sheet, sheetIndex); +} // Init from a list and make sure referenceObject is added first to obtain the right property group bool PropertyListCommand::initList(const ObjectList &list, const QString &apropertyName, QObject *referenceObject) @@ -993,19 +1001,19 @@ bool PropertyListCommand::initList(const ObjectList &list, const QString &aprope QObject* PropertyListCommand::object(int index) const { Q_ASSERT(index < m_propertyHelperList.size()); - return m_propertyHelperList[index].object(); + return m_propertyHelperList.at(index)->object(); } QVariant PropertyListCommand::oldValue(int index) const { Q_ASSERT(index < m_propertyHelperList.size()); - return m_propertyHelperList[index].oldValue(); + return m_propertyHelperList.at(index)->oldValue(); } void PropertyListCommand::setOldValue(const QVariant &oldValue, int index) { Q_ASSERT(index < m_propertyHelperList.size()); - m_propertyHelperList[index].setOldValue(oldValue); + m_propertyHelperList.at(index)->setOldValue(oldValue); } // ----- SetValueFunction: Set a new value when applied to a PropertyHelper. class SetValueFunction { @@ -1065,9 +1073,10 @@ template bool updatedPropertyEditor = false; for (PropertyListIterator it = begin; it != end; ++it) { - if (QObject* object = it->object()) { // Might have been deleted in the meantime - const PropertyHelper::Value newValue = function(*it); - updateMask |= it->updateMask(); + PropertyHelper *ph = it->data(); + if (QObject* object = ph->object()) { // Might have been deleted in the meantime + const PropertyHelper::Value newValue = function( *ph ); + updateMask |= ph->updateMask(); // Update property editor if it is the current object if (!updatedPropertyEditor && propertyEditor && object == propertyEditor->object()) { propertyEditor->setPropertyValue(propertyName, newValue.first, newValue.second); @@ -1084,9 +1093,11 @@ template unsigned PropertyListCommand::setValue(QVariant value, bool changed, unsigned subPropertyMask) { if(debugPropertyCommands) - qDebug() << "PropertyListCommand::setValue(" << value << changed << subPropertyMask << ')'; + qDebug() << "PropertyListCommand::setValue(" << value + << changed << subPropertyMask << ')'; return changePropertyList(formWindow()->core(), - m_propertyDescription.m_propertyName, m_propertyHelperList.begin(), m_propertyHelperList.end(), + m_propertyDescription.m_propertyName, + m_propertyHelperList.begin(), m_propertyHelperList.end(), SetValueFunction(formWindow(), PropertyHelper::Value(value, changed), subPropertyMask)); } @@ -1146,15 +1157,16 @@ bool PropertyListCommand::canMergeLists(const PropertyHelperList& other) const if (m_propertyHelperList.size() != other.size()) return false; for (int i = 0; i < m_propertyHelperList.size(); i++) { - if (!m_propertyHelperList[i].canMerge(other[i])) + if (!m_propertyHelperList.at(i)->canMerge(*other.at(i))) return false; } return true; } // ---- SetPropertyCommand ---- -SetPropertyCommand::SetPropertyCommand(QDesignerFormWindowInterface *formWindow) - : PropertyListCommand(formWindow), +SetPropertyCommand::SetPropertyCommand(QDesignerFormWindowInterface *formWindow, + QUndoCommand *parent) + : PropertyListCommand(formWindow, parent), m_subPropertyMask(SubPropertyAll) { } @@ -1210,7 +1222,7 @@ unsigned SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject * void SetPropertyCommand::setDescription() { if (propertyHelperList().size() == 1) { - setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList()[0].object()->objectName())); + setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName())); } else { int count = propertyHelperList().size(); setText(QApplication::translate("Command", "Changed '%1' of %n objects", "", QCoreApplication::UnicodeUTF8, count).arg(propertyName())); @@ -1231,6 +1243,11 @@ int SetPropertyCommand::id() const return 1976; } +QVariant SetPropertyCommand::mergeValue(const QVariant &newValue) +{ + return newValue; +} + bool SetPropertyCommand::mergeWith(const QUndoCommand *other) { if (id() != other->id() || !formWindow()->isDirty()) @@ -1248,7 +1265,10 @@ bool SetPropertyCommand::mergeWith(const QUndoCommand *other) !canMergeLists(cmd->propertyHelperList())) return false; - m_newValue = cmd->newValue(); + const QVariant newValue = mergeValue(cmd->newValue()); + if (!newValue.isValid()) + return false; + m_newValue = newValue; m_subPropertyMask |= cmd->m_subPropertyMask; if(debugPropertyCommands) qDebug() << "SetPropertyCommand::mergeWith() succeeded " << propertyName(); @@ -1289,7 +1309,7 @@ bool ResetPropertyCommand::init(const ObjectList &list, const QString &aproperty void ResetPropertyCommand::setDescription() { if (propertyHelperList().size() == 1) { - setText(QApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList()[0].object()->objectName())); + setText(QApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName())); } else { int count = propertyHelperList().size(); setText(QApplication::translate("Command", "Reset '%1' of %n objects", "", QCoreApplication::UnicodeUTF8, count).arg(propertyName())); diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h b/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h index f6b7262..75b23ca 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h +++ b/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h @@ -58,6 +58,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -77,11 +78,12 @@ enum SpecialProperty { //Determine special property enum SpecialProperty getSpecialProperty(const QString& propertyName); - // A helper class for applying properties to objects. // Can be used for Set commands (setValue(), restoreOldValue()) or // Reset Commands restoreDefaultValue(), restoreOldValue()). -class PropertyHelper { +// +class QDESIGNER_SHARED_EXPORT PropertyHelper { + Q_DISABLE_COPY(PropertyHelper) public: // A pair of Value and changed flag typedef QPair Value; @@ -92,11 +94,13 @@ public: SpecialProperty specialProperty, QDesignerPropertySheetExtension *sheet, int index); + virtual ~PropertyHelper() {} QObject *object() const { return m_object; } SpecialProperty specialProperty() const { return m_specialProperty; } - // set a new value - Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask); + // set a new value. Can be overwritten to perform a transformation (see + // handling of Arrow key move in FormWindow class). + virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask); // restore old value Value restoreOldValue(QDesignerFormWindowInterface *fw); @@ -147,7 +151,7 @@ class QDESIGNER_SHARED_EXPORT PropertyListCommand : public QDesignerFormWindowCo public: typedef QList ObjectList; - explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow); + explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent = 0); QObject* object(int index = 0) const; @@ -159,8 +163,8 @@ public: virtual void undo(); protected: - typedef QList PropertyHelperList; - + typedef QSharedPointer PropertyHelperPtr; + typedef QList PropertyHelperList; // add an object bool add(QObject *object, const QString &propertyName); @@ -204,6 +208,10 @@ protected: }; const PropertyDescription &propertyDescription() const { return m_propertyDescription; } +protected: + virtual PropertyHelper *createPropertyHelper(QObject *o, SpecialProperty sp, + QDesignerPropertySheetExtension *sheet, int sheetIndex) const; + private: PropertyDescription m_propertyDescription; PropertyHelperList m_propertyHelperList; @@ -215,7 +223,7 @@ class QDESIGNER_SHARED_EXPORT SetPropertyCommand: public PropertyListCommand public: typedef QList ObjectList; - explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow); + explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent = 0); bool init(QObject *object, const QString &propertyName, const QVariant &newValue); bool init(const ObjectList &list, const QString &propertyName, const QVariant &newValue, @@ -232,6 +240,10 @@ public: bool mergeWith(const QUndoCommand *other); virtual void redo(); + +protected: + virtual QVariant mergeValue(const QVariant &newValue); + private: unsigned subPropertyMask(const QVariant &newValue, QObject *referenceObject); void setDescription(); -- cgit v0.12 From 73be91d3ec0f9c0701db7260f62426d43fdf5fb0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 16 Feb 2010 11:57:10 +0100 Subject: fix line endings get your git settings fixed, windows users! --- .../declarative/webview/content/Mapping/Map.qml | 40 ++++----- .../declarative/webview/content/Mapping/map.html | 94 +++++++++++----------- examples/declarative/webview/googleMaps.qml | 62 +++++++------- .../data/NoResizeGraphicsWidget.qml | 16 ++-- .../data/SizeGraphicsWidgetToLoader.qml | 16 ++-- .../data/SizeLoaderToGraphicsWidget.qml | 12 +-- 6 files changed, 120 insertions(+), 120 deletions(-) diff --git a/examples/declarative/webview/content/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml index aae6b5d..2e98940 100644 --- a/examples/declarative/webview/content/Mapping/Map.qml +++ b/examples/declarative/webview/content/Mapping/Map.qml @@ -1,20 +1,20 @@ -import Qt 4.6 - -Item { - id: page - property real latitude: -34.397 - property real longitude: 150.644 - property string address: "" - WebView { - id: map - anchors.fill: parent - url: "map.html" - javaScriptWindowObjects: QtObject { - WebView.windowObjectName: "qml" - property real lat: page.latitude - property real lng: page.longitude - property string address: page.address - onAddressChanged: {map.evaluateJavaScript("goToAddress()")} - } - } -} +import Qt 4.6 + +Item { + id: page + property real latitude: -34.397 + property real longitude: 150.644 + property string address: "" + WebView { + id: map + anchors.fill: parent + url: "map.html" + javaScriptWindowObjects: QtObject { + WebView.windowObjectName: "qml" + property real lat: page.latitude + property real lng: page.longitude + property string address: page.address + onAddressChanged: {map.evaluateJavaScript("goToAddress()")} + } + } +} diff --git a/examples/declarative/webview/content/Mapping/map.html b/examples/declarative/webview/content/Mapping/map.html index 8afa21c..72f426a 100755 --- a/examples/declarative/webview/content/Mapping/map.html +++ b/examples/declarative/webview/content/Mapping/map.html @@ -1,47 +1,47 @@ - - - - - - - -
- - + + + + + + + +
+ + diff --git a/examples/declarative/webview/googleMaps.qml b/examples/declarative/webview/googleMaps.qml index b5b13bb..1886961 100644 --- a/examples/declarative/webview/googleMaps.qml +++ b/examples/declarative/webview/googleMaps.qml @@ -1,31 +1,31 @@ -// This example demonstrates how Web services such as Google Maps can be -// abstracted as QML types. Here we have a "Mapping" module with a "Map" -// type. The Map type has an address property. Setting that property moves -// the map. The underlying implementation uses WebView and the Google Maps -// API, but users from QML don't need to understand the implementation in -// order to create a Map. - -import Qt 4.6 -import "content/Mapping" - -Map { - id: map - width: 300 - height: 300 - address: "Paris" - Rectangle { - color: "white" - width: input.width + 20 - height: input.height + 4 - radius: 5 - anchors.bottom: parent.bottom - anchors.bottomMargin: 5 - x: 70 - TextInput { - id: input - text: map.address - anchors.centerIn: parent - Keys.onReturnPressed: map.address = input.text - } - } -} +// This example demonstrates how Web services such as Google Maps can be +// abstracted as QML types. Here we have a "Mapping" module with a "Map" +// type. The Map type has an address property. Setting that property moves +// the map. The underlying implementation uses WebView and the Google Maps +// API, but users from QML don't need to understand the implementation in +// order to create a Map. + +import Qt 4.6 +import "content/Mapping" + +Map { + id: map + width: 300 + height: 300 + address: "Paris" + Rectangle { + color: "white" + width: input.width + 20 + height: input.height + 4 + radius: 5 + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + x: 70 + TextInput { + id: input + text: map.address + anchors.centerIn: parent + Keys.onReturnPressed: map.address = input.text + } + } +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml b/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml index 0704e18..5eab965 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml @@ -1,8 +1,8 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.NoResize - source: "GraphicsWidget250x250.qml" - width: 200 - height: 80 -} +import Qt 4.6 + +Loader { + resizeMode: Loader.NoResize + source: "GraphicsWidget250x250.qml" + width: 200 + height: 80 +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml index 97c72f4..568a136 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml @@ -1,8 +1,8 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.SizeItemToLoader - width: 200 - height: 80 - source: "GraphicsWidget250x250.qml" -} +import Qt 4.6 + +Loader { + resizeMode: Loader.SizeItemToLoader + width: 200 + height: 80 + source: "GraphicsWidget250x250.qml" +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml index cb72f05..a710803 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml @@ -1,6 +1,6 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.SizeLoaderToItem - source: "GraphicsWidget250x250.qml" -} +import Qt 4.6 + +Loader { + resizeMode: Loader.SizeLoaderToItem + source: "GraphicsWidget250x250.qml" +} -- cgit v0.12 From 329148df0bdbf7e66c2ba0f6608eb49658f5f2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 16 Feb 2010 12:51:16 +0100 Subject: doc: A QPlainTextEdit is never a QTextBrowser --- src/gui/widgets/qplaintextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 02ffe13..0d798b7 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -2394,7 +2394,7 @@ void QPlainTextEdit::setReadOnly(bool ro) then the focus policy is also automatically set to Qt::ClickFocus. The default value depends on whether the QPlainTextEdit is read-only - or editable, and whether it is a QTextBrowser or not. + or editable. */ void QPlainTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags) -- cgit v0.12 From f36b0cb1ecdfd0cda6537bdd3acf47eb216db49f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Feb 2010 14:19:53 +0100 Subject: Designer: Implement isDirty()-handling using a QUndoStack. Remove Designer-specific handling of isDirty() due to its bug-proneness, use instead an extended QUndoStack.that allows for setting to 'dirty' without commands for some special cases. Task-number: QTBUG-8041 --- .../src/components/formeditor/formeditor.pri | 2 + .../src/components/formeditor/formwindow.cpp | 53 +++++----- .../src/components/formeditor/formwindow.h | 13 +-- .../components/formeditor/qdesignerundostack.cpp | 108 +++++++++++++++++++++ .../src/components/formeditor/qdesignerundostack.h | 89 +++++++++++++++++ 5 files changed, 225 insertions(+), 40 deletions(-) create mode 100644 tools/designer/src/components/formeditor/qdesignerundostack.cpp create mode 100644 tools/designer/src/components/formeditor/qdesignerundostack.h diff --git a/tools/designer/src/components/formeditor/formeditor.pri b/tools/designer/src/components/formeditor/formeditor.pri index bbe96d5..b1a9318 100644 --- a/tools/designer/src/components/formeditor/formeditor.pri +++ b/tools/designer/src/components/formeditor/formeditor.pri @@ -8,6 +8,7 @@ FORMS += $$PWD/deviceprofiledialog.ui \ $$PWD/templateoptionspage.ui HEADERS += $$PWD/qdesigner_resource.h \ + $$PWD/qdesignerundostack.h \ $$PWD/formwindow.h \ $$PWD/formwindow_widgetstack.h \ $$PWD/formwindow_dnditem.h \ @@ -41,6 +42,7 @@ HEADERS += $$PWD/qdesigner_resource.h \ $$PWD/templateoptionspage.h SOURCES += $$PWD/qdesigner_resource.cpp \ + $$PWD/qdesignerundostack.cpp \ $$PWD/formwindow.cpp \ $$PWD/formwindow_widgetstack.cpp \ $$PWD/formwindow_dnditem.cpp \ diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 8b8351d..ccb1984 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -399,8 +399,7 @@ void FormWindow::setCursorToAll(const QCursor &c, QWidget *start) void FormWindow::init() { if (FormWindowManager *manager = qobject_cast (core()->formWindowManager())) { - m_commandHistory = new QUndoStack(this); - manager->undoGroup()->addStack(m_commandHistory); + manager->undoGroup()->addStack(m_undoStack.qundoStack()); } m_blockSelectionChanged = false; @@ -429,9 +428,8 @@ void FormWindow::init() m_mainContainer = 0; m_currentWidget = 0; - connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SLOT(updateDirty())); - connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SIGNAL(changed())); - connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SLOT(checkSelection())); + connect(&m_undoStack, SIGNAL(changed()), this, SIGNAL(changed())); + connect(&m_undoStack, SIGNAL(changed()), this, SLOT(checkSelection())); core()->metaDataBase()->add(this); @@ -1227,14 +1225,14 @@ void FormWindow::insertWidget(QWidget *w, const QRect &rect, QWidget *container, if (w->parentWidget() != container) { ReparentWidgetCommand *cmd = new ReparentWidgetCommand(this); cmd->init(w, container); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } - m_commandHistory->push(geom_cmd); + m_undoStack.push(geom_cmd); InsertWidgetCommand *cmd = new InsertWidgetCommand(this); cmd->init(w, already_in_form); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); endCommand(); @@ -1277,12 +1275,10 @@ void FormWindow::resizeWidget(QWidget *widget, const QRect &geometry) Q_ASSERT(isDescendant(this, widget)); QRect r = geometry; - if (m_lastIndex > m_commandHistory->index()) - m_lastIndex = -1; SetPropertyCommand *cmd = new SetPropertyCommand(this); cmd->init(widget, QLatin1String("geometry"), r); cmd->setText(tr("Resize")); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } void FormWindow::raiseChildSelections(QWidget *w) @@ -1584,7 +1580,7 @@ void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers) ArrowKeyPropertyCommand *cmd = new ArrowKeyPropertyCommand(this); cmd->init(selection, operation); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } bool FormWindow::handleKeyReleaseEvent(QWidget *, QWidget *, QKeyEvent *e) @@ -1863,7 +1859,7 @@ void FormWindow::paste(PasteMode pasteMode) foreach (QWidget *w, clipboard.m_widgets) { InsertWidgetCommand *cmd = new InsertWidgetCommand(this); cmd->init(w); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); selectWidget(w); } } @@ -1873,7 +1869,7 @@ void FormWindow::paste(PasteMode pasteMode) ensureUniqueObjectName(a); AddActionCommand *cmd = new AddActionCommand(this); cmd->init(a); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } endCommand(); } while (false); @@ -2009,14 +2005,12 @@ void FormWindow::breakLayout(QWidget *w) void FormWindow::beginCommand(const QString &description) { - if (m_lastIndex > m_commandHistory->index()) - m_lastIndex = -1; - m_commandHistory->beginMacro(description); + m_undoStack.beginMacro(description); } void FormWindow::endCommand() { - m_commandHistory->endMacro(); + m_undoStack.endMacro(); } void FormWindow::raiseWidgets() @@ -2031,7 +2025,7 @@ void FormWindow::raiseWidgets() foreach (QWidget *widget, widgets) { RaiseWidgetCommand *cmd = new RaiseWidgetCommand(this); cmd->init(widget); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } endCommand(); } @@ -2048,7 +2042,7 @@ void FormWindow::lowerWidgets() foreach (QWidget *widget, widgets) { LowerWidgetCommand *cmd = new LowerWidgetCommand(this); cmd->init(widget); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } endCommand(); } @@ -2429,20 +2423,12 @@ FormWindow *FormWindow::findFormWindow(QWidget *w) bool FormWindow::isDirty() const { - return m_dirty; + return m_undoStack.isDirty(); } void FormWindow::setDirty(bool dirty) { - m_dirty = dirty; - - if (!m_dirty) - m_lastIndex = m_commandHistory->index(); -} - -void FormWindow::updateDirty() -{ - m_dirty = m_commandHistory->index() != m_lastIndex; + m_undoStack.setDirty(dirty); } QWidget *FormWindow::containerAt(const QPoint &pos) @@ -2811,7 +2797,7 @@ bool FormWindow::dropDockWidget(QDesignerDnDItemInterface *item, const QPoint &g qVariantSetValue(v, e); SetPropertyCommand *cmd = new SetPropertyCommand(this); cmd->init(widget, dockWidgetAreaName, v); - m_commandHistory->push(cmd); + m_undoStack.push(cmd); } endCommand(); @@ -2975,6 +2961,11 @@ QWidget *FormWindow::formContainer() const return m_widgetStack->formContainer(); } +QUndoStack *FormWindow::commandHistory() const +{ + return const_cast(m_undoStack).qundoStack(); +} + } // namespace QT_END_NAMESPACE diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index 1b2916c..06f60b5 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -43,6 +43,7 @@ #define FORMWINDOW_H #include "formeditor_global.h" +#include "qdesignerundostack.h" #include // Qt @@ -64,7 +65,6 @@ class QLabel; class QTimer; class QAction; class QMenu; -class QUndoStack; class QRubberBand; namespace qdesigner_internal { @@ -76,6 +76,7 @@ class FormWindowWidgetStack; class FormWindowManager; class FormWindowDnDItem; class SetPropertyCommand; +class QDesignerUndoStack; class QT_FORMEDITOR_EXPORT FormWindow: public FormWindowBase { @@ -165,9 +166,7 @@ public: void manageWidget(QWidget *w); void unmanageWidget(QWidget *w); - inline QUndoStack *commandHistory() const - { return m_commandHistory; } - + virtual QUndoStack *commandHistory() const; void beginCommand(const QString &description); void endCommand(); @@ -238,7 +237,6 @@ protected: private slots: void selectionChangedTimerDone(); - void updateDirty(); void checkSelection(); void checkSelectionNow(); void slotSelectWidget(QAction *); @@ -337,7 +335,7 @@ private: QPoint m_startPos; - QUndoStack *m_commandHistory; + QDesignerUndoStack m_undoStack; QString m_fileName; @@ -351,9 +349,6 @@ private: QTimer *m_checkSelectionTimer; QTimer *m_geometryChangedTimer; - int m_dirty; - int m_lastIndex; - FormWindowWidgetStack *m_widgetStack; WidgetEditorTool *m_widgetEditor; diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.cpp b/tools/designer/src/components/formeditor/qdesignerundostack.cpp new file mode 100644 index 0000000..6996bcd --- /dev/null +++ b/tools/designer/src/components/formeditor/qdesignerundostack.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** 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 Qt Designer of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdesignerundostack.h" + +#include +#include + +namespace qdesigner_internal { + +QDesignerUndoStack::QDesignerUndoStack(QObject *parent) : + QObject(parent), + m_undoStack(new QUndoStack), + m_fakeDirty(false) +{ + connect(m_undoStack, SIGNAL(indexChanged(int)), this, SIGNAL(changed())); +} + +QDesignerUndoStack::~QDesignerUndoStack() +{ // QUndoStack is managed by the QUndoGroup +} + +void QDesignerUndoStack::push(QUndoCommand * cmd) +{ + m_undoStack->push(cmd); +} + +void QDesignerUndoStack::beginMacro(const QString &text) +{ + m_undoStack->beginMacro(text); +} + +void QDesignerUndoStack::endMacro() +{ + m_undoStack->endMacro(); +} + +int QDesignerUndoStack::index() const +{ + return m_undoStack->index(); +} + +const QUndoStack *QDesignerUndoStack::qundoStack() const +{ + return m_undoStack; +} +QUndoStack *QDesignerUndoStack::qundoStack() +{ + return m_undoStack; +} + +bool QDesignerUndoStack::isDirty() const +{ + return m_fakeDirty || !m_undoStack->isClean(); +} + +void QDesignerUndoStack::setDirty(bool v) +{ + if (isDirty() == v) + return; + if (v) { + m_fakeDirty = true; + emit changed(); + } else { + m_fakeDirty = false; + m_undoStack->setClean(); + } +} + +} // namespace qdesigner_internal diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.h b/tools/designer/src/components/formeditor/qdesignerundostack.h new file mode 100644 index 0000000..b1b3389 --- /dev/null +++ b/tools/designer/src/components/formeditor/qdesignerundostack.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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 Qt Designer of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDESIGNERUNDOSTACK_H +#define QDESIGNERUNDOSTACK_H + +#include + +QT_BEGIN_NAMESPACE +class QUndoStack; +class QUndoCommand; +QT_END_NAMESPACE + +namespace qdesigner_internal { + +/* QDesignerUndoStack: A QUndoStack extended by a way of setting it to + * "dirty" indepently of commands (by modifications without commands + * such as resizing). Accomplished via bool m_fakeDirty flag. The + * lifecycle of the QUndoStack is managed by the QUndoGroup. */ +class QDesignerUndoStack : public QObject +{ + Q_DISABLE_COPY(QDesignerUndoStack) + Q_OBJECT +public: + explicit QDesignerUndoStack(QObject *parent = 0); + virtual ~QDesignerUndoStack(); + + void push(QUndoCommand * cmd); + void beginMacro(const QString &text); + void endMacro(); + int index() const; + + const QUndoStack *qundoStack() const; + QUndoStack *qundoStack(); + + bool isDirty() const; + +signals: + void changed(); + +public slots: + void setDirty(bool); + +private: + QUndoStack *m_undoStack; + bool m_fakeDirty; +}; + +} // namespace qdesigner_internal + +#endif // QDESIGNERUNDOSTACK_H -- cgit v0.12 From 684e86adea5e89d6220560e82f1823f99920bb40 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 16 Feb 2010 15:11:58 +0100 Subject: Designer: Fix compile for namespaced qt. --- tools/designer/src/components/formeditor/formwindow.cpp | 8 ++------ tools/designer/src/components/formeditor/formwindow.h | 1 - tools/designer/src/components/formeditor/qdesignerundostack.cpp | 4 ++++ tools/designer/src/components/formeditor/qdesignerundostack.h | 3 ++- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index ccb1984..631ca7c 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -1459,12 +1459,6 @@ QDebug operator<<(QDebug in, const ArrowKeyOperation &op) return in; } -} // namespace qdesigner_internal - -Q_DECLARE_METATYPE(qdesigner_internal::ArrowKeyOperation) - -namespace qdesigner_internal { - // ArrowKeyPropertyHelper: Applies a struct ArrowKeyOperation // (stored as new value) to a list of widgets using to calculate the // changed geometry of the widget in setValue(). Thus, the 'newValue' @@ -2969,3 +2963,5 @@ QUndoStack *FormWindow::commandHistory() const } // namespace QT_END_NAMESPACE + +Q_DECLARE_METATYPE(qdesigner_internal::ArrowKeyOperation) diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index 06f60b5..dc0026f 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -76,7 +76,6 @@ class FormWindowWidgetStack; class FormWindowManager; class FormWindowDnDItem; class SetPropertyCommand; -class QDesignerUndoStack; class QT_FORMEDITOR_EXPORT FormWindow: public FormWindowBase { diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.cpp b/tools/designer/src/components/formeditor/qdesignerundostack.cpp index 6996bcd..007031d 100644 --- a/tools/designer/src/components/formeditor/qdesignerundostack.cpp +++ b/tools/designer/src/components/formeditor/qdesignerundostack.cpp @@ -44,6 +44,8 @@ #include #include +QT_BEGIN_NAMESPACE + namespace qdesigner_internal { QDesignerUndoStack::QDesignerUndoStack(QObject *parent) : @@ -106,3 +108,5 @@ void QDesignerUndoStack::setDirty(bool v) } } // namespace qdesigner_internal + +QT_END_NAMESPACE diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.h b/tools/designer/src/components/formeditor/qdesignerundostack.h index b1b3389..5451ad8 100644 --- a/tools/designer/src/components/formeditor/qdesignerundostack.h +++ b/tools/designer/src/components/formeditor/qdesignerundostack.h @@ -47,7 +47,6 @@ QT_BEGIN_NAMESPACE class QUndoStack; class QUndoCommand; -QT_END_NAMESPACE namespace qdesigner_internal { @@ -86,4 +85,6 @@ private: } // namespace qdesigner_internal +QT_END_NAMESPACE + #endif // QDESIGNERUNDOSTACK_H -- cgit v0.12