diff options
145 files changed, 1248 insertions, 521 deletions
diff --git a/.qmake.conf b/.qmake.conf index fc13c75da5..5c42719444 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ load(qt_build_config) CONFIG += qt_example_installs CONFIG += warning_clean -MODULE_VERSION = 5.6.0 +MODULE_VERSION = 5.6.1 diff --git a/examples/quick/painteditem/textballoons/doc/images/declarative-textballoons_example.png b/examples/quick/customitems/painteditem/doc/images/declarative-textballoons_example.png Binary files differindex d572de597c..d572de597c 100644 --- a/examples/quick/painteditem/textballoons/doc/images/declarative-textballoons_example.png +++ b/examples/quick/customitems/painteditem/doc/images/declarative-textballoons_example.png diff --git a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc b/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc index da1658c7c6..3dc361e4a9 100644 --- a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc +++ b/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc @@ -24,8 +24,6 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - - /*! \title Scene Graph - Painted Item \brief Shows how to implement QPainter-based custom scenegraph items. diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml index 147f513456..cd8b9f3db9 100644 --- a/examples/quick/demos/stocqt/content/StockChart.qml +++ b/examples/quick/demos/stocqt/content/StockChart.qml @@ -321,11 +321,27 @@ Rectangle { ctx.restore(); } - onPaint: { - if (!stockModel.ready) { - return; - } + function drawError(ctx, msg) + { + ctx.save(); + ctx.strokeStyle = "#888888"; + ctx.font = "24px Open Sans" + ctx.textAlign = "center" + ctx.shadowOffsetX = 4; + ctx.shadowOffsetY = 4; + ctx.shadowBlur = 1.5; + ctx.shadowColor = "#aaaaaa"; + ctx.beginPath(); + ctx.fillText(msg, (canvas.width - tickMargin) / 2, + (canvas.height - yGridOffset - yGridStep) / 2); + + ctx.closePath(); + ctx.stroke(); + ctx.restore(); + } + + onPaint: { numPoints = stockModel.indexOf(chart.startDate); if (chart.gridSize == 0) @@ -337,6 +353,11 @@ Rectangle { drawBackground(ctx); + if (!stockModel.ready) { + drawError(ctx, "No data available."); + return; + } + var highestPrice = 0; var highestVolume = 0; var lowestPrice = -1; diff --git a/examples/quick/demos/stocqt/content/StockInfo.qml b/examples/quick/demos/stocqt/content/StockInfo.qml index 3c5ee196f2..88f540fa09 100644 --- a/examples/quick/demos/stocqt/content/StockInfo.qml +++ b/examples/quick/demos/stocqt/content/StockInfo.qml @@ -73,7 +73,7 @@ Rectangle { font.family: Settings.fontFamily font.pointSize: 28 font.weight: Font.DemiBold - text: parseFloat(Math.round(root.stock.stockPrice * 100) / 100).toFixed(2); + text: parseFloat(root.stock.stockPrice).toFixed(2); } } @@ -99,7 +99,7 @@ Rectangle { color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930" font.family: Settings.fontFamily font.pointSize: 18 - text: parseFloat(Math.round(root.stock.stockPriceChanged * 100) / 100).toFixed(2); + text: parseFloat(root.stock.stockPriceChanged).toFixed(2); } Text { @@ -110,9 +110,8 @@ Rectangle { font.pointSize: 18 font.weight: Font.DemiBold text: "(" + - Math.abs(Math.round( - root.stock.stockPriceChanged / - (root.stock.stockPrice - root.stock.stockPriceChanged) * 100)) / 100 + + parseFloat(root.stock.stockPriceChanged / + (root.stock.stockPrice - root.stock.stockPriceChanged) * 100.0).toFixed(2) + "%)" } } diff --git a/examples/quick/demos/stocqt/content/StockListModel.qml b/examples/quick/demos/stocqt/content/StockListModel.qml index b083b7bacc..be00e7bb1c 100644 --- a/examples/quick/demos/stocqt/content/StockListModel.qml +++ b/examples/quick/demos/stocqt/content/StockListModel.qml @@ -42,105 +42,105 @@ import QtQuick 2.0 ListModel { id: stocks - // Data from : http://en.wikipedia.org/wiki/NASDAQ-100 - ListElement {name: "Apple Inc."; stockId: "AAPL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + // Uncomment to test invalid entries + // ListElement {name: "The Qt Company"; stockId: "TQTC"; value: "999.0"; change: "0.0"; changePercentage: "0.0"} + + // Data from http://www.nasdaq.com/quotes/nasdaq-100-stocks.aspx + ListElement {name: "Activision Blizzard Inc."; stockId: "ATVI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Adobe Systems Inc."; stockId: "ADBE"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Analog Devices, Inc."; stockId: "ADI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Automatic Data Processing, Inc."; stockId: "ADP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Autodesk, Inc."; stockId: "ADSK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Akamai Technologies, Inc."; stockId: "AKAM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Altera Corp."; stockId: "ALTR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Alexion Pharmaceuticals, Inc."; stockId: "ALXN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Applied Materials, Inc."; stockId: "AMAT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Amgen Inc."; stockId: "AMGN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Akamai Technologies Inc."; stockId: "AKAM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Alexion Pharmaceuticals Inc."; stockId: "ALXN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Alphabet Inc."; stockId: "GOOG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Alphabet Inc."; stockId: "GOOGL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Amazon.com Inc."; stockId: "AMZN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Activision Blizzard, Inc."; stockId: "ATVI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Avago Technologies Limited"; stockId: "AVGO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "American Airlines Group Inc."; stockId: "AAL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Amgen Inc."; stockId: "AMGN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Analog Devices Inc."; stockId: "ADI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Apple Inc."; stockId: "AAPL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Applied Materials Inc."; stockId: "AMAT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Autodesk Inc."; stockId: "ADSK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Automatic Data Processing Inc."; stockId: "ADP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Baidu Inc."; stockId: "BIDU"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Bed Bath & Beyond Inc."; stockId: "BBBY"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Baidu, Inc."; stockId: "BIDU"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Biogen Idec Inc."; stockId: "BIIB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Broadcom Corp."; stockId: "BRCM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "CA Technologies"; stockId: "CA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Celgene Corporation"; stockId: "CELG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Cerner Corporation"; stockId: "CERN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Biogen Inc."; stockId: "BIIB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "BioMarin Pharmaceutical Inc."; stockId: "BMRN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Broadcom Limited"; stockId: "AVGO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "CA Inc."; stockId: "CA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Celgene Corp."; stockId: "CELG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Cerner Corp."; stockId: "CERN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Charter Communications Inc."; stockId: "CHTR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Check Point Software Technologies Ltd."; stockId: "CHKP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "CH Robinson Worldwide Inc."; stockId: "CHRW"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Charter Communications, Inc."; stockId: "CHTR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Comcast Corporation"; stockId: "CMCSA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Costco Wholesale Corporation"; stockId: "COST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Cisco Systems, Inc."; stockId: "CSCO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Catamaran Corporation"; stockId: "CTRX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Cognizant Technology Solutions Corporation"; stockId: "CTSH"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Citrix Systems, Inc."; stockId: "CTXS"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Discovery Communications, Inc."; stockId: "DISCA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Dish Network Corp."; stockId: "DISH"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Dollar Tree, Inc."; stockId: "DLTR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "DIRECTV"; stockId: "DTV"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Cisco Systems Inc."; stockId: "CSCO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Citrix Systems Inc."; stockId: "CTXS"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Cognizant Technology Solutions Corp."; stockId: "CTSH"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Comcast Corp."; stockId: "CMCSA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Costco Wholesale Corp."; stockId: "COST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Ctrip.com International Ltd."; stockId: "CTRP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Discovery Communications Inc."; stockId: "DISCA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Discovery Communications Inc."; stockId: "DISCK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "DISH Network Corp."; stockId: "DISH"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Dollar Tree Inc."; stockId: "DLTR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "eBay Inc."; stockId: "EBAY"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Equinix, Inc."; stockId: "EQIX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Express Scripts Holding Company"; stockId: "ESRX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Expeditors International of Washington Inc."; stockId: "EXPD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Expedia Inc."; stockId: "EXPE"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Fastenal Company"; stockId: "FAST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Facebook, Inc."; stockId: "FB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "F5 Networks, Inc."; stockId: "FFIV"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Fiserv, Inc."; stockId: "FISV"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Twenty-First Century Fox, Inc."; stockId: "FOXA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Gilead Sciences Inc."; stockId: "GILD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Keurig Green Mountain, Inc."; stockId: "GMCR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Google Inc."; stockId: "GOOG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Google Inc."; stockId: "GOOGL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Garmin Ltd."; stockId: "GRMN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Henry Schein, Inc."; stockId: "HSIC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Illumina Inc."; stockId: "ILMN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Intel Corporation"; stockId: "INTC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Electronic Arts Inc."; stockId: "EA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Endo International Plc"; stockId: "ENDP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Intel Corp."; stockId: "INTC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Intuit Inc."; stockId: "INTU"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Intuitive Surgical, Inc."; stockId: "ISRG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "KLA-Tencor Corporation"; stockId: "KLAC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Kraft Foods Group, Inc."; stockId: "KRFT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Liberty Global plc"; stockId: "LBTYA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Liberty Interactive Corporation"; stockId: "LINTA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Linear Technology Corporation"; stockId: "LLTC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Liberty Media Corporation"; stockId: "LMCA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Marriott International, Inc."; stockId: "MAR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Mattel, Inc"; stockId: "MAT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Mondelez International, Inc."; stockId: "MDLZ"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Monster Beverage Corporation"; stockId: "MNST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Microsoft Corporation"; stockId: "MSFT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Intuitive Surgical Inc."; stockId: "ISRG"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "JD.com Inc."; stockId: "JD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "KLA-Tencor Corp."; stockId: "KLAC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Lam Research Corp."; stockId: "LRCX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Liberty Global Plc"; stockId: "LBTYA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Liberty Global Plc"; stockId: "LBTYK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Liberty Interactive Corp."; stockId: "LVNTA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Liberty Interactive Corp."; stockId: "QVCA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Liberty Media Corp."; stockId: "LMCA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Liberty Media Corp."; stockId: "LMCK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Linear Technology Corp."; stockId: "LLTC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Marriott International"; stockId: "MAR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Mattel Inc."; stockId: "MAT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Maxim Integrated Products Inc."; stockId: "MXIM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Micron Technology Inc."; stockId: "MU"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Maxim Integrated Products, Inc."; stockId: "MXIM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Mylan, Inc."; stockId: "MYL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Netflix, Inc."; stockId: "NFLX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "NetApp, Inc."; stockId: "NTAP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "NVIDIA Corporation"; stockId: "NVDA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "NXP Semiconductors NV"; stockId: "NXPI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Microsoft Corp."; stockId: "MSFT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Mondelez International Inc."; stockId: "MDLZ"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Monster Beverage Corp."; stockId: "MNST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Mylan N.V."; stockId: "MYL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "NetApp Inc."; stockId: "NTAP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Netflix Inc."; stockId: "NFLX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Norwegian Cruise Line Holdings Ltd."; stockId: "NCLH"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "NVIDIA Corp."; stockId: "NVDA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "NXP Semiconductors N.V."; stockId: "NXPI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "O'Reilly Automotive Inc."; stockId: "ORLY"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Paychex, Inc."; stockId: "PAYX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "PACCAR Inc."; stockId: "PCAR"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "The Priceline Group Inc."; stockId: "PCLN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "QUALCOMM Incorporated"; stockId: "QCOM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Regeneron Pharmaceuticals, Inc."; stockId: "REGN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Paychex Inc."; stockId: "PAYX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "PayPal Holdings Inc."; stockId: "PYPL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "QUALCOMM Inc."; stockId: "QCOM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Regeneron Pharmaceuticals Inc."; stockId: "REGN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Ross Stores Inc."; stockId: "ROST"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "SanDisk Corp."; stockId: "SNDK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "SBA Communications Corp."; stockId: "SBAC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Starbucks Corporation"; stockId: "SBUX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Sigma-Aldrich Corporation"; stockId: "SIAL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Seagate Technology PLC"; stockId: "STX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Sirius XM Holdings Inc."; stockId: "SIRI"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "SanDisk Corp."; stockId: "SNDK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Staples, Inc."; stockId: "SPLS"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Stericycle, Inc."; stockId: "SRCL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Seagate Technology Public Limited Company"; stockId: "STX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Symantec Corporation"; stockId: "SYMC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "TripAdvisor Inc."; stockId: "TRIP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Tractor Supply Company"; stockId: "TSCO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Tesla Motors, Inc."; stockId: "TSLA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Skyworks Solutions Inc."; stockId: "SWKS"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Starbucks Corp."; stockId: "SBUX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Stericycle Inc."; stockId: "SRCL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Symantec Corp."; stockId: "SYMC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "T-Mobile US Inc."; stockId: "TMUS"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Tesla Motors Inc."; stockId: "TSLA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Texas Instruments Inc."; stockId: "TXN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Viacom, Inc."; stockId: "VIAB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "VimpelCom Ltd."; stockId: "VIP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Vodafone Group Public Limited Company"; stockId: "VOD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Verisk Analytics, Inc."; stockId: "VRSK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Vertex Pharmaceuticals Incorporated"; stockId: "VRTX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Western Digital Corporation"; stockId: "WDC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Whole Foods Market, Inc."; stockId: "WFM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} - ListElement {name: "Wynn Resorts Ltd."; stockId: "WYNN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "The Kraft Heinz Company"; stockId: "KHC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "The Priceline Group Inc."; stockId: "PCLN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Tractor Supply Company"; stockId: "TSCO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "TripAdvisor Inc."; stockId: "TRIP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Twenty-First Century Fox Inc."; stockId: "FOX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Twenty-First Century Fox Inc."; stockId: "FOXA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Ulta Salon Cosmetics & Fragrance Inc."; stockId: "ULTA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Verisk Analytics Inc."; stockId: "VRSK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Vertex Pharmaceuticals Inc."; stockId: "VRTX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Viacom Inc."; stockId: "VIAB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Vodafone Group Plc"; stockId: "VOD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Walgreens Boots Alliance Inc."; stockId: "WBA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Western Digital Corp."; stockId: "WDC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Whole Foods Market Inc."; stockId: "WFM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} ListElement {name: "Xilinx Inc."; stockId: "XLNX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} + ListElement {name: "Yahoo! Inc."; stockId: "YHOO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"} } diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/examples/quick/demos/stocqt/content/StockListView.qml index d1f735fde3..59f36b42cc 100644 --- a/examples/quick/demos/stocqt/content/StockListView.qml +++ b/examples/quick/demos/stocqt/content/StockListView.qml @@ -62,6 +62,7 @@ Rectangle { focus: true snapMode: ListView.SnapToItem model: StockListModel{} + currentIndex: -1 // Don't pre-select any item function requestUrl(stockId) { var endDate = new Date(""); //today @@ -95,7 +96,7 @@ Rectangle { xhr.onreadystatechange = function() { if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) { var records = xhr.responseText.split('\n'); - if (records.length > 0) { + if (records.length > 0 && xhr.status == 200) { var r = records[1].split(','); var today = parseFloat(r[4]); model.setProperty(index, "value", today.toFixed(2)); @@ -113,6 +114,9 @@ Rectangle { model.setProperty(index, "changePercentage", "+" + changePercentage.toFixed(2) + "%"); else model.setProperty(index, "changePercentage", changePercentage.toFixed(2) + "%"); + } else { + var unknown = "n/a"; + model.set(index, {"value": unknown, "change": unknown, "changePercentage": unknown}); } } } @@ -120,9 +124,10 @@ Rectangle { } onCurrentIndexChanged: { - mainRect.listViewActive = 0; - root.currentStockId = model.get(currentIndex).stockId; - root.currentStockName = model.get(currentIndex).name; + if (currentItem) { + root.currentStockId = model.get(currentIndex).stockId; + root.currentStockName = model.get(currentIndex).name; + } } delegate: Rectangle { @@ -132,7 +137,10 @@ Rectangle { MouseArea { anchors.fill: parent; onClicked: { - view.currentIndex = index; + if (view.currentIndex == index) + mainRect.currentIndex = 1; + else + view.currentIndex = index; } } @@ -243,7 +251,7 @@ Rectangle { } highlight: Rectangle { - width: parent.width + width: view.width color: "#eeeeee" } } diff --git a/examples/quick/demos/stocqt/content/StockModel.qml b/examples/quick/demos/stocqt/content/StockModel.qml index c1484d318e..035d9454d0 100644 --- a/examples/quick/demos/stocqt/content/StockModel.qml +++ b/examples/quick/demos/stocqt/content/StockModel.qml @@ -52,6 +52,9 @@ ListModel { signal dataReady function indexOf(date) { + if (model.count == 0) + return -1; + var newest = new Date(model.get(0).date); var oldest = new Date(model.get(model.count - 1).date); if (newest <= date) @@ -148,8 +151,11 @@ ListModel { model.ready = true; model.stockPrice = model.get(0).adjusted; model.stockPriceChanged = model.count > 1 ? (Math.round((model.stockPrice - model.get(1).close) * 100) / 100) : 0; - model.dataReady(); //emit signal + } else { + model.stockPrice = 0; + model.stockPriceChanged = 0; } + model.dataReady(); // emit signal - model.ready indicates whether the data is valid } } } diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/demos/stocqt/stocqt.qml index 512d6e1073..6b1da1713a 100644 --- a/examples/quick/demos/stocqt/stocqt.qml +++ b/examples/quick/demos/stocqt/stocqt.qml @@ -47,7 +47,7 @@ Rectangle { width: 1000 height: 700 - property int listViewActive: 0 + property alias currentIndex: root.currentIndex Rectangle { id: banner @@ -66,7 +66,7 @@ Rectangle { MouseArea { anchors.fill: parent - onClicked: listViewActive = 1; + onClicked: root.currentIndex = 0; } } @@ -108,11 +108,6 @@ Rectangle { focus: false orientation: ListView.Horizontal boundsBehavior: Flickable.StopAtBounds - currentIndex: listViewActive == 0 ? 1 : 0 - onCurrentIndexChanged: { - if (currentIndex == 1) - listViewActive = 0; - } StockModel { id: stock @@ -120,7 +115,7 @@ Rectangle { stockName: listView.currentStockName onStockIdChanged: stock.updateStock(); onDataReady: { - root.positionViewAtIndex(1, ListView.SnapPosition) + root.currentIndex = 1 stockView.update() } } diff --git a/examples/quick/rendercontrol/window_singlethreaded.cpp b/examples/quick/rendercontrol/window_singlethreaded.cpp index e43093e241..45f2635ca4 100644 --- a/examples/quick/rendercontrol/window_singlethreaded.cpp +++ b/examples/quick/rendercontrol/window_singlethreaded.cpp @@ -265,9 +265,10 @@ void WindowSingleThreaded::startQuick(const QString &filename) void WindowSingleThreaded::exposeEvent(QExposeEvent *) { if (isExposed()) { - m_cubeRenderer->render(this, m_context, m_quickReady ? m_fbo->texture() : 0); - if (!m_quickInitialized) + if (!m_quickInitialized) { + m_cubeRenderer->render(this, m_context, m_quickReady ? m_fbo->texture() : 0); startQuick(QStringLiteral("qrc:/rendercontrol/demo.qml")); + } } } diff --git a/qtdeclarative.pro b/qtdeclarative.pro index 0e746c3c65..5b94da9b69 100644 --- a/qtdeclarative.pro +++ b/qtdeclarative.pro @@ -3,7 +3,7 @@ load(qt_parts) !python_available { py_out = $$system('python -c "print(1)"') - !equals(py_out, 1): error("Building QtQml requires Python version 2.") + !equals(py_out, 1): error("Building QtQml requires Python.") tmp = python_available CONFIG += $$tmp cache(CONFIG, add, tmp) diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp index ebdfba42a8..b9cc9cac22 100644 --- a/src/imports/folderlistmodel/fileinfothread.cpp +++ b/src/imports/folderlistmodel/fileinfothread.cpp @@ -59,7 +59,6 @@ FileInfoThread::FileInfoThread(QObject *parent) connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString))); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString))); #endif // !QT_NO_FILESYSTEMWATCHER - start(LowPriority); } FileInfoThread::~FileInfoThread() diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index 8bfbf09769..d01fc5e74e 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -531,6 +531,7 @@ void QQuickFolderListModel::componentComplete() QString localPath = QQmlFile::urlToLocalFileOrQrc(d->currentDir); if (localPath.isEmpty() || !QDir(localPath).exists()) setFolder(QUrl::fromLocalFile(QDir::currentPath())); + d->fileInfoThread.start(QThread::LowPriority); } /*! diff --git a/src/particles/particles.pro b/src/particles/particles.pro index ba65ee3002..ab1c854253 100644 --- a/src/particles/particles.pro +++ b/src/particles/particles.pro @@ -1,4 +1,5 @@ TARGET = QtQuickParticles +MODULE = quickparticles CONFIG += internal_module @@ -13,7 +14,6 @@ exists("qqml_enable_gcov") { LIBS_PRIVATE += -lgcov } -MODULE = quickparticles -load(qt_module) - include(particles.pri) + +load(qt_module) diff --git a/src/particles/qquickparticleemitter.cpp b/src/particles/qquickparticleemitter.cpp index e34356aa66..296f215174 100644 --- a/src/particles/qquickparticleemitter.cpp +++ b/src/particles/qquickparticleemitter.cpp @@ -337,7 +337,7 @@ void QQuickParticleEmitter::emitWindow(int timeStamp) { if (m_system == 0) return; - if ((!m_enabled || !m_particlesPerSecond)&& !m_pulseLeft && m_burstQueue.isEmpty()){ + if ((!m_enabled || m_particlesPerSecond <= 0)&& !m_pulseLeft && m_burstQueue.isEmpty()){ m_reset_last = true; return; } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro b/src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro index 8d1a54e9e4..dc923b2350 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro +++ b/src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro @@ -1,10 +1,6 @@ TARGET = qmldbg_debugger QT = qml-private core-private -PLUGIN_TYPE = qmltooling -PLUGIN_CLASS_NAME = QQmlDebuggerServiceFactory -load(qt_plugin) - SOURCES += \ $$PWD/qdebugmessageservice.cpp \ $$PWD/qqmldebuggerservicefactory.cpp \ @@ -32,3 +28,6 @@ INCLUDEPATH += $$PWD \ OTHER_FILES += \ $$PWD/qqmldebuggerservice.json +PLUGIN_TYPE = qmltooling +PLUGIN_CLASS_NAME = QQmlDebuggerServiceFactory +load(qt_plugin) diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro index 1c3e5f387b..03446768a6 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro +++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro @@ -1,10 +1,6 @@ TARGET = qmldbg_inspector QT += qml-private quick-private core-private gui-private -PLUGIN_TYPE = qmltooling -PLUGIN_CLASS_NAME = QQmlInspectorServiceFactory -load(qt_plugin) - INCLUDEPATH *= $$PWD $$PWD/../shared SOURCES += \ @@ -25,3 +21,7 @@ HEADERS += \ OTHER_FILES += \ qqmlinspectorservice.json + +PLUGIN_TYPE = qmltooling +PLUGIN_CLASS_NAME = QQmlInspectorServiceFactory +load(qt_plugin) diff --git a/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro b/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro index 491be04b15..d731e47b7e 100644 --- a/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro +++ b/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro @@ -1,10 +1,6 @@ TARGET = qmldbg_local QT = qml-private -PLUGIN_TYPE = qmltooling -PLUGIN_CLASS_NAME = QLocalClientConnectionFactory -load(qt_plugin) - SOURCES += \ $$PWD/qlocalclientconnection.cpp @@ -18,3 +14,7 @@ INCLUDEPATH += $$PWD \ OTHER_FILES += \ $$PWD/qlocalclientconnection.json + +PLUGIN_TYPE = qmltooling +PLUGIN_CLASS_NAME = QLocalClientConnectionFactory +load(qt_plugin) diff --git a/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro b/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro index 7dc16b8c44..5d52a8113f 100644 --- a/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro +++ b/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro @@ -1,12 +1,12 @@ TARGET = qmldbg_native QT += qml-private core-private -PLUGIN_TYPE = qmltooling -PLUGIN_CLASS_NAME = QQmlNativeDebugConnectorFactory -load(qt_plugin) - SOURCES += \ $$PWD/qqmlnativedebugconnector.cpp OTHER_FILES += \ $$PWD/qqmlnativedebugconnector.json + +PLUGIN_TYPE = qmltooling +PLUGIN_CLASS_NAME = QQmlNativeDebugConnectorFactory +load(qt_plugin) diff --git a/src/plugins/qmltooling/qmldbg_profiler/qmldbg_profiler.pro b/src/plugins/qmltooling/qmldbg_profiler/qmldbg_profiler.pro index e1c4095d88..4fcfb41a8c 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qmldbg_profiler.pro +++ b/src/plugins/qmltooling/qmldbg_profiler/qmldbg_profiler.pro @@ -1,10 +1,6 @@ TARGET = qmldbg_profiler QT = qml-private core-private -PLUGIN_TYPE = qmltooling -PLUGIN_CLASS_NAME = QQmlProfilerServiceFactory -load(qt_plugin) - SOURCES += \ $$PWD/qqmlenginecontrolservice.cpp \ $$PWD/qqmlprofileradapter.cpp \ @@ -26,3 +22,6 @@ INCLUDEPATH += $$PWD \ OTHER_FILES += \ $$PWD/qqmlprofilerservice.json +PLUGIN_TYPE = qmltooling +PLUGIN_CLASS_NAME = QQmlProfilerServiceFactory +load(qt_plugin) diff --git a/src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro b/src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro index 5e2d0874df..54fe0a4473 100644 --- a/src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro +++ b/src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro @@ -1,10 +1,6 @@ TARGET = qmldbg_server QT = qml-private core-private -PLUGIN_TYPE = qmltooling -PLUGIN_CLASS_NAME = QQmlDebugServerFactory -load(qt_plugin) - SOURCES += \ $$PWD/qqmldebugserver.cpp \ $$PWD/../shared/qpacketprotocol.cpp @@ -20,3 +16,7 @@ INCLUDEPATH += $$PWD \ OTHER_FILES += \ qqmldebugserver.json + +PLUGIN_TYPE = qmltooling +PLUGIN_CLASS_NAME = QQmlDebugServerFactory +load(qt_plugin) diff --git a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro index fd419aeb56..1face1813e 100644 --- a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro +++ b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro @@ -1,10 +1,6 @@ TARGET = qmldbg_tcp QT = qml-private network -PLUGIN_TYPE = qmltooling -PLUGIN_CLASS_NAME = QTcpServerConnectionFactory -load(qt_plugin) - SOURCES += \ $$PWD/qtcpserverconnection.cpp @@ -18,3 +14,7 @@ INCLUDEPATH += $$PWD \ OTHER_FILES += \ $$PWD/qtcpserverconnection.json + +PLUGIN_TYPE = qmltooling +PLUGIN_CLASS_NAME = QTcpServerConnectionFactory +load(qt_plugin) diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 6fd15d1eb8..fcc0ca8d14 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1157,6 +1157,17 @@ struct StaticQtMetaObject : public QObject { return &staticQtMetaObject; } }; +bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, const QString &enumName, int enumValue, bool isQtObject) +{ + if (enumName.length() > 0 && enumName[0].isLower() && !isQtObject) { + COMPILE_EXCEPTION(binding, tr("Invalid property assignment: Enum value \"%1\" cannot start with a lowercase letter").arg(enumName)); + } + binding->type = QV4::CompiledData::Binding::Type_Number; + binding->value.d = (double)enumValue; + binding->flags |= QV4::CompiledData::Binding::IsResolvedEnum; + return true; +} + bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj, const QQmlPropertyCache *propertyCache, const QQmlPropertyData *prop, QmlIR::Binding *binding) { bool isIntProp = (prop->propType == QMetaType::Int) && !prop->isEnum(); @@ -1179,6 +1190,7 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj, return true; QHashedStringRef typeName(string.constData(), dot); + const bool isQtObject = (typeName == QLatin1String("Qt")); QString enumValue = string.mid(dot+1); if (isIntProp) { @@ -1186,16 +1198,15 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj, bool ok; int enumval = evaluateEnum(typeName.toString(), enumValue.toUtf8(), &ok); if (ok) { - binding->type = QV4::CompiledData::Binding::Type_Number; - binding->value.d = (double)enumval; - binding->flags |= QV4::CompiledData::Binding::IsResolvedEnum; + if (!assignEnumToBinding(binding, enumValue, enumval, isQtObject)) + return false; } return true; } QQmlType *type = 0; imports->resolveType(typeName, &type, 0, 0, 0); - if (!type && typeName != QLatin1String("Qt")) + if (!type && !isQtObject) return true; int value = 0; @@ -1228,10 +1239,7 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj, if (!ok) return true; - binding->type = QV4::CompiledData::Binding::Type_Number; - binding->value.d = (double)value; - binding->flags |= QV4::CompiledData::Binding::IsResolvedEnum; - return true; + return assignEnumToBinding(binding, enumValue, value, isQtObject); } int QQmlEnumTypeResolver::evaluateEnum(const QString &scope, const QByteArray &enumValue, bool *ok) const diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h index c5be92d256..091007bf25 100644 --- a/src/qml/compiler/qqmltypecompiler_p.h +++ b/src/qml/compiler/qqmltypecompiler_p.h @@ -190,6 +190,7 @@ public: bool resolveEnumBindings(); private: + bool assignEnumToBinding(QmlIR::Binding *binding, const QString &enumName, int enumValue, bool isQtObject); bool tryQualifiedEnumAssignment(const QmlIR::Object *obj, const QQmlPropertyCache *propertyCache, const QQmlPropertyData *prop, QmlIR::Binding *binding); diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc index c0b74c4fc6..04d769e4dc 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc @@ -448,8 +448,8 @@ right-hand-side of the property declaration must be a valid alias reference: [default] property alias <name>: <alias reference> \endcode -Unlike an ordinary property, an alias can only refer to a object, or the -property of a object, that is within the scope of the \l{QML Object Types} +Unlike an ordinary property, an alias can only refer to an object, or the +property of an object, that is within the scope of the \l{QML Object Types} {type} within which the alias is declared. It cannot contain arbitrary JavaScript expressions and it cannot refer to objects declared outside of the scope of its type. Also note the \e {alias reference} is not optional, diff --git a/src/qml/jsapi/qjsengine.h b/src/qml/jsapi/qjsengine.h index 40b0a60369..c3f3ace1dd 100644 --- a/src/qml/jsapi/qjsengine.h +++ b/src/qml/jsapi/qjsengine.h @@ -105,7 +105,7 @@ private: friend inline bool qjsvalue_cast_helper(const QJSValue &, int, void *); protected: - QJSEngine(QJSEnginePrivate &dd, QObject *parent = 0); + QJSEngine(QJSEnginePrivate &dd, QObject *parent = Q_NULLPTR); private: QV8Engine *d; diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 3d3ac84576..5d1dbe69e1 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -45,8 +45,6 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(MathObject); -static const double qt_PI = 2.0 * ::asin(1.0); - Heap::MathObject::MathObject() { Scope scope(internalClass->engine); diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 089b2bbd34..723afcab54 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -113,11 +113,14 @@ struct Q_QML_PRIVATE_EXPORT Value Q_ALWAYS_INLINE quint32 value() const { return _val >> 32; } #endif -#ifdef QV4_USE_64_BIT_VALUE_ENCODING +#if defined(V4_BOOTSTRAP) + Q_ALWAYS_INLINE Heap::Base *m() const { Q_UNREACHABLE(); return Q_NULLPTR; } + Q_ALWAYS_INLINE void setM(Heap::Base *b) { Q_UNUSED(b); Q_UNREACHABLE(); } +#elif defined(QV4_USE_64_BIT_VALUE_ENCODING) Q_ALWAYS_INLINE Heap::Base *m() const { Heap::Base *b; memcpy(&b, &_val, 8); return b; } Q_ALWAYS_INLINE void setM(Heap::Base *b) { memcpy(&_val, &b, 8); } #else // !QV4_USE_64_BIT_VALUE_ENCODING - Q_ALWAYS_INLINE Heap::Base *m() const { Heap::Base *b; quint32 v = value(); memcpy(&b, &v, 4); return b; } + Q_ALWAYS_INLINE Heap::Base *m() const { Q_STATIC_ASSERT(sizeof(Heap::Base*) == sizeof(quint32)); Heap::Base *b; quint32 v = value(); memcpy(&b, &v, 4); return b; } Q_ALWAYS_INLINE void setM(Heap::Base *b) { quint32 v; memcpy(&v, &b, 4); setValue(v); } #endif diff --git a/src/qml/qml.pro b/src/qml/qml.pro index d75262bf0b..e30c39c8b9 100644 --- a/src/qml/qml.pro +++ b/src/qml/qml.pro @@ -11,9 +11,6 @@ solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 # Ensure this gcc optimization is switched off for mips platforms to avoid trouble with JIT. gcc:isEqual(QT_ARCH, "mips"): QMAKE_CXXFLAGS += -fno-reorder-blocks -MODULE_PLUGIN_TYPES = \ - qmltooling - exists("qqml_enable_gcov") { QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors LIBS_PRIVATE += -lgcov @@ -29,8 +26,6 @@ greaterThan(QT_CLANG_MAJOR_VERSION, 3)|greaterThan(QT_CLANG_MINOR_VERSION, 3)| \ if(equals(QT_APPLE_CLANG_MAJOR_VERSION, 5):greaterThan(QT_APPLE_CLANG_MINOR_VERSION, 0)): \ WERROR += -Wno-error=unused-const-variable -load(qt_module) - HEADERS += qtqmlglobal.h \ qtqmlglobal_p.h @@ -46,3 +41,7 @@ include(qml/qml.pri) include(debugger/debugger.pri) include(animations/animations.pri) include(types/types.pri) + +MODULE_PLUGIN_TYPES = \ + qmltooling +load(qt_module) diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index 23cb69e2f1..02618f77f5 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -105,10 +105,11 @@ int qmlRegisterType() qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), - 0, 0, + 0, + Q_NULLPTR, QString(), - 0, 0, 0, 0, &T::staticMetaObject, + Q_NULLPTR, 0, 0, Q_NULLPTR, &T::staticMetaObject, QQmlPrivate::attachedPropertiesFunc<T>(), QQmlPrivate::attachedPropertiesMetaObject<T>(), @@ -117,9 +118,9 @@ int qmlRegisterType() QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - 0, 0, + Q_NULLPTR, Q_NULLPTR, - 0, + Q_NULLPTR, 0 }; @@ -138,7 +139,8 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), - 0, 0, + 0, + Q_NULLPTR, reason, uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, @@ -150,9 +152,9 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - 0, 0, + Q_NULLPTR, Q_NULLPTR, - 0, + Q_NULLPTR, 0 }; @@ -169,7 +171,8 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), - 0, 0, + 0, + Q_NULLPTR, reason, uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, @@ -181,9 +184,9 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - 0, 0, + Q_NULLPTR, Q_NULLPTR, - 0, + Q_NULLPTR, metaObjectRevision }; @@ -207,7 +210,8 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), - 0, 0, + 0, + Q_NULLPTR, reason, uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, @@ -221,7 +225,7 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve QQmlPrivate::createParent<E>, &E::staticMetaObject, - 0, + Q_NULLPTR, 0 }; @@ -250,9 +254,9 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - 0, 0, + Q_NULLPTR, Q_NULLPTR, - 0, + Q_NULLPTR, 0 }; @@ -281,9 +285,9 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - 0, 0, + Q_NULLPTR, Q_NULLPTR, - 0, + Q_NULLPTR, metaObjectRevision }; @@ -312,9 +316,9 @@ int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor) QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - 0, 0, + Q_NULLPTR, Q_NULLPTR, - 0, + Q_NULLPTR, metaObjectRevision }; @@ -332,10 +336,11 @@ int qmlRegisterExtendedType() qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), - 0, 0, + 0, + Q_NULLPTR, QString(), - 0, 0, 0, 0, &T::staticMetaObject, + Q_NULLPTR, 0, 0, Q_NULLPTR, &T::staticMetaObject, QQmlPrivate::attachedPropertiesFunc<T>(), QQmlPrivate::attachedPropertiesMetaObject<T>(), @@ -346,7 +351,7 @@ int qmlRegisterExtendedType() QQmlPrivate::createParent<E>, &E::staticMetaObject, - 0, + Q_NULLPTR, 0 }; @@ -385,7 +390,7 @@ int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor, QQmlPrivate::createParent<E>, &E::staticMetaObject, - 0, + Q_NULLPTR, 0 }; @@ -435,7 +440,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor, QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - 0, 0, + Q_NULLPTR, Q_NULLPTR, parser, 0 @@ -530,7 +535,7 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi uri, versionMajor, versionMinor, typeName, - callback, 0, 0, 0, 0 + callback, Q_NULLPTR, Q_NULLPTR, 0, 0 }; return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api); @@ -548,7 +553,7 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi uri, versionMajor, versionMinor, typeName, - 0, callback, &T::staticMetaObject, qRegisterNormalizedMetaType<T *>(pointerName.constData()), 0 + Q_NULLPTR, callback, &T::staticMetaObject, qRegisterNormalizedMetaType<T *>(pointerName.constData()), 0 }; return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api); diff --git a/src/qml/qml/qqmlapplicationengine.h b/src/qml/qml/qqmlapplicationengine.h index 84cb2625dc..3b91d6adfc 100644 --- a/src/qml/qml/qqmlapplicationengine.h +++ b/src/qml/qml/qqmlapplicationengine.h @@ -47,9 +47,9 @@ class Q_QML_EXPORT QQmlApplicationEngine : public QQmlEngine { Q_OBJECT public: - QQmlApplicationEngine(QObject *parent=0); - QQmlApplicationEngine(const QUrl &url, QObject *parent=0); - QQmlApplicationEngine(const QString &filePath, QObject *parent=0); + QQmlApplicationEngine(QObject *parent = Q_NULLPTR); + QQmlApplicationEngine(const QUrl &url, QObject *parent = Q_NULLPTR); + QQmlApplicationEngine(const QString &filePath, QObject *parent = Q_NULLPTR); ~QQmlApplicationEngine(); QList<QObject*> rootObjects(); diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 22a54d732e..9b52a951af 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -372,6 +372,13 @@ QQmlComponent::~QQmlComponent() if (d->state.completePending) { qWarning("QQmlComponent: Component destroyed while completion pending"); + + if (isError()) { + qWarning() << "This may have been caused by one of the following errors:"; + foreach (const QQmlError &error, d->state.errors) + qWarning().nospace().noquote() << QLatin1String(" ") << error; + } + d->completeCreate(); } diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h index 121c83db5c..58cbadff00 100644 --- a/src/qml/qml/qqmlcomponent.h +++ b/src/qml/qml/qqmlcomponent.h @@ -66,12 +66,12 @@ public: enum CompilationMode { PreferSynchronous, Asynchronous }; Q_ENUM(CompilationMode) - QQmlComponent(QObject *parent = 0); - QQmlComponent(QQmlEngine *, QObject *parent=0); - QQmlComponent(QQmlEngine *, const QString &fileName, QObject *parent = 0); - QQmlComponent(QQmlEngine *, const QString &fileName, CompilationMode mode, QObject *parent = 0); - QQmlComponent(QQmlEngine *, const QUrl &url, QObject *parent = 0); - QQmlComponent(QQmlEngine *, const QUrl &url, CompilationMode mode, QObject *parent = 0); + QQmlComponent(QObject *parent = Q_NULLPTR); + QQmlComponent(QQmlEngine *, QObject *parent = Q_NULLPTR); + QQmlComponent(QQmlEngine *, const QString &fileName, QObject *parent = Q_NULLPTR); + QQmlComponent(QQmlEngine *, const QString &fileName, CompilationMode mode, QObject *parent = Q_NULLPTR); + QQmlComponent(QQmlEngine *, const QUrl &url, QObject *parent = Q_NULLPTR); + QQmlComponent(QQmlEngine *, const QUrl &url, CompilationMode mode, QObject *parent = Q_NULLPTR); virtual ~QQmlComponent(); enum Status { Null, Ready, Loading, Error }; @@ -90,12 +90,12 @@ public: QUrl url() const; - virtual QObject *create(QQmlContext *context = 0); + virtual QObject *create(QQmlContext *context = Q_NULLPTR); virtual QObject *beginCreate(QQmlContext *); virtual void completeCreate(); - void create(QQmlIncubator &, QQmlContext *context = 0, - QQmlContext *forContext = 0); + void create(QQmlIncubator &, QQmlContext *context = Q_NULLPTR, + QQmlContext *forContext = Q_NULLPTR); QQmlContext *creationContext() const; diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index b056731e96..1d1134bb74 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -89,7 +89,7 @@ QQmlContextPrivate::QQmlContextPrivate() by name in the context, as though they were all individually added through calls to QQmlContext::setContextProperty(). Changes to the property's values are detected through the property's notify signal. Setting a context object is both - faster and easier than manually adding and maintaing context property values. + faster and easier than manually adding and maintaining context property values. The following example has the same effect as the previous one, but it uses a context object. diff --git a/src/qml/qml/qqmlcontext.h b/src/qml/qml/qqmlcontext.h index e69a2f8f69..3049ec7f71 100644 --- a/src/qml/qml/qqmlcontext.h +++ b/src/qml/qml/qqmlcontext.h @@ -56,8 +56,8 @@ class Q_QML_EXPORT QQmlContext : public QObject Q_DECLARE_PRIVATE(QQmlContext) public: - QQmlContext(QQmlEngine *parent, QObject *objParent=0); - QQmlContext(QQmlContext *parent, QObject *objParent=0); + QQmlContext(QQmlEngine *parent, QObject *objParent = Q_NULLPTR); + QQmlContext(QQmlContext *parent, QObject *objParent = Q_NULLPTR); virtual ~QQmlContext(); bool isValid() const; diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 109cfac0c3..2cfe468134 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -598,8 +598,8 @@ QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e) workerScriptEngine(0), activeObjectCreator(0), networkAccessManager(0), networkAccessManagerFactory(0), urlInterceptor(0), - scarceResourcesRefCount(0), typeLoader(e), importDatabase(e), uniqueId(1), - incubatorCount(0), incubationController(0) + scarceResourcesRefCount(0), importDatabase(e), typeLoader(e), + uniqueId(1), incubatorCount(0), incubationController(0) { } diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h index 61a884279d..bf878bd994 100644 --- a/src/qml/qml/qqmlengine.h +++ b/src/qml/qml/qqmlengine.h @@ -88,7 +88,7 @@ class Q_QML_EXPORT QQmlEngine : public QJSEngine Q_PROPERTY(QString offlineStoragePath READ offlineStoragePath WRITE setOfflineStoragePath) Q_OBJECT public: - QQmlEngine(QObject *p = 0); + explicit QQmlEngine(QObject *p = Q_NULLPTR); virtual ~QQmlEngine(); QQmlContext *rootContext() const; diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index 26ee3bd655..072a6c436a 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -166,9 +166,8 @@ public: void referenceScarceResources(); void dereferenceScarceResources(); - QQmlTypeLoader typeLoader; QQmlImportDatabase importDatabase; - + QQmlTypeLoader typeLoader; QString offlineStoragePath; diff --git a/src/qml/qml/qqmlexpression.h b/src/qml/qml/qqmlexpression.h index 408871cfc5..e3e96f8030 100644 --- a/src/qml/qml/qqmlexpression.h +++ b/src/qml/qml/qqmlexpression.h @@ -54,8 +54,8 @@ class Q_QML_EXPORT QQmlExpression : public QObject Q_OBJECT public: QQmlExpression(); - QQmlExpression(QQmlContext *, QObject *, const QString &, QObject * = 0); - explicit QQmlExpression(const QQmlScriptString &, QQmlContext * = 0, QObject * = 0, QObject * = 0); + QQmlExpression(QQmlContext *, QObject *, const QString &, QObject * = Q_NULLPTR); + explicit QQmlExpression(const QQmlScriptString &, QQmlContext * = Q_NULLPTR, QObject * = Q_NULLPTR, QObject * = Q_NULLPTR); virtual ~QQmlExpression(); QQmlEngine *engine() const; @@ -78,7 +78,7 @@ public: void clearError(); QQmlError error() const; - QVariant evaluate(bool *valueIsUndefined = 0); + QVariant evaluate(bool *valueIsUndefined = Q_NULLPTR); Q_SIGNALS: void valueChanged(); diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h index 879cc91abe..074b5e2531 100644 --- a/src/qml/qml/qqmlextensionplugin.h +++ b/src/qml/qml/qqmlextensionplugin.h @@ -52,7 +52,7 @@ class Q_QML_EXPORT QQmlExtensionPlugin Q_INTERFACES(QQmlExtensionInterface) Q_INTERFACES(QQmlTypesExtensionInterface) public: - explicit QQmlExtensionPlugin(QObject *parent = 0); + explicit QQmlExtensionPlugin(QObject *parent = Q_NULLPTR); ~QQmlExtensionPlugin(); QUrl baseUrl() const; diff --git a/src/qml/qml/qqmlfileselector.h b/src/qml/qml/qqmlfileselector.h index d86908e9cb..afc819e214 100644 --- a/src/qml/qml/qqmlfileselector.h +++ b/src/qml/qml/qqmlfileselector.h @@ -48,7 +48,7 @@ class Q_QML_EXPORT QQmlFileSelector : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QQmlFileSelector) public: - QQmlFileSelector(QQmlEngine* engine, QObject* parent=0); + explicit QQmlFileSelector(QQmlEngine *engine, QObject *parent = Q_NULLPTR); ~QQmlFileSelector(); void setSelector(QFileSelector *selector); void setExtraSelectors(QStringList &strings); // TODO Qt6: remove diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 63604d4622..a568ae440c 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -681,7 +681,7 @@ void QQmlIncubator::statusChanged(Status status) Called after the \a object is first created, but before property bindings are evaluated and, if applicable, QQmlParserStatus::componentComplete() is called. This is equivalent to the point between QQmlComponent::beginCreate() -and QQmlComponent::endCreate(), and can be used to assign initial values +and QQmlComponent::completeCreate(), and can be used to assign initial values to the object's properties. The default implementation does nothing. diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h index edd61b26c9..5a06299f3b 100644 --- a/src/qml/qml/qqmllist.h +++ b/src/qml/qml/qqmllist.h @@ -55,15 +55,41 @@ public: typedef void (*ClearFunction)(QQmlListProperty<T> *); QQmlListProperty() - : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} + : object(Q_NULLPTR), + data(Q_NULLPTR), + append(Q_NULLPTR), + count(Q_NULLPTR), + at(Q_NULLPTR), + clear(Q_NULLPTR), + dummy1(Q_NULLPTR), + dummy2(Q_NULLPTR) + {} QQmlListProperty(QObject *o, QList<T *> &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), - clear(qlist_clear), dummy1(0), dummy2(0) {} + clear(qlist_clear), + dummy1(Q_NULLPTR), + dummy2(Q_NULLPTR) + {} QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r ) - : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} + : object(o), + data(d), + append(a), + count(c), + at(t), + clear(r), + dummy1(Q_NULLPTR), + dummy2(Q_NULLPTR) + {} QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction t) - : object(o), data(d), append(0), count(c), at(t), clear(0), dummy1(0), dummy2(0) {} + : object(o), + data(d), + append(Q_NULLPTR), + count(c), at(t), + clear(Q_NULLPTR), + dummy1(Q_NULLPTR), + dummy2(Q_NULLPTR) + {} bool operator==(const QQmlListProperty &o) const { return object == o.object && data == o.data && @@ -108,7 +134,7 @@ class Q_QML_EXPORT QQmlListReference { public: QQmlListReference(); - QQmlListReference(QObject *, const char *property, QQmlEngine * = 0); + QQmlListReference(QObject *, const char *property, QQmlEngine * = Q_NULLPTR); QQmlListReference(const QQmlListReference &); QQmlListReference &operator=(const QQmlListReference &); ~QQmlListReference(); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 21e6d5f6de..15c38c1d5b 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -710,6 +710,8 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QQmlTypeNameCache::Result res = context->imports->query(stringAt(binding->propertyNameIndex)); if (res.isValid()) attachedType = res.type; + else + return false; } const int id = attachedType->attachedPropertiesId(QQmlEnginePrivate::get(engine)); QObject *qmlObject = qmlAttachedPropertiesObjectById(id, _qobject); diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 6c29f2fbb5..7ae8332ec4 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -119,6 +119,28 @@ ReturnedValue QmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, Q return w.asReturnedValue(); } +static int enumForSingleton(String *name, QObject *qobjectSingleton) +{ + // ### Optimize + QByteArray enumName = name->toQString().toUtf8(); + const QMetaObject *metaObject = qobjectSingleton->metaObject(); + for (int ii = metaObject->enumeratorCount() - 1; ii >= 0; --ii) { + QMetaEnum e = metaObject->enumerator(ii); + bool ok; + int value = e.keyToValue(enumName.constData(), &ok); + if (ok) + return value; + } + return -1; +} + +static ReturnedValue throwLowercaseEnumError(QV4::ExecutionEngine *v4, String *name, QQmlType *type) +{ + const QString message = + QStringLiteral("Cannot access enum value '%1' of '%2', enum values need to start with an uppercase letter.") + .arg(name->toQString()).arg(QLatin1String(type->typeName())); + return v4->throwTypeError(message); +} ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasProperty) { @@ -135,9 +157,9 @@ ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasPrope QQmlContextData *context = v4->callingQmlContext(); QObject *object = w->d()->object; + QQmlType *type = w->d()->type; - if (w->d()->type) { - QQmlType *type = w->d()->type; + if (type) { // singleton types are handled differently to other types. if (type->isSingleton()) { @@ -147,24 +169,29 @@ ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasPrope QObject *qobjectSingleton = siinfo->qobjectApi(e); if (qobjectSingleton) { + // check for enum value - if (name->startsWithUpper()) { - if (w->d()->mode == Heap::QmlTypeWrapper::IncludeEnums) { - // ### Optimize - QByteArray enumName = name->toQString().toUtf8(); - const QMetaObject *metaObject = qobjectSingleton->metaObject(); - for (int ii = metaObject->enumeratorCount() - 1; ii >= 0; --ii) { - QMetaEnum e = metaObject->enumerator(ii); - bool ok; - int value = e.keyToValue(enumName.constData(), &ok); - if (ok) - return QV4::Primitive::fromInt32(value).asReturnedValue(); - } - } + const bool includeEnums = w->d()->mode == Heap::QmlTypeWrapper::IncludeEnums; + if (includeEnums && name->startsWithUpper()) { + const int value = enumForSingleton(name, qobjectSingleton); + if (value != -1) + return QV4::Primitive::fromInt32(value).asReturnedValue(); } // check for property. - return QV4::QObjectWrapper::getQmlProperty(v4, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty); + bool ok; + const ReturnedValue result = QV4::QObjectWrapper::getQmlProperty(v4, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, &ok); + if (hasProperty) + *hasProperty = ok; + + // Warn when attempting to access a lowercased enum value, singleton case + if (!ok && includeEnums && !name->startsWithUpper()) { + const int value = enumForSingleton(name, qobjectSingleton); + if (value != -1) + return throwLowercaseEnumError(v4, name, type); + } + + return result; } else if (!siinfo->scriptApi(e).isUndefined()) { // NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable. QV4::ScopedObject o(scope, QJSValuePrivate::convertedToValue(v4, siinfo->scriptApi(e))); @@ -221,9 +248,20 @@ ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasPrope Q_ASSERT(!"Unreachable"); } + bool ok = false; + const ReturnedValue result = Object::get(m, name, &ok); if (hasProperty) - *hasProperty = false; - return Object::get(m, name, hasProperty); + *hasProperty = ok; + + // Warn when attempting to access a lowercased enum value, non-singleton case + if (!ok && type && !type->isSingleton() && !name->startsWithUpper()) { + bool enumOk = false; + type->enumValue(QQmlEnginePrivate::get(v4->qmlEngine()), name, &enumOk); + if (enumOk) + return throwLowercaseEnumError(v4, name, type); + } + + return result; } diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index 45b7edd316..2150f67366 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -69,7 +69,7 @@ public: void QQmlBindPrivate::validate(QObject *binding) const { - if (!obj) + if (!obj || (when.isValid() && !when)) return; if (!prop.isValid()) { @@ -179,6 +179,8 @@ void QQmlBind::setWhen(bool v) return; d->when = v; + if (v && d->componentComplete) + d->validate(this); eval(); } diff --git a/src/qml/types/qqmllistmodelworkeragent_p.h b/src/qml/types/qqmllistmodelworkeragent_p.h index be5217eaa4..9a39ecaa38 100644 --- a/src/qml/types/qqmllistmodelworkeragent_p.h +++ b/src/qml/types/qqmllistmodelworkeragent_p.h @@ -91,7 +91,8 @@ public: VariantRef &operator=(const VariantRef &o) { if (o.a) o.a->addref(); - if (a) a->release(); a = o.a; + if (a) a->release(); + a = o.a; return *this; } diff --git a/src/qml/util/qqmlpropertymap.h b/src/qml/util/qqmlpropertymap.h index 685f771452..028a299eec 100644 --- a/src/qml/util/qqmlpropertymap.h +++ b/src/qml/util/qqmlpropertymap.h @@ -49,7 +49,7 @@ class Q_QML_EXPORT QQmlPropertyMap : public QObject { Q_OBJECT public: - explicit QQmlPropertyMap(QObject *parent = 0); + explicit QQmlPropertyMap(QObject *parent = Q_NULLPTR); virtual ~QQmlPropertyMap(); QVariant value(const QString &key) const; diff --git a/src/qmldevtools/qmldevtools.pro b/src/qmldevtools/qmldevtools.pro index 85f21ce6f6..3f199e5971 100644 --- a/src/qmldevtools/qmldevtools.pro +++ b/src/qmldevtools/qmldevtools.pro @@ -13,10 +13,10 @@ intel_icc: WERROR += -ww2415 clang:if(greaterThan(QT_CLANG_MAJOR_VERSION, 3)|greaterThan(QT_CLANG_MINOR_VERSION, 3)): \ WERROR += -Wno-error=unused-const-variable -load(qt_module) - include(../3rdparty/masm/masm-defs.pri) include(../qml/parser/parser.pri) include(../qml/jsruntime/jsruntime.pri) include(../qml/compiler/compiler.pri) include(../qml/memory/memory.pri) + +load(qt_module) diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro index 289a0584e0..42224e9751 100644 --- a/src/qmltest/qmltest.pro +++ b/src/qmltest/qmltest.pro @@ -13,8 +13,6 @@ qtHaveModule(widgets) { DEFINES += QT_QMLTEST_WITH_WIDGETS } -load(qt_module) - # Install qmltestcase.prf into the Qt mkspecs so that "CONFIG += qmltestcase" # can be used in customer applications to build against QtQuickTest. feature.path = $$[QT_INSTALL_DATA]/mkspecs/features @@ -33,3 +31,5 @@ HEADERS += \ $$PWD/qtestoptions_p.h DEFINES += QT_QML_DEBUG_NO_WARNING + +load(qt_module) diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index c90308cf1a..3dbea37d27 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -290,7 +290,7 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD const QFileInfo testPathInfo(testPath); if (testPathInfo.isFile()) { - if (!testPath.endsWith(QStringLiteral(".qml"))) { + if (!testPath.endsWith(QLatin1String(".qml"))) { qWarning("'%s' does not have the suffix '.qml'.", qPrintable(testPath)); return 1; } diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf index 044c1696ff..63ada10fce 100644 --- a/src/quick/doc/qtquick.qdocconf +++ b/src/quick/doc/qtquick.qdocconf @@ -65,6 +65,7 @@ sourcedirs += ../../plugins excludedirs += ../../imports/models \ ../../imports/statemachine +excludefiles += ../util/qquickpropertychanges_p.h examples.fileextensions += "*.qm" manifestmeta.thumbnail.names += "QtQuick/Threaded ListModel Example" \ diff --git a/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc b/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc index dffcabbd5b..cb281a2d4a 100644 --- a/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc +++ b/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc @@ -102,7 +102,7 @@ has changed. If the QList changes, it is necessary to reset the model by calling QQmlContext::setContextProperty() again. -\section2 QAbstractItemModel +\section2 QAbstractItemModel subclass A model can be defined by subclassing QAbstractItemModel. This is the best approach if you have a more complex model that cannot be supported diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp index 73b0b55a29..5ac971dc7d 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture.cpp +++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp @@ -599,6 +599,11 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() void QQuickContext2DFBOTexture::endPainting() { QQuickContext2DTexture::endPainting(); + + // There may not be an FBO due to zero width or height. + if (!m_fbo) + return; + if (m_multisampledFbo) QOpenGLFramebufferObject::blitFramebuffer(m_fbo, m_multisampledFbo); diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index e37ed6c18c..d7f3f4f83b 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -310,8 +310,6 @@ struct AnimatedSpriteVertices { //TODO: Implicitly size element to size of sprite QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) : QQuickItem(parent) - , m_node(0) - , m_material(0) , m_sprite(new QQuickSprite(this)) , m_spriteEngine(0) , m_curFrame(0) @@ -325,9 +323,9 @@ QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) : { setFlag(ItemHasContents); connect(this, SIGNAL(widthChanged()), - this, SLOT(sizeVertices())); + this, SLOT(reset())); connect(this, SIGNAL(heightChanged()), - this, SLOT(sizeVertices())); + this, SLOT(reset())); } bool QQuickAnimatedSprite::isCurrentFrameChangedConnected() @@ -455,12 +453,9 @@ static QSGGeometry::AttributeSet AnimatedSprite_AttributeSet = AnimatedSprite_Attributes }; -void QQuickAnimatedSprite::sizeVertices() +void QQuickAnimatedSprite::sizeVertices(QSGGeometryNode *node) { - if (!m_node) - return; - - AnimatedSpriteVertices *p = (AnimatedSpriteVertices *) m_node->geometry()->vertexData(); + AnimatedSpriteVertices *p = (AnimatedSpriteVertices *) node->geometry()->vertexData(); p->v1.x = 0; p->v1.y = 0; @@ -488,21 +483,21 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode() return 0; } - m_material = new QQuickAnimatedSpriteMaterial(); + QQuickAnimatedSpriteMaterial *material = new QQuickAnimatedSpriteMaterial(); QImage image = m_spriteEngine->assembledImage(); //Engine prints errors if there are any if (image.isNull()) return 0; m_sheetSize = QSizeF(image.size()); - m_material->texture = window()->createTextureFromImage(image); + material->texture = window()->createTextureFromImage(image); m_spriteEngine->start(0); - m_material->animT = 0; - m_material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width(); - m_material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height(); - m_material->animX2 = m_material->animX1; - m_material->animY2 = m_material->animY1; - m_material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width(); - m_material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height(); + material->animT = 0; + material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width(); + material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height(); + material->animX2 = material->animX1; + material->animY2 = material->animY1; + material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width(); + material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height(); int vCount = 4; int iCount = 6; @@ -511,7 +506,7 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode() AnimatedSpriteVertices *p = (AnimatedSpriteVertices *) g->vertexData(); - QRectF texRect = m_material->texture->normalizedTextureSubRect(); + QRectF texRect = material->texture->normalizedTextureSubRect(); p->v1.tx = texRect.topLeft().x(); p->v1.ty = texRect.topLeft().y(); @@ -534,50 +529,51 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode() indices[5] = 2; - m_node = new QSGGeometryNode(); - m_node->setGeometry(g); - m_node->setMaterial(m_material); - m_node->setFlag(QSGGeometryNode::OwnsMaterial); - sizeVertices(); - return m_node; + QSGGeometryNode *node = new QSGGeometryNode(); + node->setGeometry(g); + node->setMaterial(material); + node->setFlag(QSGGeometryNode::OwnsMaterial); + node->setFlag(QSGGeometryNode::OwnsGeometry); + sizeVertices(node); + return node; } void QQuickAnimatedSprite::reset() { m_pleaseReset = true; + update(); } -QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *, UpdatePaintNodeData *) +QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { if (m_pleaseReset) { - delete m_node; + delete oldNode; - m_node = 0; - m_material = 0; + oldNode = 0; m_pleaseReset = false; } - prepareNextFrame(); + QSGGeometryNode *node = static_cast<QSGGeometryNode *>(oldNode); + if (!node) + node = buildNode(); + + if (node) + prepareNextFrame(node); if (m_running) { if (!m_paused) update(); - if (m_node) { - m_node->markDirty(QSGNode::DirtyMaterial); + if (node) { + node->markDirty(QSGNode::DirtyMaterial); } } - return m_node; + return node; } -void QQuickAnimatedSprite::prepareNextFrame() +void QQuickAnimatedSprite::prepareNextFrame(QSGGeometryNode *node) { - if (m_node == 0) - m_node = buildNode(); - if (m_node == 0) //error creating node - return; - int timeInt = m_timestamp.elapsed() + m_pauseOffset; qreal time = timeInt / 1000.; @@ -693,14 +689,15 @@ void QQuickAnimatedSprite::prepareNextFrame() } } - m_material->animX1 = x1; - m_material->animY1 = y1; - m_material->animX2 = x2; - m_material->animY2 = y2; - m_material->animW = w; - m_material->animH = h; - m_material->animT = m_interpolate ? progress : 0.0; - m_material->texture->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest); + QQuickAnimatedSpriteMaterial *material = static_cast<QQuickAnimatedSpriteMaterial *>(node->material()); + material->animX1 = x1; + material->animY1 = y1; + material->animX2 = x2; + material->animY2 = y2; + material->animW = w; + material->animH = h; + material->animT = m_interpolate ? progress : 0.0; + material->texture->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest); } QT_END_NAMESPACE diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h index ffaddefb47..5b181640f9 100644 --- a/src/quick/items/qquickanimatedsprite_p.h +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -351,19 +351,19 @@ public Q_SLOTS: private Q_SLOTS: void createEngine(); - void sizeVertices(); + void sizeVertices(QSGGeometryNode *node); -protected: +protected Q_SLOTS: void reset(); + +protected: void componentComplete() Q_DECL_OVERRIDE; QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; private: bool isCurrentFrameChangedConnected(); - void prepareNextFrame(); + void prepareNextFrame(QSGGeometryNode *node); void reloadImage(); QSGGeometryNode* buildNode(); - QSGGeometryNode *m_node; - QQuickAnimatedSpriteMaterial *m_material; QQuickSprite* m_sprite; QQuickSpriteEngine* m_spriteEngine; QElapsedTimer m_timestamp; diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 43405db40d..26c4e66dd4 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -59,6 +59,8 @@ static const int FlickThreshold = 15; // will ensure the Flickable retains the grab on consecutive flicks. static const int RetainGrabVelocity = 100; +static const int MovementEndingTimerInterval = 100; + static qreal EaseOvershoot(qreal t) { return qAtan(t); } @@ -238,6 +240,8 @@ void QQuickFlickablePrivate::init() contentItem->setParentItem(q); qmlobject_connect(&timeline, QQuickTimeLine, SIGNAL(completed()), q, QQuickFlickable, SLOT(timelineCompleted())) + qmlobject_connect(&velocityTimeline, QQuickTimeLine, SIGNAL(completed()), + q, QQuickFlickable, SLOT(velocityTimelineCompleted())) q->setAcceptedMouseButtons(Qt::LeftButton); q->setFiltersChildMouseEvents(true); QQuickItemPrivate *viewportPrivate = QQuickItemPrivate::get(contentItem); @@ -1196,6 +1200,8 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp hData.velocity = 0; } + if (momentum && !hData.flicking && !vData.flicking) + flickingStarted(hData.velocity != 0, vData.velocity != 0); draggingStarting(); if ((hMoved && !prevHMoved) || (vMoved && !prevVMoved)) @@ -1384,10 +1390,17 @@ void QQuickFlickable::wheelEvent(QWheelEvent *event) d->timer.start(); d->maybeBeginDrag(currentTimestamp, event->posF()); break; + case Qt::NoScrollPhase: // default phase with an ordinary wheel mouse case Qt::ScrollUpdate: + if (d->scrollingPhase) { + d->pressed = true; + d->movementEndingTimer.start(MovementEndingTimerInterval, this); + } break; case Qt::ScrollEnd: + d->pressed = false; d->scrollingPhase = false; + d->movementEndingTimer.start(MovementEndingTimerInterval, this); d->draggingEnding(); event->accept(); returnToBounds(); @@ -1409,7 +1422,6 @@ void QQuickFlickable::wheelEvent(QWheelEvent *event) valid = true; } if (valid) { - d->vData.flicking = false; d->flickY(d->vData.velocity); d->flickingStarted(false, true); if (d->vData.flicking) { @@ -1429,7 +1441,6 @@ void QQuickFlickable::wheelEvent(QWheelEvent *event) valid = true; } if (valid) { - d->hData.flicking = false; d->flickX(d->hData.velocity); d->flickingStarted(true, false); if (d->hData.flicking) { @@ -1542,6 +1553,12 @@ void QQuickFlickable::timerEvent(QTimerEvent *event) if (d->delayedPressEvent) { d->replayDelayedPress(); } + } else if (event->timerId() == d->movementEndingTimer.timerId()) { + d->movementEndingTimer.stop(); + d->pressed = false; + d->stealMouse = false; + if (!d->velocityTimeline.isActive()) + movementEnding(true, true); } } @@ -2469,6 +2486,22 @@ bool QQuickFlickable::isMovingVertically() const return d->vData.moving; } +void QQuickFlickable::velocityTimelineCompleted() +{ + Q_D(QQuickFlickable); + if ( (d->hData.transitionToBounds && d->hData.transitionToBounds->isActive()) + || (d->vData.transitionToBounds && d->vData.transitionToBounds->isActive()) ) { + return; + } + // With subclasses such as GridView, velocityTimeline.completed is emitted repeatedly: + // for example setting currentIndex results in a visual "flick" which the user + // didn't initiate directly. We don't want to end movement repeatedly, and in + // that case movementEnding will happen after the sequence of movements ends. + if (d->vData.flicking) + movementEnding(); + d->updateBeginningEnd(); +} + void QQuickFlickable::timelineCompleted() { Q_D(QQuickFlickable); diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h index ac072f0e50..f1299ee4f2 100644 --- a/src/quick/items/qquickflickable_p.h +++ b/src/quick/items/qquickflickable_p.h @@ -253,6 +253,7 @@ protected Q_SLOTS: void movementStarting(); void movementEnding(); void movementEnding(bool hMovementEnding, bool vMovementEnding); + void velocityTimelineCompleted(); void timelineCompleted(); protected: diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h index 9d75533c8a..ea46720cb6 100644 --- a/src/quick/items/qquickflickable_p_p.h +++ b/src/quick/items/qquickflickable_p_p.h @@ -212,6 +212,7 @@ public: bool calcVelocity : 1; bool pixelAligned : 1; QElapsedTimer timer; + QBasicTimer movementEndingTimer; qint64 lastPosTime; qint64 lastPressTime; QPointF lastPos; diff --git a/src/quick/items/qquickframebufferobject.h b/src/quick/items/qquickframebufferobject.h index 7fb7262222..ec40e7e97e 100644 --- a/src/quick/items/qquickframebufferobject.h +++ b/src/quick/items/qquickframebufferobject.h @@ -69,7 +69,7 @@ public: void *data; }; - QQuickFramebufferObject(QQuickItem *parent = 0); + QQuickFramebufferObject(QQuickItem *parent = Q_NULLPTR); bool textureFollowsItemSize() const; void setTextureFollowsItemSize(bool follows); diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index 65d7362e84..8d84144519 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -176,6 +176,8 @@ public: bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) Q_DECL_OVERRIDE; bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) Q_DECL_OVERRIDE; + void removeItem(FxViewItem *item); + FxViewItem *newViewItem(int index, QQuickItem *item) Q_DECL_OVERRIDE; void initializeViewItem(FxViewItem *item) Q_DECL_OVERRIDE; void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) Q_DECL_OVERRIDE; @@ -561,6 +563,17 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal return changed; } +void QQuickGridViewPrivate::removeItem(FxViewItem *item) +{ + if (item->transitionScheduledOrRunning()) { + qCDebug(lcItemViewDelegateLifecycle) << "\tnot releasing animating item:" << item->index << item->item->objectName(); + item->releaseAfterTransition = true; + releasePendingTransition.append(item); + } else { + releaseItem(item); + } +} + bool QQuickGridViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) { FxGridItemSG *item = 0; @@ -575,13 +588,7 @@ bool QQuickGridViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal buffer if (item->index != -1) visibleIndex++; visibleItems.removeFirst(); - if (item->transitionScheduledOrRunning()) { - qCDebug(lcItemViewDelegateLifecycle) << "\tnot releasing animating item:" << item->index << item->item->objectName(); - item->releaseAfterTransition = true; - releasePendingTransition.append(item); - } else { - releaseItem(item); - } + removeItem(item); changed = true; } while (visibleItems.count() > 1 @@ -591,13 +598,7 @@ bool QQuickGridViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal buffer break; qCDebug(lcItemViewDelegateLifecycle) << "refill: remove last" << visibleIndex+visibleItems.count()-1; visibleItems.removeLast(); - if (item->transitionScheduledOrRunning()) { - qCDebug(lcItemViewDelegateLifecycle) << "\tnot releasing animating item:" << item->index << item->item->objectName(); - item->releaseAfterTransition = true; - releasePendingTransition.append(item); - } else { - releaseItem(item); - } + removeItem(item); changed = true; } @@ -2380,11 +2381,12 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch int i = count - 1; int from = tempPos - buffer - displayMarginBeginning; - while (i >= 0) { - if (rowPos > from && insertionIdx < visibleIndex) { - // item won't be visible, just note the size for repositioning - insertResult->countChangeBeforeVisible++; - } else { + if (rowPos > from && insertionIdx < visibleIndex) { + // items won't be visible, just note the size for repositioning + insertResult->countChangeBeforeVisible += count; + insertResult->sizeChangesBeforeVisiblePos += ((count + columns - 1) / columns) * rowSize(); + } else { + while (i >= 0) { // item is before first visible e.g. in cache buffer FxViewItem *item = 0; if (change.isMove() && (item = currentChanges.removedItems.take(change.moveKey(modelIndex + i)))) @@ -2400,19 +2402,40 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch insertResult->changedFirstItem = true; if (!change.isMove()) { addedItems->append(item); - item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + if (transitioner) + item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + else + item->moveTo(QPointF(colPos, rowPos), true); } insertResult->sizeChangesBeforeVisiblePos += rowSize(); + + if (--colNum < 0 ) { + colNum = columns - 1; + rowPos -= rowSize(); + } + colPos = colNum * colSize(); + index++; + i--; } + } - if (--colNum < 0 ) { - colNum = columns - 1; - rowPos -= rowSize(); + // There may be gaps in the index sequence of visibleItems because + // of the index shift/update done before the insertion just above. + // Find if there is any... + int firstOkIdx = -1; + for (int i = 0; i <= insertionIdx && i < visibleItems.count() - 1; i++) { + if (visibleItems.at(i)->index + 1 != visibleItems.at(i + 1)->index) { + firstOkIdx = i + 1; + break; } - colPos = colNum * colSize(); - index++; - i--; } + // ... and remove all the items before that one + for (int i = 0; i < firstOkIdx; i++) { + FxViewItem *nvItem = visibleItems.takeFirst(); + addedItems->removeOne(nvItem); + removeItem(nvItem); + } + } else { int i = 0; int to = buffer+displayMarginEnd+tempPos+size()-1; @@ -2437,7 +2460,10 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch movingIntoView->append(MovedItem(item, change.moveKey(item->index))); } else { addedItems->append(item); - item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + if (transitioner) + item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + else + item->moveTo(QPointF(colPos, rowPos), true); } insertResult->sizeChangesAfterVisiblePos += rowSize(); diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 2dc7a29a30..24e52ff65e 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -7226,7 +7226,7 @@ void QQuickItem::setKeepTouchGrab(bool keep) } /*! - \qmlmethod object QtQuick::Item::contains(point point) + \qmlmethod bool QtQuick::Item::contains(point point) Returns true if this item contains \a point, which is in local coordinates; returns false otherwise. diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h index bda6dd4da5..bf208e1f3e 100644 --- a/src/quick/items/qquickitem.h +++ b/src/quick/items/qquickitem.h @@ -53,7 +53,7 @@ class Q_QUICK_EXPORT QQuickTransform : public QObject { Q_OBJECT public: - QQuickTransform(QObject *parent = 0); + explicit QQuickTransform(QObject *parent = Q_NULLPTR); ~QQuickTransform(); void appendToItem(QQuickItem *); @@ -189,7 +189,7 @@ public: }; Q_ENUM(TransformOrigin) - QQuickItem(QQuickItem *parent = 0); + explicit QQuickItem(QQuickItem *parent = Q_NULLPTR); virtual ~QQuickItem(); QQuickWindow *window() const; @@ -430,7 +430,7 @@ protected: virtual void updatePolish(); protected: - QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent = 0); + QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent = Q_NULLPTR); private: Q_PRIVATE_SLOT(d_func(), void _q_resourceObjectDeleted(QObject *)) diff --git a/src/quick/items/qquickitemgrabresult.h b/src/quick/items/qquickitemgrabresult.h index 055cd09095..027ed19d9e 100644 --- a/src/quick/items/qquickitemgrabresult.h +++ b/src/quick/items/qquickitemgrabresult.h @@ -73,7 +73,7 @@ private Q_SLOTS: private: friend class QQuickItem; - QQuickItemGrabResult(QObject *parent = 0); + QQuickItemGrabResult(QObject *parent = Q_NULLPTR); }; QT_END_NAMESPACE diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index e301e8f0f2..fbaec28c7c 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -2452,8 +2452,10 @@ void QQuickItemViewPrivate::updateUnrequestedIndexes() void QQuickItemViewPrivate::updateUnrequestedPositions() { - for (QHash<QQuickItem*,int>::const_iterator it = unrequestedItems.cbegin(), cend = unrequestedItems.cend(); it != cend; ++it) - repositionPackageItemAt(it.key(), it.value()); + for (QHash<QQuickItem*,int>::const_iterator it = unrequestedItems.cbegin(), cend = unrequestedItems.cend(); it != cend; ++it) { + if (it.value() >= 0) + repositionPackageItemAt(it.key(), it.value()); + } } void QQuickItemViewPrivate::updateVisibleIndex() diff --git a/src/quick/items/qquickpainteditem.h b/src/quick/items/qquickpainteditem.h index 8c9ae2eebb..bb4e7f1f85 100644 --- a/src/quick/items/qquickpainteditem.h +++ b/src/quick/items/qquickpainteditem.h @@ -51,7 +51,7 @@ class Q_QUICK_EXPORT QQuickPaintedItem : public QQuickItem Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged) public: - QQuickPaintedItem(QQuickItem *parent = 0); + explicit QQuickPaintedItem(QQuickItem *parent = Q_NULLPTR); virtual ~QQuickPaintedItem(); enum RenderTarget { @@ -112,7 +112,7 @@ Q_SIGNALS: void textureSizeChanged(); protected: - QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent = 0); + QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent = Q_NULLPTR); QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; void releaseResources() Q_DECL_OVERRIDE; diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index d00b02c005..fd8d354594 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -48,6 +48,8 @@ #include <QtQuick/private/qquickwindow_p.h> #include <QtCore/private/qobject_p.h> +#include <private/qquickshadereffectnode_p.h> + QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); @@ -175,6 +177,8 @@ void QQuickRenderControlPrivate::windowDestroyed() delete QQuickWindowPrivate::get(window)->animationController; QQuickWindowPrivate::get(window)->animationController = 0; + QQuickShaderEffectMaterial::cleanupMaterialCache(); + window = 0; } } diff --git a/src/quick/items/qquickrendercontrol.h b/src/quick/items/qquickrendercontrol.h index ff80acf766..74419ecc9c 100644 --- a/src/quick/items/qquickrendercontrol.h +++ b/src/quick/items/qquickrendercontrol.h @@ -49,7 +49,7 @@ class Q_QUICK_EXPORT QQuickRenderControl : public QObject Q_OBJECT public: - QQuickRenderControl(QObject *parent = 0); + explicit QQuickRenderControl(QObject *parent = Q_NULLPTR); ~QQuickRenderControl(); void prepareThread(QThread *targetThread); @@ -62,8 +62,8 @@ public: QImage grab(); - static QWindow *renderWindowFor(QQuickWindow *win, QPoint *offset = 0); - virtual QWindow *renderWindow(QPoint *offset) { Q_UNUSED(offset); return 0; } + static QWindow *renderWindowFor(QQuickWindow *win, QPoint *offset = Q_NULLPTR); + virtual QWindow *renderWindow(QPoint *offset) { Q_UNUSED(offset); return Q_NULLPTR; } Q_SIGNALS: void renderRequested(); diff --git a/src/quick/items/qquickscalegrid_p_p.h b/src/quick/items/qquickscalegrid_p_p.h index 1d067f1a94..de8a5b66fb 100644 --- a/src/quick/items/qquickscalegrid_p_p.h +++ b/src/quick/items/qquickscalegrid_p_p.h @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE -class QQuickScaleGrid : public QObject +class Q_AUTOTEST_EXPORT QQuickScaleGrid : public QObject { Q_OBJECT diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index 349207f145..6cb9216955 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -952,6 +952,12 @@ void QQuickShaderEffect::updateGeometry() update(); } +void QQuickShaderEffect::updateGeometryIfAtlased() +{ + if (m_supportsAtlasTextures) + updateGeometry(); +} + void QQuickShaderEffect::updateLogAndStatus(const QString &log, int status) { m_log = parseLog() + log; @@ -1000,6 +1006,8 @@ QSGNode *QQuickShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa m_dirtyUniforms = true; m_dirtyGeometry = true; connect(node, SIGNAL(logAndStatusChanged(QString,int)), this, SLOT(updateLogAndStatus(QString,int))); + connect(node, &QQuickShaderEffectNode::dirtyTexture, + this, &QQuickShaderEffect::updateGeometryIfAtlased); } QQuickShaderEffectMaterial *material = static_cast<QQuickShaderEffectMaterial *>(node->material()); diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h index a5e993ee0c..4ed87e88ac 100644 --- a/src/quick/items/qquickshadereffect_p.h +++ b/src/quick/items/qquickshadereffect_p.h @@ -167,6 +167,7 @@ protected: private Q_SLOTS: void updateGeometry(); + void updateGeometryIfAtlased(); void updateLogAndStatus(const QString &log, int status); void sourceDestroyed(QObject *object); void propertyChanged(int mappedId); diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp index 081e572e3b..954aa6c67b 100644 --- a/src/quick/items/qquickshadereffectnode.cpp +++ b/src/quick/items/qquickshadereffectnode.cpp @@ -491,6 +491,7 @@ QQuickShaderEffectNode::~QQuickShaderEffectNode() void QQuickShaderEffectNode::markDirtyTexture() { markDirty(DirtyMaterial); + Q_EMIT dirtyTexture(); } void QQuickShaderEffectNode::textureProviderDestroyed(QObject *object) diff --git a/src/quick/items/qquickshadereffectnode_p.h b/src/quick/items/qquickshadereffectnode_p.h index 76aecd1b04..8a7fd6c3a5 100644 --- a/src/quick/items/qquickshadereffectnode_p.h +++ b/src/quick/items/qquickshadereffectnode_p.h @@ -142,6 +142,7 @@ public: Q_SIGNALS: void logAndStatusChanged(const QString &, int status); + void dirtyTexture(); private Q_SLOTS: void markDirtyTexture(); diff --git a/src/quick/items/qquicksprite.cpp b/src/quick/items/qquicksprite.cpp index e69e12d967..0538707a5d 100644 --- a/src/quick/items/qquicksprite.cpp +++ b/src/quick/items/qquicksprite.cpp @@ -218,6 +218,11 @@ QQuickSprite::QQuickSprite(QObject *parent) { } +/*! \internal */ +QQuickSprite::~QQuickSprite() +{ +} + int QQuickSprite::variedDuration() const //Deals with precedence when multiple durations are set { if (m_frameSync) diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h index 43c5e44be3..555ba0f8d9 100644 --- a/src/quick/items/qquicksprite_p.h +++ b/src/quick/items/qquicksprite_p.h @@ -55,7 +55,8 @@ QT_BEGIN_NAMESPACE -class QQuickSprite : public QQuickStochasticState +// exported, since it's used in QtQuickParticles +class Q_QUICK_EXPORT QQuickSprite : public QQuickStochasticState { Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) @@ -78,6 +79,7 @@ class QQuickSprite : public QQuickStochasticState public: explicit QQuickSprite(QObject *parent = 0); + ~QQuickSprite(); QUrl source() const { diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index ba7142856b..ffc94dfd46 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -1886,11 +1886,15 @@ bool QQuickTextInput::isRightToLeft(int start, int end) \qmlmethod QtQuick::TextInput::cut() Moves the currently selected text to the system clipboard. + + \note If the echo mode is set to a mode other than Normal then cut + will not work. This is to prevent using cut as a method of bypassing + password features of the line control. */ void QQuickTextInput::cut() { Q_D(QQuickTextInput); - if (!d->m_readOnly) { + if (!d->m_readOnly && d->m_echoMode == QQuickTextInput::Normal) { d->copy(); d->del(); } @@ -1900,6 +1904,10 @@ void QQuickTextInput::cut() \qmlmethod QtQuick::TextInput::copy() Copies the currently selected text to the system clipboard. + + \note If the echo mode is set to a mode other than Normal then copy + will not work. This is to prevent using copy as a method of bypassing + password features of the line control. */ void QQuickTextInput::copy() { @@ -4251,10 +4259,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event) } } else if (event == QKeySequence::Cut) { - if (!m_readOnly) { - copy(); - del(); - } + q->cut(); } else if (event == QKeySequence::DeleteEndOfLine) { if (!m_readOnly) diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index a65b98acd1..18cb1d0083 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -822,14 +822,15 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, for (int i = 0; i < node->ranges.size(); ++i) { const QPair<int, int> &range = node->ranges.at(i); - int rangeLength = range.second - range.first; + int rangeLength = range.second - range.first + 1; if (previousNode != 0) { for (int j = 0; j < previousNode->ranges.size(); ++j) { const QPair<int, int> &otherRange = previousNode->ranges.at(j); + if (range.first < otherRange.second && range.second > otherRange.first) { int start = qMax(range.first, otherRange.first); int end = qMin(range.second, otherRange.second); - rangeLength -= end - start; + rangeLength -= end - start + 1; if (rangeLength == 0) break; } @@ -843,7 +844,7 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, if (range.first < otherRange.second && range.second > otherRange.first) { int start = qMax(range.first, otherRange.first); int end = qMin(range.second, otherRange.second); - rangeLength -= end - start; + rangeLength -= end - start + 1; if (rangeLength == 0) break; } diff --git a/src/quick/items/qquickview.h b/src/quick/items/qquickview.h index 80da0ba4f1..46dfe96506 100644 --- a/src/quick/items/qquickview.h +++ b/src/quick/items/qquickview.h @@ -54,9 +54,9 @@ class Q_QUICK_EXPORT QQuickView : public QQuickWindow Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) public: - explicit QQuickView(QWindow *parent = 0); + explicit QQuickView(QWindow *parent = Q_NULLPTR); QQuickView(QQmlEngine* engine, QWindow *parent); - QQuickView(const QUrl &source, QWindow *parent = 0); + explicit QQuickView(const QUrl &source, QWindow *parent = Q_NULLPTR); virtual ~QQuickView(); QUrl source() const; diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h index 6f970f959d..71b39f5b0f 100644 --- a/src/quick/items/qquickview_p.h +++ b/src/quick/items/qquickview_p.h @@ -70,7 +70,7 @@ class QQmlError; class QQuickItem; class QQmlComponent; -class QQuickViewPrivate : public QQuickWindowPrivate, +class Q_QUICK_PRIVATE_EXPORT QQuickViewPrivate : public QQuickWindowPrivate, public QQuickItemChangeListener { Q_DECLARE_PUBLIC(QQuickView) diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index d4ffb100de..522101c7e4 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -89,7 +89,7 @@ public: }; Q_ENUM(SceneGraphError) - QQuickWindow(QWindow *parent = 0); + explicit QQuickWindow(QWindow *parent = Q_NULLPTR); explicit QQuickWindow(QQuickRenderControl *renderControl); virtual ~QQuickWindow(); @@ -123,7 +123,7 @@ public: // Scene graph specific functions QSGTexture *createTextureFromImage(const QImage &image) const; QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options) const; - QSGTexture *createTextureFromId(uint id, const QSize &size, CreateTextureOptions options = CreateTextureOption(0)) const; + QSGTexture *createTextureFromId(uint id, const QSize &size, CreateTextureOptions options = CreateTextureOption()) const; void setClearBeforeRendering(bool enabled); bool clearBeforeRendering() const; @@ -170,7 +170,7 @@ public Q_SLOTS: void releaseResources(); protected: - QQuickWindow(QQuickWindowPrivate &dd, QWindow *parent = 0); + QQuickWindow(QQuickWindowPrivate &dd, QWindow *parent = Q_NULLPTR); void exposeEvent(QExposeEvent *) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; diff --git a/src/quick/items/qquickwindowattached.cpp b/src/quick/items/qquickwindowattached.cpp index e33e32631c..b1961386bb 100644 --- a/src/quick/items/qquickwindowattached.cpp +++ b/src/quick/items/qquickwindowattached.cpp @@ -89,21 +89,21 @@ void QQuickWindowAttached::windowChanged(QQuickWindow *window) if (oldWindow) oldWindow->disconnect(this); - if (!window) - return; // No values to get, therefore nothing to emit - - if (!oldWindow || window->visibility() != oldWindow->visibility()) + if (!oldWindow || !window || window->visibility() != oldWindow->visibility()) emit visibilityChanged(); - if (!oldWindow || window->isActive() != oldWindow->isActive()) + if (!oldWindow || !window || window->isActive() != oldWindow->isActive()) emit activeChanged(); - if (!oldWindow || window->activeFocusItem() != oldWindow->activeFocusItem()) + if (!oldWindow || !window || window->activeFocusItem() != oldWindow->activeFocusItem()) emit activeFocusItemChanged(); emit contentItemChanged(); - if (!oldWindow || window->width() != oldWindow->width()) + if (!oldWindow || !window || window->width() != oldWindow->width()) emit widthChanged(); - if (!oldWindow || window->height() != oldWindow->height()) + if (!oldWindow || !window || window->height() != oldWindow->height()) emit heightChanged(); + if (!window) + return; + // QQuickWindowQmlImpl::visibilityChanged also exists, and window might even // be QQuickWindowQmlImpl, but that's not what we are connecting to. // So this is actual window state rather than a buffered or as-requested one. diff --git a/src/quick/quick.pro b/src/quick/quick.pro index c8aa47d939..1c14ff8d57 100644 --- a/src/quick/quick.pro +++ b/src/quick/quick.pro @@ -24,8 +24,6 @@ ANDROID_BUNDLED_FILES += \ qml \ lib/libQt5QuickParticles.so -load(qt_module) - include(util/util.pri) include(scenegraph/scenegraph.pri) include(items/items.pri) @@ -43,3 +41,5 @@ SOURCES += qtquick2.cpp # To make #include "qquickcontext2d_jsclass.cpp" work INCLUDEPATH += $$PWD + +load(qt_module) diff --git a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h index 2f7da6f610..8eb16ed129 100644 --- a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h +++ b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h @@ -80,7 +80,7 @@ Q_SIGNALS: void sceneGraphChanged(); protected: - QSGAbstractRenderer(QObject *parent = 0); + explicit QSGAbstractRenderer(QObject *parent = Q_NULLPTR); virtual void nodeChanged(QSGNode *node, QSGNode::DirtyState state) = 0; private: diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index b1792d27a7..dd1ff14924 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -2654,7 +2654,9 @@ void Renderer::render() if (m_alphaBatches.size()) std::sort(&m_alphaBatches.first(), &m_alphaBatches.last() + 1, qsg_sort_batch_increasing_order); - m_zRange = 1.0 / (m_nextRenderOrder); + m_zRange = m_nextRenderOrder != 0 + ? 1.0 / (m_nextRenderOrder) + : 0; } if (Q_UNLIKELY(debug_render())) timeSorting = timer.restart(); diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index 4c9ae7251e..f73fcdacf2 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -145,7 +145,7 @@ public: QT_DEPRECATED void clearDirty() { } void markDirty(DirtyState bits); - QT_DEPRECATED DirtyState dirtyState() const { return 0; } + QT_DEPRECATED DirtyState dirtyState() const { return Q_NULLPTR; } virtual bool isSubtreeBlocked() const; diff --git a/src/quick/scenegraph/util/qsgengine.h b/src/quick/scenegraph/util/qsgengine.h index 325d3a9ca2..438c6d789b 100644 --- a/src/quick/scenegraph/util/qsgengine.h +++ b/src/quick/scenegraph/util/qsgengine.h @@ -57,15 +57,15 @@ public: }; Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption) - QSGEngine(QObject *parent = 0); + explicit QSGEngine(QObject *parent = Q_NULLPTR); ~QSGEngine(); void initialize(QOpenGLContext *context); void invalidate(); QSGAbstractRenderer *createRenderer() const; - QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options = CreateTextureOption(0)) const; - QSGTexture *createTextureFromId(uint id, const QSize &size, CreateTextureOptions options = CreateTextureOption(0)) const; + QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options = CreateTextureOption()) const; + QSGTexture *createTextureFromId(uint id, const QSize &size, CreateTextureOptions options = CreateTextureOption()) const; }; QT_END_NAMESPACE diff --git a/src/quick/util/qquickanimator.cpp b/src/quick/util/qquickanimator.cpp index 8a5cad4011..ca6dc74519 100644 --- a/src/quick/util/qquickanimator.cpp +++ b/src/quick/util/qquickanimator.cpp @@ -211,7 +211,8 @@ qreal QQuickAnimator::from() const void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job, const QString &propertyName, QQuickStateActions &actions, - QQmlProperties &modified) + QQmlProperties &modified, + QObject *defaultTarget) { if (actions.size()) { @@ -243,14 +244,20 @@ void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job, // the item when a transition is cancelled. action.fromValue = action.toValue; } - } else { + } + + if (modified.isEmpty()) { job->setTarget(target); job->setFrom(from); job->setTo(to); } - if (!job->target() && defaultProperty.object()) - job->setTarget(qobject_cast<QQuickItem *>(defaultProperty.object())); + if (!job->target()) { + if (defaultProperty.object()) + job->setTarget(qobject_cast<QQuickItem *>(defaultProperty.object())); + else + job->setTarget(qobject_cast<QQuickItem *>(defaultTarget)); + } job->setDuration(duration); job->setLoopCount(loopCount); @@ -260,7 +267,7 @@ void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job, QAbstractAnimationJob *QQuickAnimator::transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, - QObject *) + QObject *defaultTarget) { Q_D(QQuickAnimator); @@ -277,7 +284,7 @@ QAbstractAnimationJob *QQuickAnimator::transition(QQuickStateActions &actions, if (!job) return 0; - d->apply(job, propertyName(), actions, modified); + d->apply(job, propertyName(), actions, modified, defaultTarget); if (!job->target()) { delete job; diff --git a/src/quick/util/qquickanimator_p_p.h b/src/quick/util/qquickanimator_p_p.h index f5f0295f74..11598bf78e 100644 --- a/src/quick/util/qquickanimator_p_p.h +++ b/src/quick/util/qquickanimator_p_p.h @@ -76,7 +76,7 @@ public: uint isFromDefined : 1; uint isToDefined : 1; - void apply(QQuickAnimatorJob *job, const QString &propertyName, QQuickStateActions &actions, QQmlProperties &modified); + void apply(QQuickAnimatorJob *job, const QString &propertyName, QQuickStateActions &actions, QQmlProperties &modified, QObject *defaultTarget); }; class QQuickRotationAnimatorPrivate : public QQuickAnimatorPrivate diff --git a/src/quick/util/qquickimageprovider.h b/src/quick/util/qquickimageprovider.h index cc03eb0fa0..9ecedf60ad 100644 --- a/src/quick/util/qquickimageprovider.h +++ b/src/quick/util/qquickimageprovider.h @@ -81,7 +81,7 @@ Q_SIGNALS: class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase { public: - QQuickImageProvider(ImageType type, Flags flags = 0); + QQuickImageProvider(ImageType type, Flags flags = Flags()); virtual ~QQuickImageProvider(); ImageType imageType() const; diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index ed6da8ac91..230c31807c 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -509,7 +509,6 @@ void QQuickPixmapReader::asyncResponseFinished(QQuickImageResponse *response) QQuickTextureFactory *t = 0; QQuickPixmapReply::ReadError error = QQuickPixmapReply::NoError; QString errorString; - QSize readSize; if (!response->errorString().isEmpty()) { error = QQuickPixmapReply::Loading; errorString = response->errorString(); @@ -1185,8 +1184,6 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q *ok = true; return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, autoTransform, appliedTransform); } - errorString = QQuickPixmap::tr("Invalid image data: %1").arg(url.toString()); - } else { errorString = QQuickPixmap::tr("Cannot open: %1").arg(url.toString()); } diff --git a/src/quickwidgets/qquickwidget.h b/src/quickwidgets/qquickwidget.h index 5bb6b49a49..53d3c16533 100644 --- a/src/quickwidgets/qquickwidget.h +++ b/src/quickwidgets/qquickwidget.h @@ -58,9 +58,9 @@ class Q_QUICKWIDGETS_EXPORT QQuickWidget : public QWidget Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) public: - explicit QQuickWidget(QWidget *parent = 0); + explicit QQuickWidget(QWidget *parent = Q_NULLPTR); QQuickWidget(QQmlEngine* engine, QWidget *parent); - QQuickWidget(const QUrl &source, QWidget *parent = 0); + explicit QQuickWidget(const QUrl &source, QWidget *parent = Q_NULLPTR); virtual ~QQuickWidget(); QUrl source() const; diff --git a/src/quickwidgets/quickwidgets.pro b/src/quickwidgets/quickwidgets.pro index ab388ff9d3..87409e31c5 100644 --- a/src/quickwidgets/quickwidgets.pro +++ b/src/quickwidgets/quickwidgets.pro @@ -4,9 +4,6 @@ QT = core-private gui-private qml-private quick-private widgets-private DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES - -load(qt_module) - HEADERS += \ qquickwidget.h \ qquickwidget_p.h \ @@ -15,5 +12,4 @@ HEADERS += \ SOURCES += \ qquickwidget.cpp - - +load(qt_module) diff --git a/tests/auto/qml/qqmlbinding/data/disabledReadonly.qml b/tests/auto/qml/qqmlbinding/data/disabledReadonly.qml new file mode 100644 index 0000000000..2d1715364c --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/disabledReadonly.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + id: root + + readonly property string name: "John" + + Binding { + target: root + property: "name" + value: "Doe" + when: false + } +} diff --git a/tests/auto/qml/qqmlbinding/data/disabledUnknown.qml b/tests/auto/qml/qqmlbinding/data/disabledUnknown.qml new file mode 100644 index 0000000000..08e1cff5d1 --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/disabledUnknown.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + id: root + + Binding { + target: root + property: "unknown" + value: 42 + when: false + } +} diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp index 3e49f3b3c4..9747fed420 100644 --- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp +++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp @@ -52,6 +52,8 @@ private slots: void deletedObject(); void warningOnUnknownProperty(); void warningOnReadOnlyProperty(); + void disabledOnUnknownProperty(); + void disabledOnReadonlyProperty(); private: QQmlEngine engine; @@ -258,6 +260,32 @@ void tst_qqmlbinding::warningOnReadOnlyProperty() QCOMPARE(messageHandler.messages().first(), expectedMessage); } +void tst_qqmlbinding::disabledOnUnknownProperty() +{ + QQmlTestMessageHandler messageHandler; + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("disabledUnknown.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + delete item; + + QCOMPARE(messageHandler.messages().count(), 0); +} + +void tst_qqmlbinding::disabledOnReadonlyProperty() +{ + QQmlTestMessageHandler messageHandler; + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("disabledReadonly.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + delete item; + + QCOMPARE(messageHandler.messages().count(), 0); +} + QTEST_MAIN(tst_qqmlbinding) #include "tst_qqmlbinding.moc" diff --git a/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.1.errors.txt b/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.1.errors.txt new file mode 100644 index 0000000000..33360e96cf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.1.errors.txt @@ -0,0 +1 @@ +5:5:Invalid property assignment: Enum value "lowercaseEnumVal" cannot start with a lowercase letter diff --git a/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.1.qml b/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.1.qml new file mode 100644 index 0000000000..f6c3e9b404 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.1.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Test 1.0 + +MyTypeObject { + intProperty: MyTypeObject.lowercaseEnumVal +} diff --git a/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.2.errors.txt b/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.2.errors.txt new file mode 100644 index 0000000000..33360e96cf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.2.errors.txt @@ -0,0 +1 @@ +5:5:Invalid property assignment: Enum value "lowercaseEnumVal" cannot start with a lowercase letter diff --git a/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.2.qml b/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.2.qml new file mode 100644 index 0000000000..0dfe26c71d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lowercaseEnumCompileTime.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Test 1.0 + +MyTypeObject { + enumProperty: MyTypeObjectSingleton.lowercaseEnumVal +} diff --git a/tests/auto/qml/qqmllanguage/data/lowercaseEnumRuntime.1.qml b/tests/auto/qml/qqmllanguage/data/lowercaseEnumRuntime.1.qml new file mode 100644 index 0000000000..866b49e1d5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lowercaseEnumRuntime.1.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import Test 1.0 + +MyTypeObject { + enumProperty: MyTypeObject.EnumVal1 + Component.onCompleted: { + var a = MyTypeObject.EnumVal1; + var b = MyTypeObject.lowercaseEnumVal + } +} diff --git a/tests/auto/qml/qqmllanguage/data/lowercaseEnumRuntime.2.qml b/tests/auto/qml/qqmllanguage/data/lowercaseEnumRuntime.2.qml new file mode 100644 index 0000000000..686977a11a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lowercaseEnumRuntime.2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import Test 1.0 + +MyTypeObject { + intProperty: MyTypeObjectSingleton.EnumVal1 + Component.onCompleted: { + var a = MyTypeObjectSingleton.EnumVal1; + var b = MyTypeObjectSingleton.lowercaseEnumVal; + } +} diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index 95a98788c3..5a8190756d 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -34,6 +34,14 @@ #include <private/qqmlcompiler_p.h> +static QObject *myTypeObjectSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + + return new MyTypeObject(); +} + void registerTypes() { qmlRegisterInterface<MyInterface>("MyInterface"); @@ -93,6 +101,8 @@ void registerTypes() qmlRegisterType<RootObjectInCreationTester>("Test", 1, 0, "RootObjectInCreationTester"); qmlRegisterType<MyCompositeBaseType>("Test", 1, 0, "MyCompositeBaseType"); + + qmlRegisterSingletonType<MyTypeObjectSingleton>("Test", 1, 0, "MyTypeObjectSingleton", myTypeObjectSingleton); } QVariant myCustomVariantTypeConverter(const QString &data) diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index c64fda5ea1..c6c956cf36 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -297,7 +297,7 @@ public: emit flagPropertyChanged(); } - enum MyEnum { EnumVal1, EnumVal2 }; + enum MyEnum { EnumVal1, EnumVal2, lowercaseEnumVal }; MyEnum enumPropertyValue; MyEnum enumProperty() const { return enumPropertyValue; @@ -597,6 +597,12 @@ signals: }; Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags) +// FIXME: If no subclass is used for the singleton registration with qmlRegisterSingletonType(), +// the valueTypes() test will fail. +class MyTypeObjectSingleton : public MyTypeObject +{ + Q_OBJECT +}; class MyContainer : public QObject { diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 71f206ed8f..f66caa31f1 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -203,6 +203,10 @@ private slots: void crash2(); void globalEnums(); + void lowercaseEnumRuntime_data(); + void lowercaseEnumRuntime(); + void lowercaseEnumCompileTime_data(); + void lowercaseEnumCompileTime(); void literals_data(); void literals(); @@ -3502,6 +3506,45 @@ void tst_qqmllanguage::globalEnums() delete o; } +void tst_qqmllanguage::lowercaseEnumRuntime_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("errorMessage"); + + QTest::newRow("enum from normal type") << "lowercaseEnumRuntime.1.qml" << ":8: TypeError: Cannot access enum value 'lowercaseEnumVal' of 'MyTypeObject', enum values need to start with an uppercase letter."; + QTest::newRow("enum from singleton type") << "lowercaseEnumRuntime.2.qml" << ":8: TypeError: Cannot access enum value 'lowercaseEnumVal' of 'MyTypeObjectSingleton', enum values need to start with an uppercase letter."; +} + +void tst_qqmllanguage::lowercaseEnumRuntime() +{ + QFETCH(QString, file); + QFETCH(QString, errorMessage); + + QQmlComponent component(&engine, testFileUrl(file)); + VERIFY_ERRORS(0); + QString warning = component.url().toString() + errorMessage; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + delete component.create(); +} + +void tst_qqmllanguage::lowercaseEnumCompileTime_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("errorFile"); + + QTest::newRow("assignment to int property") << "lowercaseEnumCompileTime.1.qml" << "lowercaseEnumCompileTime.1.errors.txt"; + QTest::newRow("assignment to enum property") << "lowercaseEnumCompileTime.2.qml" << "lowercaseEnumCompileTime.2.errors.txt"; +} + +void tst_qqmllanguage::lowercaseEnumCompileTime() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + + QQmlComponent component(&engine, testFileUrl(file)); + VERIFY_ERRORS(qPrintable(errorFile)); +} + void tst_qqmllanguage::literals_data() { QTest::addColumn<QString>("property"); diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp index c9e1a43414..3cb7ff511f 100644 --- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp +++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -35,6 +35,7 @@ #include <QtQuick/qquickview.h> #include <private/qabstractanimation_p.h> #include <private/qquickanimatedsprite_p.h> +#include <private/qquickitem_p.h> #include <QtGui/qpainter.h> #include <QtGui/qopenglcontext.h> #include <QtGui/qopenglfunctions.h> @@ -53,6 +54,7 @@ private slots: void test_frameChangedSignal(); void test_largeAnimation_data(); void test_largeAnimation(); + void test_reparenting(); }; void tst_qquickanimatedsprite::initTestCase() @@ -268,6 +270,26 @@ void tst_qquickanimatedsprite::test_largeAnimation() delete window; } +void tst_qquickanimatedsprite::test_reparenting() +{ + QQuickView window; + window.setSource(testFileUrl("basic.qml")); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QVERIFY(window.rootObject()); + QQuickAnimatedSprite* sprite = window.rootObject()->findChild<QQuickAnimatedSprite*>("sprite"); + QVERIFY(sprite); + + QTRY_VERIFY(sprite->running()); + sprite->setParentItem(0); + + sprite->setParentItem(window.rootObject()); + // don't crash (QTBUG-51162) + sprite->polish(); + QTRY_COMPARE(QQuickItemPrivate::get(sprite)->polishScheduled, true); + QTRY_COMPARE(QQuickItemPrivate::get(sprite)->polishScheduled, false); +} QTEST_MAIN(tst_qquickanimatedsprite) diff --git a/tests/auto/quick/qquickanimators/data/positionerWithAnimator.qml b/tests/auto/quick/qquickanimators/data/positionerWithAnimator.qml new file mode 100644 index 0000000000..bfd475266e --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/positionerWithAnimator.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 + +Column { + width: 200 + height: 200 + + property alias repeater: repeater + property alias transition: transition + + anchors.centerIn: parent + populate: Transition { + id: transition + ScaleAnimator { + from: 0 + to: 1 + } + } + + Repeater { + id: repeater + model: ["red", "green", "blue"] + + Rectangle { + width: 100 + height: 100 + color: modelData + scale: 0 + } + } +} diff --git a/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp b/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp index 4108c1a124..7cacf3ba90 100644 --- a/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp +++ b/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp @@ -35,6 +35,8 @@ #include <QtQuick> #include <private/qquickanimator_p.h> +#include <private/qquickrepeater_p.h> +#include <private/qquicktransition_p.h> #include <QtQml> @@ -45,6 +47,7 @@ class tst_Animators: public QObject private slots: void testMultiWinAnimator_data(); void testMultiWinAnimator(); + void testTransitions(); }; void tst_Animators::testMultiWinAnimator_data() @@ -99,6 +102,28 @@ void tst_Animators::testMultiWinAnimator() QVERIFY(true); } +void tst_Animators::testTransitions() +{ + QQuickView view(QUrl::fromLocalFile("data/positionerWithAnimator.qml")); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(view.rootObject()); + + QQuickRepeater *repeater = view.rootObject()->property("repeater").value<QQuickRepeater *>(); + QVERIFY(repeater); + + QQuickItem *child = repeater->itemAt(0); + QVERIFY(child); + QCOMPARE(child->scale(), qreal(0.0)); + + QQuickTransition *transition = view.rootObject()->property("transition").value<QQuickTransition *>(); + QVERIFY(transition); + + QTRY_VERIFY(transition->running()); + QTRY_VERIFY(!transition->running()); + QCOMPARE(child->scale(), qreal(1.0)); +} + #include "tst_qquickanimators.moc" QTEST_MAIN(tst_Animators) diff --git a/tests/auto/quick/qquickgridview/data/qtbug48870.qml b/tests/auto/quick/qquickgridview/data/qtbug48870.qml new file mode 100644 index 0000000000..7c0783fbb5 --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/qtbug48870.qml @@ -0,0 +1,30 @@ +import QtQuick 2.6 + +Rectangle { + width: 500 + height: 500 + color: "blue" + + GridView { + id: view + objectName: "view" + anchors.fill: parent + model: testModel + cellWidth: 150 + cellHeight: 150 + readonly property int columns: Math.floor(width / cellWidth) + + delegate: Rectangle { + width: GridView.view.cellWidth + height: GridView.view.cellHeight + color: (row & 1) != (col & 1) ? "green" : "red" + readonly property int row: index / view.columns + readonly property int col: index % view.columns + + Text { + anchors.centerIn: parent + text: "Item " + index + } + } + } +} diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 3699bef56d..4edfb0ed3b 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -41,6 +41,7 @@ #include <QtQml/qqmlincubator.h> #include <QtQml/qqmlcontext.h> #include <QtQuick/private/qquickitem_p.h> +#include <QtQuick/private/qquickitemview_p_p.h> #include <QtQuick/private/qquickgridview_p.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQml/private/qqmllistmodel_p.h> @@ -210,6 +211,7 @@ private slots: void contentHeightWithDelayRemove(); void QTBUG_45640(); + void QTBUG_48870_fastModelUpdates(); private: QList<int> toIntList(const QVariantList &list); @@ -6566,6 +6568,42 @@ void tst_QQuickGridView::QTBUG_45640() delete window; } +void tst_QQuickGridView::QTBUG_48870_fastModelUpdates() +{ + StressTestModel model; + + QScopedPointer<QQuickView> window(createView()); + QQmlContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); + + window->setSource(testFileUrl("qtbug48870.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickGridView *view = findItem<QQuickGridView>(window->rootObject(), "view"); + QTRY_VERIFY(view != 0); + + QQuickItemViewPrivate *priv = QQuickItemViewPrivate::get(view); + bool nonUnique; + FxViewItem *item = Q_NULLPTR; + int expectedIdx; + QVERIFY(testVisibleItems(priv, &nonUnique, &item, &expectedIdx)); + + for (int i = 0; i < 10; i++) { + QTest::qWait(100); + QVERIFY2(testVisibleItems(priv, &nonUnique, &item, &expectedIdx), + qPrintable(!item ? QString("Unexpected null item") + : nonUnique ? QString("Non-unique item at %1 and %2").arg(item->index).arg(expectedIdx) + : QString("Found index %1, expected index is %3").arg(item->index).arg(expectedIdx))); + if (i % 3 != 0) { + if (i & 1) + flick(window.data(), QPoint(100, 200), QPoint(100, 0), 100); + else + flick(window.data(), QPoint(100, 200), QPoint(100, 400), 100); + } + } +} + QTEST_MAIN(tst_QQuickGridView) #include "tst_qquickgridview.moc" diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 0153d40b50..19f4010f8c 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -8202,99 +8202,9 @@ void tst_QQuickListView::QTBUG_48044_currentItemNotVisibleAfterTransition() QVERIFY(!currentPriv->culled); } -static bool testVisibleItems(const QQuickItemViewPrivate *priv, bool *nonUnique, FxViewItem **failItem, int *expectedIdx) -{ - QHash<QQuickItem*, int> uniqueItems; - - int skip = 0; - for (int i = 0; i < priv->visibleItems.count(); ++i) { - FxViewItem *item = priv->visibleItems.at(i); - if (!item) { - *failItem = Q_NULLPTR; - return false; - } -#if 0 - qDebug() << "\t" << item->index - << item->item - << item->position() - << (!item->item || QQuickItemPrivate::get(item->item)->culled ? "hidden" : "visible"); -#endif - if (item->index == -1) { - ++skip; - } else if (item->index != priv->visibleIndex + i - skip) { - *nonUnique = false; - *failItem = item; - *expectedIdx = priv->visibleIndex + i - skip; - return false; - } else if (uniqueItems.contains(item->item)) { - *nonUnique = true; - *failItem = item; - *expectedIdx = uniqueItems.find(item->item).value(); - return false; - } - - uniqueItems.insert(item->item, item->index); - } - - return true; -} - -class QTBUG_48870_Model : public QAbstractListModel -{ - Q_OBJECT - -public: - - QTBUG_48870_Model() - : QAbstractListModel() - , m_rowCount(20) - { - QTimer *t = new QTimer(this); - t->setInterval(500); - t->start(); - - qsrand(qHash(QDateTime::currentDateTime())); - connect(t, &QTimer::timeout, this, &QTBUG_48870_Model::updateModel); - } - - int rowCount(const QModelIndex &) const - { - return m_rowCount; - } - - QVariant data(const QModelIndex &, int) const - { - return QVariant(); - } - -public Q_SLOTS: - void updateModel() - { - if (m_rowCount > 10) { - for (int i = 0; i < 10; ++i) { - int rnum = qrand() % m_rowCount; - beginRemoveRows(QModelIndex(), rnum, rnum); - m_rowCount--; - endRemoveRows(); - } - } - if (m_rowCount < 20) { - for (int i = 0; i < 10; ++i) { - int rnum = qrand() % m_rowCount; - beginInsertRows(QModelIndex(), rnum, rnum); - m_rowCount++; - endInsertRows(); - } - } - } - -private: - int m_rowCount; -}; - void tst_QQuickListView::QTBUG_48870_fastModelUpdates() { - QTBUG_48870_Model model; + StressTestModel model; QScopedPointer<QQuickView> window(createView()); QQmlContext *ctxt = window->rootContext(); diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index f53ade9541..c597cf03dd 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -2050,6 +2050,11 @@ void tst_qquickwindow::attachedProperty() QCOMPARE(text->property("contentItem").value<QQuickItem*>(), innerWindow->contentItem()); QCOMPARE(text->property("windowWidth").toInt(), innerWindow->width()); QCOMPARE(text->property("windowHeight").toInt(), innerWindow->height()); + + text->setParentItem(0); + QVERIFY(!text->property("contentItem").value<QQuickItem*>()); + QCOMPARE(text->property("windowWidth").toInt(), 0); + QCOMPARE(text->property("windowHeight").toInt(), 0); } class RenderJob : public QRunnable diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 1330cbccc9..5a1006c8e0 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -40,6 +40,7 @@ #include <QtTest/QTest> #include <private/qquickwindow_p.h> +#include <private/qquickitemview_p_p.h> QQuickView *QQuickViewTestUtil::createView() @@ -348,6 +349,85 @@ QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues return data; } +QQuickViewTestUtil::StressTestModel::StressTestModel() + : QAbstractListModel() + , m_rowCount(20) +{ + QTimer *t = new QTimer(this); + t->setInterval(500); + t->start(); + + qsrand(qHash(QDateTime::currentDateTime())); + connect(t, &QTimer::timeout, this, &StressTestModel::updateModel); +} + +int QQuickViewTestUtil::StressTestModel::rowCount(const QModelIndex &) const +{ + return m_rowCount; +} + +QVariant QQuickViewTestUtil::StressTestModel::data(const QModelIndex &, int) const +{ + return QVariant(); +} + +void QQuickViewTestUtil::StressTestModel::updateModel() +{ + if (m_rowCount > 10) { + for (int i = 0; i < 10; ++i) { + int rnum = qrand() % m_rowCount; + beginRemoveRows(QModelIndex(), rnum, rnum); + m_rowCount--; + endRemoveRows(); + } + } + if (m_rowCount < 20) { + for (int i = 0; i < 10; ++i) { + int rnum = qrand() % m_rowCount; + beginInsertRows(QModelIndex(), rnum, rnum); + m_rowCount++; + endInsertRows(); + } + } +} + +bool QQuickViewTestUtil::testVisibleItems(const QQuickItemViewPrivate *priv, bool *nonUnique, FxViewItem **failItem, int *expectedIdx) +{ + QHash<QQuickItem*, int> uniqueItems; + + int skip = 0; + for (int i = 0; i < priv->visibleItems.count(); ++i) { + FxViewItem *item = priv->visibleItems.at(i); + if (!item) { + *failItem = Q_NULLPTR; + return false; + } +#if 0 + qDebug() << "\t" << item->index + << item->item + << item->position() + << (!item->item || QQuickItemPrivate::get(item->item)->culled ? "hidden" : "visible"); +#endif + if (item->index == -1) { + ++skip; + } else if (item->index != priv->visibleIndex + i - skip) { + *nonUnique = false; + *failItem = item; + *expectedIdx = priv->visibleIndex + i - skip; + return false; + } else if (uniqueItems.contains(item->item)) { + *nonUnique = true; + *failItem = item; + *expectedIdx = uniqueItems.find(item->item).value(); + return false; + } + + uniqueItems.insert(item->item, item->index); + } + + return true; +} + namespace QQuickTouchUtils { /* QQuickWindow does event compression and only delivers events just diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h index 1643eca979..155d7967ba 100644 --- a/tests/auto/quick/shared/viewtestutil.h +++ b/tests/auto/quick/shared/viewtestutil.h @@ -39,6 +39,8 @@ #include <QtCore/QAbstractListModel> QT_FORWARD_DECLARE_CLASS(QQuickView) +QT_FORWARD_DECLARE_CLASS(QQuickItemViewPrivate) +QT_FORWARD_DECLARE_CLASS(FxViewItem) namespace QQuickViewTestUtil { @@ -158,6 +160,26 @@ namespace QQuickViewTestUtil for (; f != replaced.end(); ++f, ++t) *t = *f; } + + class StressTestModel : public QAbstractListModel + { + Q_OBJECT + + public: + + StressTestModel(); + + int rowCount(const QModelIndex &) const; + QVariant data(const QModelIndex &, int) const; + + public Q_SLOTS: + void updateModel(); + + private: + int m_rowCount; + }; + + bool testVisibleItems(const QQuickItemViewPrivate *priv, bool *nonUnique, FxViewItem **failItem, int *expectedIdx); } namespace QQuickTouchUtils { diff --git a/tests/benchmarks/qml/qml.pro b/tests/benchmarks/qml/qml.pro index 9c7583cd3b..b80ead6072 100644 --- a/tests/benchmarks/qml/qml.pro +++ b/tests/benchmarks/qml/qml.pro @@ -11,7 +11,6 @@ SUBDIRS += \ qqmlimage \ qqmlmetaproperty \ # script \ ### FIXME: doesn't build - qmltime \ js \ qquickwindow diff --git a/tests/manual/scenegraph_lancelot/data/text/textedit_multiline_selected_linebreaks_and_linewraps.qml b/tests/manual/scenegraph_lancelot/data/text/textedit_multiline_selected_linebreaks_and_linewraps.qml new file mode 100644 index 0000000000..a1004d0374 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/textedit_multiline_selected_linebreaks_and_linewraps.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 480 + + TextEdit { + id: textEdit + anchors.centerIn: parent + font.family: "Arial" + font.pixelSize: 64 + width: 200 + textFormat: TextEdit.RichText + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + text: "ABC ABC<br>ABC" + + Component.onCompleted: { + textEdit.selectAll() + } + } + +} diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index 189459f9af..ce91062edc 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -90,7 +90,7 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con if (!importNode->fileName.isEmpty()) { QString name = importNode->fileName.toString(); import[QStringLiteral("name")] = name; - if (name.endsWith(QStringLiteral(".js"))) { + if (name.endsWith(QLatin1String(".js"))) { import[QStringLiteral("type")] = QStringLiteral("javascript"); } else { import[QStringLiteral("type")] = QStringLiteral("directory"); @@ -193,7 +193,7 @@ QVariantList findPathsForModuleImports(const QVariantList &imports) for (int i = 0; i < importsCopy.length(); ++i) { QVariantMap import = qvariant_cast<QVariantMap>(importsCopy[i]); - if (import[QStringLiteral("type")] == QStringLiteral("module")) { + if (import[QStringLiteral("type")] == QLatin1String("module")) { QString path = resolveImportPath(import.value(QStringLiteral("name")).toString(), import.value(QStringLiteral("version")).toString()); if (!path.isEmpty()) import[QStringLiteral("path")] = path; @@ -324,9 +324,9 @@ QVariantList findQmlImportsInFile(const QString &filePath) QFile f; if (f.open(stdin, QIODevice::ReadOnly)) imports = findQmlImportsInQmlCode(QLatin1String("<stdin>"), QString::fromUtf8(f.readAll())); - } else if (filePath.endsWith(QStringLiteral(".qml"))) { + } else if (filePath.endsWith(QLatin1String(".qml"))) { imports = findQmlImportsInQmlFile(filePath); - } else if (filePath.endsWith(QStringLiteral(".js"))) { + } else if (filePath.endsWith(QLatin1String(".js"))) { imports = findQmlImportsInJavascriptFile(filePath); } @@ -387,10 +387,10 @@ QVariantList findQmlImportsInDirectory(const QString &qmlDir) continue; // skip obvious build output directories - if (path.contains(QStringLiteral("Debug-iphoneos")) || path.contains(QStringLiteral("Release-iphoneos")) || - path.contains(QStringLiteral("Debug-iphonesimulator")) || path.contains(QStringLiteral("Release-iphonesimulator")) + if (path.contains(QLatin1String("Debug-iphoneos")) || path.contains(QLatin1String("Release-iphoneos")) || + path.contains(QLatin1String("Debug-iphonesimulator")) || path.contains(QLatin1String("Release-iphonesimulator")) #ifdef Q_OS_WIN - || path.contains(QStringLiteral("/release/")) || path.contains(QStringLiteral("/debug/")) + || path.contains(QLatin1String("/release/")) || path.contains(QLatin1String("/debug/")) #endif ){ continue; @@ -409,7 +409,7 @@ QSet<QString> importModulePaths(QVariantList imports) { QVariantMap import = qvariant_cast<QVariantMap>(importVariant); QString path = import.value(QStringLiteral("path")).toString(); QString type = import.value(QStringLiteral("type")).toString(); - if (type == QStringLiteral("module") && !path.isEmpty()) + if (type == QLatin1String("module") && !path.isEmpty()) ret.insert(QDir(path).canonicalPath()); } return ret; diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index fe92f80bad..393abc8883 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -56,9 +56,11 @@ #include <QtCore/private/qobject_p.h> #include <QtCore/private/qmetaobject_p.h> +#include <QRegularExpression> #include <iostream> #include <algorithm> +#include "qmltypereader.h" #include "qmlstreamwriter.h" #ifdef QT_SIMULATOR @@ -733,7 +735,7 @@ void sigSegvHandler(int) { void printUsage(const QString &appName) { std::cerr << qPrintable(QString( - "Usage: %1 [-v] [-noinstantiate] [-defaultplatform] [-[non]relocatable] [-dependencies <dependencies.json>] module.uri version [module/import/path]\n" + "Usage: %1 [-v] [-noinstantiate] [-defaultplatform] [-[non]relocatable] [-dependencies <dependencies.json>] [-merge <file-to-merge.qmltypes>] module.uri version [module/import/path]\n" " %1 [-v] [-noinstantiate] -path path/to/qmldir/directory [version]\n" " %1 [-v] -builtins\n" "Example: %1 Qt.labs.folderlistmodel 2.0 /home/user/dev/qt-install/imports").arg( @@ -987,6 +989,7 @@ int main(int argc, char *argv[]) QString pluginImportVersion; bool relocatable = true; QString dependenciesFile; + QString mergeFile; enum Action { Uri, Path, Builtins }; Action action = Uri; { @@ -1005,6 +1008,13 @@ int main(int argc, char *argv[]) return EXIT_INVALIDARGUMENTS; } dependenciesFile = args.at(iArg); + } else if (arg == QLatin1String("--merge") + || arg == QLatin1String("-merge")) { + if (++iArg == args.size()) { + std::cerr << "missing merge file" << std::endl; + return EXIT_INVALIDARGUMENTS; + } + mergeFile = args.at(iArg); } else if (arg == QLatin1String("--notrelocatable") || arg == QLatin1String("-notrelocatable") || arg == QLatin1String("--nonrelocatable") @@ -1066,6 +1076,26 @@ int main(int argc, char *argv[]) QDir::setCurrent(pluginImportPath); engine.addImportPath(pluginImportPath); } + + // Merge file. + QStringList mergeDependencies; + QString mergeComponents; + if (!mergeFile.isEmpty()) { + QStringList merge = readQmlTypes(mergeFile); + if (!merge.isEmpty()) { + QRegularExpression re("(\\w+\\.*\\w*\\s*\\d+\\.\\d+)"); + QRegularExpressionMatchIterator i = re.globalMatch(merge[1]); + while (i.hasNext()) { + QRegularExpressionMatch m = i.next(); + QString d = m.captured(1); + mergeDependencies << m.captured(1); + } + mergeComponents = merge [2]; + } + } + + // Dependencies. + bool calculateDependencies = !pluginImportUri.isEmpty() && !pluginImportVersion.isEmpty(); QStringList dependencies; if (!dependenciesFile.isEmpty()) @@ -1215,6 +1245,13 @@ int main(int argc, char *argv[]) "// '%1 %2'\n" "\n").arg(QFileInfo(args.at(0)).baseName(), args.mid(1).join(QLatin1Char(' ')))); qml.writeStartObject("Module"); + + // Insert merge dependencies. + if (!mergeDependencies.isEmpty()) { + dependencies << mergeDependencies; + } + compactDependencies(&dependencies); + QStringList quotedDependencies; foreach (const QString &dep, dependencies) quotedDependencies << enquote(dep); @@ -1241,6 +1278,9 @@ int main(int argc, char *argv[]) if (pluginImportUri.isEmpty()) dumper.writeEasingCurve(); + // Insert merge file. + qml.write(mergeComponents); + qml.writeEndObject(); qml.writeEndDocument(); diff --git a/tools/qmlplugindump/qmlplugindump.pro b/tools/qmlplugindump/qmlplugindump.pro index 6fdcd349d1..e45a7fad83 100644 --- a/tools/qmlplugindump/qmlplugindump.pro +++ b/tools/qmlplugindump/qmlplugindump.pro @@ -6,10 +6,12 @@ QTPLUGIN.platforms = qminimal SOURCES += \ main.cpp \ - qmlstreamwriter.cpp + qmlstreamwriter.cpp \ + qmltypereader.cpp HEADERS += \ - qmlstreamwriter.h + qmlstreamwriter.h \ + qmltypereader.h macx { # Prevent qmlplugindump from popping up in the dock when launched. diff --git a/tools/qmlplugindump/qmltypereader.cpp b/tools/qmlplugindump/qmltypereader.cpp new file mode 100644 index 0000000000..67ba415388 --- /dev/null +++ b/tools/qmlplugindump/qmltypereader.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmltypereader.h" + +#include <QFileInfo> +#include <QFile> +#include <QRegularExpression> + +#include <iostream> + +QStringList readQmlTypes(const QString &filename) { + QRegularExpression re("import QtQuick.tooling 1.2.*Module {\\s*dependencies:\\[([^\\]]*)\\](.*)}", + QRegularExpression::DotMatchesEverythingOption); + if (!QFileInfo(filename).exists()) { + std::cerr << "Non existing file: " << filename.toStdString() << std::endl; + return QStringList(); + } + QFile f(filename); + if (!f.open(QFileDevice::ReadOnly)) { + std::cerr << "Error in opening file " << filename.toStdString() << " : " + << f.errorString().toStdString() << std::endl; + return QStringList(); + } + QByteArray fileData = f.readAll(); + QString data(fileData); + QRegularExpressionMatch m = re.match(data); + if (m.lastCapturedIndex() != 2) { + std::cerr << "Malformed file: " << filename.toStdString() << std::endl; + return QStringList(); + } + return m.capturedTexts(); +} diff --git a/tools/qmlplugindump/qmltypereader.h b/tools/qmlplugindump/qmltypereader.h new file mode 100644 index 0000000000..b995566e0b --- /dev/null +++ b/tools/qmlplugindump/qmltypereader.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLTYPEREADER_H +#define QMLTYPEREADER_H + +#include <QString> +#include <QStringList> + +QStringList readQmlTypes(const QString &filename); + +#endif // QMLTYPEREADER_H diff --git a/tests/benchmarks/qml/qmltime/example.qml b/tools/qmltime/example.qml index 3ef15d7567..3ef15d7567 100644 --- a/tests/benchmarks/qml/qmltime/example.qml +++ b/tools/qmltime/example.qml diff --git a/tests/benchmarks/qml/qmltime/linelaidout.qml b/tools/qmltime/linelaidout.qml index 90b7d14253..90b7d14253 100644 --- a/tests/benchmarks/qml/qmltime/linelaidout.qml +++ b/tools/qmltime/linelaidout.qml diff --git a/tests/benchmarks/qml/qmltime/qmltime.cpp b/tools/qmltime/qmltime.cpp index bd8477164a..2abe71fb4c 100644 --- a/tests/benchmarks/qml/qmltime/qmltime.cpp +++ b/tools/qmltime/qmltime.cpp @@ -33,11 +33,13 @@ #include <QQmlEngine> #include <QQmlComponent> #include <QDebug> -#include <QApplication> +#include <QGuiApplication> #include <QTime> #include <QQmlContext> -#include <QGraphicsScene> -#include <QGraphicsRectItem> +#include <QQuickView> +#include <QQuickItem> + +#include <private/qquickview_p.h> class Timer : public QObject { @@ -64,22 +66,22 @@ private: static Timer *m_timer; bool m_willparent; - QGraphicsScene m_scene; - QGraphicsRectItem m_item; + QQuickView m_view; + QQuickItem *m_item; }; QML_DECLARE_TYPE(Timer); Timer *Timer::m_timer = 0; Timer::Timer() -: m_component(0), m_willparent(false) + : m_component(0) + , m_willparent(false) + , m_item(new QQuickItem) { if (m_timer) qWarning("Timer: Timer already registered"); + QQuickViewPrivate::get(&m_view)->setRootObject(m_item); m_timer = this; - - m_scene.setItemIndexMethod(QGraphicsScene::NoIndex); - m_scene.addItem(&m_item); } QQmlComponent *Timer::component() const @@ -102,9 +104,9 @@ void Timer::run(uint iterations) QQmlContext context(qmlContext(this)); QObject *o = m_component->create(&context); - QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o); - if (m_willparent && go) - go->setParentItem(&m_item); + QQuickItem *i = qobject_cast<QQuickItem *>(o); + if (m_willparent && i) + i->setParentItem(m_item); delete o; runTest(&context, iterations); @@ -126,9 +128,9 @@ void Timer::runTest(QQmlContext *context, uint iterations) t.start(); for (uint ii = 0; ii < iterations; ++ii) { QObject *o = m_component->create(context); - QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o); - if (m_willparent && go) - go->setParentItem(&m_item); + QQuickItem *i = qobject_cast<QQuickItem *>(o); + if (m_willparent && i) + i->setParentItem(m_item); delete o; } @@ -207,7 +209,7 @@ void usage(const char *name) int main(int argc, char ** argv) { - QApplication app(argc, argv); + QGuiApplication app(argc, argv); qmlRegisterType<Timer>("QmlTime", 1, 0, "Timer"); diff --git a/tests/benchmarks/qml/qmltime/qmltime.pro b/tools/qmltime/qmltime.pro index 4e3e9471a4..80a7073c3c 100644 --- a/tests/benchmarks/qml/qmltime/qmltime.pro +++ b/tools/qmltime/qmltime.pro @@ -1,9 +1,8 @@ CONFIG += testcase TEMPLATE = app TARGET = qmltime -QT += qml widgets testlib +QT += qml testlib quick +QT += quick-private macx:CONFIG -= app_bundle SOURCES += qmltime.cpp - -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/empty.qml b/tools/qmltime/tests/anchors/empty.qml index 309b4caa7e..309b4caa7e 100644 --- a/tests/benchmarks/qml/qmltime/tests/anchors/empty.qml +++ b/tools/qmltime/tests/anchors/empty.qml diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/fill.qml b/tools/qmltime/tests/anchors/fill.qml index df32da66e5..df32da66e5 100644 --- a/tests/benchmarks/qml/qmltime/tests/anchors/fill.qml +++ b/tools/qmltime/tests/anchors/fill.qml diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/null.qml b/tools/qmltime/tests/anchors/null.qml index 8a1ae0c25d..8a1ae0c25d 100644 --- a/tests/benchmarks/qml/qmltime/tests/anchors/null.qml +++ b/tools/qmltime/tests/anchors/null.qml diff --git a/tests/benchmarks/qml/qmltime/tests/animation/large.qml b/tools/qmltime/tests/animation/large.qml index 0c791961dd..0c791961dd 100644 --- a/tests/benchmarks/qml/qmltime/tests/animation/large.qml +++ b/tools/qmltime/tests/animation/large.qml diff --git a/tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml b/tools/qmltime/tests/animation/largeNoProps.qml index 734ee46b77..734ee46b77 100644 --- a/tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml +++ b/tools/qmltime/tests/animation/largeNoProps.qml diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/children.qml b/tools/qmltime/tests/item_creation/children.qml index 87085c1134..87085c1134 100644 --- a/tests/benchmarks/qml/qmltime/tests/item_creation/children.qml +++ b/tools/qmltime/tests/item_creation/children.qml diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/data.qml b/tools/qmltime/tests/item_creation/data.qml index 96804fda40..96804fda40 100644 --- a/tests/benchmarks/qml/qmltime/tests/item_creation/data.qml +++ b/tools/qmltime/tests/item_creation/data.qml diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml b/tools/qmltime/tests/item_creation/no_creation.qml index 64561eb211..64561eb211 100644 --- a/tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml +++ b/tools/qmltime/tests/item_creation/no_creation.qml diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml b/tools/qmltime/tests/item_creation/resources.qml index c896666b9a..c896666b9a 100644 --- a/tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml +++ b/tools/qmltime/tests/item_creation/resources.qml diff --git a/tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml b/tools/qmltime/tests/loader/Loaded.qml index 8dedef1361..8dedef1361 100644 --- a/tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml +++ b/tools/qmltime/tests/loader/Loaded.qml diff --git a/tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml b/tools/qmltime/tests/loader/component_loader.qml index 9c245aeb21..9c245aeb21 100644 --- a/tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml +++ b/tools/qmltime/tests/loader/component_loader.qml diff --git a/tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml b/tools/qmltime/tests/loader/empty_loader.qml index 9f288f8ad5..9f288f8ad5 100644 --- a/tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml +++ b/tools/qmltime/tests/loader/empty_loader.qml diff --git a/tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml b/tools/qmltime/tests/loader/no_loader.qml index c84b9d3dd6..c84b9d3dd6 100644 --- a/tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml +++ b/tools/qmltime/tests/loader/no_loader.qml diff --git a/tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml b/tools/qmltime/tests/loader/source_loader.qml index 41a1792d2c..41a1792d2c 100644 --- a/tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml +++ b/tools/qmltime/tests/loader/source_loader.qml diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml b/tools/qmltime/tests/positioner_creation/no_positioner.qml index 09a3fb4321..09a3fb4321 100644 --- a/tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml +++ b/tools/qmltime/tests/positioner_creation/no_positioner.qml diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml b/tools/qmltime/tests/positioner_creation/null_positioner.qml index 957688bcee..957688bcee 100644 --- a/tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml +++ b/tools/qmltime/tests/positioner_creation/null_positioner.qml diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml b/tools/qmltime/tests/positioner_creation/positioner.qml index 4e6f08a1fe..4e6f08a1fe 100644 --- a/tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml +++ b/tools/qmltime/tests/positioner_creation/positioner.qml diff --git a/tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml b/tools/qmltime/tests/vmemetaobject/null.qml index f695c989a3..f695c989a3 100644 --- a/tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml +++ b/tools/qmltime/tests/vmemetaobject/null.qml diff --git a/tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml b/tools/qmltime/tests/vmemetaobject/property.qml index f0ccabe2f0..f0ccabe2f0 100644 --- a/tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml +++ b/tools/qmltime/tests/vmemetaobject/property.qml diff --git a/tests/benchmarks/qml/qmltime/textingrid.qml b/tools/qmltime/textingrid.qml index 69dbdb5dd6..69dbdb5dd6 100644 --- a/tests/benchmarks/qml/qmltime/textingrid.qml +++ b/tools/qmltime/textingrid.qml diff --git a/tools/tools.pro b/tools/tools.pro index b2e9e27066..96cf80405a 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -12,7 +12,12 @@ qmlimportscanner.CONFIG = host_build qmlprofiler \ qmllint qtHaveModule(quick) { - !static: SUBDIRS += qmlscene qmlplugindump + !static: { + SUBDIRS += \ + qmlscene \ + qmlplugindump \ + qmltime + } qtHaveModule(widgets): SUBDIRS += qmleasing } qtHaveModule(qmltest): SUBDIRS += qmltestrunner |