summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/corecon/ccapi.h436
-rw-r--r--src/shared/corecon/ccapi_11.h73
-rw-r--r--src/shared/corecon/ccapi_12.h73
-rw-r--r--src/shared/corecon/corecon.cpp466
-rw-r--r--src/shared/corecon/corecon.h94
-rw-r--r--src/shared/deviceskin/deviceskin.cpp121
-rw-r--r--src/shared/deviceskin/deviceskin.h40
-rw-r--r--src/shared/deviceskin/skins/ClamshellPhone.qrc5
-rw-r--r--src/shared/deviceskin/skins/PortableMedia.qrc5
-rw-r--r--src/shared/deviceskin/skins/S60-QVGA-Candybar.qrc5
-rw-r--r--src/shared/deviceskin/skins/S60-nHD-Touchscreen.qrc5
-rw-r--r--src/shared/deviceskin/skins/SmartPhone.qrc5
-rw-r--r--src/shared/deviceskin/skins/SmartPhone2.qrc5
-rw-r--r--src/shared/deviceskin/skins/SmartPhoneWithButtons.qrc5
-rw-r--r--src/shared/deviceskin/skins/TouchscreenPhone.qrc5
-rw-r--r--src/shared/findwidget/abstractfindwidget.cpp72
-rw-r--r--src/shared/findwidget/abstractfindwidget.h40
-rw-r--r--src/shared/findwidget/findwidget.qrc14
-rw-r--r--src/shared/findwidget/itemviewfindwidget.cpp46
-rw-r--r--src/shared/findwidget/itemviewfindwidget.h40
-rw-r--r--src/shared/findwidget/texteditfindwidget.cpp40
-rw-r--r--src/shared/findwidget/texteditfindwidget.h40
-rw-r--r--src/shared/fontpanel/fontpanel.cpp52
-rw-r--r--src/shared/fontpanel/fontpanel.h40
-rw-r--r--src/shared/qtgradienteditor/qtcolorbutton.cpp47
-rw-r--r--src/shared/qtgradienteditor/qtcolorbutton.h44
-rw-r--r--src/shared/qtgradienteditor/qtcolorline.cpp40
-rw-r--r--src/shared/qtgradienteditor/qtcolorline.h44
-rw-r--r--src/shared/qtgradienteditor/qtgradientdialog.cpp50
-rw-r--r--src/shared/qtgradienteditor/qtgradientdialog.h41
-rw-r--r--src/shared/qtgradienteditor/qtgradientdialog.ui42
-rw-r--r--src/shared/qtgradienteditor/qtgradienteditor.cpp374
-rw-r--r--src/shared/qtgradienteditor/qtgradienteditor.h64
-rw-r--r--src/shared/qtgradienteditor/qtgradienteditor.qrc18
-rw-r--r--src/shared/qtgradienteditor/qtgradienteditor.ui42
-rw-r--r--src/shared/qtgradienteditor/qtgradientmanager.cpp44
-rw-r--r--src/shared/qtgradienteditor/qtgradientmanager.h40
-rw-r--r--src/shared/qtgradienteditor/qtgradientstopscontroller.cpp249
-rw-r--r--src/shared/qtgradienteditor/qtgradientstopscontroller.h67
-rw-r--r--src/shared/qtgradienteditor/qtgradientstopsmodel.cpp69
-rw-r--r--src/shared/qtgradienteditor/qtgradientstopsmodel.h42
-rw-r--r--src/shared/qtgradienteditor/qtgradientstopswidget.cpp195
-rw-r--r--src/shared/qtgradienteditor/qtgradientstopswidget.h55
-rw-r--r--src/shared/qtgradienteditor/qtgradientutils.cpp224
-rw-r--r--src/shared/qtgradienteditor/qtgradientutils.h41
-rw-r--r--src/shared/qtgradienteditor/qtgradientview.cpp96
-rw-r--r--src/shared/qtgradienteditor/qtgradientview.h48
-rw-r--r--src/shared/qtgradienteditor/qtgradientviewdialog.cpp48
-rw-r--r--src/shared/qtgradienteditor/qtgradientviewdialog.h40
-rw-r--r--src/shared/qtgradienteditor/qtgradientviewdialog.ui42
-rw-r--r--src/shared/qtgradienteditor/qtgradientwidget.cpp40
-rw-r--r--src/shared/qtgradienteditor/qtgradientwidget.h41
-rw-r--r--src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp88
-rw-r--r--src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h47
-rw-r--r--src/shared/qtpropertybrowser/qteditorfactory.cpp513
-rw-r--r--src/shared/qtpropertybrowser/qteditorfactory.h100
-rw-r--r--src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp101
-rw-r--r--src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h45
-rw-r--r--src/shared/qtpropertybrowser/qtpropertybrowser.cpp143
-rw-r--r--src/shared/qtpropertybrowser/qtpropertybrowser.h67
-rw-r--r--src/shared/qtpropertybrowser/qtpropertybrowser.qrc23
-rw-r--r--src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp106
-rw-r--r--src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h43
-rw-r--r--src/shared/qtpropertybrowser/qtpropertymanager.cpp1063
-rw-r--r--src/shared/qtpropertybrowser/qtpropertymanager.h67
-rw-r--r--src/shared/qtpropertybrowser/qttreepropertybrowser.cpp132
-rw-r--r--src/shared/qtpropertybrowser/qttreepropertybrowser.h49
-rw-r--r--src/shared/qtpropertybrowser/qtvariantproperty.cpp791
-rw-r--r--src/shared/qtpropertybrowser/qtvariantproperty.h81
-rw-r--r--src/shared/qttoolbardialog/qttoolbardialog.cpp204
-rw-r--r--src/shared/qttoolbardialog/qttoolbardialog.h56
-rw-r--r--src/shared/qttoolbardialog/qttoolbardialog.qrc10
-rw-r--r--src/shared/winutils/elfreader.cpp440
-rw-r--r--src/shared/winutils/elfreader.h176
-rw-r--r--src/shared/winutils/qmlutils.cpp160
-rw-r--r--src/shared/winutils/qmlutils.h65
-rw-r--r--src/shared/winutils/utils.cpp1006
-rw-r--r--src/shared/winutils/utils.h404
78 files changed, 2154 insertions, 7740 deletions
diff --git a/src/shared/corecon/ccapi.h b/src/shared/corecon/ccapi.h
deleted file mode 100644
index 01ec1db54..000000000
--- a/src/shared/corecon/ccapi.h
+++ /dev/null
@@ -1,436 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CCAPI_VERSIONED_H
-#define CCAPI_VERSIONED_H
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Core Connectivity API (Experimental)
- *
- * These interfaces for deploying to Windows Phone devices are available as
- * registered DLLs if the Windows Phone tools have been installed.
- * As the IDL is not part of the Windows SDK, these interfaces were crafted by
- * hand via the MSDN documentation and the information gathered by OLEView.
- * As a consequence, not all interfaces have been stubbed out, and not all
- * methods have been tested. This means that some methods may end up in the
- * wrong position in the vtable, causing unexpected behavior or crashes.
- * You have been warned!
- *
- * CoreConnectivity documentation:
- * http://msdn.microsoft.com/en-us/library/ee481381.aspx
- * SmartDevice Connectivity documentation:
- * http://msdn.microsoft.com/en-us/library/microsoft.smartdevice.connectivity.aspx
- *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#include <windows.h>
-
-#ifndef CORECON_VER
-static_assert(false, "You must define the CoreCon version with CORECON_VER.");
-#endif
-
-#if CORECON_VER==11
-
-static const CLSID CLSID_ConMan_11 = { 0x349AB2E8, 0x71B6, 0x4069, 0xAD, 0x9C, 0x11, 0x70, 0x84, 0x9D, 0xA6, 0x4C };
-
-// Undefined
-struct ICcFormFactorContainer_11;
-struct ICcOSImage_11;
-struct ICcOSImageContainer_11;
-struct ICcPackageContainer_11;
-struct ICcProjectContainer_11;
-struct ICcServiceCategoryContainer_11;
-struct ICcServiceCB_11;
-struct ICcServiceInfo_11;
-struct ICcTransportStream_11;
-struct ICcTypeToArchitectureMap_11;
-
-// Defined
-struct ICcConnection_11;
-struct ICcCollection_11;
-struct ICcConnection3_11;
-struct ICcDatastore_11;
-struct ICcDevice_11;
-struct ICcDeviceContainer_11;
-struct ICcObject_11;
-struct ICcObjectContainer_11;
-struct ICcPlatform_11;
-struct ICcPlatformContainer_11;
-struct ICcProperty_11;
-struct ICcPropertyContainer_11;
-struct ICcServer_11;
-
-#elif CORECON_VER==12
-
-static const CLSID CLSID_ConMan_12 = { 0x2D0A16C9, 0x53D9, 0x42C1, 0xBC, 0xC2, 0x8D, 0x2A, 0x13, 0x5E, 0x21, 0x63 };
-
-// Undefined
-struct ICcFormFactorContainer_12;
-struct ICcOSImage_12;
-struct ICcOSImageContainer_12;
-struct ICcPackageContainer_12;
-struct ICcProjectContainer_12;
-struct ICcServiceCategoryContainer_12;
-struct ICcServiceCB_12;
-struct ICcServiceInfo_12;
-struct ICcTransportStream_12;
-struct ICcTypeToArchitectureMap_12;
-
-// Defined
-struct ICcConnection_12;
-struct ICcCollection_12;
-struct ICcConnection3_12;
-struct ICcDatastore_12;
-struct ICcDevice_12;
-struct ICcDeviceContainer_12;
-struct ICcObject_12;
-struct ICcObjectContainer_12;
-struct ICcPlatform_12;
-struct ICcPlatformContainer_12;
-struct ICcProperty_12;
-struct ICcPropertyContainer_12;
-struct ICcServer_12;
-
-#endif
-
-
-#ifndef CCAPI_H
-#define CCAPI_H
-
-typedef struct tagFileInfo{
- LONG m_FileAttribues;
- LONGLONG m_FileSize;
- FILETIME m_CreationTime;
- FILETIME m_LastAccessTime;
- FILETIME m_LastWriteTime;
-} FileInfo;
-
-typedef struct tagFileVerifyVersion{
- DWORD m_Major;
- DWORD m_Minor;
- DWORD m_Build;
- DWORD m_Revision;
-} FileVerifyVersion;
-
-typedef struct tagFileVerifyInfo{
- FileVerifyVersion m_AssemblyVersion;
- FileVerifyVersion m_Win32Version;
- BSTR m_Culture;
- BYTE m_PublicKeyToken[12 + 3/*PUBLIC_KEY_TOKEN_LENGTH*/]; //### What is the key length?
- DWORD m_Flags;
-} FileVerifyInfo;
-
-typedef struct tagFileVerifyReference{
- BSTR m_Name;
- BSTR m_SourcePath;
- FileVerifyInfo m_Info;
-} FileVerifyReference;
-
-typedef struct tagFileVerifyResult{
- DWORD m_Version;
- FileVerifyInfo _Info;
-} FileVerifyResult;
-
-typedef struct tagPlatformInfo{
- DWORD m_OSMajor;
- DWORD m_OSMinor;
- DWORD m_BuildNo;
- DWORD m_ProcessorArchitecture;
- DWORD m_InstructionSet;
-} SystemInfo;
-
-#endif // CCAPI_H
-
-#if CORECON_VER==11
-struct __declspec(uuid("{7A4AA9D3-0F9E-4CD4-8D52-62B6C0653752}")) ICcCollection_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{9A83560F-377D-419F-B572-AEC3C1A44671}")) ICcCollection_12 : public IDispatch
-#endif
-{
- virtual HRESULT __stdcall get_Count(long *count) = 0;
-#if CORECON_VER==11
- virtual HRESULT __stdcall get_Item(long index, ICcObject_11 **object) = 0;
-#elif CORECON_VER==12
- virtual HRESULT __stdcall get_Item(long index, ICcObject_12 **object) = 0;
-#endif
- virtual HRESULT __stdcall get_NewEnum(IUnknown **val) = 0;
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{CEF4C928-326F-49A9-B7E7-8FE7588B74B5}")) ICcConnection_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{906D8E75-8AE6-46B5-B4B6-43B83D9A0948}")) ICcConnection_12 : public IDispatch
-#endif
-{
- virtual HRESULT __stdcall DeviceId(BSTR *deviceId) = 0;
- virtual HRESULT __stdcall GetSystemInfo(SystemInfo *systemInfo) = 0;
- virtual HRESULT __stdcall SendFile(BSTR desktopFile, BSTR deviceFile, DWORD creationFlags, BSTR customFileAction) = 0;
- virtual HRESULT __stdcall ReceiveFile(BSTR deviceFile, BSTR desktopFile, DWORD fileAction) = 0;
- virtual HRESULT __stdcall RemoveFile(BSTR deviceFile) = 0;
- virtual HRESULT __stdcall GetFileInfo(BSTR deviceFile, FileInfo *fileInfo) = 0;
- virtual HRESULT __stdcall SetFileInfo(BSTR deviceFile, FileInfo *fileInfo) = 0;
- virtual HRESULT __stdcall DeleteDirectory(BSTR deviceDirectory, VARIANT_BOOL removeAll) = 0;
- virtual HRESULT __stdcall MakeDirectory(BSTR deviceDirectory) = 0;
- virtual HRESULT __stdcall DownloadPackage(BSTR packageId) = 0;
- virtual HRESULT __stdcall LaunchProcess(BSTR executable, BSTR arguments, DWORD creationFlags, DWORD *processId, DWORD *processHandle) = 0;
- virtual HRESULT __stdcall TerminateProcess(DWORD processId) = 0;
- virtual HRESULT __stdcall GetProcessExitCode(DWORD processId, VARIANT_BOOL *processExited, DWORD *exitCode) = 0;
- virtual HRESULT __stdcall RegistryCreateKey(LONG key, BSTR subKey) = 0;
- virtual HRESULT __stdcall RegistryDeleteKey(LONG key, BSTR subKey) = 0;
- virtual HRESULT __stdcall RegistrySetValue(LONG key, BSTR subKey, BSTR valueName, DWORD type, BSTR data, DWORD length) = 0;
- virtual HRESULT __stdcall RegistryQueryValue(LONG key, BSTR subKey, BSTR valueName, DWORD type, WCHAR *value, LONG *length) = 0;
- virtual HRESULT __stdcall RegistryDeleteValue(LONG key, BSTR subKey, BSTR valueName) = 0;
- virtual HRESULT __stdcall IsConnected(VARIANT_BOOL *connected) = 0;
- virtual HRESULT __stdcall VerifyFilesInstalled(DWORD arraySize, FileVerifyReference *infoArray, FileVerifyResult *existenceArray) = 0;
- virtual HRESULT __stdcall ConnectDevice() = 0;
- virtual HRESULT __stdcall DisconnectDevice() = 0;
- virtual HRESULT __stdcall SearchFileSystem(BSTR criteria, BSTR startingDirectory, SAFEARRAY/*<BSTR>*/ *results) = 0;
-#if CORECON_VER==11
- virtual HRESULT __stdcall CreateStream(BSTR streamId, DWORD timeout, ICcServiceCB_11 *callback, DWORD *cookieId, ICcTransportStream_11 **stream) = 0;
-#elif CORECON_VER==12
- virtual HRESULT __stdcall CreateStream(BSTR streamId, DWORD timeout, ICcServiceCB_12 *callback, DWORD *cookieId, ICcTransportStream_12 **stream) = 0;
-#endif
- virtual HRESULT __stdcall EnumerateProcesses(SAFEARRAY/*<BSTR>*/ **processes, SAFEARRAY/*<DWORD>*/ **processIds) = 0;
- virtual HRESULT __stdcall CloseProcessHandle(DWORD processHandle) = 0;
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{F4B43EA3-3106-4D3D-94E3-084D4136C40C}")) ICcConnection3_11 : public IUnknown
-#elif CORECON_VER==12
-struct __declspec(uuid("{B158FE65-7DCC-4809-9054-A7B52FD43DE3}")) ICcConnection3_12 : public IUnknown
-#endif
-{
- virtual HRESULT __stdcall GetInstalledApplicationCount(int *count) = 0; // E_NOTIMPL
- virtual HRESULT __stdcall GetInstalledApplicationIDs(SAFEARRAY/*<BSTR>*/ **productIds, SAFEARRAY/*<BSTR>*/ **instanceIds) = 0;
- virtual HRESULT __stdcall IsApplicationInstalled(BSTR productId, VARIANT_BOOL *installed) = 0;
- virtual HRESULT __stdcall InstallApplication(BSTR productId, BSTR instanceId, BSTR genre, BSTR iconPath, BSTR xapPath) = 0;
- virtual HRESULT __stdcall UpdateApplication(BSTR productId, BSTR instanceId, BSTR genre, BSTR applicationPath, BSTR xapPath) = 0;
- virtual HRESULT __stdcall GetInstalledFileInfo(BSTR productId, BSTR fileName, FileInfo *fileInfo) = 0; // E_NOTIMPL
- virtual HRESULT __stdcall IsApplicationRunning(BSTR productId, VARIANT_BOOL *isRunning) = 0; // E_NOTIMPL
- virtual HRESULT __stdcall UninstallApplication(BSTR productId) = 0;
- virtual HRESULT __stdcall LaunchApplicationWithService(BSTR productId, BSTR serviceInfo) = 0; // E_NOTIMPL
- virtual HRESULT __stdcall TerminateRunningApplicationInstances(BSTR productId) = 0;
- virtual HRESULT __stdcall LaunchApplication(BSTR productId, DWORD *processId) = 0;
-
-// Untested
- virtual HRESULT __stdcall UpdateInstalledFile(BSTR productId, BSTR fileRelativePath, BSTR sourceFilePath, VARIANT_BOOL updateFileInfo) = 0;
- virtual HRESULT __stdcall UpdateInstalledFilesInfo(BSTR productId, SAFEARRAY/*<BSTR>*/ *fileNames, SAFEARRAY/*<BSTR>*/ *xapRelativePaths) = 0;
- virtual HRESULT __stdcall UpdateInstalledFiles(BSTR productId, SAFEARRAY/*<BSTR>*/ *fileNames, SAFEARRAY/*<BSTR>*/ *xapRelativePaths) = 0;
- virtual HRESULT __stdcall ActivateDevice() = 0;
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{5F25394E-D9B6-4F8E-A0DF-325610A35BFA}")) ICcConnection4_11 : public IUnknown
-#elif CORECON_VER==12
-struct __declspec(uuid("{68CBC76F-ADF6-4586-B495-E34771B8EAC2}")) ICcConnection4_12 : public IUnknown
-#endif
-{
- virtual HRESULT __stdcall GetDirectoryListing(BSTR deviceDirPath, SAFEARRAY/*<BSTR>*/ **listing) = 0;
- virtual HRESULT __stdcall GetApplicationType(BSTR productId, DWORD *type) = 0;
- virtual HRESULT __stdcall GetEndPoints(int localPort, BSTR localIp, BSTR remoteIp, int remotePort) = 0;
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{EDB0A0CA-F0F8-4EBF-9D31-43E182569A5A}")) ICcDatastore_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{2E6AF7C6-CBAB-4E6E-B78A-90A04A2CE523}")) ICcDatastore_12 : public IDispatch
-#endif
-{
- virtual HRESULT __stdcall Save() = 0;
- virtual HRESULT __stdcall RegisterRefreshEvent(BSTR eventName) = 0;
- virtual HRESULT __stdcall UnregisterRefreshEvent() = 0;
-#if CORECON_VER==11
- virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer_11 **dc) = 0;
- virtual HRESULT __stdcall get_OSImageContainer(ICcOSImageContainer_11 **oc) = 0;
- virtual HRESULT __stdcall get_PackageContainer(ICcPackageContainer_11 **pc) = 0;
- virtual HRESULT __stdcall get_PlatformContainer(ICcPlatformContainer_11 **pc) = 0;
- virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer_11 **pc) = 0;
- virtual HRESULT __stdcall get_ServiceCategoryContainer(ICcServiceCategoryContainer_11 **scc) = 0;
-#elif CORECON_VER==12
- virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer_12 **dc) = 0;
- virtual HRESULT __stdcall get_OSImageContainer(ICcOSImageContainer_12 **oc) = 0;
- virtual HRESULT __stdcall get_PackageContainer(ICcPackageContainer_12 **pc) = 0;
- virtual HRESULT __stdcall get_PlatformContainer(ICcPlatformContainer_12 **pc) = 0;
- virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer_12 **pc) = 0;
- virtual HRESULT __stdcall get_ServiceCategoryContainer(ICcServiceCategoryContainer_12 **scc) = 0;
-#endif
- virtual HRESULT __stdcall get_Version(BSTR *version) = 0;
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{971BF639-8C53-4057-B635-375D7BCDFF3E}")) ICcDevice_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{22773666-28CC-4AD6-9F07-E06BE40EEDB3}")) ICcDevice_12 : public IDispatch
-#endif
-{
- virtual HRESULT __stdcall ClearOSImage() = 0;
- virtual HRESULT __stdcall ClearServiceMap(BSTR serviceCatetoryId) = 0;
-#if CORECON_VER==11
- virtual HRESULT __stdcall GetOSImage(ICcOSImage_11 **image) = 0;
- virtual HRESULT __stdcall GetServiceMap(BSTR serviceCategoryId, ICcServiceInfo_11 **serviceInfo) = 0;
-#elif CORECON_VER==12
- virtual HRESULT __stdcall GetOSImage(ICcOSImage_12 **image) = 0;
- virtual HRESULT __stdcall GetServiceMap(BSTR serviceCategoryId, ICcServiceInfo_12 **serviceInfo) = 0;
-#endif
- virtual HRESULT __stdcall SetOSImage(BSTR osImage) = 0;
- virtual HRESULT __stdcall SetServiceMap(BSTR serviceCategoryId, BSTR serviceInfoId) = 0;
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{88152DD3-5ECB-47A2-8F15-610C4C390122}")) ICcDeviceContainer_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{D747386E-3EAB-4E04-8DD5-7037D192A06D}")) ICcDeviceContainer_12 : public IDispatch
-#endif
-{
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{B669EC21-E8FC-42E4-AEC5-8F0EF3673AB8}")) ICcObject_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{F84BC223-B877-43A2-BE9C-68CFB0020732}")) ICcObject_12 : public IDispatch
-#endif
-{
- virtual HRESULT __stdcall get_Name(BSTR *name) = 0;
- virtual HRESULT __stdcall put_Name(BSTR name) = 0;
- virtual HRESULT __stdcall get_ID(BSTR *id) = 0;
- virtual HRESULT __stdcall get_IsProtected(VARIANT_BOOL *isProtected) = 0;
-#if CORECON_VER==11
- virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer_11 **pc) = 0;
-#elif CORECON_VER==12
- virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer_12 **pc) = 0;
-#endif
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{1C0048A9-A73F-41B3-BD75-467D615CB9E5}")) ICcObjectContainer_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{ADEFAC99-D191-46A1-B42F-58B22755C293}")) ICcObjectContainer_12 : public IDispatch
-#endif
-{
-#if CORECON_VER==11
- virtual HRESULT __stdcall FindObject(BSTR nameOrId, ICcObject_11 **object) = 0;
- virtual HRESULT __stdcall EnumerateObjects(ICcCollection_11 **collection) = 0;
- virtual HRESULT __stdcall AddObject(BSTR name, BSTR id, ICcObject_11 **object) = 0;
-#elif CORECON_VER==12
- virtual HRESULT __stdcall FindObject(BSTR nameOrId, ICcObject_12 **object) = 0;
- virtual HRESULT __stdcall EnumerateObjects(ICcCollection_12 **collection) = 0;
- virtual HRESULT __stdcall AddObject(BSTR name, BSTR id, ICcObject_12 **object) = 0;
-#endif
- virtual HRESULT __stdcall DeleteObject(BSTR nameOrId) = 0;
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{2E12E75A-1625-44B6-B527-7A1E7ED61577}")) ICcPlatform_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{9124335F-7D55-443D-A86C-4DBC245A1051}")) ICcPlatform_12 : public IDispatch
-#endif
-{
-#if CORECON_VER==11
- virtual HRESULT __stdcall get_ProjectContainer(ICcProjectContainer_11 **container) = 0;
- virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer_11 **container) = 0;
- virtual HRESULT __stdcall get_FormFactorContainer(ICcFormFactorContainer_11 **container) = 0;
- virtual HRESULT __stdcall get_TypeToArchitectureMap(ICcTypeToArchitectureMap_11 **map) = 0;
-#elif CORECON_VER==12
- virtual HRESULT __stdcall get_ProjectContainer(ICcProjectContainer_12 **container) = 0;
- virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer_12 **container) = 0;
- virtual HRESULT __stdcall get_FormFactorContainer(ICcFormFactorContainer_12 **container) = 0;
- virtual HRESULT __stdcall get_TypeToArchitectureMap(ICcTypeToArchitectureMap_12 **map) = 0;
-#endif
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{C434B7DA-ABAA-428A-944A-3AF1A7419A92}")) ICcPlatformContainer_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{2D405E9C-BBA4-406B-9E9F-A4E41CAC520C}")) ICcPlatformContainer_12 : public IDispatch
-#endif
-{
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{A918FF41-F287-488D-BE16-99DBF54E331D}")) ICcProperty_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{750F503B-6686-4715-81EB-9E23EA0FC424}")) ICcProperty_12 : public IDispatch
-#endif
-{
- virtual HRESULT __stdcall get_Value(BSTR *val) = 0;
- virtual HRESULT __stdcall set_Value(BSTR val) = 0;
- virtual HRESULT __stdcall AddPropertyContainer() = 0;
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{9636B4A4-633C-4542-A809-9E96ABF01FA5}")) ICcPropertyContainer_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{E92A5704-87B2-4059-81A2-C5C54424CF38}")) ICcPropertyContainer_12 : public IDispatch
-#endif
-{
-};
-
-#if CORECON_VER==11
-struct __declspec(uuid("{F19FF2DB-0A4E-4148-ABE3-47EE7E31194F}")) ICcServer_11 : public IDispatch
-#elif CORECON_VER==12
-struct __declspec(uuid("{D0D076C5-5C71-4947-A056-94E8E760DFFE}")) ICcServer_12 : public IDispatch
-#endif
-{
- virtual HRESULT __stdcall get_Locale(DWORD *locale) = 0;
- virtual HRESULT __stdcall put_Locale(DWORD *locale) = 0;
-#if CORECON_VER==11
- virtual HRESULT __stdcall GetDatastore(DWORD locale, ICcDatastore_11 **datastore) = 0;
- virtual HRESULT __stdcall GetConnection(ICcDevice_11 *device, DWORD timeout, ICcServiceCB_11 *callback, BSTR *connectionId, ICcConnection_11 **connection) = 0;
- virtual HRESULT __stdcall EnumerateConnections(DWORD sizeActual, DWORD *sizeReturned, BSTR *connections, VARIANT_BOOL *moreEntries) = 0;
- virtual HRESULT __stdcall GetConnectionFromId(BSTR connectionId, ICcConnection_11 **connection) = 0;
-#elif CORECON_VER==12
- virtual HRESULT __stdcall GetDatastore(DWORD locale, ICcDatastore_12 **datastore) = 0;
- virtual HRESULT __stdcall GetConnection(ICcDevice_12 *device, DWORD timeout, ICcServiceCB_12 *callback, BSTR *connectionId, ICcConnection_12 **connection) = 0;
- virtual HRESULT __stdcall EnumerateConnections(DWORD sizeActual, DWORD *sizeReturned, BSTR *connections, VARIANT_BOOL *moreEntries) = 0;
- virtual HRESULT __stdcall GetConnectionFromId(BSTR connectionId, ICcConnection_12 **connection) = 0;
-#endif
-};
-
-#endif
diff --git a/src/shared/corecon/ccapi_11.h b/src/shared/corecon/ccapi_11.h
deleted file mode 100644
index b863ad73c..000000000
--- a/src/shared/corecon/ccapi_11.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CCAPI_11_H
-#define CCAPI_11_H
-
-#define CORECON_VER 11
-#include "ccapi.h"
-
-#define CLSID_ConMan CLSID_ConMan_11;
-typedef ICcCollection_11 ICcCollection;
-typedef ICcConnection_11 ICcConnection;
-typedef ICcConnection3_11 ICcConnection3;
-typedef ICcConnection4_11 ICcConnection4;
-typedef ICcDatastore_11 ICcDatastore;
-typedef ICcDevice_11 ICcDevice;
-typedef ICcDeviceContainer_11 ICcDeviceContainer;
-typedef ICcObject_11 ICcObject;
-typedef ICcObjectContainer_11 ICcObjectContainer;
-typedef ICcPlatform_11 ICcPlatform;
-typedef ICcPlatformContainer_11 ICcPlatformContainer;
-typedef ICcProperty_11 ICcProperty;
-typedef ICcPropertyContainer_11 ICcPropertyContainer;
-typedef ICcServer_11 ICcServer;
-
-#endif // CCAPI_11_H
diff --git a/src/shared/corecon/ccapi_12.h b/src/shared/corecon/ccapi_12.h
deleted file mode 100644
index d4f9bb853..000000000
--- a/src/shared/corecon/ccapi_12.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CCAPI_12_H
-#define CCAPI_12_H
-
-#define CORECON_VER 12
-#include "ccapi.h"
-
-#define CLSID_ConMan CLSID_ConMan_12;
-typedef ICcCollection_12 ICcCollection;
-typedef ICcConnection_12 ICcConnection;
-typedef ICcConnection3_12 ICcConnection3;
-typedef ICcConnection4_12 ICcConnection4;
-typedef ICcDatastore_12 ICcDatastore;
-typedef ICcDevice_12 ICcDevice;
-typedef ICcDeviceContainer_12 ICcDeviceContainer;
-typedef ICcObject_12 ICcObject;
-typedef ICcObjectContainer_12 ICcObjectContainer;
-typedef ICcPlatform_12 ICcPlatform;
-typedef ICcPlatformContainer_12 ICcPlatformContainer;
-typedef ICcProperty_12 ICcProperty;
-typedef ICcPropertyContainer_12 ICcPropertyContainer;
-typedef ICcServer_12 ICcServer;
-
-#endif // CCAPI_12_H
diff --git a/src/shared/corecon/corecon.cpp b/src/shared/corecon/corecon.cpp
deleted file mode 100644
index a742205c8..000000000
--- a/src/shared/corecon/corecon.cpp
+++ /dev/null
@@ -1,466 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "corecon.h"
-
-// Force all versions of CoreCon in scope
-#ifdef CCAPI_VERSIONED_H
-#undef CCAPI_VERSIONED_H
-#endif
-#ifdef CORECON_VER
-#undef CORECON_VER
-#endif
-#define CORECON_VER 11
-#include "ccapi.h"
-
-#ifdef CCAPI_VERSIONED_H
-#undef CCAPI_VERSIONED_H
-#endif
-#ifdef CORECON_VER
-#undef CORECON_VER
-#endif
-#define CORECON_VER 12
-#include "ccapi.h"
-
-#include <QtCore/QString>
-#include <QtCore/QMutex>
-#include <QtCore/QMutexLocker>
-
-#include <comdef.h>
-#include <wrl.h>
-using namespace Microsoft::WRL;
-
-QT_USE_NAMESPACE
-
-Q_LOGGING_CATEGORY(lcCoreCon, "qt.corecon")
-
-#define wchar(str) reinterpret_cast<LPCWSTR>(str.utf16())
-
-template <typename ObjectContainerType, typename ContainerType, typename CollectionType>
-static inline HRESULT collectionFor(const ComPtr<ContainerType> &container, ComPtr<CollectionType> &collection)
-{
- ComPtr<ObjectContainerType> objectContainer;
- HRESULT hr = container.As(&objectContainer);
- if (FAILED(hr))
- return hr;
- hr = objectContainer->EnumerateObjects(&collection);
- return hr;
-}
-
-class CoreConDevicePrivate
-{
-public:
- QString name;
- QString id;
- bool isEmulator;
- int version;
-
-protected:
- CoreConDevicePrivate(int version) : version(version) { }
-};
-
-template <typename DeviceType>
-class CoreConDevicePrivateVersioned : public CoreConDevicePrivate
-{
-public:
- CoreConDevicePrivateVersioned(int version) : CoreConDevicePrivate(version) { }
- ComPtr<DeviceType> handle;
-};
-
-CoreConDevice::CoreConDevice(int version)
-{
- if (version == 11)
- d_ptr.reset(new CoreConDevicePrivateVersioned<ICcDevice_11>(version));
- else if (version == 12)
- d_ptr.reset(new CoreConDevicePrivateVersioned<ICcDevice_12>(version));
- else
- qCCritical(lcCoreCon) << "Invalid CoreCon version specified:" << version;
-}
-
-CoreConDevice::~CoreConDevice()
-{
-}
-
-QString CoreConDevice::name() const
-{
- Q_D(const CoreConDevice);
- return d->name;
-}
-
-QString CoreConDevice::id() const
-{
- Q_D(const CoreConDevice);
- return d->id;
-}
-
-bool CoreConDevice::isEmulator() const
-{
- Q_D(const CoreConDevice);
- return d->isEmulator;
-}
-
-Qt::HANDLE CoreConDevice::handle() const
-{
- Q_D(const CoreConDevice);
- if (d->version == 11)
- return static_cast<const CoreConDevicePrivateVersioned<ICcDevice_11> *>(d)->handle.Get();
- if (d->version == 12)
- return static_cast<const CoreConDevicePrivateVersioned<ICcDevice_12> *>(d)->handle.Get();
- return 0;
-}
-
-class ComInitializer
-{
-protected:
- ComInitializer()
- {
- hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
- if (FAILED(hr))
- qCDebug(lcCoreCon) << "Failed to initialize COM.";
- }
- virtual ~ComInitializer()
- {
- if (SUCCEEDED(hr))
- CoUninitialize();
- }
- HRESULT hr;
-};
-
-class CoreConServerPrivate : private ComInitializer
-{
-public:
- CoreConServerPrivate(int version) : version(version), langModule(0)
- {
- }
- ~CoreConServerPrivate()
- {
- qDeleteAll(devices);
- devices.clear();
- }
-
- virtual bool initialize() = 0;
-
- int version;
- QList<CoreConDevice *> devices;
- HMODULE langModule;
-
- template <typename T>
- static CoreConDevicePrivateVersioned<T> *deviceHandle(CoreConDevice *device)
- {
- return static_cast<CoreConDevicePrivateVersioned<T> *>(device->d_ptr.data());
- }
-};
-
-template <typename ServerType, typename DataStoreType, typename PlatformType,
- typename PlatformContainerType, typename CollectionType, typename DeviceType, typename DeviceContainerType,
- typename ObjectType, typename ObjectContainerType, typename PropertyType, typename PropertyContainerType>
-class CoreConServerPrivateVersioned : public CoreConServerPrivate
-{
-public:
- CoreConServerPrivateVersioned(CoreConServer *server, int version)
- : CoreConServerPrivate(version)
- {
- HRESULT hr = E_FAIL;
- if (version == 11)
- hr = CoCreateInstance(CLSID_ConMan_11, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&handle));
- else if (version == 12)
- hr = CoCreateInstance(CLSID_ConMan_12, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&handle));
- else
- qCCritical(lcCoreCon) << "Invalid CoreCon version specified:" << version;
-
- if (FAILED(hr))
- qCWarning(lcCoreCon) << "Failed to initialize connection server." << server->formatError(hr);
-
- // The language module is available as long as the above succeeded
- langModule = GetModuleHandle(L"conmanui");
- }
-
- bool initialize()
- {
- ComPtr<DataStoreType> dataStore;
- HRESULT hr = handle->GetDatastore(GetUserDefaultLCID(), &dataStore);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the data store. HRESULT: 0x%x", hr);
- return false;
- }
-
- ComPtr<PlatformContainerType> platformContainer;
- hr = dataStore->get_PlatformContainer(&platformContainer);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the platform container. HRESULT: 0x%x", hr);
- return false;
- }
-
- ComPtr<CollectionType> platformCollection;
- hr = collectionFor<ObjectContainerType>(platformContainer, platformCollection);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the platform collection. HRESULT: 0x%x", hr);
- return false;
- }
-
- long platformCount;
- hr = platformCollection->get_Count(&platformCount);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the platform object count. HRESULT: 0x%x", hr);
- return false;
- }
- for (long platformIndex = 0; platformIndex < platformCount; ++platformIndex) {
- ComPtr<ObjectType> platformObject;
- hr = platformCollection->get_Item(platformIndex, &platformObject);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "\1: %d", platformIndex);
- continue;
- }
-
- ComPtr<PlatformType> platform;
- hr = platformObject.As(&platform);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "\1: %d", platformIndex);
- continue;
- }
-
- ComPtr<DeviceContainerType> deviceContainer;
- hr = platform->get_DeviceContainer(&deviceContainer);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the device container.. 0x%x", hr);
- continue;
- }
-
- ComPtr<CollectionType> deviceCollection;
- hr = collectionFor<ObjectContainerType>(deviceContainer, deviceCollection);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the device object collection.. 0x%x", hr);
- continue;
- }
-
- long deviceCount;
- hr = deviceCollection->get_Count(&deviceCount);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the device object count.. 0x%x", hr);
- continue;
- }
- for (long deviceIndex = 0; deviceIndex < deviceCount; ++deviceIndex) {
- std::unique_ptr<CoreConDevice> device(new CoreConDevice(version));
-
- ComPtr<ObjectType> deviceObject;
- hr = deviceCollection->get_Item(deviceIndex, &deviceObject);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the device object at index: %d", deviceIndex);
- continue;
- }
-
- hr = deviceObject.As(&deviceHandle<DeviceType>(device.get())->handle);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to confirm a device from the object at index: %d", deviceIndex);
- continue;
- }
-
- _bstr_t deviceId;
- hr = deviceObject->get_ID(deviceId.GetAddress());
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain device id at index: %d", deviceIndex);
- continue;
- }
- deviceHandle<DeviceType>(device.get())->id = QString::fromWCharArray(deviceId);
- _bstr_t deviceName;
- hr = deviceObject->get_Name(deviceName.GetAddress());
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain device name at index: %d", deviceIndex);
- continue;
- }
- deviceHandle<DeviceType>(device.get())->name = QString::fromWCharArray(deviceName);
-
- ComPtr<PropertyContainerType> propertyContainer;
- hr = deviceObject->get_PropertyContainer(&propertyContainer);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain a property container at index: %d", deviceIndex);
- continue;
- }
-
- ComPtr<CollectionType> propertyCollection;
- hr = collectionFor<ObjectContainerType>(propertyContainer, propertyCollection);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain property collection of device at index: %d", deviceIndex);
- continue;
- }
-
- bool isPseudoDevice = false;
- long propertyCount;
- hr = propertyCollection->get_Count(&propertyCount);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain property count of device at index: %d", deviceIndex);
- continue;
- }
-
- for (long propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex) {
- ComPtr<ObjectType> propertyObject;
- hr = propertyCollection->get_Item(propertyIndex, &propertyObject);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain property at index: %d", propertyIndex);
- continue;
- }
-
- _bstr_t id;
- hr = propertyObject->get_ID(id.GetAddress());
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain property id at index: %d", propertyIndex);
- continue;
- }
-
- ComPtr<PropertyType> property;
- hr = propertyObject.As(&property);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to cast the property object at index: %d", propertyIndex);
- continue;
- }
-
- if (id == _bstr_t(L"IsPseudoDevice")) {
- _bstr_t value;
- hr = property->get_Value(value.GetAddress());
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to cast the property value at index: %d", propertyIndex);
- continue;
- }
- if (value == _bstr_t(L"true")) {
- isPseudoDevice = true;
- break; // No need to look at this device further
- }
- }
-
- if (id == _bstr_t(L"Emulator")) {
- _bstr_t value;
- hr = property->get_Value(value.GetAddress());
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to cast the property value at index: %d", propertyIndex);
- continue;
- }
- deviceHandle<DeviceType>(device.get())->isEmulator = value == _bstr_t(L"true");
- }
- }
-
- if (!isPseudoDevice)
- devices.append(device.release());
- }
- }
- return true;
- }
-
- ComPtr<ServerType> handle;
-};
-
-typedef CoreConServerPrivateVersioned<ICcServer_11, ICcDatastore_11, ICcPlatform_11,
- ICcPlatformContainer_11, ICcCollection_11, ICcDevice_11, ICcDeviceContainer_11,
- ICcObject_11, ICcObjectContainer_11,
- ICcProperty_11, ICcPropertyContainer_11> CoreConServerPrivate_11;
-
-typedef CoreConServerPrivateVersioned<ICcServer_12, ICcDatastore_12, ICcPlatform_12,
- ICcPlatformContainer_12, ICcCollection_12, ICcDevice_12, ICcDeviceContainer_12,
- ICcObject_12, ICcObjectContainer_12,
- ICcProperty_12, ICcPropertyContainer_12> CoreConServerPrivate_12;
-
-CoreConServer::CoreConServer(int version)
-{
- if (version == 11)
- d_ptr.reset(new CoreConServerPrivate_11(this, version));
- else if (version == 12)
- d_ptr.reset(new CoreConServerPrivate_12(this, version));
- else
- qCCritical(lcCoreCon) << "Invalid CoreCon version specified:" << version;
-
- initialize();
-}
-
-CoreConServer::~CoreConServer()
-{
-}
-
-Qt::HANDLE CoreConServer::handle() const
-{
- Q_D(const CoreConServer);
- if (d->version == 11)
- return static_cast<const CoreConServerPrivate_11 *>(d)->handle.Get();
- if (d->version == 12)
- return static_cast<const CoreConServerPrivate_12 *>(d)->handle.Get();
- return 0;
-}
-
-QList<CoreConDevice *> CoreConServer::devices() const
-{
- Q_D(const CoreConServer);
- return d->devices;
-}
-
-bool CoreConServer::initialize()
-{
- Q_D(CoreConServer);
- if (!d || !handle())
- return false;
-
- if (!d->devices.isEmpty())
- return true;
-
- return d->initialize();
-}
-
-QString CoreConServer::formatError(HRESULT hr) const
-{
- Q_D(const CoreConServer);
- wchar_t error[1024];
- HMODULE module = 0;
- DWORD origin = HRESULT_FACILITY(hr);
- if (origin == 0x973 || origin == 0x974 || origin == 0x103)
- module = d->langModule;
- if (module) {
- int length = LoadString(module, HRESULT_CODE(hr), error, sizeof(error)/sizeof(wchar_t));
- if (length)
- return QString::fromWCharArray(error, length).trimmed();
- }
- return qt_error_string(hr);
-}
diff --git a/src/shared/corecon/corecon.h b/src/shared/corecon/corecon.h
deleted file mode 100644
index 39d8f32a1..000000000
--- a/src/shared/corecon/corecon.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CORECON_H
-#define CORECON_H
-
-#include <QtCore/qt_windows.h>
-#include <QtCore/QList>
-#include <QtCore/QScopedPointer>
-#include <QtCore/QLoggingCategory>
-
-QT_USE_NAMESPACE
-
-class CoreConDevicePrivate;
-class CoreConDevice
-{
-public:
- explicit CoreConDevice(int version);
- ~CoreConDevice();
- QString name() const;
- QString id() const;
- bool isEmulator() const;
- Qt::HANDLE handle() const;
-private:
- QScopedPointer<CoreConDevicePrivate> d_ptr;
- Q_DECLARE_PRIVATE(CoreConDevice)
-friend class CoreConServerPrivate;
-};
-
-class CoreConServerPrivate;
-class CoreConServer
-{
-public:
- explicit CoreConServer(int version);
- ~CoreConServer();
- bool initialize();
- Qt::HANDLE handle() const;
- QList<CoreConDevice *> devices() const;
- QString formatError(HRESULT hr) const;
-private:
- QScopedPointer<CoreConServerPrivate> d_ptr;
- Q_DECLARE_PRIVATE(CoreConServer)
-};
-
-Q_DECLARE_LOGGING_CATEGORY(lcCoreCon)
-
-#endif // CORECON_H
diff --git a/src/shared/deviceskin/deviceskin.cpp b/src/shared/deviceskin/deviceskin.cpp
index 3d936cccd..2c6df22c1 100644
--- a/src/shared/deviceskin/deviceskin.cpp
+++ b/src/shared/deviceskin/deviceskin.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "deviceskin.h"
@@ -55,14 +19,16 @@
#include <QtCore/QDebug>
#ifdef TEST_SKIN
-# include <QtGui/QMainWindow>
-# include <QtGui/QDialog>
-# include <QtGui/QDialogButtonBox>
-# include <QtGui/QHBoxLayout>
+# include <QtWidgets/QMainWindow>
+# include <QtWidgets/QDialog>
+# include <QtWidgets/QDialogButtonBox>
+# include <QtWidgets/QHBoxLayout>
#endif
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace {
enum { joydistance = 10, key_repeat_period = 50, key_repeat_delay = 500 };
enum { debugDeviceSkin = 0 };
@@ -117,7 +83,7 @@ bool DeviceSkinParameters::read(const QString &skinDirectory, ReadMode rm, QSt
// Figure out the name. remove ending '/' if present
QString skinFile = skinDirectory;
if (skinFile.endsWith(QLatin1Char('/')))
- skinFile.truncate(skinFile.length() - 1);
+ skinFile.truncate(skinFile.size() - 1);
QFileInfo fi(skinFile);
QString fn;
@@ -126,7 +92,7 @@ bool DeviceSkinParameters::read(const QString &skinDirectory, ReadMode rm, QSt
prefix += QLatin1Char('/');
fn = prefix;
fn += fi.baseName();
- fn += QLatin1String(".skin");
+ fn += ".skin"_L1;
} else if (fi.isFile()){
fn = skinFile;
prefix = fi.path();
@@ -143,7 +109,8 @@ bool DeviceSkinParameters::read(const QString &skinDirectory, ReadMode rm, QSt
QTextStream ts(&f);
const bool rc = read(ts, rm, errorMessage);
if (!rc)
- *errorMessage = DeviceSkin::tr("The skin configuration file '%1' could not be read: %2").arg(fn).arg(*errorMessage);
+ *errorMessage = DeviceSkin::tr("The skin configuration file '%1' could not be read: %2")
+ .arg(fn, *errorMessage);
return rc;
}
bool DeviceSkinParameters::read(QTextStream &ts, ReadMode rm, QString *errorMessage)
@@ -156,31 +123,31 @@ bool DeviceSkinParameters::read(QTextStream &ts, ReadMode rm, QString *errorMess
QString mark;
ts >> mark;
hasMouseHover = true; // historical default
- if ( mark == QLatin1String("[SkinFile]") ) {
- const QString UpKey = QLatin1String("Up");
- const QString DownKey = QLatin1String("Down");
- const QString ClosedKey = QLatin1String("Closed");
- const QString ClosedAreasKey = QLatin1String("ClosedAreas");
- const QString ScreenKey = QLatin1String("Screen");
- const QString ScreenDepthKey = QLatin1String("ScreenDepth");
- const QString BackScreenKey = QLatin1String("BackScreen");
- const QString ClosedScreenKey = QLatin1String("ClosedScreen");
- const QString CursorKey = QLatin1String("Cursor");
- const QString AreasKey = QLatin1String("Areas");
- const QString ToggleAreasKey = QLatin1String("ToggleAreas");
- const QString ToggleActiveAreasKey = QLatin1String("ToggleActiveAreas");
- const QString HasMouseHoverKey = QLatin1String("HasMouseHover");
+ if (mark == "[SkinFile]"_L1) {
+ const QString UpKey = "Up"_L1;
+ const QString DownKey = "Down"_L1;
+ const QString ClosedKey = "Closed"_L1;
+ const QString ClosedAreasKey = "ClosedAreas"_L1;
+ const QString ScreenKey = "Screen"_L1;
+ const QString ScreenDepthKey = "ScreenDepth"_L1;
+ const QString BackScreenKey = "BackScreen"_L1;
+ const QString ClosedScreenKey = "ClosedScreen"_L1;
+ const QString CursorKey = "Cursor"_L1;
+ const QString AreasKey = "Areas"_L1;
+ const QString ToggleAreasKey = "ToggleAreas"_L1;
+ const QString ToggleActiveAreasKey = "ToggleActiveAreas"_L1;
+ const QString HasMouseHoverKey = "HasMouseHover"_L1;
// New
while (!nareas) {
QString line = ts.readLine();
if ( line.isNull() )
break;
- if ( line[0] != QLatin1Char('#') && !line.isEmpty() ) {
+ if (!line.isEmpty() && line.at(0) != u'#') {
int eq = line.indexOf(QLatin1Char('='));
if ( eq >= 0 ) {
const QString key = line.left(eq);
eq++;
- while (eq<line.length()-1 && line[eq].isSpace())
+ while (eq<line.size()-1 && line[eq].isSpace())
eq++;
const QString value = line.mid(eq);
if ( key == UpKey ) {
@@ -210,7 +177,7 @@ bool DeviceSkinParameters::read(QTextStream &ts, ReadMode rm, QString *errorMess
} else if ( key == ToggleActiveAreasKey ) {
toggleActiveAreas = value.split(QLatin1Char(' '));
} else if ( key == HasMouseHoverKey ) {
- hasMouseHover = value == QLatin1String("true") || value == QLatin1String("1");
+ hasMouseHover = value == "true"_L1 || value == "1"_L1;
}
} else {
*errorMessage = DeviceSkin::tr("Syntax error: %1").arg(line);
@@ -284,8 +251,8 @@ bool DeviceSkinParameters::read(QTextStream &ts, ReadMode rm, QString *errorMess
int i = 0;
ts.readLine(); // eol
joystick = -1;
- const QString Joystick = QLatin1String("Joystick");
- const QRegularExpression splitRe(QLatin1String("[ \t][ \t]*"));
+ const QString Joystick = "Joystick"_L1;
+ const QRegularExpression splitRe("[ \t][ \t]*"_L1);
Q_ASSERT(splitRe.isValid());
while (i < nareas && !ts.atEnd() ) {
buttonAreas.push_back(DeviceSkinButtonArea());
@@ -293,20 +260,20 @@ bool DeviceSkinParameters::read(QTextStream &ts, ReadMode rm, QString *errorMess
const QString line = ts.readLine();
if ( !line.isEmpty() && line[0] != QLatin1Char('#') ) {
const QStringList tok = line.split(splitRe);
- if ( tok.count()<6 ) {
+ if ( tok.size()<6 ) {
*errorMessage = DeviceSkin::tr("Syntax error in area definition: %1").arg(line);
return false;
} else {
area.name = tok[0];
QString k = tok[1];
- if ( k.left(2).toLower() == QLatin1String("0x")) {
+ if ( k.left(2).toLower() == "0x"_L1) {
area.keyCode = k.mid(2).toInt(0,16);
} else {
area.keyCode = k.toInt();
}
int p=0;
- for (int j=2; j < tok.count() - 1; ) {
+ for (int j=2; j < tok.size() - 1; ) {
const int x = tok[j++].toInt();
const int y = tok[j++].toInt();
area.area.putPoints(p++,1,x,y);
@@ -317,7 +284,7 @@ bool DeviceSkinParameters::read(QTextStream &ts, ReadMode rm, QString *errorMess
area.name.truncate(area.name.size() - 1);
area.name.remove(0, 1);
}
- if ( area.name.length() == 1 )
+ if ( area.name.size() == 1 )
area.text = area.name;
if ( area.name == Joystick)
joystick = i;
@@ -406,8 +373,8 @@ void DeviceSkin::calcRegions()
{
const int numAreas = m_parameters.buttonAreas.size();
for (int i=0; i<numAreas; i++) {
- QPolygon xa(m_parameters.buttonAreas[i].area.count());
- int n = m_parameters.buttonAreas[i].area.count();
+ QPolygon xa(m_parameters.buttonAreas[i].area.size());
+ int n = m_parameters.buttonAreas[i].area.size();
for (int p = 0; p < n; p++) {
xa.setPoint(p,transform.map(m_parameters.buttonAreas[i].area[p]));
}
@@ -539,17 +506,17 @@ void DeviceSkin::paintEvent( QPaintEvent *)
if ( buttonPressed == true ) {
toDraw += buttonIndex;
}
- for (int toggle : qAsConst(m_parameters.toggleAreaList)) {
+ for (int toggle : std::as_const(m_parameters.toggleAreaList)) {
const DeviceSkinButtonArea &ba = m_parameters.buttonAreas[toggle];
if (flipped_open || ba.activeWhenClosed) {
if (ba.toggleArea && ba.toggleActiveArea)
toDraw += toggle;
}
}
- for (int button : qAsConst(toDraw)) {
+ for (int button : std::as_const(toDraw)) {
const DeviceSkinButtonArea &ba = m_parameters.buttonAreas[button];
const QRect r = buttonRegions[button].boundingRect();
- if ( ba.area.count() > 2 )
+ if ( ba.area.size() > 2 )
p.setClipRegion(buttonRegions[button]);
p.drawPixmap( r.topLeft(), skinImageDown, r);
}
@@ -826,16 +793,16 @@ int main(int argc,char *argv[])
QHBoxLayout *dialogLayout = new QHBoxLayout();
dialog->setLayout(dialogLayout);
QDialogButtonBox *dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
- QObject::connect(dialogButtonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
- QObject::connect(dialogButtonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
+ QObject::connect(dialogButtonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
+ QObject::connect(dialogButtonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
dialogLayout->addWidget(dialogButtonBox);
dialog->setFixedSize(params.screenSize());
dialog->setParent(&ds, Qt::SubWindow);
dialog->setAutoFillBackground(true);
ds.setView(dialog);
- QObject::connect(&ds, SIGNAL(popupMenu()), &mw, SLOT(close()));
- QObject::connect(&ds, SIGNAL(skinKeyPressEvent(int,QString,bool)), &mw, SLOT(close()));
+ QObject::connect(&ds, &DeviceSkin::popupMenu, &mw, &QWidget::close);
+ QObject::connect(&ds, &DeviceSkin::skinKeyPressEvent, &mw, &QWidget::close);
mw.show();
return app.exec();
}
diff --git a/src/shared/deviceskin/deviceskin.h b/src/shared/deviceskin/deviceskin.h
index 2f7d09510..2c27d9b4a 100644
--- a/src/shared/deviceskin/deviceskin.h
+++ b/src/shared/deviceskin/deviceskin.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef SKIN_H
#define SKIN_H
diff --git a/src/shared/deviceskin/skins/ClamshellPhone.qrc b/src/shared/deviceskin/skins/ClamshellPhone.qrc
deleted file mode 100644
index 39cd42274..000000000
--- a/src/shared/deviceskin/skins/ClamshellPhone.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/skins">
- <file>ClamshellPhone.skin</file>
-</qresource>
-</RCC>
diff --git a/src/shared/deviceskin/skins/PortableMedia.qrc b/src/shared/deviceskin/skins/PortableMedia.qrc
deleted file mode 100644
index a902f1a73..000000000
--- a/src/shared/deviceskin/skins/PortableMedia.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/skins">
- <file>PortableMedia.skin</file>
-</qresource>
-</RCC>
diff --git a/src/shared/deviceskin/skins/S60-QVGA-Candybar.qrc b/src/shared/deviceskin/skins/S60-QVGA-Candybar.qrc
deleted file mode 100644
index 813848479..000000000
--- a/src/shared/deviceskin/skins/S60-QVGA-Candybar.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/skins">
- <file>S60-QVGA-Candybar.skin</file>
-</qresource>
-</RCC>
diff --git a/src/shared/deviceskin/skins/S60-nHD-Touchscreen.qrc b/src/shared/deviceskin/skins/S60-nHD-Touchscreen.qrc
deleted file mode 100644
index daf0cc363..000000000
--- a/src/shared/deviceskin/skins/S60-nHD-Touchscreen.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/skins">
- <file>S60-nHD-Touchscreen.skin</file>
-</qresource>
-</RCC>
diff --git a/src/shared/deviceskin/skins/SmartPhone.qrc b/src/shared/deviceskin/skins/SmartPhone.qrc
deleted file mode 100644
index 8bb53259a..000000000
--- a/src/shared/deviceskin/skins/SmartPhone.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/skins">
- <file>SmartPhone.skin</file>
-</qresource>
-</RCC>
diff --git a/src/shared/deviceskin/skins/SmartPhone2.qrc b/src/shared/deviceskin/skins/SmartPhone2.qrc
deleted file mode 100644
index 751e9852b..000000000
--- a/src/shared/deviceskin/skins/SmartPhone2.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/skins">
- <file>SmartPhone2.skin</file>
-</qresource>
-</RCC>
diff --git a/src/shared/deviceskin/skins/SmartPhoneWithButtons.qrc b/src/shared/deviceskin/skins/SmartPhoneWithButtons.qrc
deleted file mode 100644
index f3393ba9d..000000000
--- a/src/shared/deviceskin/skins/SmartPhoneWithButtons.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/skins">
- <file>SmartPhoneWithButtons.skin</file>
-</qresource>
-</RCC>
diff --git a/src/shared/deviceskin/skins/TouchscreenPhone.qrc b/src/shared/deviceskin/skins/TouchscreenPhone.qrc
deleted file mode 100644
index 023144d2f..000000000
--- a/src/shared/deviceskin/skins/TouchscreenPhone.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/skins">
- <file>TouchscreenPhone.skin</file>
-</qresource>
-</RCC>
diff --git a/src/shared/findwidget/abstractfindwidget.cpp b/src/shared/findwidget/abstractfindwidget.cpp
index f627f6b25..1944beaf1 100644
--- a/src/shared/findwidget/abstractfindwidget.cpp
+++ b/src/shared/findwidget/abstractfindwidget.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
/*! \class AbstractFindWidget
@@ -71,7 +35,9 @@
QT_BEGIN_NAMESPACE
-static QIcon createIconSet(const QString &name)
+using namespace Qt::StringLiterals;
+
+static QIcon afwCreateIconSet(const QString &name)
{
QStringList candidates = QStringList()
<< (QString::fromUtf8(":/qt-project.org/shared/images/") + name)
@@ -81,7 +47,7 @@ static QIcon createIconSet(const QString &name)
<< (QString::fromUtf8(":/qt-project.org/shared/images/win/") + name);
#endif
- for (const QString &f : qAsConst(candidates)) {
+ for (const QString &f : std::as_const(candidates)) {
if (QFile::exists(f))
return QIcon(f);
}
@@ -113,32 +79,32 @@ AbstractFindWidget::AbstractFindWidget(FindFlags flags, QWidget *parent)
#endif
m_toolClose = new QToolButton(this);
- m_toolClose->setIcon(createIconSet(QLatin1String("closetab.png")));
+ m_toolClose->setIcon(afwCreateIconSet("closetab.png"_L1));
m_toolClose->setAutoRaise(true);
layOut->addWidget(m_toolClose);
- connect(m_toolClose, SIGNAL(clicked()), SLOT(deactivate()));
+ connect(m_toolClose, &QAbstractButton::clicked, this, &AbstractFindWidget::deactivate);
m_editFind = new QLineEdit(this);
layOut->addWidget(m_editFind);
- connect(m_editFind, SIGNAL(returnPressed()), SLOT(findNext()));
- connect(m_editFind, SIGNAL(textChanged(QString)), SLOT(findCurrentText()));
- connect(m_editFind, SIGNAL(textChanged(QString)), SLOT(updateButtons()));
+ connect(m_editFind, &QLineEdit::returnPressed, this, &AbstractFindWidget::findNext);
+ connect(m_editFind, &QLineEdit::textChanged, this, &AbstractFindWidget::findCurrentText);
+ connect(m_editFind, &QLineEdit::textChanged, this, &AbstractFindWidget::updateButtons);
m_toolPrevious = new QToolButton(this);
m_toolPrevious->setAutoRaise(true);
m_toolPrevious->setText(tr("&Previous"));
m_toolPrevious->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
- m_toolPrevious->setIcon(createIconSet(QLatin1String("previous.png")));
+ m_toolPrevious->setIcon(afwCreateIconSet("previous.png"_L1));
layOut->addWidget(m_toolPrevious);
- connect(m_toolPrevious, SIGNAL(clicked()), SLOT(findPrevious()));
+ connect(m_toolPrevious, &QAbstractButton::clicked, this, &AbstractFindWidget::findPrevious);
m_toolNext = new QToolButton(this);
m_toolNext->setAutoRaise(true);
m_toolNext->setText(tr("&Next"));
m_toolNext->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
- m_toolNext->setIcon(createIconSet(QLatin1String("next.png")));
+ m_toolNext->setIcon(afwCreateIconSet("next.png"_L1));
layOut->addWidget(m_toolNext);
- connect(m_toolNext, SIGNAL(clicked()), SLOT(findNext()));
+ connect(m_toolNext, &QAbstractButton::clicked, this, &AbstractFindWidget::findNext);
if (flags & NarrowLayout) {
QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Fixed);
@@ -160,7 +126,8 @@ AbstractFindWidget::AbstractFindWidget(FindFlags flags, QWidget *parent)
if (!(flags & NoCaseSensitive)) {
m_checkCase = new QCheckBox(tr("&Case sensitive"), this);
layOut->addWidget(m_checkCase);
- connect(m_checkCase, SIGNAL(toggled(bool)), SLOT(findCurrentText()));
+ connect(m_checkCase, &QAbstractButton::toggled,
+ this, &AbstractFindWidget::findCurrentText);
} else {
m_checkCase = 0;
}
@@ -168,7 +135,8 @@ AbstractFindWidget::AbstractFindWidget(FindFlags flags, QWidget *parent)
if (!(flags & NoWholeWords)) {
m_checkWholeWords = new QCheckBox(tr("Whole &words"), this);
layOut->addWidget(m_checkWholeWords);
- connect(m_checkWholeWords, SIGNAL(toggled(bool)), SLOT(findCurrentText()));
+ connect(m_checkWholeWords, &QAbstractButton::toggled,
+ this, &AbstractFindWidget::findCurrentText);
} else {
m_checkWholeWords = 0;
}
@@ -203,7 +171,7 @@ AbstractFindWidget::~AbstractFindWidget() = default;
*/
QIcon AbstractFindWidget::findIconSet()
{
- return createIconSet(QLatin1String("searchfind.png"));
+ return afwCreateIconSet("searchfind.png"_L1);
}
/*!
diff --git a/src/shared/findwidget/abstractfindwidget.h b/src/shared/findwidget/abstractfindwidget.h
index 5e04456c9..ca3ad0d0c 100644
--- a/src/shared/findwidget/abstractfindwidget.h
+++ b/src/shared/findwidget/abstractfindwidget.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef ABSTRACTFINDWIDGET_H
#define ABSTRACTFINDWIDGET_H
diff --git a/src/shared/findwidget/findwidget.qrc b/src/shared/findwidget/findwidget.qrc
deleted file mode 100644
index 8abc2d8e9..000000000
--- a/src/shared/findwidget/findwidget.qrc
+++ /dev/null
@@ -1,14 +0,0 @@
-<RCC>
- <qresource prefix="/qt-project.org/shared">
- <file>images/mac/closetab.png</file>
- <file>images/mac/next.png</file>
- <file>images/mac/previous.png</file>
- <file>images/mac/searchfind.png</file>
- <file>images/win/closetab.png</file>
- <file>images/win/next.png</file>
- <file>images/win/previous.png</file>
- <file>images/win/searchfind.png</file>
- <file>images/wrap.png</file>
- </qresource>
-</RCC>
-
diff --git a/src/shared/findwidget/itemviewfindwidget.cpp b/src/shared/findwidget/itemviewfindwidget.cpp
index 3ab73f094..3981a4952 100644
--- a/src/shared/findwidget/itemviewfindwidget.cpp
+++ b/src/shared/findwidget/itemviewfindwidget.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
/*! \class ItemViewFindWidget
@@ -71,6 +35,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
Constructs a ItemViewFindWidget.
@@ -302,8 +268,8 @@ QModelIndex ItemViewFindWidget::findHelper(const QString &textToFind, bool skipC
Qt::CaseSensitivity cs = caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
if (wholeWords()) {
- QString rx = QLatin1String("\\b") + QRegularExpression::escape(textToFind)
- + QLatin1String("\\b");
+ QString rx = "\\b"_L1 + QRegularExpression::escape(textToFind)
+ + "\\b"_L1;
QRegularExpression re(rx);
if (cs == Qt::CaseInsensitive)
re.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
diff --git a/src/shared/findwidget/itemviewfindwidget.h b/src/shared/findwidget/itemviewfindwidget.h
index 07b45a6de..dee3bc31d 100644
--- a/src/shared/findwidget/itemviewfindwidget.h
+++ b/src/shared/findwidget/itemviewfindwidget.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef ITEMVIEWFINDWIDGET_H
#define ITEMVIEWFINDWIDGET_H
diff --git a/src/shared/findwidget/texteditfindwidget.cpp b/src/shared/findwidget/texteditfindwidget.cpp
index bb3c5d4e3..1b3a1b53f 100644
--- a/src/shared/findwidget/texteditfindwidget.cpp
+++ b/src/shared/findwidget/texteditfindwidget.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
/*! \class TextEditFindWidget
diff --git a/src/shared/findwidget/texteditfindwidget.h b/src/shared/findwidget/texteditfindwidget.h
index 6e676f41d..603ab65ac 100644
--- a/src/shared/findwidget/texteditfindwidget.h
+++ b/src/shared/findwidget/texteditfindwidget.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef TEXTEDITFINDWIDGET_H
#define TEXTEDITFINDWIDGET_H
diff --git a/src/shared/fontpanel/fontpanel.cpp b/src/shared/fontpanel/fontpanel.cpp
index 7bd51aa54..9a0d892d6 100644
--- a/src/shared/fontpanel/fontpanel.cpp
+++ b/src/shared/fontpanel/fontpanel.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "fontpanel.h"
@@ -49,6 +13,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
FontPanel::FontPanel(QWidget *parentWidget) :
QGroupBox(parentWidget),
m_previewLineEdit(new QLineEdit),
@@ -66,7 +32,7 @@ FontPanel::FontPanel(QWidget *parentWidget) :
auto writingSystems = QFontDatabase::writingSystems();
writingSystems.push_front(QFontDatabase::Any);
- for (QFontDatabase::WritingSystem ws : qAsConst(writingSystems))
+ for (QFontDatabase::WritingSystem ws : std::as_const(writingSystems))
m_writingSystemComboBox->addItem(QFontDatabase::writingSystemName(ws), QVariant(ws));
connect(m_writingSystemComboBox, &QComboBox::currentIndexChanged,
this, &FontPanel::slotWritingSystemChanged);
@@ -98,9 +64,9 @@ QFont FontPanel::selectedFont() const
const QString family = rc.family();
rc.setPointSize(pointSize());
const QString styleDescription = styleString();
- if (styleDescription.contains(QLatin1String("Italic")))
+ if (styleDescription.contains("Italic"_L1))
rc.setStyle(QFont::StyleItalic);
- else if (styleDescription.contains(QLatin1String("Oblique")))
+ else if (styleDescription.contains("Oblique"_L1))
rc.setStyle(QFont::StyleOblique);
else
rc.setStyle(QFont::StyleNormal);
@@ -216,7 +182,7 @@ void FontPanel::updateFamily(const QString &family)
m_styleComboBox->setEnabled(hasStyles);
int normalIndex = -1;
- const QString normalStyle = QLatin1String("Normal");
+ const QString normalStyle = "Normal"_L1;
if (hasStyles) {
for (const QString &style : styles) {
@@ -277,7 +243,7 @@ void FontPanel::updatePointSizes(const QString &family, const QString &styleStri
// try to maintain selection or select closest.
if (hasSizes) {
QString n;
- for (int pointSize : qAsConst(pointSizes))
+ for (int pointSize : std::as_const(pointSizes))
m_pointSizeComboBox->addItem(n.setNum(pointSize), QVariant(pointSize));
const int closestIndex = closestPointSizeIndex(oldPointSize);
if (closestIndex != -1)
diff --git a/src/shared/fontpanel/fontpanel.h b/src/shared/fontpanel/fontpanel.h
index 701baa7d2..1750b4260 100644
--- a/src/shared/fontpanel/fontpanel.h
+++ b/src/shared/fontpanel/fontpanel.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
diff --git a/src/shared/qtgradienteditor/qtcolorbutton.cpp b/src/shared/qtgradienteditor/qtcolorbutton.cpp
index 33b084781..fd824ef74 100644
--- a/src/shared/qtgradienteditor/qtcolorbutton.cpp
+++ b/src/shared/qtgradienteditor/qtcolorbutton.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtcolorbutton.h"
#include <QtWidgets/QColorDialog>
@@ -47,8 +11,9 @@
QT_BEGIN_NAMESPACE
-class QtColorButtonPrivate
+class QtColorButtonPrivate : public QObject
{
+ Q_OBJECT
QtColorButton *q_ptr;
Q_DECLARE_PUBLIC(QtColorButton)
public:
@@ -124,7 +89,7 @@ QtColorButton::QtColorButton(QWidget *parent)
setAcceptDrops(true);
- connect(this, SIGNAL(clicked()), this, SLOT(slotEditColor()));
+ connect(this, &QToolButton::clicked, d_ptr.data(), &QtColorButtonPrivate::slotEditColor);
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
}
@@ -268,4 +233,4 @@ void QtColorButton::dropEvent(QDropEvent *event)
QT_END_NAMESPACE
-#include "moc_qtcolorbutton.cpp"
+#include "qtcolorbutton.moc"
diff --git a/src/shared/qtgradienteditor/qtcolorbutton.h b/src/shared/qtgradienteditor/qtcolorbutton.h
index 892b7d465..1dfe56d99 100644
--- a/src/shared/qtgradienteditor/qtcolorbutton.h
+++ b/src/shared/qtgradienteditor/qtcolorbutton.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTCOLORBUTTON_H
#define QTCOLORBUTTON_H
@@ -58,11 +22,11 @@ public:
QColor color() const;
public slots:
-
void setColor(const QColor &color);
signals:
void colorChanged(const QColor &color);
+
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
@@ -72,11 +36,11 @@ protected:
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent *event) override;
#endif
+
private:
QScopedPointer<class QtColorButtonPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtColorButton)
Q_DISABLE_COPY_MOVE(QtColorButton)
- Q_PRIVATE_SLOT(d_func(), void slotEditColor())
};
QT_END_NAMESPACE
diff --git a/src/shared/qtgradienteditor/qtcolorline.cpp b/src/shared/qtgradienteditor/qtcolorline.cpp
index d67fafe36..425e5471e 100644
--- a/src/shared/qtgradienteditor/qtcolorline.cpp
+++ b/src/shared/qtgradienteditor/qtcolorline.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtcolorline.h"
#include "qdrawutil.h"
diff --git a/src/shared/qtgradienteditor/qtcolorline.h b/src/shared/qtgradienteditor/qtcolorline.h
index a9d0d191c..24d549a8a 100644
--- a/src/shared/qtgradienteditor/qtcolorline.h
+++ b/src/shared/qtgradienteditor/qtcolorline.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTCOLORLINE_H
#define QTCOLORLINE_H
@@ -94,15 +58,12 @@ public:
ColorComponent colorComponent() const;
public slots:
-
void setColor(const QColor &color);
signals:
-
void colorChanged(const QColor &color);
protected:
-
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
@@ -111,7 +72,6 @@ protected:
void mouseDoubleClickEvent(QMouseEvent *event) override;
private:
-
QScopedPointer<class QtColorLinePrivate> d_ptr;
Q_DECLARE_PRIVATE(QtColorLine)
Q_DISABLE_COPY_MOVE(QtColorLine)
diff --git a/src/shared/qtgradienteditor/qtgradientdialog.cpp b/src/shared/qtgradienteditor/qtgradientdialog.cpp
index c47a374b4..40f3b6881 100644
--- a/src/shared/qtgradienteditor/qtgradientdialog.cpp
+++ b/src/shared/qtgradienteditor/qtgradientdialog.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientdialog.h"
#include "ui_qtgradientdialog.h"
@@ -43,12 +7,12 @@
QT_BEGIN_NAMESPACE
-class QtGradientDialogPrivate
+class QtGradientDialogPrivate : public QObject
{
+ Q_OBJECT
QtGradientDialog *q_ptr;
Q_DECLARE_PUBLIC(QtGradientDialog)
public:
-
void slotAboutToShowDetails(bool details, int extensionWidthHint);
Ui::QtGradientDialog m_ui;
@@ -205,8 +169,8 @@ QtGradientDialog::QtGradientDialog(QWidget *parent)
button = d_ptr->m_ui.buttonBox->button(QDialogButtonBox::Cancel);
if (button)
button->setAutoDefault(false);
- connect(d_ptr->m_ui.gradientEditor, SIGNAL(aboutToShowDetails(bool,int)),
- this, SLOT(slotAboutToShowDetails(bool,int)));
+ connect(d_ptr->m_ui.gradientEditor, &QtGradientEditor::aboutToShowDetails,
+ d_ptr.data(), &QtGradientDialogPrivate::slotAboutToShowDetails);
}
/*!
@@ -348,4 +312,4 @@ QGradient QtGradientDialog::getGradient(bool *ok, QWidget *parent, const QString
QT_END_NAMESPACE
-#include "moc_qtgradientdialog.cpp"
+#include "qtgradientdialog.moc"
diff --git a/src/shared/qtgradienteditor/qtgradientdialog.h b/src/shared/qtgradienteditor/qtgradientdialog.h
index 852c3a143..c2d3903c1 100644
--- a/src/shared/qtgradienteditor/qtgradientdialog.h
+++ b/src/shared/qtgradienteditor/qtgradientdialog.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTGRADIENTDIALOG_H
#define QTGRADIENTDIALOG_H
@@ -77,7 +41,6 @@ private:
QScopedPointer<class QtGradientDialogPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtGradientDialog)
Q_DISABLE_COPY_MOVE(QtGradientDialog)
- Q_PRIVATE_SLOT(d_func(), void slotAboutToShowDetails(bool details, int extensionWidthHint))
};
QT_END_NAMESPACE
diff --git a/src/shared/qtgradienteditor/qtgradientdialog.ui b/src/shared/qtgradienteditor/qtgradientdialog.ui
index e598c4a05..398754a10 100644
--- a/src/shared/qtgradienteditor/qtgradientdialog.ui
+++ b/src/shared/qtgradienteditor/qtgradientdialog.ui
@@ -1,42 +1,8 @@
<ui version="4.0" >
- <comment>*********************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-*********************************************************************</comment>
+<comment>
+* Copyright (C) 2016 The Qt Company Ltd.
+* SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+</comment>
<class>QtGradientDialog</class>
<widget class="QDialog" name="QtGradientDialog" >
<property name="geometry" >
diff --git a/src/shared/qtgradienteditor/qtgradienteditor.cpp b/src/shared/qtgradienteditor/qtgradienteditor.cpp
index 0eb096505..e6f01b59f 100644
--- a/src/shared/qtgradienteditor/qtgradienteditor.cpp
+++ b/src/shared/qtgradienteditor/qtgradienteditor.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradienteditor.h"
#include "qtgradientstopscontroller.h"
@@ -45,12 +9,17 @@
QT_BEGIN_NAMESPACE
-class QtGradientEditorPrivate
+using namespace Qt::StringLiterals;
+
+class QtGradientEditorPrivate : public QObject
{
+ Q_OBJECT
QtGradientEditor *q_ptr;
Q_DECLARE_PUBLIC(QtGradientEditor)
public:
- QtGradientEditorPrivate() : m_gradient(QLinearGradient()) {}
+ QtGradientEditorPrivate(QtGradientEditor *q);
+
+ void setBackgroundCheckered(bool checkered);
void slotGradientStopsChanged(const QGradientStops &stops);
void slotTypeChanged(int type);
@@ -89,7 +58,8 @@ public:
void setType(QGradient::Type type);
void showDetails(bool details);
- void setSpinBox(QDoubleSpinBox *spinBox, const char *slot, double max = 1.0, double step = 0.01, int decimals = 3);
+ using DoubleSlotPtr = void (QtGradientEditorPrivate::*)(double);
+ void setupSpinBox(QDoubleSpinBox *spinBox, DoubleSlotPtr slot, double max = 1.0, double step = 0.01, int decimals = 3);
void reset();
void setLayout(bool details);
void layoutDetails(bool details);
@@ -105,36 +75,131 @@ public:
Ui::QtGradientEditor m_ui;
QtGradientStopsController *m_gradientStopsController;
- QDoubleSpinBox *startLinearXSpinBox;
- QDoubleSpinBox *startLinearYSpinBox;
- QDoubleSpinBox *endLinearXSpinBox;
- QDoubleSpinBox *endLinearYSpinBox;
- QDoubleSpinBox *centralRadialXSpinBox;
- QDoubleSpinBox *centralRadialYSpinBox;
- QDoubleSpinBox *focalRadialXSpinBox;
- QDoubleSpinBox *focalRadialYSpinBox;
- QDoubleSpinBox *radiusRadialSpinBox;
- QDoubleSpinBox *centralConicalXSpinBox;
- QDoubleSpinBox *centralConicalYSpinBox;
- QDoubleSpinBox *angleConicalSpinBox;
-
- QButtonGroup *m_typeGroup;
- QButtonGroup *m_spreadGroup;
-
- QGradient::Type m_type;
-
- QGridLayout *m_gridLayout;
- QWidget *m_hiddenWidget;
- QGridLayout *m_hiddenLayout;
- bool m_details;
- bool m_detailsButtonVisible;
- bool m_backgroundCheckered;
+ QDoubleSpinBox *startLinearXSpinBox = nullptr;
+ QDoubleSpinBox *startLinearYSpinBox = nullptr;
+ QDoubleSpinBox *endLinearXSpinBox = nullptr;
+ QDoubleSpinBox *endLinearYSpinBox = nullptr;
+ QDoubleSpinBox *centralRadialXSpinBox = nullptr;
+ QDoubleSpinBox *centralRadialYSpinBox = nullptr;
+ QDoubleSpinBox *focalRadialXSpinBox = nullptr;
+ QDoubleSpinBox *focalRadialYSpinBox = nullptr;
+ QDoubleSpinBox *radiusRadialSpinBox = nullptr;
+ QDoubleSpinBox *centralConicalXSpinBox = nullptr;
+ QDoubleSpinBox *centralConicalYSpinBox = nullptr;
+ QDoubleSpinBox *angleConicalSpinBox = nullptr;
+
+ QButtonGroup *m_typeGroup = nullptr;
+ QButtonGroup *m_spreadGroup = nullptr;
+
+ QGradient::Type m_type = QGradient::RadialGradient;
+
+ QGridLayout *m_gridLayout = nullptr;
+ QWidget *m_hiddenWidget = nullptr;
+ QGridLayout *m_hiddenLayout = nullptr;
+ bool m_details = false;
+ bool m_detailsButtonVisible = true;
+ bool m_backgroundCheckered = true;
QGradient m_gradient;
- bool m_combos;
+ bool m_combos = true;
};
+QtGradientEditorPrivate::QtGradientEditorPrivate(QtGradientEditor *q)
+ : q_ptr(q)
+ , m_gradientStopsController(new QtGradientStopsController(this))
+ , m_gradient(QLinearGradient())
+{
+ m_ui.setupUi(q_ptr);
+ m_gradientStopsController->setUi(&m_ui);
+ reset();
+ setType(QGradient::LinearGradient);
+ setCombos(!m_combos);
+
+ showDetails(m_details);
+ setBackgroundCheckered(m_backgroundCheckered);
+
+ setStartLinear(QPointF(0, 0));
+ setEndLinear(QPointF(1, 1));
+ setCentralRadial(QPointF(0.5, 0.5));
+ setFocalRadial(QPointF(0.5, 0.5));
+ setRadiusRadial(0.5);
+ setCentralConical(QPointF(0.5, 0.5));
+ setAngleConical(0);
+
+ QIcon icon;
+ icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowRight), QIcon::Normal, QIcon::Off);
+ icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowLeft), QIcon::Normal, QIcon::On);
+ m_ui.detailsButton->setIcon(icon);
+
+ connect(m_ui.detailsButton, &QAbstractButton::clicked,
+ this, &QtGradientEditorPrivate::slotDetailsChanged);
+ connect(m_gradientStopsController, &QtGradientStopsController::gradientStopsChanged,
+ this, &QtGradientEditorPrivate::slotGradientStopsChanged);
+
+ QIcon iconLinear(":/qt-project.org/qtgradienteditor/images/typelinear.png"_L1);
+ QIcon iconRadial(":/qt-project.org/qtgradienteditor/images/typeradial.png"_L1);
+ QIcon iconConical(":/qt-project.org/qtgradienteditor/images/typeconical.png"_L1);
+
+ m_ui.typeComboBox->addItem(iconLinear, QtGradientEditor::tr("Linear"));
+ m_ui.typeComboBox->addItem(iconRadial, QtGradientEditor::tr("Radial"));
+ m_ui.typeComboBox->addItem(iconConical, QtGradientEditor::tr("Conical"));
+
+ m_ui.linearButton->setIcon(iconLinear);
+ m_ui.radialButton->setIcon(iconRadial);
+ m_ui.conicalButton->setIcon(iconConical);
+
+ m_typeGroup = new QButtonGroup(this);
+ m_typeGroup->addButton(m_ui.linearButton, 0);
+ m_typeGroup->addButton(m_ui.radialButton, 1);
+ m_typeGroup->addButton(m_ui.conicalButton, 2);
+
+ connect(m_typeGroup, &QButtonGroup::idClicked,
+ this, &QtGradientEditorPrivate::slotTypeChanged);
+ connect(m_ui.typeComboBox, &QComboBox::activated,
+ this, &QtGradientEditorPrivate::slotTypeChanged);
+
+ QIcon iconPad(":/qt-project.org/qtgradienteditor/images/spreadpad.png"_L1);
+ QIcon iconRepeat(":/qt-project.org/qtgradienteditor/images/spreadrepeat.png"_L1);
+ QIcon iconReflect(":/qt-project.org/qtgradienteditor/images/spreadreflect.png"_L1);
+
+ m_ui.spreadComboBox->addItem(iconPad, QtGradientEditor::tr("Pad"));
+ m_ui.spreadComboBox->addItem(iconRepeat, QtGradientEditor::tr("Repeat"));
+ m_ui.spreadComboBox->addItem(iconReflect, QtGradientEditor::tr("Reflect"));
+
+ m_ui.padButton->setIcon(iconPad);
+ m_ui.repeatButton->setIcon(iconRepeat);
+ m_ui.reflectButton->setIcon(iconReflect);
+
+ m_spreadGroup = new QButtonGroup(this);
+ m_spreadGroup->addButton(m_ui.padButton, 0);
+ m_spreadGroup->addButton(m_ui.repeatButton, 1);
+ m_spreadGroup->addButton(m_ui.reflectButton, 2);
+ connect(m_spreadGroup, &QButtonGroup::idClicked,
+ this, &QtGradientEditorPrivate::slotSpreadChanged);
+ connect(m_ui.spreadComboBox, &QComboBox::activated,
+ this, &QtGradientEditorPrivate::slotSpreadChanged);
+
+ connect(m_ui.gradientWidget, &QtGradientWidget::startLinearChanged,
+ this, &QtGradientEditorPrivate::startLinearChanged);
+ connect(m_ui.gradientWidget, &QtGradientWidget::endLinearChanged,
+ this, &QtGradientEditorPrivate::endLinearChanged);
+ connect(m_ui.gradientWidget, &QtGradientWidget::centralRadialChanged,
+ this, &QtGradientEditorPrivate::centralRadialChanged);
+ connect(m_ui.gradientWidget, &QtGradientWidget::focalRadialChanged,
+ this, &QtGradientEditorPrivate::focalRadialChanged);
+ connect(m_ui.gradientWidget, &QtGradientWidget::radiusRadialChanged,
+ this, &QtGradientEditorPrivate::radiusRadialChanged);
+ connect(m_ui.gradientWidget, &QtGradientWidget::centralConicalChanged,
+ this, &QtGradientEditorPrivate::centralConicalChanged);
+ connect(m_ui.gradientWidget, &QtGradientWidget::angleConicalChanged,
+ this, &QtGradientEditorPrivate::angleConicalChanged);
+
+ QGradientStops stops = gradient().stops();
+ m_gradientStopsController->setGradientStops(stops);
+ m_ui.gradientWidget->setGradientStops(stops);
+}
+
QGradient QtGradientEditorPrivate::gradient() const
{
QGradient *gradient = nullptr;
@@ -315,6 +380,9 @@ int QtGradientEditorPrivate::extensionWidthHint() const
void QtGradientEditorPrivate::slotDetailsChanged(bool details)
{
+ if (m_details == details)
+ return;
+
showDetails(details);
}
@@ -334,9 +402,6 @@ bool QtGradientEditorPrivate::row5Visible() const
void QtGradientEditorPrivate::showDetails(bool details)
{
- if (m_details == details)
- return;
-
bool blocked = m_ui.detailsButton->signalsBlocked();
m_ui.detailsButton->blockSignals(true);
m_ui.detailsButton->setChecked(details);
@@ -375,7 +440,8 @@ void QtGradientEditorPrivate::showDetails(bool details)
q_ptr->update();
}
-void QtGradientEditorPrivate::setSpinBox(QDoubleSpinBox *spinBox, const char *slot, double max, double step, int decimals)
+void QtGradientEditorPrivate::setupSpinBox(QDoubleSpinBox *spinBox, DoubleSlotPtr slot,
+ double max, double step, int decimals)
{
bool blocked = spinBox->signalsBlocked();
spinBox->blockSignals(true);
@@ -383,7 +449,7 @@ void QtGradientEditorPrivate::setSpinBox(QDoubleSpinBox *spinBox, const char *sl
spinBox->setMaximum(max);
spinBox->setSingleStep(step);
spinBox->blockSignals(blocked);
- QObject::connect(spinBox, SIGNAL(valueChanged(double)), q_ptr, slot);
+ QObject::connect(spinBox, &QDoubleSpinBox::valueChanged, this, slot);
}
void QtGradientEditorPrivate::reset()
@@ -408,11 +474,11 @@ void QtGradientEditorPrivate::setType(QGradient::Type type)
return;
m_type = type;
- m_ui.spinBox1->disconnect(SIGNAL(valueChanged(double)));
- m_ui.spinBox2->disconnect(SIGNAL(valueChanged(double)));
- m_ui.spinBox3->disconnect(SIGNAL(valueChanged(double)));
- m_ui.spinBox4->disconnect(SIGNAL(valueChanged(double)));
- m_ui.spinBox5->disconnect(SIGNAL(valueChanged(double)));
+ m_ui.spinBox1->disconnect(this);
+ m_ui.spinBox2->disconnect(this);
+ m_ui.spinBox3->disconnect(this);
+ m_ui.spinBox4->disconnect(this);
+ m_ui.spinBox5->disconnect(this);
reset();
@@ -427,42 +493,42 @@ void QtGradientEditorPrivate::setType(QGradient::Type type)
if (type == QGradient::LinearGradient) {
startLinearXSpinBox = m_ui.spinBox1;
- setSpinBox(startLinearXSpinBox, SLOT(slotStartLinearXChanged(double)));
+ setupSpinBox(startLinearXSpinBox, &QtGradientEditorPrivate::slotStartLinearXChanged);
m_ui.label1->setText(QCoreApplication::translate("QtGradientEditor", "Start X"));
startLinearYSpinBox = m_ui.spinBox2;
- setSpinBox(startLinearYSpinBox, SLOT(slotStartLinearYChanged(double)));
+ setupSpinBox(startLinearYSpinBox, &QtGradientEditorPrivate::slotStartLinearYChanged);
m_ui.label2->setText(QCoreApplication::translate("QtGradientEditor", "Start Y"));
endLinearXSpinBox = m_ui.spinBox3;
- setSpinBox(endLinearXSpinBox, SLOT(slotEndLinearXChanged(double)));
+ setupSpinBox(endLinearXSpinBox, &QtGradientEditorPrivate::slotEndLinearXChanged);
m_ui.label3->setText(QCoreApplication::translate("QtGradientEditor", "Final X"));
endLinearYSpinBox = m_ui.spinBox4;
- setSpinBox(endLinearYSpinBox, SLOT(slotEndLinearYChanged(double)));
+ setupSpinBox(endLinearYSpinBox, &QtGradientEditorPrivate::slotEndLinearYChanged);
m_ui.label4->setText(QCoreApplication::translate("QtGradientEditor", "Final Y"));
setStartLinear(m_ui.gradientWidget->startLinear());
setEndLinear(m_ui.gradientWidget->endLinear());
} else if (type == QGradient::RadialGradient) {
centralRadialXSpinBox = m_ui.spinBox1;
- setSpinBox(centralRadialXSpinBox, SLOT(slotCentralRadialXChanged(double)));
+ setupSpinBox(centralRadialXSpinBox, &QtGradientEditorPrivate::slotCentralRadialXChanged);
m_ui.label1->setText(QCoreApplication::translate("QtGradientEditor", "Central X"));
centralRadialYSpinBox = m_ui.spinBox2;
- setSpinBox(centralRadialYSpinBox, SLOT(slotCentralRadialYChanged(double)));
+ setupSpinBox(centralRadialYSpinBox, &QtGradientEditorPrivate::slotCentralRadialYChanged);
m_ui.label2->setText(QCoreApplication::translate("QtGradientEditor", "Central Y"));
focalRadialXSpinBox = m_ui.spinBox3;
- setSpinBox(focalRadialXSpinBox, SLOT(slotFocalRadialXChanged(double)));
+ setupSpinBox(focalRadialXSpinBox, &QtGradientEditorPrivate::slotFocalRadialXChanged);
m_ui.label3->setText(QCoreApplication::translate("QtGradientEditor", "Focal X"));
focalRadialYSpinBox = m_ui.spinBox4;
- setSpinBox(focalRadialYSpinBox, SLOT(slotFocalRadialYChanged(double)));
+ setupSpinBox(focalRadialYSpinBox, &QtGradientEditorPrivate::slotFocalRadialYChanged);
m_ui.label4->setText(QCoreApplication::translate("QtGradientEditor", "Focal Y"));
radiusRadialSpinBox = m_ui.spinBox5;
- setSpinBox(radiusRadialSpinBox, SLOT(slotRadiusRadialChanged(double)), 2.0);
+ setupSpinBox(radiusRadialSpinBox, &QtGradientEditorPrivate::slotRadiusRadialChanged, 2.0);
m_ui.label5->setText(QCoreApplication::translate("QtGradientEditor", "Radius"));
setCentralRadial(m_ui.gradientWidget->centralRadial());
@@ -470,15 +536,15 @@ void QtGradientEditorPrivate::setType(QGradient::Type type)
setRadiusRadial(m_ui.gradientWidget->radiusRadial());
} else if (type == QGradient::ConicalGradient) {
centralConicalXSpinBox = m_ui.spinBox1;
- setSpinBox(centralConicalXSpinBox, SLOT(slotCentralConicalXChanged(double)));
+ setupSpinBox(centralConicalXSpinBox, &QtGradientEditorPrivate::slotCentralConicalXChanged);
m_ui.label1->setText(QCoreApplication::translate("QtGradientEditor", "Central X"));
centralConicalYSpinBox = m_ui.spinBox2;
- setSpinBox(centralConicalYSpinBox, SLOT(slotCentralConicalYChanged(double)));
+ setupSpinBox(centralConicalYSpinBox, &QtGradientEditorPrivate::slotCentralConicalYChanged);
m_ui.label2->setText(QCoreApplication::translate("QtGradientEditor", "Central Y"));
angleConicalSpinBox = m_ui.spinBox3;
- setSpinBox(angleConicalSpinBox, SLOT(slotAngleConicalChanged(double)), 360.0, 1.0, 1);
+ setupSpinBox(angleConicalSpinBox, &QtGradientEditorPrivate::slotAngleConicalChanged, 360.0, 1.0, 1);
m_ui.label3->setText(QCoreApplication::translate("QtGradientEditor", "Angle"));
setCentralConical(m_ui.gradientWidget->centralConical());
@@ -496,9 +562,20 @@ void QtGradientEditorPrivate::setType(QGradient::Type type)
m_ui.label5->setVisible(row5Visible());
m_ui.spinBox5->setVisible(row5Visible());
- if (m_gridLayout) {
+ if (m_gridLayout)
m_gridLayout->setEnabled(ena);
- }
+}
+
+void QtGradientEditorPrivate::setBackgroundCheckered(bool checkered)
+{
+ m_backgroundCheckered = checkered;
+ m_ui.hueColorLine->setBackgroundCheckered(checkered);
+ m_ui.saturationColorLine->setBackgroundCheckered(checkered);
+ m_ui.valueColorLine->setBackgroundCheckered(checkered);
+ m_ui.alphaColorLine->setBackgroundCheckered(checkered);
+ m_ui.gradientWidget->setBackgroundCheckered(checkered);
+ m_ui.gradientStopsWidget->setBackgroundCheckered(checkered);
+ m_ui.colorButton->setBackgroundCheckered(checkered);
}
void QtGradientEditorPrivate::slotGradientStopsChanged(const QGradientStops &stops)
@@ -723,107 +800,8 @@ void QtGradientEditorPrivate::setAngleConical(qreal angle)
}
QtGradientEditor::QtGradientEditor(QWidget *parent)
- : QWidget(parent), d_ptr(new QtGradientEditorPrivate())
-{
- d_ptr->q_ptr = this;
- d_ptr->m_type = QGradient::RadialGradient;
- d_ptr->m_ui.setupUi(this);
- d_ptr->m_gridLayout = 0;
- d_ptr->m_hiddenLayout = 0;
- d_ptr->m_hiddenWidget = 0;
- bool detailsDefault = false;
- d_ptr->m_details = !detailsDefault;
- d_ptr->m_detailsButtonVisible = true;
- bool checkeredDefault = true;
- d_ptr->m_backgroundCheckered = !checkeredDefault;
- d_ptr->m_gradientStopsController = new QtGradientStopsController(this);
- d_ptr->m_gradientStopsController->setUi(&d_ptr->m_ui);
- d_ptr->reset();
- d_ptr->setType(QGradient::LinearGradient);
- d_ptr->m_combos = true;
- d_ptr->setCombos(!d_ptr->m_combos);
-
- d_ptr->showDetails(detailsDefault);
- setBackgroundCheckered(checkeredDefault);
-
- d_ptr->setStartLinear(QPointF(0, 0));
- d_ptr->setEndLinear(QPointF(1, 1));
- d_ptr->setCentralRadial(QPointF(0.5, 0.5));
- d_ptr->setFocalRadial(QPointF(0.5, 0.5));
- d_ptr->setRadiusRadial(0.5);
- d_ptr->setCentralConical(QPointF(0.5, 0.5));
- d_ptr->setAngleConical(0);
-
- QIcon icon;
- icon.addPixmap(style()->standardPixmap(QStyle::SP_ArrowRight), QIcon::Normal, QIcon::Off);
- icon.addPixmap(style()->standardPixmap(QStyle::SP_ArrowLeft), QIcon::Normal, QIcon::On);
- d_ptr->m_ui.detailsButton->setIcon(icon);
-
- connect(d_ptr->m_ui.detailsButton, SIGNAL(clicked(bool)), this, SLOT(slotDetailsChanged(bool)));
- connect(d_ptr->m_gradientStopsController, SIGNAL(gradientStopsChanged(QGradientStops)),
- this, SLOT(slotGradientStopsChanged(QGradientStops)));
-
- QIcon iconLinear(QLatin1String(":/qt-project.org/qtgradienteditor/images/typelinear.png"));
- QIcon iconRadial(QLatin1String(":/qt-project.org/qtgradienteditor/images/typeradial.png"));
- QIcon iconConical(QLatin1String(":/qt-project.org/qtgradienteditor/images/typeconical.png"));
-
- d_ptr->m_ui.typeComboBox->addItem(iconLinear, tr("Linear"));
- d_ptr->m_ui.typeComboBox->addItem(iconRadial, tr("Radial"));
- d_ptr->m_ui.typeComboBox->addItem(iconConical, tr("Conical"));
-
- d_ptr->m_ui.linearButton->setIcon(iconLinear);
- d_ptr->m_ui.radialButton->setIcon(iconRadial);
- d_ptr->m_ui.conicalButton->setIcon(iconConical);
-
- d_ptr->m_typeGroup = new QButtonGroup(this);
- d_ptr->m_typeGroup->addButton(d_ptr->m_ui.linearButton, 0);
- d_ptr->m_typeGroup->addButton(d_ptr->m_ui.radialButton, 1);
- d_ptr->m_typeGroup->addButton(d_ptr->m_ui.conicalButton, 2);
-
- connect(d_ptr->m_typeGroup, SIGNAL(buttonClicked(int)),
- this, SLOT(slotTypeChanged(int)));
- connect(d_ptr->m_ui.typeComboBox, SIGNAL(activated(int)),
- this, SLOT(slotTypeChanged(int)));
-
- QIcon iconPad(QLatin1String(":/qt-project.org/qtgradienteditor/images/spreadpad.png"));
- QIcon iconRepeat(QLatin1String(":/qt-project.org/qtgradienteditor/images/spreadrepeat.png"));
- QIcon iconReflect(QLatin1String(":/qt-project.org/qtgradienteditor/images/spreadreflect.png"));
-
- d_ptr->m_ui.spreadComboBox->addItem(iconPad, tr("Pad"));
- d_ptr->m_ui.spreadComboBox->addItem(iconRepeat, tr("Repeat"));
- d_ptr->m_ui.spreadComboBox->addItem(iconReflect, tr("Reflect"));
-
- d_ptr->m_ui.padButton->setIcon(iconPad);
- d_ptr->m_ui.repeatButton->setIcon(iconRepeat);
- d_ptr->m_ui.reflectButton->setIcon(iconReflect);
-
- d_ptr->m_spreadGroup = new QButtonGroup(this);
- d_ptr->m_spreadGroup->addButton(d_ptr->m_ui.padButton, 0);
- d_ptr->m_spreadGroup->addButton(d_ptr->m_ui.repeatButton, 1);
- d_ptr->m_spreadGroup->addButton(d_ptr->m_ui.reflectButton, 2);
- connect(d_ptr->m_spreadGroup, SIGNAL(buttonClicked(int)),
- this, SLOT(slotSpreadChanged(int)));
- connect(d_ptr->m_ui.spreadComboBox, SIGNAL(activated(int)),
- this, SLOT(slotSpreadChanged(int)));
-
- connect(d_ptr->m_ui.gradientWidget, SIGNAL(startLinearChanged(QPointF)),
- this, SLOT(startLinearChanged(QPointF)));
- connect(d_ptr->m_ui.gradientWidget, SIGNAL(endLinearChanged(QPointF)),
- this, SLOT(endLinearChanged(QPointF)));
- connect(d_ptr->m_ui.gradientWidget, SIGNAL(centralRadialChanged(QPointF)),
- this, SLOT(centralRadialChanged(QPointF)));
- connect(d_ptr->m_ui.gradientWidget, SIGNAL(focalRadialChanged(QPointF)),
- this, SLOT(focalRadialChanged(QPointF)));
- connect(d_ptr->m_ui.gradientWidget, SIGNAL(radiusRadialChanged(qreal)),
- this, SLOT(radiusRadialChanged(qreal)));
- connect(d_ptr->m_ui.gradientWidget, SIGNAL(centralConicalChanged(QPointF)),
- this, SLOT(centralConicalChanged(QPointF)));
- connect(d_ptr->m_ui.gradientWidget, SIGNAL(angleConicalChanged(qreal)),
- this, SLOT(angleConicalChanged(qreal)));
-
- QGradientStops stops = gradient().stops();
- d_ptr->m_gradientStopsController->setGradientStops(stops);
- d_ptr->m_ui.gradientWidget->setGradientStops(stops);
+ : QWidget(parent), d_ptr(new QtGradientEditorPrivate(this))
+{
}
QtGradientEditor::~QtGradientEditor()
@@ -903,14 +881,7 @@ void QtGradientEditor::setBackgroundCheckered(bool checkered)
if (d_ptr->m_backgroundCheckered == checkered)
return;
- d_ptr->m_backgroundCheckered = checkered;
- d_ptr->m_ui.hueColorLine->setBackgroundCheckered(checkered);
- d_ptr->m_ui.saturationColorLine->setBackgroundCheckered(checkered);
- d_ptr->m_ui.valueColorLine->setBackgroundCheckered(checkered);
- d_ptr->m_ui.alphaColorLine->setBackgroundCheckered(checkered);
- d_ptr->m_ui.gradientWidget->setBackgroundCheckered(checkered);
- d_ptr->m_ui.gradientStopsWidget->setBackgroundCheckered(checkered);
- d_ptr->m_ui.colorButton->setBackgroundCheckered(checkered);
+ d_ptr->setBackgroundCheckered(checkered);
}
bool QtGradientEditor::detailsVisible() const
@@ -920,6 +891,9 @@ bool QtGradientEditor::detailsVisible() const
void QtGradientEditor::setDetailsVisible(bool visible)
{
+ if (d_ptr->m_details == visible)
+ return;
+
d_ptr->showDetails(visible);
}
@@ -949,4 +923,4 @@ void QtGradientEditor::setSpec(QColor::Spec spec)
QT_END_NAMESPACE
-#include "moc_qtgradienteditor.cpp"
+#include "qtgradienteditor.moc"
diff --git a/src/shared/qtgradienteditor/qtgradienteditor.h b/src/shared/qtgradienteditor/qtgradienteditor.h
index 5d91fb0d4..8e0fcadfc 100644
--- a/src/shared/qtgradienteditor/qtgradienteditor.h
+++ b/src/shared/qtgradienteditor/qtgradienteditor.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTGRADIENTEDITOR_H
#define QTGRADIENTEDITOR_H
@@ -71,7 +35,6 @@ public:
void setSpec(QColor::Spec spec);
signals:
-
void gradientChanged(const QGradient &gradient);
void aboutToShowDetails(bool details, int extenstionWidthHint);
@@ -79,29 +42,6 @@ private:
QScopedPointer<class QtGradientEditorPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtGradientEditor)
Q_DISABLE_COPY_MOVE(QtGradientEditor)
- Q_PRIVATE_SLOT(d_func(), void slotGradientStopsChanged(const QGradientStops &stops))
- Q_PRIVATE_SLOT(d_func(), void slotTypeChanged(int type))
- Q_PRIVATE_SLOT(d_func(), void slotSpreadChanged(int type))
- Q_PRIVATE_SLOT(d_func(), void slotStartLinearXChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotStartLinearYChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotEndLinearXChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotEndLinearYChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotCentralRadialXChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotCentralRadialYChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotFocalRadialXChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotFocalRadialYChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotRadiusRadialChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotCentralConicalXChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotCentralConicalYChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotAngleConicalChanged(double value))
- Q_PRIVATE_SLOT(d_func(), void slotDetailsChanged(bool details))
- Q_PRIVATE_SLOT(d_func(), void startLinearChanged(const QPointF &))
- Q_PRIVATE_SLOT(d_func(), void endLinearChanged(const QPointF &))
- Q_PRIVATE_SLOT(d_func(), void centralRadialChanged(const QPointF &))
- Q_PRIVATE_SLOT(d_func(), void focalRadialChanged(const QPointF &))
- Q_PRIVATE_SLOT(d_func(), void radiusRadialChanged(qreal))
- Q_PRIVATE_SLOT(d_func(), void centralConicalChanged(const QPointF &))
- Q_PRIVATE_SLOT(d_func(), void angleConicalChanged(qreal))
};
QT_END_NAMESPACE
diff --git a/src/shared/qtgradienteditor/qtgradienteditor.qrc b/src/shared/qtgradienteditor/qtgradienteditor.qrc
deleted file mode 100644
index 74c236202..000000000
--- a/src/shared/qtgradienteditor/qtgradienteditor.qrc
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
- <qresource prefix="/qt-project.org/qtgradienteditor">
- <file>images/edit.png</file>
- <file>images/zoomin.png</file>
- <file>images/zoomout.png</file>
- <file>images/up.png</file>
- <file>images/down.png</file>
- <file>images/plus.png</file>
- <file>images/minus.png</file>
- <file>images/editdelete.png</file>
- <file>images/spreadpad.png</file>
- <file>images/spreadrepeat.png</file>
- <file>images/spreadreflect.png</file>
- <file>images/typelinear.png</file>
- <file>images/typeradial.png</file>
- <file>images/typeconical.png</file>
- </qresource>
-</RCC>
diff --git a/src/shared/qtgradienteditor/qtgradienteditor.ui b/src/shared/qtgradienteditor/qtgradienteditor.ui
index d5e6f67bc..c2846774c 100644
--- a/src/shared/qtgradienteditor/qtgradienteditor.ui
+++ b/src/shared/qtgradienteditor/qtgradienteditor.ui
@@ -1,42 +1,8 @@
<ui version="4.0" >
- <comment>*********************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-*********************************************************************</comment>
+<comment>
+* Copyright (C) 2016 The Qt Company Ltd.
+* SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+</comment>
<class>QtGradientEditor</class>
<widget class="QWidget" name="QtGradientEditor" >
<property name="geometry" >
diff --git a/src/shared/qtgradienteditor/qtgradientmanager.cpp b/src/shared/qtgradienteditor/qtgradientmanager.cpp
index 2662221b5..c0b165e21 100644
--- a/src/shared/qtgradienteditor/qtgradientmanager.cpp
+++ b/src/shared/qtgradienteditor/qtgradientmanager.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientmanager.h"
#include <QtGui/QPixmap>
@@ -59,8 +23,8 @@ QString QtGradientManager::uniqueId(const QString &id) const
return id;
QString base = id;
- while (base.count() > 0 && base.at(base.count() - 1).isDigit())
- base = base.left(base.count() - 1);
+ while (base.size() > 0 && base.at(base.size() - 1).isDigit())
+ base = base.left(base.size() - 1);
QString newId = base;
int counter = 0;
while (m_idToGradient.contains(newId)) {
diff --git a/src/shared/qtgradienteditor/qtgradientmanager.h b/src/shared/qtgradienteditor/qtgradientmanager.h
index f1cc60656..e3373c0c3 100644
--- a/src/shared/qtgradienteditor/qtgradientmanager.h
+++ b/src/shared/qtgradienteditor/qtgradientmanager.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef GRADIENTMANAGER_H
#define GRADIENTMANAGER_H
diff --git a/src/shared/qtgradienteditor/qtgradientstopscontroller.cpp b/src/shared/qtgradienteditor/qtgradientstopscontroller.cpp
index 20cea9499..8dcd0171a 100644
--- a/src/shared/qtgradienteditor/qtgradientstopscontroller.cpp
+++ b/src/shared/qtgradienteditor/qtgradientstopscontroller.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientstopscontroller.h"
#include "ui_qtgradienteditor.h"
@@ -45,13 +9,18 @@
QT_BEGIN_NAMESPACE
-class QtGradientStopsControllerPrivate
+using namespace Qt::StringLiterals;
+
+class QtGradientStopsControllerPrivate : public QObject
{
+ Q_OBJECT
QtGradientStopsController *q_ptr;
Q_DECLARE_PUBLIC(QtGradientStopsController)
public:
- typedef QMap<qreal, QColor> PositionColorMap;
- typedef QMap<qreal, QtGradientStop *> PositionStopMap;
+ using PositionColorMap = QMap<qreal, QColor>;
+ using PositionStopMap = QMap<qreal, QtGradientStop *>;
+
+ void setUi(Ui::QtGradientEditor *ui);
void slotHsvClicked();
void slotRgbClicked();
@@ -66,10 +35,10 @@ public:
void slotUpdatePositionSpinBox();
void slotChangeColor(const QColor &color);
- void slotChangeHue(const QColor &color);
- void slotChangeSaturation(const QColor &color);
- void slotChangeValue(const QColor &color);
- void slotChangeAlpha(const QColor &color);
+ void slotChangeHueColor(const QColor &color);
+ void slotChangeSaturationColor(const QColor &color);
+ void slotChangeValueColor(const QColor &color);
+ void slotChangeAlphaColor(const QColor &color);
void slotChangeHue(int color);
void slotChangeSaturation(int color);
void slotChangeValue(int color);
@@ -88,12 +57,83 @@ public:
QGradientStops makeGradientStops(const PositionColorMap &data) const;
void updateZoom(double zoom);
- QtGradientStopsModel *m_model;
- QColor::Spec m_spec;
+ QtGradientStopsModel *m_model = nullptr;
+ QColor::Spec m_spec = QColor::Hsv;
Ui::QtGradientEditor *m_ui;
};
+void QtGradientStopsControllerPrivate::setUi(Ui::QtGradientEditor *ui)
+{
+ m_ui = ui;
+
+ m_ui->hueColorLine->setColorComponent(QtColorLine::Hue);
+ m_ui->saturationColorLine->setColorComponent(QtColorLine::Saturation);
+ m_ui->valueColorLine->setColorComponent(QtColorLine::Value);
+ m_ui->alphaColorLine->setColorComponent(QtColorLine::Alpha);
+
+ m_model = new QtGradientStopsModel(this);
+ m_ui->gradientStopsWidget->setGradientStopsModel(m_model);
+ connect(m_model, &QtGradientStopsModel::currentStopChanged,
+ this, &QtGradientStopsControllerPrivate::slotCurrentStopChanged);
+ connect(m_model, &QtGradientStopsModel::stopMoved,
+ this, &QtGradientStopsControllerPrivate::slotStopMoved);
+ connect(m_model, &QtGradientStopsModel::stopsSwapped,
+ this, &QtGradientStopsControllerPrivate::slotStopsSwapped);
+ connect(m_model, &QtGradientStopsModel::stopChanged,
+ this, &QtGradientStopsControllerPrivate::slotStopChanged);
+ connect(m_model, &QtGradientStopsModel::stopSelected,
+ this, &QtGradientStopsControllerPrivate::slotStopSelected);
+ connect(m_model, &QtGradientStopsModel::stopAdded,
+ this, &QtGradientStopsControllerPrivate::slotStopAdded);
+ connect(m_model, &QtGradientStopsModel::stopRemoved,
+ this, &QtGradientStopsControllerPrivate::slotStopRemoved);
+
+ connect(m_ui->hueColorLine, &QtColorLine::colorChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeHueColor);
+ connect(m_ui->saturationColorLine, &QtColorLine::colorChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeSaturationColor);
+ connect(m_ui->valueColorLine, &QtColorLine::colorChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeValueColor);
+ connect(m_ui->alphaColorLine, &QtColorLine::colorChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeAlphaColor);
+ connect(m_ui->colorButton, &QtColorButton::colorChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeColor);
+
+ connect(m_ui->hueSpinBox, &QSpinBox::valueChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeHue);
+ connect(m_ui->saturationSpinBox, &QSpinBox::valueChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeSaturation);
+ connect(m_ui->valueSpinBox, &QSpinBox::valueChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeValue);
+ connect(m_ui->alphaSpinBox, &QSpinBox::valueChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeAlpha);
+
+ connect(m_ui->positionSpinBox, &QDoubleSpinBox::valueChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangePosition);
+
+ connect(m_ui->zoomSpinBox, &QSpinBox::valueChanged,
+ this, &QtGradientStopsControllerPrivate::slotChangeZoom);
+ connect(m_ui->zoomInButton, &QToolButton::clicked,
+ this, &QtGradientStopsControllerPrivate::slotZoomIn);
+ connect(m_ui->zoomOutButton, &QToolButton::clicked,
+ this, &QtGradientStopsControllerPrivate::slotZoomOut);
+ connect(m_ui->zoomAllButton, &QToolButton::clicked,
+ this, &QtGradientStopsControllerPrivate::slotZoomAll);
+ connect(m_ui->gradientStopsWidget, &QtGradientStopsWidget::zoomChanged,
+ this, &QtGradientStopsControllerPrivate::slotZoomChanged);
+
+ connect(m_ui->hsvRadioButton, &QRadioButton::clicked,
+ this, &QtGradientStopsControllerPrivate::slotHsvClicked);
+ connect(m_ui->rgbRadioButton, &QRadioButton::clicked,
+ this, &QtGradientStopsControllerPrivate::slotRgbClicked);
+
+ enableCurrent(false);
+ m_ui->zoomInButton->setIcon(QIcon(":/qt-project.org/qtgradienteditor/images/zoomin.png"_L1));
+ m_ui->zoomOutButton->setIcon(QIcon(":/qt-project.org/qtgradienteditor/images/zoomout.png"_L1));
+ updateZoom(1);
+}
+
void QtGradientStopsControllerPrivate::enableCurrent(bool enable)
{
m_ui->positionLabel->setEnabled(enable);
@@ -124,25 +164,16 @@ void QtGradientStopsControllerPrivate::enableCurrent(bool enable)
QtGradientStopsControllerPrivate::PositionColorMap QtGradientStopsControllerPrivate::stopsData(const PositionStopMap &stops) const
{
PositionColorMap data;
- PositionStopMap::ConstIterator itStop = stops.constBegin();
- while (itStop != stops.constEnd()) {
- QtGradientStop *stop = itStop.value();
+ for (QtGradientStop *stop : stops)
data[stop->position()] = stop->color();
-
- ++itStop;
- }
return data;
}
QGradientStops QtGradientStopsControllerPrivate::makeGradientStops(const PositionColorMap &data) const
{
QGradientStops stops;
- PositionColorMap::ConstIterator itData = data.constBegin();
- while (itData != data.constEnd()) {
- stops << QPair<qreal, QColor>(itData.key(), itData.value());
-
- ++itData;
- }
+ for (auto itData = data.cbegin(), cend = data.cend(); itData != cend; ++itData)
+ stops << std::pair<qreal, QColor>(itData.key(), itData.value());
return stops;
}
@@ -274,7 +305,7 @@ void QtGradientStopsControllerPrivate::slotCurrentStopChanged(QtGradientStop *st
}
enableCurrent(true);
- QTimer::singleShot(0, q_ptr, SLOT(slotUpdatePositionSpinBox()));
+ QTimer::singleShot(0, this, &QtGradientStopsControllerPrivate::slotUpdatePositionSpinBox);
m_ui->colorButton->setColor(stop->color());
m_ui->hueColorLine->setColor(stop->color());
@@ -286,7 +317,7 @@ void QtGradientStopsControllerPrivate::slotCurrentStopChanged(QtGradientStop *st
void QtGradientStopsControllerPrivate::slotStopMoved(QtGradientStop *stop, qreal newPos)
{
- QTimer::singleShot(0, q_ptr, SLOT(slotUpdatePositionSpinBox()));
+ QTimer::singleShot(0, this, &QtGradientStopsControllerPrivate::slotUpdatePositionSpinBox);
PositionColorMap stops = stopsData(m_model->stops());
stops.remove(stop->position());
@@ -298,7 +329,7 @@ void QtGradientStopsControllerPrivate::slotStopMoved(QtGradientStop *stop, qreal
void QtGradientStopsControllerPrivate::slotStopsSwapped(QtGradientStop *stop1, QtGradientStop *stop2)
{
- QTimer::singleShot(0, q_ptr, SLOT(slotUpdatePositionSpinBox()));
+ QTimer::singleShot(0, this, &QtGradientStopsControllerPrivate::slotUpdatePositionSpinBox);
PositionColorMap stops = stopsData(m_model->stops());
const qreal pos1 = stop1->position();
@@ -350,7 +381,7 @@ void QtGradientStopsControllerPrivate::slotStopSelected(QtGradientStop *stop, bo
{
Q_UNUSED(stop);
Q_UNUSED(selected);
- QTimer::singleShot(0, q_ptr, SLOT(slotUpdatePositionSpinBox()));
+ QTimer::singleShot(0, this, &QtGradientStopsControllerPrivate::slotUpdatePositionSpinBox);
}
void QtGradientStopsControllerPrivate::slotUpdatePositionSpinBox()
@@ -409,7 +440,7 @@ void QtGradientStopsControllerPrivate::slotChangeColor(const QColor &color)
}
}
-void QtGradientStopsControllerPrivate::slotChangeHue(const QColor &color)
+void QtGradientStopsControllerPrivate::slotChangeHueColor(const QColor &color)
{
QtGradientStop *stop = m_model->currentStop();
if (!stop)
@@ -435,10 +466,10 @@ void QtGradientStopsControllerPrivate::slotChangeHue(int color)
c.setHsvF(qreal(color) / 360.0, c.saturationF(), c.valueF(), c.alphaF());
else
c.setRed(color);
- slotChangeHue(c);
+ slotChangeHueColor(c);
}
-void QtGradientStopsControllerPrivate::slotChangeSaturation(const QColor &color)
+void QtGradientStopsControllerPrivate::slotChangeSaturationColor(const QColor &color)
{
QtGradientStop *stop = m_model->currentStop();
if (!stop)
@@ -468,10 +499,10 @@ void QtGradientStopsControllerPrivate::slotChangeSaturation(int color)
c.setHsvF(c.hueF(), qreal(color) / 255, c.valueF(), c.alphaF());
else
c.setGreen(color);
- slotChangeSaturation(c);
+ slotChangeSaturationColor(c);
}
-void QtGradientStopsControllerPrivate::slotChangeValue(const QColor &color)
+void QtGradientStopsControllerPrivate::slotChangeValueColor(const QColor &color)
{
QtGradientStop *stop = m_model->currentStop();
if (!stop)
@@ -501,10 +532,10 @@ void QtGradientStopsControllerPrivate::slotChangeValue(int color)
c.setHsvF(c.hueF(), c.saturationF(), qreal(color) / 255, c.alphaF());
else
c.setBlue(color);
- slotChangeValue(c);
+ slotChangeValueColor(c);
}
-void QtGradientStopsControllerPrivate::slotChangeAlpha(const QColor &color)
+void QtGradientStopsControllerPrivate::slotChangeAlphaColor(const QColor &color)
{
QtGradientStop *stop = m_model->currentStop();
if (!stop)
@@ -534,7 +565,7 @@ void QtGradientStopsControllerPrivate::slotChangeAlpha(int color)
c.setHsvF(c.hueF(), c.saturationF(), c.valueF(), qreal(color) / 255);
else
c.setAlpha(color);
- slotChangeAlpha(c);
+ slotChangeAlphaColor(c);
}
void QtGradientStopsControllerPrivate::slotChangePosition(double value)
@@ -581,79 +612,11 @@ QtGradientStopsController::QtGradientStopsController(QObject *parent)
: QObject(parent), d_ptr(new QtGradientStopsControllerPrivate())
{
d_ptr->q_ptr = this;
-
- d_ptr->m_spec = QColor::Hsv;
}
void QtGradientStopsController::setUi(Ui::QtGradientEditor *ui)
{
- d_ptr->m_ui = ui;
-
- d_ptr->m_ui->hueColorLine->setColorComponent(QtColorLine::Hue);
- d_ptr->m_ui->saturationColorLine->setColorComponent(QtColorLine::Saturation);
- d_ptr->m_ui->valueColorLine->setColorComponent(QtColorLine::Value);
- d_ptr->m_ui->alphaColorLine->setColorComponent(QtColorLine::Alpha);
-
- d_ptr->m_model = new QtGradientStopsModel(this);
- d_ptr->m_ui->gradientStopsWidget->setGradientStopsModel(d_ptr->m_model);
- connect(d_ptr->m_model, SIGNAL(currentStopChanged(QtGradientStop*)),
- this, SLOT(slotCurrentStopChanged(QtGradientStop*)));
- connect(d_ptr->m_model, SIGNAL(stopMoved(QtGradientStop*,qreal)),
- this, SLOT(slotStopMoved(QtGradientStop*,qreal)));
- connect(d_ptr->m_model, SIGNAL(stopsSwapped(QtGradientStop*,QtGradientStop*)),
- this, SLOT(slotStopsSwapped(QtGradientStop*,QtGradientStop*)));
- connect(d_ptr->m_model, SIGNAL(stopChanged(QtGradientStop*,QColor)),
- this, SLOT(slotStopChanged(QtGradientStop*,QColor)));
- connect(d_ptr->m_model, SIGNAL(stopSelected(QtGradientStop*,bool)),
- this, SLOT(slotStopSelected(QtGradientStop*,bool)));
- connect(d_ptr->m_model, SIGNAL(stopAdded(QtGradientStop*)),
- this, SLOT(slotStopAdded(QtGradientStop*)));
- connect(d_ptr->m_model, SIGNAL(stopRemoved(QtGradientStop*)),
- this, SLOT(slotStopRemoved(QtGradientStop*)));
-
- connect(d_ptr->m_ui->hueColorLine, SIGNAL(colorChanged(QColor)),
- this, SLOT(slotChangeHue(QColor)));
- connect(d_ptr->m_ui->saturationColorLine, SIGNAL(colorChanged(QColor)),
- this, SLOT(slotChangeSaturation(QColor)));
- connect(d_ptr->m_ui->valueColorLine, SIGNAL(colorChanged(QColor)),
- this, SLOT(slotChangeValue(QColor)));
- connect(d_ptr->m_ui->alphaColorLine, SIGNAL(colorChanged(QColor)),
- this, SLOT(slotChangeAlpha(QColor)));
- connect(d_ptr->m_ui->colorButton, SIGNAL(colorChanged(QColor)),
- this, SLOT(slotChangeColor(QColor)));
-
- connect(d_ptr->m_ui->hueSpinBox, SIGNAL(valueChanged(int)),
- this, SLOT(slotChangeHue(int)));
- connect(d_ptr->m_ui->saturationSpinBox, SIGNAL(valueChanged(int)),
- this, SLOT(slotChangeSaturation(int)));
- connect(d_ptr->m_ui->valueSpinBox, SIGNAL(valueChanged(int)),
- this, SLOT(slotChangeValue(int)));
- connect(d_ptr->m_ui->alphaSpinBox, SIGNAL(valueChanged(int)),
- this, SLOT(slotChangeAlpha(int)));
-
- connect(d_ptr->m_ui->positionSpinBox, SIGNAL(valueChanged(double)),
- this, SLOT(slotChangePosition(double)));
-
- connect(d_ptr->m_ui->zoomSpinBox, SIGNAL(valueChanged(int)),
- this, SLOT(slotChangeZoom(int)));
- connect(d_ptr->m_ui->zoomInButton, SIGNAL(clicked()),
- this, SLOT(slotZoomIn()));
- connect(d_ptr->m_ui->zoomOutButton, SIGNAL(clicked()),
- this, SLOT(slotZoomOut()));
- connect(d_ptr->m_ui->zoomAllButton, SIGNAL(clicked()),
- this, SLOT(slotZoomAll()));
- connect(d_ptr->m_ui->gradientStopsWidget, SIGNAL(zoomChanged(double)),
- this, SLOT(slotZoomChanged(double)));
-
- connect(d_ptr->m_ui->hsvRadioButton, SIGNAL(clicked()),
- this, SLOT(slotHsvClicked()));
- connect(d_ptr->m_ui->rgbRadioButton, SIGNAL(clicked()),
- this, SLOT(slotRgbClicked()));
-
- d_ptr->enableCurrent(false);
- d_ptr->m_ui->zoomInButton->setIcon(QIcon(QLatin1String(":/qt-project.org/qtgradienteditor/images/zoomin.png")));
- d_ptr->m_ui->zoomOutButton->setIcon(QIcon(QLatin1String(":/qt-project.org/qtgradienteditor/images/zoomout.png")));
- d_ptr->updateZoom(1);
+ d_ptr->setUi(ui);
}
QtGradientStopsController::~QtGradientStopsController()
@@ -664,7 +627,7 @@ void QtGradientStopsController::setGradientStops(const QGradientStops &stops)
{
d_ptr->m_model->clear();
QtGradientStop *first = nullptr;
- for (const QPair<qreal, QColor> &pair : stops) {
+ for (const std::pair<qreal, QColor> &pair : stops) {
QtGradientStop *stop = d_ptr->m_model->addStop(pair.first, pair.second);
if (!first)
first = stop;
@@ -678,7 +641,7 @@ QGradientStops QtGradientStopsController::gradientStops() const
QGradientStops stops;
const auto stopsList = d_ptr->m_model->stops().values();
for (const QtGradientStop *stop : stopsList)
- stops << QPair<qreal, QColor>(stop->position(), stop->color());
+ stops.append({stop->position(), stop->color()});
return stops;
}
@@ -704,4 +667,4 @@ void QtGradientStopsController::setSpec(QColor::Spec spec)
QT_END_NAMESPACE
-#include "moc_qtgradientstopscontroller.cpp"
+#include "qtgradientstopscontroller.moc"
diff --git a/src/shared/qtgradienteditor/qtgradientstopscontroller.h b/src/shared/qtgradienteditor/qtgradientstopscontroller.h
index 1b3bbd391..c93b91c34 100644
--- a/src/shared/qtgradienteditor/qtgradientstopscontroller.h
+++ b/src/shared/qtgradienteditor/qtgradientstopscontroller.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTGRADIENTSTOPSCONTROLLER_H
#define QTGRADIENTSTOPSCONTROLLER_H
@@ -64,39 +28,12 @@ public:
void setSpec(QColor::Spec spec);
signals:
-
void gradientStopsChanged(const QGradientStops &stops);
private:
QScopedPointer<class QtGradientStopsControllerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtGradientStopsController)
Q_DISABLE_COPY_MOVE(QtGradientStopsController)
- Q_PRIVATE_SLOT(d_func(), void slotHsvClicked())
- Q_PRIVATE_SLOT(d_func(), void slotRgbClicked())
- Q_PRIVATE_SLOT(d_func(), void slotCurrentStopChanged(QtGradientStop *stop))
- Q_PRIVATE_SLOT(d_func(), void slotStopMoved(QtGradientStop *stop, qreal newPos))
- Q_PRIVATE_SLOT(d_func(), void slotStopsSwapped(QtGradientStop *stop1, QtGradientStop *stop2))
- Q_PRIVATE_SLOT(d_func(), void slotStopChanged(QtGradientStop *stop, const QColor &newColor))
- Q_PRIVATE_SLOT(d_func(), void slotStopSelected(QtGradientStop *stop, bool selected))
- Q_PRIVATE_SLOT(d_func(), void slotStopAdded(QtGradientStop *stop))
- Q_PRIVATE_SLOT(d_func(), void slotStopRemoved(QtGradientStop *stop))
- Q_PRIVATE_SLOT(d_func(), void slotUpdatePositionSpinBox())
- Q_PRIVATE_SLOT(d_func(), void slotChangeColor(const QColor &color))
- Q_PRIVATE_SLOT(d_func(), void slotChangeHue(const QColor &color))
- Q_PRIVATE_SLOT(d_func(), void slotChangeSaturation(const QColor &color))
- Q_PRIVATE_SLOT(d_func(), void slotChangeValue(const QColor &color))
- Q_PRIVATE_SLOT(d_func(), void slotChangeAlpha(const QColor &color))
- Q_PRIVATE_SLOT(d_func(), void slotChangeHue(int))
- Q_PRIVATE_SLOT(d_func(), void slotChangeSaturation(int))
- Q_PRIVATE_SLOT(d_func(), void slotChangeValue(int))
- Q_PRIVATE_SLOT(d_func(), void slotChangeAlpha(int))
- //Q_PRIVATE_SLOT(d_func(), void slotChangePosition(double newPos))
- Q_PRIVATE_SLOT(d_func(), void slotChangePosition(double value))
- Q_PRIVATE_SLOT(d_func(), void slotChangeZoom(int value))
- Q_PRIVATE_SLOT(d_func(), void slotZoomIn())
- Q_PRIVATE_SLOT(d_func(), void slotZoomOut())
- Q_PRIVATE_SLOT(d_func(), void slotZoomAll())
- Q_PRIVATE_SLOT(d_func(), void slotZoomChanged(double))
};
QT_END_NAMESPACE
diff --git a/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp b/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp
index 0afbf49bb..cea8feb6b 100644
--- a/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp
+++ b/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp
@@ -1,44 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientstopsmodel.h"
+
#include <QtGui/QColor>
+#include <QtCore/QHash>
QT_BEGIN_NAMESPACE
@@ -93,8 +59,8 @@ class QtGradientStopsModelPrivate
Q_DECLARE_PUBLIC(QtGradientStopsModel)
public:
QMap<qreal, QtGradientStop *> m_posToStop;
- QMap<QtGradientStop *, qreal> m_stopToPos;
- QMap<QtGradientStop *, bool> m_selection;
+ QHash<QtGradientStop *, qreal> m_stopToPos;
+ QHash<QtGradientStop *, bool> m_selection;
QtGradientStop *m_current;
};
@@ -133,7 +99,7 @@ QColor QtGradientStopsModel::color(qreal pos) const
return gradStops[pos]->color();
gradStops[pos] = 0;
- PositionStopMap::ConstIterator itStop = gradStops.constFind(pos);
+ auto itStop = gradStops.constFind(pos);
if (itStop == gradStops.constBegin()) {
++itStop;
return itStop.value()->color();
@@ -142,8 +108,8 @@ QColor QtGradientStopsModel::color(qreal pos) const
--itStop;
return itStop.value()->color();
}
- PositionStopMap::ConstIterator itPrev = itStop;
- PositionStopMap::ConstIterator itNext = itStop;
+ auto itPrev = itStop;
+ auto itNext = itStop;
--itPrev;
++itNext;
@@ -301,7 +267,7 @@ void QtGradientStopsModel::setCurrentStop(QtGradientStop *stop)
QtGradientStop *QtGradientStopsModel::firstSelected() const
{
PositionStopMap stopList = stops();
- PositionStopMap::ConstIterator itStop = stopList.constBegin();
+ auto itStop = stopList.cbegin();
while (itStop != stopList.constEnd()) {
QtGradientStop *stop = itStop.value();
if (isSelected(stop))
@@ -314,7 +280,7 @@ QtGradientStop *QtGradientStopsModel::firstSelected() const
QtGradientStop *QtGradientStopsModel::lastSelected() const
{
PositionStopMap stopList = stops();
- PositionStopMap::ConstIterator itStop = stopList.constEnd();
+ auto itStop = stopList.cend();
while (itStop != stopList.constBegin()) {
--itStop;
@@ -380,7 +346,7 @@ void QtGradientStopsModel::moveStops(double newPosition)
stopList[stop->position()] = stop;
stopList[current->position()] = current;
- PositionStopMap::ConstIterator itStop = forward ? stopList.constBegin() : stopList.constEnd();
+ auto itStop = forward ? stopList.cbegin() : stopList.cend();
while (itStop != (forward ? stopList.constEnd() : stopList.constBegin())) {
if (!forward)
--itStop;
@@ -418,17 +384,12 @@ void QtGradientStopsModel::clearSelection()
selectStop(stop, false);
}
-namespace {
- template <typename BidirectionalIterator>
- std::reverse_iterator<BidirectionalIterator> rev(BidirectionalIterator it)
- { return std::reverse_iterator<BidirectionalIterator>(it); }
-}
-
void QtGradientStopsModel::flipAll()
{
QMap<qreal, QtGradientStop *> stopsMap = stops();
- QMap<QtGradientStop *, bool> swappedList;
- for (auto itStop = rev(stopsMap.keyValueEnd()), end = rev(stopsMap.keyValueBegin()); itStop != end; ++itStop) {
+ QHash<QtGradientStop *, bool> swappedList;
+ for (auto itStop = stopsMap.keyValueEnd(), begin = stopsMap.keyValueBegin(); itStop != begin;) {
+ --itStop;
QtGradientStop *stop = (*itStop).second;
if (swappedList.contains(stop))
continue;
diff --git a/src/shared/qtgradienteditor/qtgradientstopsmodel.h b/src/shared/qtgradienteditor/qtgradientstopsmodel.h
index 71a8783e0..0325501ac 100644
--- a/src/shared/qtgradienteditor/qtgradientstopsmodel.h
+++ b/src/shared/qtgradienteditor/qtgradientstopsmodel.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTGRADIENTSTOPSMODEL_H
#define QTGRADIENTSTOPSMODEL_H
@@ -69,7 +33,7 @@ class QtGradientStopsModel : public QObject
{
Q_OBJECT
public:
- typedef QMap<qreal, QtGradientStop *> PositionStopMap;
+ using PositionStopMap = QMap<qreal, QtGradientStop *>;
QtGradientStopsModel(QObject *parent = 0);
~QtGradientStopsModel();
diff --git a/src/shared/qtgradienteditor/qtgradientstopswidget.cpp b/src/shared/qtgradienteditor/qtgradientstopswidget.cpp
index 80bc3ed68..c0aff22eb 100644
--- a/src/shared/qtgradienteditor/qtgradientstopswidget.cpp
+++ b/src/shared/qtgradienteditor/qtgradientstopswidget.cpp
@@ -1,46 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientstopswidget.h"
#include "qtgradientstopsmodel.h"
#include <QtCore/QMap>
+#include <QtCore/QHash>
#include <QtCore/QMimeData>
#include <QtGui/QImage>
#include <QtGui/QPainter>
@@ -51,13 +16,13 @@
QT_BEGIN_NAMESPACE
-class QtGradientStopsWidgetPrivate
+class QtGradientStopsWidgetPrivate : public QObject
{
+ Q_OBJECT
QtGradientStopsWidget *q_ptr;
Q_DECLARE_PUBLIC(QtGradientStopsWidget)
public:
- typedef QMap<qreal, QColor> PositionColorMap;
- typedef QMap<QtGradientStop *, qreal> StopPositionMap;
+ void setGradientStopsModel(QtGradientStopsModel *model);
void slotStopAdded(QtGradientStop *stop);
void slotStopRemoved(QtGradientStop *stop);
@@ -109,11 +74,65 @@ public:
bool m_moving;
int m_moveOffset;
- StopPositionMap m_moveStops;
+ QHash<QtGradientStop *, qreal> m_moveStops;
- PositionColorMap m_moveOriginal;
+ QMap<qreal, QColor> m_moveOriginal;
};
+void QtGradientStopsWidgetPrivate::setGradientStopsModel(QtGradientStopsModel *model)
+{
+ if (m_model == model)
+ return;
+
+ if (m_model) {
+ disconnect(m_model, &QtGradientStopsModel::stopAdded,
+ this, &QtGradientStopsWidgetPrivate::slotStopAdded);
+ disconnect(m_model, &QtGradientStopsModel::stopRemoved,
+ this, &QtGradientStopsWidgetPrivate::slotStopRemoved);
+ disconnect(m_model, &QtGradientStopsModel::stopMoved,
+ this, &QtGradientStopsWidgetPrivate::slotStopMoved);
+ disconnect(m_model, &QtGradientStopsModel::stopsSwapped,
+ this, &QtGradientStopsWidgetPrivate::slotStopsSwapped);
+ disconnect(m_model, &QtGradientStopsModel::stopChanged,
+ this, &QtGradientStopsWidgetPrivate::slotStopChanged);
+ disconnect(m_model, &QtGradientStopsModel::stopSelected,
+ this, &QtGradientStopsWidgetPrivate::slotStopSelected);
+ disconnect(m_model, &QtGradientStopsModel::currentStopChanged,
+ this, &QtGradientStopsWidgetPrivate::slotCurrentStopChanged);
+
+ m_stops.clear();
+ }
+
+ m_model = model;
+
+ if (m_model) {
+ connect(m_model, &QtGradientStopsModel::stopAdded,
+ this, &QtGradientStopsWidgetPrivate::slotStopAdded);
+ connect(m_model, &QtGradientStopsModel::stopRemoved,
+ this, &QtGradientStopsWidgetPrivate::slotStopRemoved);
+ connect(m_model, &QtGradientStopsModel::stopMoved,
+ this, &QtGradientStopsWidgetPrivate::slotStopMoved);
+ connect(m_model, &QtGradientStopsModel::stopsSwapped,
+ this, &QtGradientStopsWidgetPrivate::slotStopsSwapped);
+ connect(m_model, &QtGradientStopsModel::stopChanged,
+ this, &QtGradientStopsWidgetPrivate::slotStopChanged);
+ connect(m_model, &QtGradientStopsModel::stopSelected,
+ this, &QtGradientStopsWidgetPrivate::slotStopSelected);
+ connect(m_model, &QtGradientStopsModel::currentStopChanged,
+ this, &QtGradientStopsWidgetPrivate::slotCurrentStopChanged);
+
+ const auto stopsMap = m_model->stops();
+ for (auto it = stopsMap.cbegin(), end = stopsMap.cend(); it != end; ++it)
+ slotStopAdded(it.value());
+
+ const auto selected = m_model->selectedStops();
+ for (QtGradientStop *stop : selected)
+ slotStopSelected(stop, true);
+
+ slotCurrentStopChanged(m_model->currentStop());
+ }
+}
+
double QtGradientStopsWidgetPrivate::fromViewport(int x) const
{
QSize size = q_ptr->viewport()->size();
@@ -406,61 +425,11 @@ bool QtGradientStopsWidget::isBackgroundCheckered() const
void QtGradientStopsWidget::setGradientStopsModel(QtGradientStopsModel *model)
{
- if (d_ptr->m_model == model)
- return;
-
- if (d_ptr->m_model) {
- disconnect(d_ptr->m_model, SIGNAL(stopAdded(QtGradientStop*)),
- this, SLOT(slotStopAdded(QtGradientStop*)));
- disconnect(d_ptr->m_model, SIGNAL(stopRemoved(QtGradientStop*)),
- this, SLOT(slotStopRemoved(QtGradientStop*)));
- disconnect(d_ptr->m_model, SIGNAL(stopMoved(QtGradientStop*,qreal)),
- this, SLOT(slotStopMoved(QtGradientStop*,qreal)));
- disconnect(d_ptr->m_model, SIGNAL(stopsSwapped(QtGradientStop*,QtGradientStop*)),
- this, SLOT(slotStopsSwapped(QtGradientStop*,QtGradientStop*)));
- disconnect(d_ptr->m_model, SIGNAL(stopChanged(QtGradientStop*,QColor)),
- this, SLOT(slotStopChanged(QtGradientStop*,QColor)));
- disconnect(d_ptr->m_model, SIGNAL(stopSelected(QtGradientStop*,bool)),
- this, SLOT(slotStopSelected(QtGradientStop*,bool)));
- disconnect(d_ptr->m_model, SIGNAL(currentStopChanged(QtGradientStop*)),
- this, SLOT(slotCurrentStopChanged(QtGradientStop*)));
-
- d_ptr->m_stops.clear();
- }
-
- d_ptr->m_model = model;
-
- if (d_ptr->m_model) {
- connect(d_ptr->m_model, SIGNAL(stopAdded(QtGradientStop*)),
- this, SLOT(slotStopAdded(QtGradientStop*)));
- connect(d_ptr->m_model, SIGNAL(stopRemoved(QtGradientStop*)),
- this, SLOT(slotStopRemoved(QtGradientStop*)));
- connect(d_ptr->m_model, SIGNAL(stopMoved(QtGradientStop*,qreal)),
- this, SLOT(slotStopMoved(QtGradientStop*,qreal)));
- connect(d_ptr->m_model, SIGNAL(stopsSwapped(QtGradientStop*,QtGradientStop*)),
- this, SLOT(slotStopsSwapped(QtGradientStop*,QtGradientStop*)));
- connect(d_ptr->m_model, SIGNAL(stopChanged(QtGradientStop*,QColor)),
- this, SLOT(slotStopChanged(QtGradientStop*,QColor)));
- connect(d_ptr->m_model, SIGNAL(stopSelected(QtGradientStop*,bool)),
- this, SLOT(slotStopSelected(QtGradientStop*,bool)));
- connect(d_ptr->m_model, SIGNAL(currentStopChanged(QtGradientStop*)),
- this, SLOT(slotCurrentStopChanged(QtGradientStop*)));
-
- const QtGradientStopsModel::PositionStopMap stopsMap = d_ptr->m_model->stops();
- for (auto it = stopsMap.cbegin(), end = stopsMap.cend(); it != end; ++it)
- d_ptr->slotStopAdded(it.value());
-
- const auto selected = d_ptr->m_model->selectedStops();
- for (QtGradientStop *stop : selected)
- d_ptr->slotStopSelected(stop, true);
-
- d_ptr->slotCurrentStopChanged(d_ptr->m_model->currentStop());
- }
+ d_ptr->setGradientStopsModel(model);
}
void QtGradientStopsWidget::mousePressEvent(QMouseEvent *e)
{
- typedef QtGradientStopsModel::PositionStopMap PositionStopMap;
if (!d_ptr->m_model)
return;
@@ -479,8 +448,8 @@ void QtGradientStopsWidget::mousePressEvent(QMouseEvent *e)
} else if (e->modifiers() & Qt::ShiftModifier) {
QtGradientStop *oldCurrent = d_ptr->m_model->currentStop();
if (oldCurrent) {
- PositionStopMap stops = d_ptr->m_model->stops();
- PositionStopMap::ConstIterator itSt = stops.constFind(oldCurrent->position());
+ const auto stops = d_ptr->m_model->stops();
+ auto itSt = stops.constFind(oldCurrent->position());
if (itSt != stops.constEnd()) {
while (itSt != stops.constFind(stop->position())) {
d_ptr->m_model->selectStop(itSt.value(), true);
@@ -523,9 +492,6 @@ void QtGradientStopsWidget::mouseReleaseEvent(QMouseEvent *e)
void QtGradientStopsWidget::mouseMoveEvent(QMouseEvent *e)
{
- typedef QtGradientStopsWidgetPrivate::PositionColorMap PositionColorMap;
- typedef QtGradientStopsModel::PositionStopMap PositionStopMap;
- typedef QtGradientStopsWidgetPrivate::StopPositionMap StopPositionMap;
if (!d_ptr->m_model)
return;
@@ -539,7 +505,7 @@ void QtGradientStopsWidget::mouseMoveEvent(QMouseEvent *e)
double maxOffset = 0.0;
double minOffset = 0.0;
bool first = true;
- StopPositionMap::ConstIterator itStop = d_ptr->m_moveStops.constBegin();
+ auto itStop = d_ptr->m_moveStops.cbegin();
while (itStop != d_ptr->m_moveStops.constEnd()) {
double offset = itStop.value();
@@ -559,7 +525,7 @@ void QtGradientStopsWidget::mouseMoveEvent(QMouseEvent *e)
double viewportMin = d_ptr->toViewport(-minOffset);
double viewportMax = d_ptr->toViewport(1.0 - maxOffset);
- PositionStopMap newPositions;
+ QtGradientStopsModel::PositionStopMap newPositions;
int viewportX = e->position().toPoint().x() - d_ptr->m_moveOffset;
@@ -585,7 +551,7 @@ void QtGradientStopsWidget::mouseMoveEvent(QMouseEvent *e)
}
bool forward = true;
- PositionStopMap::ConstIterator itNewPos = newPositions.constBegin();
+ auto itNewPos = newPositions.cbegin();
if (itNewPos.value()->position() < itNewPos.key())
forward = false;
@@ -609,7 +575,7 @@ void QtGradientStopsWidget::mouseMoveEvent(QMouseEvent *e)
++itNewPos;
}
- PositionColorMap::ConstIterator itOld = d_ptr->m_moveOriginal.constBegin();
+ auto itOld = d_ptr->m_moveOriginal.cbegin();
while (itOld != d_ptr->m_moveOriginal.constEnd()) {
double position = itOld.key();
if (!d_ptr->m_model->at(position))
@@ -658,7 +624,7 @@ void QtGradientStopsWidget::mouseMoveEvent(QMouseEvent *e)
double x1 = d_ptr->fromViewport(xv1);
double x2 = d_ptr->fromViewport(xv2);
- for (QtGradientStop *stop : qAsConst(d_ptr->m_stops)) {
+ for (QtGradientStop *stop : std::as_const(d_ptr->m_stops)) {
if ((stop->position() >= x1 && stop->position() <= x2) ||
beginList.contains(stop) || endList.contains(stop))
d_ptr->m_model->selectStop(stop, true);
@@ -699,7 +665,6 @@ void QtGradientStopsWidget::mouseDoubleClickEvent(QMouseEvent *e)
void QtGradientStopsWidget::keyPressEvent(QKeyEvent *e)
{
- typedef QtGradientStopsModel::PositionStopMap PositionStopMap;
if (!d_ptr->m_model)
return;
@@ -707,7 +672,7 @@ void QtGradientStopsWidget::keyPressEvent(QKeyEvent *e)
d_ptr->m_model->deleteStops();
} else if (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right ||
e->key() == Qt::Key_Home || e->key() == Qt::Key_End) {
- PositionStopMap stops = d_ptr->m_model->stops();
+ const auto stops = d_ptr->m_model->stops();
if (stops.isEmpty())
return;
QtGradientStop *newCurrent = nullptr;
@@ -718,7 +683,7 @@ void QtGradientStopsWidget::keyPressEvent(QKeyEvent *e)
else if (e->key() == Qt::Key_Right || e->key() == Qt::Key_End)
newCurrent = (--stops.constEnd()).value();
} else {
- PositionStopMap::ConstIterator itStop = stops.constBegin();
+ auto itStop = stops.cbegin();
while (itStop.value() != current)
++itStop;
if (e->key() == Qt::Key_Left && itStop != stops.constBegin())
@@ -940,13 +905,13 @@ void QtGradientStopsWidget::contextMenuEvent(QContextMenuEvent *e)
} else if (zoom() >= 100) {
zoomInAction->setEnabled(false);
}
- connect(newStopAction, SIGNAL(triggered()), this, SLOT(slotNewStop()));
- connect(deleteAction, SIGNAL(triggered()), this, SLOT(slotDelete()));
- connect(flipAllAction, SIGNAL(triggered()), this, SLOT(slotFlipAll()));
- connect(selectAllAction, SIGNAL(triggered()), this, SLOT(slotSelectAll()));
- connect(zoomInAction, SIGNAL(triggered()), this, SLOT(slotZoomIn()));
- connect(zoomOutAction, SIGNAL(triggered()), this, SLOT(slotZoomOut()));
- connect(zoomAllAction, SIGNAL(triggered()), this, SLOT(slotResetZoom()));
+ connect(newStopAction, &QAction::triggered, d_ptr.data(), &QtGradientStopsWidgetPrivate::slotNewStop);
+ connect(deleteAction, &QAction::triggered, d_ptr.data(), &QtGradientStopsWidgetPrivate::slotDelete);
+ connect(flipAllAction, &QAction::triggered, d_ptr.data(), &QtGradientStopsWidgetPrivate::slotFlipAll);
+ connect(selectAllAction, &QAction::triggered, d_ptr.data(), &QtGradientStopsWidgetPrivate::slotSelectAll);
+ connect(zoomInAction, &QAction::triggered, d_ptr.data(), &QtGradientStopsWidgetPrivate::slotZoomIn);
+ connect(zoomOutAction, &QAction::triggered, d_ptr.data(), &QtGradientStopsWidgetPrivate::slotZoomOut);
+ connect(zoomAllAction, &QAction::triggered, d_ptr.data(), &QtGradientStopsWidgetPrivate::slotResetZoom);
menu.addAction(newStopAction);
menu.addAction(deleteAction);
menu.addAction(flipAllAction);
@@ -1132,4 +1097,4 @@ double QtGradientStopsWidget::zoom() const
QT_END_NAMESPACE
-#include "moc_qtgradientstopswidget.cpp"
+#include "qtgradientstopswidget.moc"
diff --git a/src/shared/qtgradienteditor/qtgradientstopswidget.h b/src/shared/qtgradienteditor/qtgradientstopswidget.h
index 025f72846..57db5a36a 100644
--- a/src/shared/qtgradienteditor/qtgradientstopswidget.h
+++ b/src/shared/qtgradienteditor/qtgradientstopswidget.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTGRADIENTSTOPSWIDGET_H
#define QTGRADIENTSTOPSWIDGET_H
@@ -67,7 +31,6 @@ public:
double zoom() const;
signals:
-
void zoomChanged(double zoom);
protected:
@@ -92,20 +55,6 @@ private:
QScopedPointer<QtGradientStopsWidgetPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtGradientStopsWidget)
Q_DISABLE_COPY_MOVE(QtGradientStopsWidget)
- Q_PRIVATE_SLOT(d_func(), void slotStopAdded(QtGradientStop *stop))
- Q_PRIVATE_SLOT(d_func(), void slotStopRemoved(QtGradientStop *stop))
- Q_PRIVATE_SLOT(d_func(), void slotStopMoved(QtGradientStop *stop, qreal newPos))
- Q_PRIVATE_SLOT(d_func(), void slotStopsSwapped(QtGradientStop *stop1, QtGradientStop *stop2))
- Q_PRIVATE_SLOT(d_func(), void slotStopChanged(QtGradientStop *stop, const QColor &newColor))
- Q_PRIVATE_SLOT(d_func(), void slotStopSelected(QtGradientStop *stop, bool selected))
- Q_PRIVATE_SLOT(d_func(), void slotCurrentStopChanged(QtGradientStop *stop))
- Q_PRIVATE_SLOT(d_func(), void slotNewStop())
- Q_PRIVATE_SLOT(d_func(), void slotDelete())
- Q_PRIVATE_SLOT(d_func(), void slotFlipAll())
- Q_PRIVATE_SLOT(d_func(), void slotSelectAll())
- Q_PRIVATE_SLOT(d_func(), void slotZoomIn())
- Q_PRIVATE_SLOT(d_func(), void slotZoomOut())
- Q_PRIVATE_SLOT(d_func(), void slotResetZoom())
};
QT_END_NAMESPACE
diff --git a/src/shared/qtgradienteditor/qtgradientutils.cpp b/src/shared/qtgradienteditor/qtgradientutils.cpp
index 11e8d089a..fa79826b9 100644
--- a/src/shared/qtgradienteditor/qtgradientutils.cpp
+++ b/src/shared/qtgradienteditor/qtgradientutils.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientutils.h"
#include "qtgradientmanager.h"
@@ -47,24 +11,26 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static QString gradientTypeToString(QGradient::Type type)
{
if (type == QGradient::LinearGradient)
- return QLatin1String("LinearGradient");
+ return "LinearGradient"_L1;
if (type == QGradient::RadialGradient)
- return QLatin1String("RadialGradient");
+ return "RadialGradient"_L1;
if (type == QGradient::ConicalGradient)
- return QLatin1String("ConicalGradient");
- return QLatin1String("NoGradient");
+ return "ConicalGradient"_L1;
+ return "NoGradient"_L1;
}
static QGradient::Type stringToGradientType(const QString &name)
{
- if (name == QLatin1String("LinearGradient"))
+ if (name == "LinearGradient"_L1)
return QGradient::LinearGradient;
- if (name == QLatin1String("RadialGradient"))
+ if (name == "RadialGradient"_L1)
return QGradient::RadialGradient;
- if (name == QLatin1String("ConicalGradient"))
+ if (name == "ConicalGradient"_L1)
return QGradient::ConicalGradient;
return QGradient::NoGradient;
}
@@ -72,21 +38,21 @@ static QGradient::Type stringToGradientType(const QString &name)
static QString gradientSpreadToString(QGradient::Spread spread)
{
if (spread == QGradient::PadSpread)
- return QLatin1String("PadSpread");
+ return "PadSpread"_L1;
if (spread == QGradient::RepeatSpread)
- return QLatin1String("RepeatSpread");
+ return "RepeatSpread"_L1;
if (spread == QGradient::ReflectSpread)
- return QLatin1String("ReflectSpread");
- return QLatin1String("PadSpread");
+ return "ReflectSpread"_L1;
+ return "PadSpread"_L1;
}
static QGradient::Spread stringToGradientSpread(const QString &name)
{
- if (name == QLatin1String("PadSpread"))
+ if (name == "PadSpread"_L1)
return QGradient::PadSpread;
- if (name == QLatin1String("RepeatSpread"))
+ if (name == "RepeatSpread"_L1)
return QGradient::RepeatSpread;
- if (name == QLatin1String("ReflectSpread"))
+ if (name == "ReflectSpread"_L1)
return QGradient::ReflectSpread;
return QGradient::PadSpread;
}
@@ -94,42 +60,42 @@ static QGradient::Spread stringToGradientSpread(const QString &name)
static QString gradientCoordinateModeToString(QGradient::CoordinateMode mode)
{
if (mode == QGradient::LogicalMode)
- return QLatin1String("LogicalMode");
+ return "LogicalMode"_L1;
if (mode == QGradient::StretchToDeviceMode)
- return QLatin1String("StretchToDeviceMode");
+ return "StretchToDeviceMode"_L1;
if (mode == QGradient::ObjectBoundingMode)
- return QLatin1String("ObjectBoundingMode");
- return QLatin1String("StretchToDeviceMode");
+ return "ObjectBoundingMode"_L1;
+ return "StretchToDeviceMode"_L1;
}
static QGradient::CoordinateMode stringToGradientCoordinateMode(const QString &name)
{
- if (name == QLatin1String("LogicalMode"))
+ if (name == "LogicalMode"_L1)
return QGradient::LogicalMode;
- if (name == QLatin1String("StretchToDeviceMode"))
+ if (name == "StretchToDeviceMode"_L1)
return QGradient::StretchToDeviceMode;
- if (name == QLatin1String("ObjectBoundingMode"))
+ if (name == "ObjectBoundingMode"_L1)
return QGradient::ObjectBoundingMode;
return QGradient::StretchToDeviceMode;
}
static QDomElement saveColor(QDomDocument &doc, const QColor &color)
{
- QDomElement colorElem = doc.createElement(QLatin1String("colorData"));
+ QDomElement colorElem = doc.createElement("colorData"_L1);
- colorElem.setAttribute(QLatin1String("r"), QString::number(color.red()));
- colorElem.setAttribute(QLatin1String("g"), QString::number(color.green()));
- colorElem.setAttribute(QLatin1String("b"), QString::number(color.blue()));
- colorElem.setAttribute(QLatin1String("a"), QString::number(color.alpha()));
+ colorElem.setAttribute("r"_L1, QString::number(color.red()));
+ colorElem.setAttribute("g"_L1, QString::number(color.green()));
+ colorElem.setAttribute("b"_L1, QString::number(color.blue()));
+ colorElem.setAttribute("a"_L1, QString::number(color.alpha()));
return colorElem;
}
static QDomElement saveGradientStop(QDomDocument &doc, const QGradientStop &stop)
{
- QDomElement stopElem = doc.createElement(QLatin1String("stopData"));
+ QDomElement stopElem = doc.createElement("stopData"_L1);
- stopElem.setAttribute(QLatin1String("position"), QString::number(stop.first));
+ stopElem.setAttribute("position"_L1, QString::number(stop.first));
const QDomElement colorElem = saveColor(doc, stop.second);
stopElem.appendChild(colorElem);
@@ -139,12 +105,12 @@ static QDomElement saveGradientStop(QDomDocument &doc, const QGradientStop &stop
static QDomElement saveGradient(QDomDocument &doc, const QGradient &gradient)
{
- QDomElement gradElem = doc.createElement(QLatin1String("gradientData"));
+ QDomElement gradElem = doc.createElement("gradientData"_L1);
const QGradient::Type type = gradient.type();
- gradElem.setAttribute(QLatin1String("type"), gradientTypeToString(type));
- gradElem.setAttribute(QLatin1String("spread"), gradientSpreadToString(gradient.spread()));
- gradElem.setAttribute(QLatin1String("coordinateMode"), gradientCoordinateModeToString(gradient.coordinateMode()));
+ gradElem.setAttribute("type"_L1, gradientTypeToString(type));
+ gradElem.setAttribute("spread"_L1, gradientSpreadToString(gradient.spread()));
+ gradElem.setAttribute("coordinateMode"_L1, gradientCoordinateModeToString(gradient.coordinateMode()));
const QGradientStops stops = gradient.stops();
for (const QGradientStop &stop : stops)
@@ -152,22 +118,22 @@ static QDomElement saveGradient(QDomDocument &doc, const QGradient &gradient)
if (type == QGradient::LinearGradient) {
const QLinearGradient &g = *static_cast<const QLinearGradient *>(&gradient);
- gradElem.setAttribute(QLatin1String("startX"), QString::number(g.start().x()));
- gradElem.setAttribute(QLatin1String("startY"), QString::number(g.start().y()));
- gradElem.setAttribute(QLatin1String("endX"), QString::number(g.finalStop().x()));
- gradElem.setAttribute(QLatin1String("endY"), QString::number(g.finalStop().y()));
+ gradElem.setAttribute("startX"_L1, QString::number(g.start().x()));
+ gradElem.setAttribute("startY"_L1, QString::number(g.start().y()));
+ gradElem.setAttribute("endX"_L1, QString::number(g.finalStop().x()));
+ gradElem.setAttribute("endY"_L1, QString::number(g.finalStop().y()));
} else if (type == QGradient::RadialGradient) {
const QRadialGradient &g = *static_cast<const QRadialGradient *>(&gradient);
- gradElem.setAttribute(QLatin1String("centerX"), QString::number(g.center().x()));
- gradElem.setAttribute(QLatin1String("centerY"), QString::number(g.center().y()));
- gradElem.setAttribute(QLatin1String("focalX"), QString::number(g.focalPoint().x()));
- gradElem.setAttribute(QLatin1String("focalY"), QString::number(g.focalPoint().y()));
- gradElem.setAttribute(QLatin1String("radius"), QString::number(g.radius()));
+ gradElem.setAttribute("centerX"_L1, QString::number(g.center().x()));
+ gradElem.setAttribute("centerY"_L1, QString::number(g.center().y()));
+ gradElem.setAttribute("focalX"_L1, QString::number(g.focalPoint().x()));
+ gradElem.setAttribute("focalY"_L1, QString::number(g.focalPoint().y()));
+ gradElem.setAttribute("radius"_L1, QString::number(g.radius()));
} else if (type == QGradient::ConicalGradient) {
const QConicalGradient &g = *static_cast<const QConicalGradient*>(&gradient);
- gradElem.setAttribute(QLatin1String("centerX"), QString::number(g.center().x()));
- gradElem.setAttribute(QLatin1String("centerY"), QString::number(g.center().y()));
- gradElem.setAttribute(QLatin1String("angle"), QString::number(g.angle()));
+ gradElem.setAttribute("centerX"_L1, QString::number(g.center().x()));
+ gradElem.setAttribute("centerY"_L1, QString::number(g.center().y()));
+ gradElem.setAttribute("angle"_L1, QString::number(g.angle()));
}
return gradElem;
@@ -175,50 +141,50 @@ static QDomElement saveGradient(QDomDocument &doc, const QGradient &gradient)
static QColor loadColor(const QDomElement &elem)
{
- if (elem.tagName() != QLatin1String("colorData"))
+ if (elem.tagName() != "colorData"_L1)
return QColor();
- return QColor(elem.attribute(QLatin1String("r")).toInt(),
- elem.attribute(QLatin1String("g")).toInt(),
- elem.attribute(QLatin1String("b")).toInt(),
- elem.attribute(QLatin1String("a")).toInt());
+ return QColor(elem.attribute("r"_L1).toInt(),
+ elem.attribute("g"_L1).toInt(),
+ elem.attribute("b"_L1).toInt(),
+ elem.attribute("a"_L1).toInt());
}
static QGradientStop loadGradientStop(const QDomElement &elem)
{
- if (elem.tagName() != QLatin1String("stopData"))
+ if (elem.tagName() != "stopData"_L1)
return QGradientStop();
- const qreal pos = static_cast<qreal>(elem.attribute(QLatin1String("position")).toDouble());
- return qMakePair(pos, loadColor(elem.firstChild().toElement()));
+ const qreal pos = static_cast<qreal>(elem.attribute("position"_L1).toDouble());
+ return std::make_pair(pos, loadColor(elem.firstChild().toElement()));
}
static QGradient loadGradient(const QDomElement &elem)
{
- if (elem.tagName() != QLatin1String("gradientData"))
+ if (elem.tagName() != "gradientData"_L1)
return QLinearGradient();
- const QGradient::Type type = stringToGradientType(elem.attribute(QLatin1String("type")));
- const QGradient::Spread spread = stringToGradientSpread(elem.attribute(QLatin1String("spread")));
- const QGradient::CoordinateMode mode = stringToGradientCoordinateMode(elem.attribute(QLatin1String("coordinateMode")));
+ const QGradient::Type type = stringToGradientType(elem.attribute("type"_L1));
+ const QGradient::Spread spread = stringToGradientSpread(elem.attribute("spread"_L1));
+ const QGradient::CoordinateMode mode = stringToGradientCoordinateMode(elem.attribute("coordinateMode"_L1));
QGradient gradient = QLinearGradient();
if (type == QGradient::LinearGradient) {
QLinearGradient g;
- g.setStart(elem.attribute(QLatin1String("startX")).toDouble(), elem.attribute(QLatin1String("startY")).toDouble());
- g.setFinalStop(elem.attribute(QLatin1String("endX")).toDouble(), elem.attribute(QLatin1String("endY")).toDouble());
+ g.setStart(elem.attribute("startX"_L1).toDouble(), elem.attribute("startY"_L1).toDouble());
+ g.setFinalStop(elem.attribute("endX"_L1).toDouble(), elem.attribute("endY"_L1).toDouble());
gradient = g;
} else if (type == QGradient::RadialGradient) {
QRadialGradient g;
- g.setCenter(elem.attribute(QLatin1String("centerX")).toDouble(), elem.attribute(QLatin1String("centerY")).toDouble());
- g.setFocalPoint(elem.attribute(QLatin1String("focalX")).toDouble(), elem.attribute(QLatin1String("focalY")).toDouble());
- g.setRadius(elem.attribute(QLatin1String("radius")).toDouble());
+ g.setCenter(elem.attribute("centerX"_L1).toDouble(), elem.attribute("centerY"_L1).toDouble());
+ g.setFocalPoint(elem.attribute("focalX"_L1).toDouble(), elem.attribute("focalY"_L1).toDouble());
+ g.setRadius(elem.attribute("radius"_L1).toDouble());
gradient = g;
} else if (type == QGradient::ConicalGradient) {
QConicalGradient g;
- g.setCenter(elem.attribute(QLatin1String("centerX")).toDouble(), elem.attribute(QLatin1String("centerY")).toDouble());
- g.setAngle(elem.attribute(QLatin1String("angle")).toDouble());
+ g.setCenter(elem.attribute("centerX"_L1).toDouble(), elem.attribute("centerY"_L1).toDouble());
+ g.setAngle(elem.attribute("angle"_L1).toDouble());
gradient = g;
}
@@ -241,12 +207,12 @@ QString QtGradientUtils::saveState(const QtGradientManager *manager)
{
QDomDocument doc;
- QDomElement rootElem = doc.createElement(QLatin1String("gradients"));
+ QDomElement rootElem = doc.createElement("gradients"_L1);
QMap<QString, QGradient> grads = manager->gradients();
for (auto itGrad = grads.cbegin(), end = grads.cend(); itGrad != end; ++itGrad) {
- QDomElement idElem = doc.createElement(QLatin1String("gradient"));
- idElem.setAttribute(QLatin1String("name"), itGrad.key());
+ QDomElement idElem = doc.createElement("gradient"_L1);
+ idElem.setAttribute("name"_L1, itGrad.key());
QDomElement gradElem = saveGradient(doc, itGrad.value());
idElem.appendChild(gradElem);
@@ -269,7 +235,7 @@ void QtGradientUtils::restoreState(QtGradientManager *manager, const QString &st
QDomElement gradElem = rootElem.firstChildElement();
while (!gradElem.isNull()) {
- const QString name = gradElem.attribute(QLatin1String("name"));
+ const QString name = gradElem.attribute("name"_L1);
const QGradient gradient = loadGradient(gradElem.firstChildElement());
manager->addGradient(name, gradient);
@@ -315,13 +281,13 @@ static QString styleSheetFillName(const QGradient &gradient)
switch (gradient.type()) {
case QGradient::LinearGradient:
- result += QLatin1String("qlineargradient");
+ result += "qlineargradient"_L1;
break;
case QGradient::RadialGradient:
- result += QLatin1String("qradialgradient");
+ result += "qradialgradient"_L1;
break;
case QGradient::ConicalGradient:
- result += QLatin1String("qconicalgradient");
+ result += "qconicalgradient"_L1;
break;
default:
qWarning() << "QtGradientUtils::styleSheetFillName(): gradient type" << gradient.type() << "not supported!";
@@ -339,44 +305,44 @@ static QStringList styleSheetParameters(const QGradient &gradient)
QString spread;
switch (gradient.spread()) {
case QGradient::PadSpread:
- spread = QLatin1String("pad");
+ spread = "pad"_L1;
break;
case QGradient::ReflectSpread:
- spread = QLatin1String("reflect");
+ spread = "reflect"_L1;
break;
case QGradient::RepeatSpread:
- spread = QLatin1String("repeat");
+ spread = "repeat"_L1;
break;
default:
qWarning() << "QtGradientUtils::styleSheetParameters(): gradient spread" << gradient.spread() << "not supported!";
break;
}
- result << QLatin1String("spread:") + spread;
+ result << "spread:"_L1 + spread;
}
switch (gradient.type()) {
case QGradient::LinearGradient: {
const QLinearGradient *linearGradient = static_cast<const QLinearGradient*>(&gradient);
- result << QLatin1String("x1:") + QString::number(linearGradient->start().x())
- << QLatin1String("y1:") + QString::number(linearGradient->start().y())
- << QLatin1String("x2:") + QString::number(linearGradient->finalStop().x())
- << QLatin1String("y2:") + QString::number(linearGradient->finalStop().y());
+ result << "x1:"_L1 + QString::number(linearGradient->start().x())
+ << "y1:"_L1 + QString::number(linearGradient->start().y())
+ << "x2:"_L1 + QString::number(linearGradient->finalStop().x())
+ << "y2:"_L1 + QString::number(linearGradient->finalStop().y());
break;
}
case QGradient::RadialGradient: {
const QRadialGradient *radialGradient = static_cast<const QRadialGradient*>(&gradient);
- result << QLatin1String("cx:") + QString::number(radialGradient->center().x())
- << QLatin1String("cy:") + QString::number(radialGradient->center().y())
- << QLatin1String("radius:") + QString::number(radialGradient->radius())
- << QLatin1String("fx:") + QString::number(radialGradient->focalPoint().x())
- << QLatin1String("fy:") + QString::number(radialGradient->focalPoint().y());
+ result << "cx:"_L1 + QString::number(radialGradient->center().x())
+ << "cy:"_L1 + QString::number(radialGradient->center().y())
+ << "radius:"_L1 + QString::number(radialGradient->radius())
+ << "fx:"_L1 + QString::number(radialGradient->focalPoint().x())
+ << "fy:"_L1 + QString::number(radialGradient->focalPoint().y());
break;
}
case QGradient::ConicalGradient: {
const QConicalGradient *conicalGradient = static_cast<const QConicalGradient*>(&gradient);
- result << QLatin1String("cx:") + QString::number(conicalGradient->center().x())
- << QLatin1String("cy:") + QString::number(conicalGradient->center().y())
- << QLatin1String("angle:") + QString::number(conicalGradient->angle());
+ result << "cx:"_L1 + QString::number(conicalGradient->center().x())
+ << "cy:"_L1 + QString::number(conicalGradient->center().y())
+ << "angle:"_L1 + QString::number(conicalGradient->angle());
break;
}
default:
@@ -394,10 +360,10 @@ static QStringList styleSheetStops(const QGradient &gradient)
for (const QGradientStop &stop : stops) {
const QColor color = stop.second;
- const QString stopDescription = QLatin1String("stop:") + QString::number(stop.first) + QLatin1String(" rgba(")
- + QString::number(color.red()) + QLatin1String(", ")
- + QString::number(color.green()) + QLatin1String(", ")
- + QString::number(color.blue()) + QLatin1String(", ")
+ const QString stopDescription = "stop:"_L1 + QString::number(stop.first) + " rgba("_L1
+ + QString::number(color.red()) + ", "_L1
+ + QString::number(color.green()) + ", "_L1
+ + QString::number(color.blue()) + ", "_L1
+ QString::number(color.alpha()) + QLatin1Char(')');
result << stopDescription;
}
@@ -410,7 +376,7 @@ QString QtGradientUtils::styleSheetCode(const QGradient &gradient)
QStringList gradientParameters;
gradientParameters << styleSheetParameters(gradient) << styleSheetStops(gradient);
- return styleSheetFillName(gradient) + QLatin1Char('(') + gradientParameters.join(QLatin1String(", ")) + QLatin1Char(')');
+ return styleSheetFillName(gradient) + QLatin1Char('(') + gradientParameters.join(", "_L1) + QLatin1Char(')');
}
QT_END_NAMESPACE
diff --git a/src/shared/qtgradienteditor/qtgradientutils.h b/src/shared/qtgradienteditor/qtgradientutils.h
index e0fe68193..fb71c7f3c 100644
--- a/src/shared/qtgradienteditor/qtgradientutils.h
+++ b/src/shared/qtgradienteditor/qtgradientutils.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef GRADIENTUTILS_H
#define GRADIENTUTILS_H
@@ -56,7 +20,6 @@ public:
static void restoreState(QtGradientManager *manager, const QString &state);
static QPixmap gradientPixmap(const QGradient &gradient, const QSize &size = QSize(64, 64), bool checkeredBackground = false);
-
};
QT_END_NAMESPACE
diff --git a/src/shared/qtgradienteditor/qtgradientview.cpp b/src/shared/qtgradienteditor/qtgradientview.cpp
index 34c71e6fb..b6828d967 100644
--- a/src/shared/qtgradienteditor/qtgradientview.cpp
+++ b/src/shared/qtgradienteditor/qtgradientview.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientview.h"
#include "qtgradientmanager.h"
@@ -50,6 +14,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
void QtGradientView::slotGradientAdded(const QString &id, const QGradient &gradient)
{
QListWidgetItem *item = new QListWidgetItem(QtGradientUtils::gradientPixmap(gradient), id, m_ui.listWidget);
@@ -149,7 +115,7 @@ void QtGradientView::slotRenameGradient()
m_ui.listWidget->editItem(item);
}
-void QtGradientView::slotRenameGradient(QListWidgetItem *item)
+void QtGradientView::slotRenameGradientItem(QListWidgetItem *item)
{
if (!item)
return;
@@ -202,19 +168,19 @@ QtGradientView::QtGradientView(QWidget *parent)
pal.setBrush(QPalette::Base, QBrush(pm));
m_ui.listWidget->viewport()->setPalette(pal);
- connect(m_ui.listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotGradientActivated(QListWidgetItem*)));
- connect(m_ui.listWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotRenameGradient(QListWidgetItem*)));
- connect(m_ui.listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(slotCurrentItemChanged(QListWidgetItem*)));
+ connect(m_ui.listWidget, &QListWidget::itemDoubleClicked, this, &QtGradientView::slotGradientActivated);
+ connect(m_ui.listWidget, &QListWidget::itemChanged, this, &QtGradientView::slotRenameGradientItem);
+ connect(m_ui.listWidget, &QListWidget::currentItemChanged, this, &QtGradientView::slotCurrentItemChanged);
- m_newAction = new QAction(QIcon(QLatin1String(":/qt-project.org/qtgradienteditor/images/plus.png")), tr("New..."), this);
- m_editAction = new QAction(QIcon(QLatin1String(":/qt-project.org/qtgradienteditor/images/edit.png")), tr("Edit..."), this);
+ m_newAction = new QAction(QIcon(":/qt-project.org/qtgradienteditor/images/plus.png"_L1), tr("New..."), this);
+ m_editAction = new QAction(QIcon(":/qt-project.org/qtgradienteditor/images/edit.png"_L1), tr("Edit..."), this);
m_renameAction = new QAction(tr("Rename"), this);
- m_removeAction = new QAction(QIcon(QLatin1String(":/qt-project.org/qtgradienteditor/images/minus.png")), tr("Remove"), this);
+ m_removeAction = new QAction(QIcon(":/qt-project.org/qtgradienteditor/images/minus.png"_L1), tr("Remove"), this);
- connect(m_newAction, SIGNAL(triggered()), this, SLOT(slotNewGradient()));
- connect(m_editAction, SIGNAL(triggered()), this, SLOT(slotEditGradient()));
- connect(m_removeAction, SIGNAL(triggered()), this, SLOT(slotRemoveGradient()));
- connect(m_renameAction, SIGNAL(triggered()), this, SLOT(slotRenameGradient()));
+ connect(m_newAction, &QAction::triggered, this, &QtGradientView::slotNewGradient);
+ connect(m_editAction, &QAction::triggered, this, &QtGradientView::slotEditGradient);
+ connect(m_removeAction, &QAction::triggered, this, &QtGradientView::slotRemoveGradient);
+ connect(m_renameAction, &QAction::triggered, this, &QtGradientView::slotRenameGradient);
m_ui.listWidget->addAction(m_newAction);
m_ui.listWidget->addAction(m_editAction);
@@ -235,14 +201,14 @@ void QtGradientView::setGradientManager(QtGradientManager *manager)
return;
if (m_manager) {
- disconnect(m_manager, SIGNAL(gradientAdded(QString,QGradient)),
- this, SLOT(slotGradientAdded(QString,QGradient)));
- disconnect(m_manager, SIGNAL(gradientRenamed(QString,QString)),
- this, SLOT(slotGradientRenamed(QString,QString)));
- disconnect(m_manager, SIGNAL(gradientChanged(QString,QGradient)),
- this, SLOT(slotGradientChanged(QString,QGradient)));
- disconnect(m_manager, SIGNAL(gradientRemoved(QString)),
- this, SLOT(slotGradientRemoved(QString)));
+ disconnect(m_manager, &QtGradientManager::gradientAdded,
+ this, &QtGradientView::slotGradientAdded);
+ disconnect(m_manager, &QtGradientManager::gradientRenamed,
+ this, &QtGradientView::slotGradientRenamed);
+ disconnect(m_manager, &QtGradientManager::gradientChanged,
+ this, &QtGradientView::slotGradientChanged);
+ disconnect(m_manager, &QtGradientManager::gradientRemoved,
+ this, &QtGradientView::slotGradientRemoved);
m_ui.listWidget->clear();
m_idToItem.clear();
@@ -258,14 +224,14 @@ void QtGradientView::setGradientManager(QtGradientManager *manager)
for (auto itGrad = gradients.cbegin(), end = gradients.cend(); itGrad != end; ++itGrad)
slotGradientAdded(itGrad.key(), itGrad.value());
- connect(m_manager, SIGNAL(gradientAdded(QString,QGradient)),
- this, SLOT(slotGradientAdded(QString,QGradient)));
- connect(m_manager, SIGNAL(gradientRenamed(QString,QString)),
- this, SLOT(slotGradientRenamed(QString,QString)));
- connect(m_manager, SIGNAL(gradientChanged(QString,QGradient)),
- this, SLOT(slotGradientChanged(QString,QGradient)));
- connect(m_manager, SIGNAL(gradientRemoved(QString)),
- this, SLOT(slotGradientRemoved(QString)));
+ connect(m_manager, &QtGradientManager::gradientAdded,
+ this, &QtGradientView::slotGradientAdded);
+ connect(m_manager, &QtGradientManager::gradientRenamed,
+ this, &QtGradientView::slotGradientRenamed);
+ connect(m_manager, &QtGradientManager::gradientChanged,
+ this, &QtGradientView::slotGradientChanged);
+ connect(m_manager, &QtGradientManager::gradientRemoved,
+ this, &QtGradientView::slotGradientRemoved);
}
QtGradientManager *QtGradientView::gradientManager() const
diff --git a/src/shared/qtgradienteditor/qtgradientview.h b/src/shared/qtgradienteditor/qtgradientview.h
index c1637cd8f..53a44cf24 100644
--- a/src/shared/qtgradienteditor/qtgradientview.h
+++ b/src/shared/qtgradienteditor/qtgradientview.h
@@ -1,47 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef GRADIENTVIEW_H
#define GRADIENTVIEW_H
#include <QtWidgets/QWidget>
-#include <QtCore/QMap>
+#include <QtCore/QHash>
#include "ui_qtgradientview.h"
QT_BEGIN_NAMESPACE
@@ -75,13 +39,13 @@ private slots:
void slotEditGradient();
void slotRemoveGradient();
void slotRenameGradient();
- void slotRenameGradient(QListWidgetItem *item);
+ void slotRenameGradientItem(QListWidgetItem *item);
void slotCurrentItemChanged(QListWidgetItem *item);
void slotGradientActivated(QListWidgetItem *item);
private:
- QMap<QString, QListWidgetItem *> m_idToItem;
- QMap<QListWidgetItem *, QString> m_itemToId;
+ QHash<QString, QListWidgetItem *> m_idToItem;
+ QHash<QListWidgetItem *, QString> m_itemToId;
QAction *m_newAction;
QAction *m_editAction;
diff --git a/src/shared/qtgradienteditor/qtgradientviewdialog.cpp b/src/shared/qtgradienteditor/qtgradientviewdialog.cpp
index 103c4492e..6cb49e3bc 100644
--- a/src/shared/qtgradienteditor/qtgradientviewdialog.cpp
+++ b/src/shared/qtgradienteditor/qtgradientviewdialog.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientviewdialog.h"
#include "qtgradientmanager.h"
@@ -48,10 +12,10 @@ QtGradientViewDialog::QtGradientViewDialog(QWidget *parent)
{
m_ui.setupUi(this);
m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
- connect(m_ui.gradientView, SIGNAL(currentGradientChanged(QString)),
- this, SLOT(slotGradientSelected(QString)));
- connect(m_ui.gradientView, SIGNAL(gradientActivated(QString)),
- this, SLOT(slotGradientActivated(QString)));
+ connect(m_ui.gradientView, &QtGradientView::currentGradientChanged,
+ this, &QtGradientViewDialog::slotGradientSelected);
+ connect(m_ui.gradientView, &QtGradientView::gradientActivated,
+ this, &QtGradientViewDialog::slotGradientActivated);
}
void QtGradientViewDialog::setGradientManager(QtGradientManager *manager)
diff --git a/src/shared/qtgradienteditor/qtgradientviewdialog.h b/src/shared/qtgradienteditor/qtgradientviewdialog.h
index bfba02d6c..ecd089a85 100644
--- a/src/shared/qtgradienteditor/qtgradientviewdialog.h
+++ b/src/shared/qtgradienteditor/qtgradientviewdialog.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef GRADIENTVIEWDIALOG_H
#define GRADIENTVIEWDIALOG_H
diff --git a/src/shared/qtgradienteditor/qtgradientviewdialog.ui b/src/shared/qtgradienteditor/qtgradientviewdialog.ui
index 115ee7da8..431e88392 100644
--- a/src/shared/qtgradienteditor/qtgradientviewdialog.ui
+++ b/src/shared/qtgradienteditor/qtgradientviewdialog.ui
@@ -1,42 +1,8 @@
<ui version="4.0" >
- <comment>*********************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-*********************************************************************</comment>
+<comment>
+* Copyright (C) 2016 The Qt Company Ltd.
+* SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+</comment>
<class>QtGradientViewDialog</class>
<widget class="QDialog" name="QtGradientViewDialog" >
<property name="geometry" >
diff --git a/src/shared/qtgradienteditor/qtgradientwidget.cpp b/src/shared/qtgradienteditor/qtgradientwidget.cpp
index 7853e3723..1816a7e90 100644
--- a/src/shared/qtgradienteditor/qtgradientwidget.cpp
+++ b/src/shared/qtgradienteditor/qtgradientwidget.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgradientwidget.h"
#include <QtCore/QMap>
diff --git a/src/shared/qtgradienteditor/qtgradientwidget.h b/src/shared/qtgradienteditor/qtgradientwidget.h
index a5609e77b..5f3ce36af 100644
--- a/src/shared/qtgradienteditor/qtgradientwidget.h
+++ b/src/shared/qtgradienteditor/qtgradientwidget.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTGRADIENTWIDGET_H
#define QTGRADIENTWIDGET_H
@@ -90,6 +54,7 @@ public:
public slots:
void setGradientStops(const QGradientStops &stops);
+
signals:
void startLinearChanged(const QPointF &point);
diff --git a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp
index edef8564e..9b1a1ff5a 100644
--- a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp
+++ b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp
@@ -1,50 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtbuttonpropertybrowser.h"
-#include <QtCore/QSet>
+
+#include <QtCore/QHash>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QLabel>
-#include <QtCore/QTimer>
-#include <QtCore/QMap>
#include <QtWidgets/QToolButton>
-#include <QtWidgets/QStyle>
QT_BEGIN_NAMESPACE
@@ -88,10 +50,10 @@ private:
void setExpanded(WidgetItem *item, bool expanded);
QToolButton *createButton(QWidget *panret = 0) const;
- QMap<QtBrowserItem *, WidgetItem *> m_indexToItem;
- QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex;
- QMap<QWidget *, WidgetItem *> m_widgetToItem;
- QMap<QObject *, WidgetItem *> m_buttonToItem;
+ QHash<QtBrowserItem *, WidgetItem *> m_indexToItem;
+ QHash<WidgetItem *, QtBrowserItem *> m_itemToIndex;
+ QHash<QWidget *, WidgetItem *> m_widgetToItem;
+ QHash<QObject *, WidgetItem *> m_buttonToItem;
QGridLayout *m_mainLayout;
QList<WidgetItem *> m_children;
QList<WidgetItem *> m_recreateQueue;
@@ -99,7 +61,7 @@ private:
QToolButton *QtButtonPropertyBrowserPrivate::createButton(QWidget *parent) const
{
- QToolButton *button = new QToolButton(parent);
+ auto *button = new QToolButton(parent);
button->setCheckable(true);
button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@@ -123,7 +85,7 @@ int QtButtonPropertyBrowserPrivate::gridRow(WidgetItem *item) const
siblings = m_children;
int row = 0;
- for (WidgetItem *sibling : qAsConst(siblings)) {
+ for (WidgetItem *sibling : std::as_const(siblings)) {
if (sibling == item)
return row;
row += gridSpan(sibling);
@@ -142,25 +104,24 @@ void QtButtonPropertyBrowserPrivate::init(QWidget *parent)
{
m_mainLayout = new QGridLayout();
parent->setLayout(m_mainLayout);
- QLayoutItem *item = new QSpacerItem(0, 0,
- QSizePolicy::Fixed, QSizePolicy::Expanding);
+ auto *item = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
m_mainLayout->addItem(item, 0, 0);
}
void QtButtonPropertyBrowserPrivate::slotEditorDestroyed()
{
- QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender());
+ auto *editor = qobject_cast<QWidget *>(q_ptr->sender());
if (!editor)
return;
if (!m_widgetToItem.contains(editor))
return;
- m_widgetToItem[editor]->widget = 0;
+ m_widgetToItem[editor]->widget = nullptr;
m_widgetToItem.remove(editor);
}
void QtButtonPropertyBrowserPrivate::slotUpdate()
{
- for (WidgetItem *item : qAsConst(m_recreateQueue)) {
+ for (WidgetItem *item : std::as_const(m_recreateQueue)) {
WidgetItem *parent = item->parent;
QWidget *w = nullptr;
QGridLayout *l = nullptr;
@@ -232,7 +193,7 @@ void QtButtonPropertyBrowserPrivate::slotToggled(bool checked)
void QtButtonPropertyBrowserPrivate::updateLater()
{
- QTimer::singleShot(0, q_ptr, SLOT(slotUpdate()));
+ QMetaObject::invokeMethod(q_ptr, [this] { slotUpdate(); }, Qt::QueuedConnection);
}
void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex)
@@ -240,7 +201,7 @@ void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBr
WidgetItem *afterItem = m_indexToItem.value(afterIndex);
WidgetItem *parentItem = m_indexToItem.value(index->parent());
- WidgetItem *newItem = new WidgetItem();
+ auto *newItem = new WidgetItem();
newItem->parent = parentItem;
QGridLayout *layout = nullptr;
@@ -274,13 +235,14 @@ void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBr
} else {
l = m_mainLayout;
}
- QFrame *container = new QFrame();
+ auto *container = new QFrame();
container->setFrameShape(QFrame::Panel);
container->setFrameShadow(QFrame::Raised);
parentItem->container = container;
parentItem->button = createButton();
m_buttonToItem[parentItem->button] = parentItem;
- q_ptr->connect(parentItem->button, SIGNAL(toggled(bool)), q_ptr, SLOT(slotToggled(bool)));
+ q_ptr->connect(parentItem->button, &QAbstractButton::toggled,
+ q_ptr, [this](bool checked) { slotToggled(checked); });
parentItem->layout = new QGridLayout();
container->setLayout(parentItem->layout);
if (parentItem->label) {
@@ -302,7 +264,8 @@ void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBr
newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
newItem->widget = createEditor(index->property(), parentWidget);
if (newItem->widget) {
- QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, SLOT(slotEditorDestroyed()));
+ QObject::connect(newItem->widget, &QWidget::destroyed,
+ q_ptr, [this] { slotEditorDestroyed(); });
m_widgetToItem[newItem->widget] = newItem;
} else if (index->property()->hasValue()) {
newItem->widgetLabel = new QLabel(parentWidget);
@@ -360,7 +323,7 @@ void QtButtonPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index)
removeRow(m_mainLayout, row);
if (colSpan > 1)
removeRow(m_mainLayout, row);
- } else if (parentItem->children.count() != 0) {
+ } else if (parentItem->children.size() != 0) {
removeRow(parentItem->layout, row);
if (colSpan > 1)
removeRow(parentItem->layout, row);
@@ -397,7 +360,7 @@ void QtButtonPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index)
void QtButtonPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) const
{
- QMap<QLayoutItem *, QRect> itemToPos;
+ QHash<QLayoutItem *, QRect> itemToPos;
int idx = 0;
while (idx < layout->count()) {
int r, c, rs, cs;
@@ -417,7 +380,7 @@ void QtButtonPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) con
void QtButtonPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const
{
- QMap<QLayoutItem *, QRect> itemToPos;
+ QHash<QLayoutItem *, QRect> itemToPos;
int idx = 0;
while (idx < layout->count()) {
int r, c, rs, cs;
@@ -553,8 +516,7 @@ QtButtonPropertyBrowser::QtButtonPropertyBrowser(QWidget *parent)
*/
QtButtonPropertyBrowser::~QtButtonPropertyBrowser()
{
- const QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator icend = d_ptr->m_itemToIndex.constEnd();
- for (QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator it = d_ptr->m_itemToIndex.constBegin(); it != icend; ++it)
+ for (auto it = d_ptr->m_itemToIndex.cbegin(), icend = d_ptr->m_itemToIndex.cend(); it != icend; ++it)
delete it.key();
}
diff --git a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h
index f76d476c5..2a02405aa 100644
--- a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h
+++ b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTBUTTONPROPERTYBROWSER_H
#define QTBUTTONPROPERTYBROWSER_H
@@ -50,7 +14,6 @@ class QtButtonPropertyBrowser : public QtAbstractPropertyBrowser
{
Q_OBJECT
public:
-
QtButtonPropertyBrowser(QWidget *parent = 0);
~QtButtonPropertyBrowser();
@@ -58,7 +21,6 @@ public:
bool isExpanded(QtBrowserItem *item) const;
Q_SIGNALS:
-
void collapsed(QtBrowserItem *item);
void expanded(QtBrowserItem *item);
@@ -68,14 +30,9 @@ protected:
void itemChanged(QtBrowserItem *item) override;
private:
-
QScopedPointer<QtButtonPropertyBrowserPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtButtonPropertyBrowser)
Q_DISABLE_COPY_MOVE(QtButtonPropertyBrowser)
- Q_PRIVATE_SLOT(d_func(), void slotUpdate())
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed())
- Q_PRIVATE_SLOT(d_func(), void slotToggled(bool))
-
};
QT_END_NAMESPACE
diff --git a/src/shared/qtpropertybrowser/qteditorfactory.cpp b/src/shared/qtpropertybrowser/qteditorfactory.cpp
index 31211333e..1f51f2ba7 100644
--- a/src/shared/qtpropertybrowser/qteditorfactory.cpp
+++ b/src/shared/qtpropertybrowser/qteditorfactory.cpp
@@ -1,63 +1,28 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qteditorfactory.h"
#include "qtpropertybrowserutils_p.h"
-#include <QtWidgets/QSpinBox>
-#include <QtWidgets/QScrollBar>
-#include <QtWidgets/QComboBox>
-#include <QtWidgets/QAbstractItemView>
-#include <QtWidgets/QLineEdit>
-#include <QtWidgets/QDateTimeEdit>
-#include <QtWidgets/QHBoxLayout>
-#include <QtWidgets/QMenu>
+
+#include <QtCore/QHash>
+#include <QtCore/QRegularExpression>
#include <QtGui/QKeyEvent>
#include <QtGui/QRegularExpressionValidator>
+#include <QtWidgets/QAbstractItemView>
#include <QtWidgets/QApplication>
-#include <QtWidgets/QLabel>
-#include <QtWidgets/QToolButton>
+#include <QtWidgets/QBoxLayout>
#include <QtWidgets/QColorDialog>
+#include <QtWidgets/QComboBox>
+#include <QtWidgets/QDateTimeEdit>
#include <QtWidgets/QFontDialog>
-#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QKeySequenceEdit>
-#include <QtCore/QMap>
-#include <QtCore/QRegularExpression>
+#include <QtWidgets/QLabel>
+#include <QtWidgets/QLineEdit>
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QScrollBar>
+#include <QtWidgets/QSpacerItem>
+#include <QtWidgets/QSpinBox>
+#include <QtWidgets/QToolButton>
#if defined(Q_CC_MSVC)
# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */
@@ -85,9 +50,9 @@ class EditorFactoryPrivate
{
public:
- typedef QList<Editor *> EditorList;
- typedef QMap<QtProperty *, EditorList> PropertyToEditorListMap;
- typedef QMap<Editor *, QtProperty *> EditorToPropertyMap;
+ using EditorList = QList<Editor *>;
+ using PropertyToEditorListMap = QHash<QtProperty *, EditorList>;
+ using EditorToPropertyMap = QHash<Editor *, QtProperty *>;
Editor *createEditor(QtProperty *property, QWidget *parent);
void initializeEditor(QtProperty *property, Editor *e);
@@ -100,7 +65,7 @@ public:
template <class Editor>
Editor *EditorFactoryPrivate<Editor>::createEditor(QtProperty *property, QWidget *parent)
{
- Editor *editor = new Editor(parent);
+ auto *editor = new Editor(parent);
initializeEditor(property, editor);
return editor;
}
@@ -108,7 +73,7 @@ Editor *EditorFactoryPrivate<Editor>::createEditor(QtProperty *property, QWidget
template <class Editor>
void EditorFactoryPrivate<Editor>::initializeEditor(QtProperty *property, Editor *editor)
{
- typename PropertyToEditorListMap::iterator it = m_createdEditors.find(property);
+ auto it = m_createdEditors.find(property);
if (it == m_createdEditors.end())
it = m_createdEditors.insert(property, EditorList());
it.value().append(editor);
@@ -118,12 +83,12 @@ void EditorFactoryPrivate<Editor>::initializeEditor(QtProperty *property, Editor
template <class Editor>
void EditorFactoryPrivate<Editor>::slotEditorDestroyed(QObject *object)
{
- const typename EditorToPropertyMap::iterator ecend = m_editorToProperty.end();
- for (typename EditorToPropertyMap::iterator itEditor = m_editorToProperty.begin(); itEditor != ecend; ++itEditor) {
+ const auto ecend = m_editorToProperty.end();
+ for (auto itEditor = m_editorToProperty.begin(); itEditor != ecend; ++itEditor) {
if (itEditor.key() == object) {
Editor *editor = itEditor.key();
QtProperty *property = itEditor.value();
- const typename PropertyToEditorListMap::iterator pit = m_createdEditors.find(property);
+ const auto pit = m_createdEditors.find(property);
if (pit != m_createdEditors.end()) {
pit.value().removeAll(editor);
if (pit.value().isEmpty())
@@ -196,8 +161,7 @@ void QtSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, int st
void QtSpinBoxFactoryPrivate::slotSetValue(int value)
{
QObject *object = q_ptr->sender();
- const QMap<QSpinBox *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) {
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) {
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtIntPropertyManager *manager = q_ptr->propertyManager(property);
@@ -246,12 +210,15 @@ QtSpinBoxFactory::~QtSpinBoxFactory()
*/
void QtSpinBoxFactory::connectPropertyManager(QtIntPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotPropertyChanged(QtProperty*,int)));
- connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)),
- this, SLOT(slotSingleStepChanged(QtProperty*,int)));
+ connect(manager, &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotPropertyChanged(property, value); });
+ connect(manager, &QtIntPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, int min, int max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(manager, &QtIntPropertyManager::singleStepChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotSingleStepChanged(property, value); });
}
/*!
@@ -268,9 +235,10 @@ QWidget *QtSpinBoxFactory::createEditor(QtIntPropertyManager *manager, QtPropert
editor->setValue(manager->value(property));
editor->setKeyboardTracking(false);
- connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QSpinBox::valueChanged,
+ this, [this](int value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -281,12 +249,9 @@ QWidget *QtSpinBoxFactory::createEditor(QtIntPropertyManager *manager, QtPropert
*/
void QtSpinBoxFactory::disconnectPropertyManager(QtIntPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotPropertyChanged(QtProperty*,int)));
- disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)),
- this, SLOT(slotSingleStepChanged(QtProperty*,int)));
+ disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr);
+ disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr);
+ disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr);
}
// QtSliderFactory
@@ -347,8 +312,7 @@ void QtSliderFactoryPrivate::slotSingleStepChanged(QtProperty *property, int ste
void QtSliderFactoryPrivate::slotSetValue(int value)
{
QObject *object = q_ptr->sender();
- const QMap<QSlider *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QSlider *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor ) {
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor ) {
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtIntPropertyManager *manager = q_ptr->propertyManager(property);
@@ -397,12 +361,15 @@ QtSliderFactory::~QtSliderFactory()
*/
void QtSliderFactory::connectPropertyManager(QtIntPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotPropertyChanged(QtProperty*,int)));
- connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)),
- this, SLOT(slotSingleStepChanged(QtProperty*,int)));
+ connect(manager, &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotPropertyChanged(property, value); });
+ connect(manager, &QtIntPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, int min, int max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(manager, &QtIntPropertyManager::singleStepChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotSingleStepChanged(property, value); });
}
/*!
@@ -413,15 +380,16 @@ void QtSliderFactory::connectPropertyManager(QtIntPropertyManager *manager)
QWidget *QtSliderFactory::createEditor(QtIntPropertyManager *manager, QtProperty *property,
QWidget *parent)
{
- QSlider *editor = new QSlider(Qt::Horizontal, parent);
+ auto *editor = new QSlider(Qt::Horizontal, parent);
d_ptr->initializeEditor(property, editor);
editor->setSingleStep(manager->singleStep(property));
editor->setRange(manager->minimum(property), manager->maximum(property));
editor->setValue(manager->value(property));
- connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QSlider::valueChanged,
+ this, [this](int value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -432,12 +400,9 @@ QWidget *QtSliderFactory::createEditor(QtIntPropertyManager *manager, QtProperty
*/
void QtSliderFactory::disconnectPropertyManager(QtIntPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotPropertyChanged(QtProperty*,int)));
- disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)),
- this, SLOT(slotSingleStepChanged(QtProperty*,int)));
+ disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr);
+ disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr);
+ disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr);
}
// QtSliderFactory
@@ -499,8 +464,7 @@ void QtScrollBarFactoryPrivate::slotSingleStepChanged(QtProperty *property, int
void QtScrollBarFactoryPrivate::slotSetValue(int value)
{
QObject *object = q_ptr->sender();
- const QMap<QScrollBar *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QScrollBar *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtIntPropertyManager *manager = q_ptr->propertyManager(property);
@@ -548,12 +512,15 @@ QtScrollBarFactory::~QtScrollBarFactory()
*/
void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotPropertyChanged(QtProperty*,int)));
- connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)),
- this, SLOT(slotSingleStepChanged(QtProperty*,int)));
+ connect(manager, &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotPropertyChanged(property, value); });
+ connect(manager, &QtIntPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, int min, int max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(manager, &QtIntPropertyManager::singleStepChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotSingleStepChanged(property, value); });
}
/*!
@@ -564,14 +531,15 @@ void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager *manager)
QWidget *QtScrollBarFactory::createEditor(QtIntPropertyManager *manager, QtProperty *property,
QWidget *parent)
{
- QScrollBar *editor = new QScrollBar(Qt::Horizontal, parent);
+ auto *editor = new QScrollBar(Qt::Horizontal, parent);
d_ptr->initializeEditor(property, editor);
editor->setSingleStep(manager->singleStep(property));
editor->setRange(manager->minimum(property), manager->maximum(property));
editor->setValue(manager->value(property));
- connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QScrollBar::valueChanged,
+ this, [this](int value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -582,12 +550,9 @@ QWidget *QtScrollBarFactory::createEditor(QtIntPropertyManager *manager, QtPrope
*/
void QtScrollBarFactory::disconnectPropertyManager(QtIntPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotPropertyChanged(QtProperty*,int)));
- disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)),
- this, SLOT(slotSingleStepChanged(QtProperty*,int)));
+ disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr);
+ disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr);
+ disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr);
}
// QtCheckBoxFactory
@@ -618,8 +583,7 @@ void QtCheckBoxFactoryPrivate::slotSetValue(bool value)
{
QObject *object = q_ptr->sender();
- const QMap<QtBoolEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QtBoolEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtBoolPropertyManager *manager = q_ptr->propertyManager(property);
@@ -667,8 +631,9 @@ QtCheckBoxFactory::~QtCheckBoxFactory()
*/
void QtCheckBoxFactory::connectPropertyManager(QtBoolPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,bool)),
- this, SLOT(slotPropertyChanged(QtProperty*,bool)));
+ connect(manager, &QtBoolPropertyManager::valueChanged,
+ this, [this](QtProperty *property, bool value)
+ { d_ptr->slotPropertyChanged(property, value); });
}
/*!
@@ -682,9 +647,10 @@ QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtPrope
QtBoolEdit *editor = d_ptr->createEditor(property, parent);
editor->setChecked(manager->value(property));
- connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QtBoolEdit::toggled,
+ this, [this](bool value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -695,8 +661,7 @@ QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtPrope
*/
void QtCheckBoxFactory::disconnectPropertyManager(QtBoolPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,bool)),
- this, SLOT(slotPropertyChanged(QtProperty*,bool)));
+ disconnect(manager, &QtBoolPropertyManager::valueChanged, this, nullptr);
}
// QtDoubleSpinBoxFactory
@@ -785,8 +750,7 @@ void QtDoubleSpinBoxFactoryPrivate::slotDecimalsChanged(QtProperty *property, in
void QtDoubleSpinBoxFactoryPrivate::slotSetValue(double value)
{
QObject *object = q_ptr->sender();
- const QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itcend = m_editorToProperty.constEnd();
- for (QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != itcend; ++itEditor) {
+ for (auto itEditor = m_editorToProperty.cbegin(), itcend = m_editorToProperty.cend(); itEditor != itcend; ++itEditor) {
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtDoublePropertyManager *manager = q_ptr->propertyManager(property);
@@ -834,14 +798,18 @@ QtDoubleSpinBoxFactory::~QtDoubleSpinBoxFactory()
*/
void QtDoubleSpinBoxFactory::connectPropertyManager(QtDoublePropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotPropertyChanged(QtProperty*,double)));
- connect(manager, SIGNAL(rangeChanged(QtProperty*,double,double)),
- this, SLOT(slotRangeChanged(QtProperty*,double,double)));
- connect(manager, SIGNAL(singleStepChanged(QtProperty*,double)),
- this, SLOT(slotSingleStepChanged(QtProperty*,double)));
- connect(manager, SIGNAL(decimalsChanged(QtProperty*,int)),
- this, SLOT(slotDecimalsChanged(QtProperty*,int)));
+ connect(manager, &QtDoublePropertyManager::valueChanged,
+ this, [this](QtProperty *property, double value)
+ { d_ptr->slotPropertyChanged(property, value); });
+ connect(manager, &QtDoublePropertyManager::rangeChanged,
+ this, [this](QtProperty *property, double min, double max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(manager, &QtDoublePropertyManager::singleStepChanged,
+ this, [this](QtProperty *property, double value)
+ { d_ptr->slotSingleStepChanged(property, value); });
+ connect(manager, &QtDoublePropertyManager::decimalsChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotDecimalsChanged(property, value); });
}
/*!
@@ -859,9 +827,10 @@ QWidget *QtDoubleSpinBoxFactory::createEditor(QtDoublePropertyManager *manager,
editor->setValue(manager->value(property));
editor->setKeyboardTracking(false);
- connect(editor, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QDoubleSpinBox::valueChanged,
+ this, [this](double value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -872,14 +841,10 @@ QWidget *QtDoubleSpinBoxFactory::createEditor(QtDoublePropertyManager *manager,
*/
void QtDoubleSpinBoxFactory::disconnectPropertyManager(QtDoublePropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotPropertyChanged(QtProperty*,double)));
- disconnect(manager, SIGNAL(rangeChanged(QtProperty*,double,double)),
- this, SLOT(slotRangeChanged(QtProperty*,double,double)));
- disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,double)),
- this, SLOT(slotSingleStepChanged(QtProperty*,double)));
- disconnect(manager, SIGNAL(decimalsChanged(QtProperty*,int)),
- this, SLOT(slotDecimalsChanged(QtProperty*,int)));
+ disconnect(manager, &QtDoublePropertyManager::valueChanged, this, nullptr);
+ disconnect(manager, &QtDoublePropertyManager::rangeChanged, this, nullptr);
+ disconnect(manager, &QtDoublePropertyManager::singleStepChanged, this, nullptr);
+ disconnect(manager, &QtDoublePropertyManager::decimalsChanged, this, nullptr);
}
// QtLineEditFactory
@@ -936,8 +901,7 @@ void QtLineEditFactoryPrivate::slotRegExpChanged(QtProperty *property,
void QtLineEditFactoryPrivate::slotSetValue(const QString &value)
{
QObject *object = q_ptr->sender();
- const QMap<QLineEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QLineEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtStringPropertyManager *manager = q_ptr->propertyManager(property);
@@ -985,10 +949,12 @@ QtLineEditFactory::~QtLineEditFactory()
*/
void QtLineEditFactory::connectPropertyManager(QtStringPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QString)),
- this, SLOT(slotPropertyChanged(QtProperty*,QString)));
- connect(manager, SIGNAL(regExpChanged(QtProperty*,QRegularExpression)),
- this, SLOT(slotRegExpChanged(QtProperty*,QRegularExpression)));
+ connect(manager, &QtStringPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QString &value)
+ { d_ptr->slotPropertyChanged(property, value); });
+ connect(manager, &QtStringPropertyManager::regExpChanged,
+ this, [this](QtProperty *property, const QRegularExpression &value)
+ { d_ptr->slotRegExpChanged(property, value); });
}
/*!
@@ -999,19 +965,18 @@ void QtLineEditFactory::connectPropertyManager(QtStringPropertyManager *manager)
QWidget *QtLineEditFactory::createEditor(QtStringPropertyManager *manager,
QtProperty *property, QWidget *parent)
{
-
QLineEdit *editor = d_ptr->createEditor(property, parent);
QRegularExpression regExp = manager->regExp(property);
if (regExp.isValid() && !regExp.pattern().isEmpty()) {
- QValidator *validator = new QRegularExpressionValidator(regExp, editor);
+ auto *validator = new QRegularExpressionValidator(regExp, editor);
editor->setValidator(validator);
}
editor->setText(manager->value(property));
- connect(editor, SIGNAL(textEdited(QString)),
- this, SLOT(slotSetValue(QString)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QLineEdit::textEdited,
+ this, [this](const QString &value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -1022,10 +987,8 @@ QWidget *QtLineEditFactory::createEditor(QtStringPropertyManager *manager,
*/
void QtLineEditFactory::disconnectPropertyManager(QtStringPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QString)),
- this, SLOT(slotPropertyChanged(QtProperty*,QString)));
- disconnect(manager, SIGNAL(regExpChanged(QtProperty*,QRegularExpression)),
- this, SLOT(slotRegExpChanged(QtProperty*,QRegularExpression)));
+ disconnect(manager, &QtStringPropertyManager::valueChanged, this, nullptr);
+ disconnect(manager, &QtStringPropertyManager::regExpChanged, this, nullptr);
}
// QtDateEditFactory
@@ -1074,8 +1037,7 @@ void QtDateEditFactoryPrivate::slotRangeChanged(QtProperty *property, QDate min,
void QtDateEditFactoryPrivate::slotSetValue(QDate value)
{
QObject *object = q_ptr->sender();
- const QMap<QDateEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QDateEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtDatePropertyManager *manager = q_ptr->propertyManager(property);
@@ -1123,10 +1085,12 @@ QtDateEditFactory::~QtDateEditFactory()
*/
void QtDateEditFactory::connectPropertyManager(QtDatePropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QDate)),
- this, SLOT(slotPropertyChanged(QtProperty*,QDate)));
- connect(manager, SIGNAL(rangeChanged(QtProperty*,QDate,QDate)),
- this, SLOT(slotRangeChanged(QtProperty*,QDate,QDate)));
+ connect(manager, &QtDatePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QDate &value)
+ { d_ptr->slotPropertyChanged(property, value); });
+ connect(manager, &QtDatePropertyManager::rangeChanged,
+ this, [this](QtProperty *property, const QDate &min, const QDate &max)
+ { d_ptr->slotRangeChanged(property, min, max); });
}
/*!
@@ -1143,10 +1107,10 @@ QWidget *QtDateEditFactory::createEditor(QtDatePropertyManager *manager, QtPrope
editor->setDateRange(manager->minimum(property), manager->maximum(property));
editor->setDate(manager->value(property));
- connect(editor, SIGNAL(dateChanged(QDate)),
- this, SLOT(slotSetValue(QDate)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QDateEdit::dateChanged,
+ this, [this](const QDate &value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -1157,10 +1121,8 @@ QWidget *QtDateEditFactory::createEditor(QtDatePropertyManager *manager, QtPrope
*/
void QtDateEditFactory::disconnectPropertyManager(QtDatePropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QDate)),
- this, SLOT(slotPropertyChanged(QtProperty*,QDate)));
- disconnect(manager, SIGNAL(rangeChanged(QtProperty*,QDate,QDate)),
- this, SLOT(slotRangeChanged(QtProperty*,QDate,QDate)));
+ disconnect(manager, &QtDatePropertyManager::valueChanged, this, nullptr);
+ disconnect(manager, &QtDatePropertyManager::rangeChanged, this, nullptr);
}
// QtTimeEditFactory
@@ -1190,8 +1152,7 @@ void QtTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, QTime v
void QtTimeEditFactoryPrivate::slotSetValue(QTime value)
{
QObject *object = q_ptr->sender();
- const QMap<QTimeEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QTimeEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtTimePropertyManager *manager = q_ptr->propertyManager(property);
@@ -1239,8 +1200,9 @@ QtTimeEditFactory::~QtTimeEditFactory()
*/
void QtTimeEditFactory::connectPropertyManager(QtTimePropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QTime)),
- this, SLOT(slotPropertyChanged(QtProperty*,QTime)));
+ connect(manager, &QtTimePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QTime &value)
+ { d_ptr->slotPropertyChanged(property, value); });
}
/*!
@@ -1255,10 +1217,10 @@ QWidget *QtTimeEditFactory::createEditor(QtTimePropertyManager *manager, QtPrope
editor->setDisplayFormat(QtPropertyBrowserUtils::timeFormat());
editor->setTime(manager->value(property));
- connect(editor, SIGNAL(timeChanged(QTime)),
- this, SLOT(slotSetValue(QTime)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QTimeEdit::timeChanged,
+ this, [this](const QTime &value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -1269,8 +1231,7 @@ QWidget *QtTimeEditFactory::createEditor(QtTimePropertyManager *manager, QtPrope
*/
void QtTimeEditFactory::disconnectPropertyManager(QtTimePropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QTime)),
- this, SLOT(slotPropertyChanged(QtProperty*,QTime)));
+ disconnect(manager, &QtTimePropertyManager::valueChanged, this, nullptr);
}
// QtDateTimeEditFactory
@@ -1303,8 +1264,7 @@ void QtDateTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property,
void QtDateTimeEditFactoryPrivate::slotSetValue(const QDateTime &value)
{
QObject *object = q_ptr->sender();
- const QMap<QDateTimeEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QDateTimeEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtDateTimePropertyManager *manager = q_ptr->propertyManager(property);
@@ -1352,8 +1312,9 @@ QtDateTimeEditFactory::~QtDateTimeEditFactory()
*/
void QtDateTimeEditFactory::connectPropertyManager(QtDateTimePropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QDateTime)),
- this, SLOT(slotPropertyChanged(QtProperty*,QDateTime)));
+ connect(manager, &QtDateTimePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QDateTime &value)
+ { d_ptr->slotPropertyChanged(property, value); });
}
/*!
@@ -1368,10 +1329,10 @@ QWidget *QtDateTimeEditFactory::createEditor(QtDateTimePropertyManager *manager,
editor->setDisplayFormat(QtPropertyBrowserUtils::dateTimeFormat());
editor->setDateTime(manager->value(property));
- connect(editor, SIGNAL(dateTimeChanged(QDateTime)),
- this, SLOT(slotSetValue(QDateTime)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QDateTimeEdit::dateTimeChanged,
+ this, [this](const QDateTime &value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -1382,8 +1343,7 @@ QWidget *QtDateTimeEditFactory::createEditor(QtDateTimePropertyManager *manager,
*/
void QtDateTimeEditFactory::disconnectPropertyManager(QtDateTimePropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QDateTime)),
- this, SLOT(slotPropertyChanged(QtProperty*,QDateTime)));
+ disconnect(manager, &QtDateTimePropertyManager::valueChanged, this, nullptr);
}
// QtKeySequenceEditorFactory
@@ -1415,8 +1375,7 @@ void QtKeySequenceEditorFactoryPrivate::slotPropertyChanged(QtProperty *property
void QtKeySequenceEditorFactoryPrivate::slotSetValue(const QKeySequence &value)
{
QObject *object = q_ptr->sender();
- const QMap<QKeySequenceEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QKeySequenceEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtKeySequencePropertyManager *manager = q_ptr->propertyManager(property);
@@ -1464,8 +1423,9 @@ QtKeySequenceEditorFactory::~QtKeySequenceEditorFactory()
*/
void QtKeySequenceEditorFactory::connectPropertyManager(QtKeySequencePropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QKeySequence)),
- this, SLOT(slotPropertyChanged(QtProperty*,QKeySequence)));
+ connect(manager, &QtKeySequencePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QKeySequence &value)
+ { d_ptr->slotPropertyChanged(property, value); });
}
/*!
@@ -1479,10 +1439,10 @@ QWidget *QtKeySequenceEditorFactory::createEditor(QtKeySequencePropertyManager *
QKeySequenceEdit *editor = d_ptr->createEditor(property, parent);
editor->setKeySequence(manager->value(property));
- connect(editor, SIGNAL(keySequenceChanged(QKeySequence)),
- this, SLOT(slotSetValue(QKeySequence)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QKeySequenceEdit::keySequenceChanged,
+ this, [this](const QKeySequence &value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -1493,8 +1453,7 @@ QWidget *QtKeySequenceEditorFactory::createEditor(QtKeySequencePropertyManager *
*/
void QtKeySequenceEditorFactory::disconnectPropertyManager(QtKeySequencePropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QKeySequence)),
- this, SLOT(slotPropertyChanged(QtProperty*,QKeySequence)));
+ disconnect(manager, &QtKeySequencePropertyManager::valueChanged, this, nullptr);
}
// QtCharEdit
@@ -1529,7 +1488,7 @@ private:
QtCharEdit::QtCharEdit(QWidget *parent)
: QWidget(parent), m_lineEdit(new QLineEdit(this))
{
- QHBoxLayout *layout = new QHBoxLayout(this);
+ auto *layout = new QHBoxLayout(this);
layout->addWidget(m_lineEdit);
layout->setContentsMargins(QMargins());
m_lineEdit->installEventFilter(this);
@@ -1550,17 +1509,17 @@ bool QtCharEdit::eventFilter(QObject *o, QEvent *e)
QString actionString = action->text();
const int pos = actionString.lastIndexOf(QLatin1Char('\t'));
if (pos > 0)
- actionString = actionString.remove(pos, actionString.length() - pos);
+ actionString = actionString.remove(pos, actionString.size() - pos);
action->setText(actionString);
}
QAction *actionBefore = nullptr;
- if (actions.count() > 0)
+ if (actions.size() > 0)
actionBefore = actions[0];
- QAction *clearAction = new QAction(tr("Clear Char"), menu);
+ auto *clearAction = new QAction(tr("Clear Char"), menu);
menu->insertAction(actionBefore, clearAction);
menu->insertSeparator(actionBefore);
clearAction->setEnabled(!m_value.isNull());
- connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearChar()));
+ connect(clearAction, &QAction::triggered, this, &QtCharEdit::slotClearChar);
menu->exec(c->globalPos());
delete menu;
e->accept();
@@ -1594,7 +1553,7 @@ void QtCharEdit::handleKeyEvent(QKeyEvent *e)
}
const QString text = e->text();
- if (text.count() != 1)
+ if (text.size() != 1)
return;
const QChar c = text.at(0);
@@ -1694,8 +1653,7 @@ void QtCharEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
void QtCharEditorFactoryPrivate::slotSetValue(const QChar &value)
{
QObject *object = q_ptr->sender();
- const QMap<QtCharEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QtCharEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtCharPropertyManager *manager = q_ptr->propertyManager(property);
@@ -1743,8 +1701,9 @@ QtCharEditorFactory::~QtCharEditorFactory()
*/
void QtCharEditorFactory::connectPropertyManager(QtCharPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QChar)),
- this, SLOT(slotPropertyChanged(QtProperty*,QChar)));
+ connect(manager, &QtCharPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QChar &value)
+ { d_ptr->slotPropertyChanged(property, value); });
}
/*!
@@ -1758,10 +1717,10 @@ QWidget *QtCharEditorFactory::createEditor(QtCharPropertyManager *manager,
QtCharEdit *editor = d_ptr->createEditor(property, parent);
editor->setValue(manager->value(property));
- connect(editor, SIGNAL(valueChanged(QChar)),
- this, SLOT(slotSetValue(QChar)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QtCharEdit::valueChanged,
+ this, [this](const QChar &value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -1772,8 +1731,7 @@ QWidget *QtCharEditorFactory::createEditor(QtCharPropertyManager *manager,
*/
void QtCharEditorFactory::disconnectPropertyManager(QtCharPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QChar)),
- this, SLOT(slotPropertyChanged(QtProperty*,QChar)));
+ disconnect(manager, &QtCharPropertyManager::valueChanged, this, nullptr);
}
// QtEnumEditorFactory
@@ -1820,7 +1778,7 @@ void QtEnumEditorFactoryPrivate::slotEnumNamesChanged(QtProperty *property,
editor->blockSignals(true);
editor->clear();
editor->addItems(enumNames);
- const int nameCount = enumNames.count();
+ const int nameCount = enumNames.size();
for (int i = 0; i < nameCount; i++)
editor->setItemIcon(i, enumIcons.value(i));
editor->setCurrentIndex(manager->value(property));
@@ -1842,7 +1800,7 @@ void QtEnumEditorFactoryPrivate::slotEnumIconsChanged(QtProperty *property,
const QStringList enumNames = manager->enumNames(property);
for (QComboBox *editor : it.value()) {
editor->blockSignals(true);
- const int nameCount = enumNames.count();
+ const int nameCount = enumNames.size();
for (int i = 0; i < nameCount; i++)
editor->setItemIcon(i, enumIcons.value(i));
editor->setCurrentIndex(manager->value(property));
@@ -1853,8 +1811,7 @@ void QtEnumEditorFactoryPrivate::slotEnumIconsChanged(QtProperty *property,
void QtEnumEditorFactoryPrivate::slotSetValue(int value)
{
QObject *object = q_ptr->sender();
- const QMap<QComboBox *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
- for (QMap<QComboBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtEnumPropertyManager *manager = q_ptr->propertyManager(property);
@@ -1902,10 +1859,12 @@ QtEnumEditorFactory::~QtEnumEditorFactory()
*/
void QtEnumEditorFactory::connectPropertyManager(QtEnumPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotPropertyChanged(QtProperty*,int)));
- connect(manager, SIGNAL(enumNamesChanged(QtProperty*,QStringList)),
- this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList)));
+ connect(manager, &QtEnumPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotPropertyChanged(property, value); });
+ connect(manager, &QtEnumPropertyManager::enumNamesChanged,
+ this, [this](QtProperty *property, const QStringList &value)
+ { d_ptr->slotEnumNamesChanged(property, value); });
}
/*!
@@ -1922,14 +1881,15 @@ QWidget *QtEnumEditorFactory::createEditor(QtEnumPropertyManager *manager, QtPro
QStringList enumNames = manager->enumNames(property);
editor->addItems(enumNames);
QMap<int, QIcon> enumIcons = manager->enumIcons(property);
- const int enumNamesCount = enumNames.count();
+ const int enumNamesCount = enumNames.size();
for (int i = 0; i < enumNamesCount; i++)
editor->setItemIcon(i, enumIcons.value(i));
editor->setCurrentIndex(manager->value(property));
- connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int)));
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QComboBox::currentIndexChanged,
+ this, [this](int value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -1940,16 +1900,12 @@ QWidget *QtEnumEditorFactory::createEditor(QtEnumPropertyManager *manager, QtPro
*/
void QtEnumEditorFactory::disconnectPropertyManager(QtEnumPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotPropertyChanged(QtProperty*,int)));
- disconnect(manager, SIGNAL(enumNamesChanged(QtProperty*,QStringList)),
- this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList)));
+ disconnect(manager, &QtEnumPropertyManager::valueChanged, this, nullptr);
+ disconnect(manager, &QtEnumPropertyManager::enumNamesChanged, this, nullptr);
}
// QtCursorEditorFactory
-Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase)
-
class QtCursorEditorFactoryPrivate
{
QtCursorEditorFactory *q_ptr;
@@ -1964,10 +1920,10 @@ public:
QtEnumEditorFactory *m_enumEditorFactory;
QtEnumPropertyManager *m_enumPropertyManager;
- QMap<QtProperty *, QtProperty *> m_propertyToEnum;
- QMap<QtProperty *, QtProperty *> m_enumToProperty;
- QMap<QtProperty *, QWidgetList > m_enumToEditors;
- QMap<QWidget *, QtProperty *> m_editorToEnum;
+ QHash<QtProperty *, QtProperty *> m_propertyToEnum;
+ QHash<QtProperty *, QtProperty *> m_enumToProperty;
+ QHash<QtProperty *, QWidgetList > m_enumToEditors;
+ QHash<QWidget *, QtProperty *> m_editorToEnum;
bool m_updatingEnum;
};
@@ -1985,7 +1941,8 @@ void QtCursorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, con
return;
m_updatingEnum = true;
- m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(cursor));
+ auto *cdb = QtCursorDatabase::instance();
+ m_enumPropertyManager->setValue(enumProp, cdb->cursorToValue(cursor));
m_updatingEnum = false;
}
@@ -2001,7 +1958,8 @@ void QtCursorEditorFactoryPrivate::slotEnumChanged(QtProperty *property, int val
if (!cursorManager)
return;
#ifndef QT_NO_CURSOR
- cursorManager->setValue(prop, QCursor(cursorDatabase()->valueToCursor(value)));
+ auto *cdb = QtCursorDatabase::instance();
+ cursorManager->setValue(prop, QCursor(cdb->valueToCursor(value)));
#endif
}
@@ -2010,8 +1968,7 @@ void QtCursorEditorFactoryPrivate::slotEditorDestroyed(QObject *object)
// remove from m_editorToEnum map;
// remove from m_enumToEditors map;
// if m_enumToEditors doesn't contains more editors delete enum property;
- const QMap<QWidget *, QtProperty *>::ConstIterator ecend = m_editorToEnum.constEnd();
- for (QMap<QWidget *, QtProperty *>::ConstIterator itEditor = m_editorToEnum.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToEnum.cbegin(), ecend = m_editorToEnum.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QWidget *editor = itEditor.key();
QtProperty *enumProp = itEditor.value();
@@ -2050,8 +2007,9 @@ QtCursorEditorFactory::QtCursorEditorFactory(QObject *parent)
d_ptr->m_enumEditorFactory = new QtEnumEditorFactory(this);
d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
- connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotEnumChanged(QtProperty*,int)));
+ connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotEnumChanged(property, value); });
d_ptr->m_enumEditorFactory->addPropertyManager(d_ptr->m_enumPropertyManager);
}
@@ -2069,8 +2027,9 @@ QtCursorEditorFactory::~QtCursorEditorFactory()
*/
void QtCursorEditorFactory::connectPropertyManager(QtCursorPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QCursor)),
- this, SLOT(slotPropertyChanged(QtProperty*,QCursor)));
+ connect(manager, &QtCursorPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QCursor &value)
+ { d_ptr->slotPropertyChanged(property, value); });
}
/*!
@@ -2086,10 +2045,11 @@ QWidget *QtCursorEditorFactory::createEditor(QtCursorPropertyManager *manager, Q
enumProp = d_ptr->m_propertyToEnum[property];
} else {
enumProp = d_ptr->m_enumPropertyManager->addProperty(property->propertyName());
- d_ptr->m_enumPropertyManager->setEnumNames(enumProp, cursorDatabase()->cursorShapeNames());
- d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, cursorDatabase()->cursorShapeIcons());
+ auto *cdb = QtCursorDatabase::instance();
+ d_ptr->m_enumPropertyManager->setEnumNames(enumProp, cdb->cursorShapeNames());
+ d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, cdb->cursorShapeIcons());
#ifndef QT_NO_CURSOR
- d_ptr->m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(manager->value(property)));
+ d_ptr->m_enumPropertyManager->setValue(enumProp, cdb->cursorToValue(manager->value(property)));
#endif
d_ptr->m_propertyToEnum[property] = enumProp;
d_ptr->m_enumToProperty[enumProp] = property;
@@ -2098,8 +2058,8 @@ QWidget *QtCursorEditorFactory::createEditor(QtCursorPropertyManager *manager, Q
QWidget *editor = af->createEditor(enumProp, parent);
d_ptr->m_enumToEditors[enumProp].append(editor);
d_ptr->m_editorToEnum[editor] = enumProp;
- connect(editor, SIGNAL(destroyed(QObject*)),
- this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -2110,8 +2070,7 @@ QWidget *QtCursorEditorFactory::createEditor(QtCursorPropertyManager *manager, Q
*/
void QtCursorEditorFactory::disconnectPropertyManager(QtCursorPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QCursor)),
- this, SLOT(slotPropertyChanged(QtProperty*,QCursor)));
+ disconnect(manager, &QtCursorPropertyManager::valueChanged, this, nullptr);
}
// QtColorEditWidget
@@ -2146,7 +2105,7 @@ QtColorEditWidget::QtColorEditWidget(QWidget *parent) :
m_label(new QLabel),
m_button(new QToolButton)
{
- QHBoxLayout *lt = new QHBoxLayout(this);
+ auto *lt = new QHBoxLayout(this);
setupTreeViewEditorMargin(lt);
lt->setSpacing(0);
lt->addWidget(m_pixmapLabel);
@@ -2159,7 +2118,7 @@ QtColorEditWidget::QtColorEditWidget(QWidget *parent) :
setFocusPolicy(m_button->focusPolicy());
m_button->setText(tr("..."));
m_button->installEventFilter(this);
- connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
+ connect(m_button, &QAbstractButton::clicked, this, &QtColorEditWidget::buttonClicked);
lt->addWidget(m_button);
m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::brushValuePixmap(QBrush(m_color)));
m_label->setText(QtPropertyBrowserUtils::colorValueText(m_color));
@@ -2222,7 +2181,7 @@ public:
void QtColorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
const QColor &value)
{
- const PropertyToEditorListMap::const_iterator it = m_createdEditors.constFind(property);
+ const auto it = m_createdEditors.constFind(property);
if (it == m_createdEditors.constEnd())
return;
@@ -2233,8 +2192,7 @@ void QtColorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
void QtColorEditorFactoryPrivate::slotSetValue(const QColor &value)
{
QObject *object = q_ptr->sender();
- const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd();
- for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtColorPropertyManager *manager = q_ptr->propertyManager(property);
@@ -2282,8 +2240,9 @@ QtColorEditorFactory::~QtColorEditorFactory()
*/
void QtColorEditorFactory::connectPropertyManager(QtColorPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QColor)),
- this, SLOT(slotPropertyChanged(QtProperty*,QColor)));
+ connect(manager, &QtColorPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QColor &value)
+ { d_ptr->slotPropertyChanged(property, value); });
}
/*!
@@ -2296,8 +2255,10 @@ QWidget *QtColorEditorFactory::createEditor(QtColorPropertyManager *manager,
{
QtColorEditWidget *editor = d_ptr->createEditor(property, parent);
editor->setValue(manager->value(property));
- connect(editor, SIGNAL(valueChanged(QColor)), this, SLOT(slotSetValue(QColor)));
- connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QtColorEditWidget::valueChanged,
+ this, [this](const QColor &value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -2308,7 +2269,7 @@ QWidget *QtColorEditorFactory::createEditor(QtColorPropertyManager *manager,
*/
void QtColorEditorFactory::disconnectPropertyManager(QtColorPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QColor)), this, SLOT(slotPropertyChanged(QtProperty*,QColor)));
+ disconnect(manager, &QtColorPropertyManager::valueChanged, this, nullptr);
}
// QtFontEditWidget
@@ -2343,7 +2304,7 @@ QtFontEditWidget::QtFontEditWidget(QWidget *parent) :
m_label(new QLabel),
m_button(new QToolButton)
{
- QHBoxLayout *lt = new QHBoxLayout(this);
+ auto *lt = new QHBoxLayout(this);
setupTreeViewEditorMargin(lt);
lt->setSpacing(0);
lt->addWidget(m_pixmapLabel);
@@ -2356,7 +2317,7 @@ QtFontEditWidget::QtFontEditWidget(QWidget *parent) :
setFocusPolicy(m_button->focusPolicy());
m_button->setText(tr("..."));
m_button->installEventFilter(this);
- connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
+ connect(m_button, &QAbstractButton::clicked, this, &QtFontEditWidget::buttonClicked);
lt->addWidget(m_button);
m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(m_font));
m_label->setText(QtPropertyBrowserUtils::fontValueText(m_font));
@@ -2434,7 +2395,7 @@ public:
void QtFontEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
const QFont &value)
{
- const PropertyToEditorListMap::const_iterator it = m_createdEditors.constFind(property);
+ const auto it = m_createdEditors.constFind(property);
if (it == m_createdEditors.constEnd())
return;
@@ -2445,8 +2406,7 @@ void QtFontEditorFactoryPrivate::slotPropertyChanged(QtProperty *property,
void QtFontEditorFactoryPrivate::slotSetValue(const QFont &value)
{
QObject *object = q_ptr->sender();
- const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd();
- for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
+ for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor)
if (itEditor.key() == object) {
QtProperty *property = itEditor.value();
QtFontPropertyManager *manager = q_ptr->propertyManager(property);
@@ -2494,8 +2454,9 @@ QtFontEditorFactory::~QtFontEditorFactory()
*/
void QtFontEditorFactory::connectPropertyManager(QtFontPropertyManager *manager)
{
- connect(manager, SIGNAL(valueChanged(QtProperty*,QFont)),
- this, SLOT(slotPropertyChanged(QtProperty*,QFont)));
+ connect(manager, &QtFontPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QFont &value)
+ { d_ptr->slotPropertyChanged(property, value); });
}
/*!
@@ -2508,8 +2469,10 @@ QWidget *QtFontEditorFactory::createEditor(QtFontPropertyManager *manager,
{
QtFontEditWidget *editor = d_ptr->createEditor(property, parent);
editor->setValue(manager->value(property));
- connect(editor, SIGNAL(valueChanged(QFont)), this, SLOT(slotSetValue(QFont)));
- connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QtFontEditWidget::valueChanged,
+ this, [this](const QFont &value) { d_ptr->slotSetValue(value); });
+ connect(editor, &QObject::destroyed,
+ this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); });
return editor;
}
@@ -2520,7 +2483,7 @@ QWidget *QtFontEditorFactory::createEditor(QtFontPropertyManager *manager,
*/
void QtFontEditorFactory::disconnectPropertyManager(QtFontPropertyManager *manager)
{
- disconnect(manager, SIGNAL(valueChanged(QtProperty*,QFont)), this, SLOT(slotPropertyChanged(QtProperty*,QFont)));
+ disconnect(manager, &QtFontPropertyManager::valueChanged, this, nullptr);
}
QT_END_NAMESPACE
diff --git a/src/shared/qtpropertybrowser/qteditorfactory.h b/src/shared/qtpropertybrowser/qteditorfactory.h
index 84cd797cd..bc848f777 100644
--- a/src/shared/qtpropertybrowser/qteditorfactory.h
+++ b/src/shared/qtpropertybrowser/qteditorfactory.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTEDITORFACTORY_H
#define QTEDITORFACTORY_H
@@ -63,11 +27,6 @@ private:
QScopedPointer<QtSpinBoxFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtSpinBoxFactory)
Q_DISABLE_COPY_MOVE(QtSpinBoxFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
- Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(int))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtSliderFactoryPrivate;
@@ -87,11 +46,6 @@ private:
QScopedPointer<QtSliderFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtSliderFactory)
Q_DISABLE_COPY_MOVE(QtSliderFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
- Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(int))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtScrollBarFactoryPrivate;
@@ -111,11 +65,6 @@ private:
QScopedPointer<QtScrollBarFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtScrollBarFactory)
Q_DISABLE_COPY_MOVE(QtScrollBarFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
- Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(int))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtCheckBoxFactoryPrivate;
@@ -135,9 +84,6 @@ private:
QScopedPointer<QtCheckBoxFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtCheckBoxFactory)
Q_DISABLE_COPY_MOVE(QtCheckBoxFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtDoubleSpinBoxFactoryPrivate;
@@ -157,12 +103,6 @@ private:
QScopedPointer<QtDoubleSpinBoxFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtDoubleSpinBoxFactory)
Q_DISABLE_COPY_MOVE(QtDoubleSpinBoxFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, double))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double))
- Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double))
- Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(double))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtLineEditFactoryPrivate;
@@ -182,10 +122,6 @@ private:
QScopedPointer<QtLineEditFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtLineEditFactory)
Q_DISABLE_COPY_MOVE(QtLineEditFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QString &))
- Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegularExpression &))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtDateEditFactoryPrivate;
@@ -205,10 +141,6 @@ private:
QScopedPointer<QtDateEditFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtDateEditFactory)
Q_DISABLE_COPY_MOVE(QtDateEditFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, QDate))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, QDate, QDate))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(QDate))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtTimeEditFactoryPrivate;
@@ -228,9 +160,6 @@ private:
QScopedPointer<QtTimeEditFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtTimeEditFactory)
Q_DISABLE_COPY_MOVE(QtTimeEditFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, QTime))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(QTime))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtDateTimeEditFactoryPrivate;
@@ -250,9 +179,6 @@ private:
QScopedPointer<QtDateTimeEditFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtDateTimeEditFactory)
Q_DISABLE_COPY_MOVE(QtDateTimeEditFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QDateTime &))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDateTime &))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtKeySequenceEditorFactoryPrivate;
@@ -272,9 +198,6 @@ private:
QScopedPointer<QtKeySequenceEditorFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtKeySequenceEditorFactory)
Q_DISABLE_COPY_MOVE(QtKeySequenceEditorFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QKeySequence &))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QKeySequence &))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtCharEditorFactoryPrivate;
@@ -294,9 +217,6 @@ private:
QScopedPointer<QtCharEditorFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtCharEditorFactory)
Q_DISABLE_COPY_MOVE(QtCharEditorFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QChar &))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QChar &))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtEnumEditorFactoryPrivate;
@@ -316,13 +236,6 @@ private:
QScopedPointer<QtEnumEditorFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtEnumEditorFactory)
Q_DISABLE_COPY_MOVE(QtEnumEditorFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *,
- const QStringList &))
- Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *,
- const QMap<int, QIcon> &))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(int))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtCursorEditorFactoryPrivate;
@@ -342,9 +255,6 @@ private:
QScopedPointer<QtCursorEditorFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtCursorEditorFactory)
Q_DISABLE_COPY_MOVE(QtCursorEditorFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QCursor &))
- Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
};
class QtColorEditorFactoryPrivate;
@@ -364,9 +274,6 @@ private:
QScopedPointer<QtColorEditorFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtColorEditorFactory)
Q_DISABLE_COPY_MOVE(QtColorEditorFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QColor &))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QColor &))
};
class QtFontEditorFactoryPrivate;
@@ -386,9 +293,6 @@ private:
QScopedPointer<QtFontEditorFactoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtFontEditorFactory)
Q_DISABLE_COPY_MOVE(QtFontEditorFactory)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QFont &))
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
- Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QFont &))
};
QT_END_NAMESPACE
diff --git a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp
index 43ca132d8..9f08f67a9 100644
--- a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp
+++ b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp
@@ -1,49 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtgroupboxpropertybrowser.h"
-#include <QtCore/QSet>
+
+#include <QtCore/QHash>
#include <QtWidgets/QGridLayout>
-#include <QtWidgets/QLabel>
#include <QtWidgets/QGroupBox>
-#include <QtCore/QTimer>
-#include <QtCore/QMap>
+#include <QtWidgets/QLabel>
QT_BEGIN_NAMESPACE
@@ -83,9 +46,9 @@ private:
bool hasHeader(WidgetItem *item) const;
- QMap<QtBrowserItem *, WidgetItem *> m_indexToItem;
- QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex;
- QMap<QWidget *, WidgetItem *> m_widgetToItem;
+ QHash<QtBrowserItem *, WidgetItem *> m_indexToItem;
+ QHash<WidgetItem *, QtBrowserItem *> m_itemToIndex;
+ QHash<QWidget *, WidgetItem *> m_widgetToItem;
QGridLayout *m_mainLayout;
QList<WidgetItem *> m_children;
QList<WidgetItem *> m_recreateQueue;
@@ -95,25 +58,24 @@ void QtGroupBoxPropertyBrowserPrivate::init(QWidget *parent)
{
m_mainLayout = new QGridLayout();
parent->setLayout(m_mainLayout);
- QLayoutItem *item = new QSpacerItem(0, 0,
- QSizePolicy::Fixed, QSizePolicy::Expanding);
+ auto *item = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
m_mainLayout->addItem(item, 0, 0);
}
void QtGroupBoxPropertyBrowserPrivate::slotEditorDestroyed()
{
- QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender());
+ auto *editor = qobject_cast<QWidget *>(q_ptr->sender());
if (!editor)
return;
if (!m_widgetToItem.contains(editor))
return;
- m_widgetToItem[editor]->widget = 0;
+ m_widgetToItem[editor]->widget = nullptr;
m_widgetToItem.remove(editor);
}
void QtGroupBoxPropertyBrowserPrivate::slotUpdate()
{
- for (WidgetItem *item : qAsConst(m_recreateQueue)) {
+ for (WidgetItem *item : std::as_const(m_recreateQueue)) {
WidgetItem *par = item->parent;
QWidget *w = nullptr;
QGridLayout *l = nullptr;
@@ -155,7 +117,7 @@ void QtGroupBoxPropertyBrowserPrivate::slotUpdate()
void QtGroupBoxPropertyBrowserPrivate::updateLater()
{
- QTimer::singleShot(0, q_ptr, SLOT(slotUpdate()));
+ QMetaObject::invokeMethod(q_ptr, [this] { slotUpdate(); }, Qt::QueuedConnection);
}
void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex)
@@ -163,7 +125,7 @@ void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, Qt
WidgetItem *afterItem = m_indexToItem.value(afterIndex);
WidgetItem *parentItem = m_indexToItem.value(index->parent());
- WidgetItem *newItem = new WidgetItem();
+ auto *newItem = new WidgetItem();
newItem->parent = parentItem;
QGridLayout *layout = nullptr;
@@ -244,7 +206,8 @@ void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, Qt
if (!newItem->widget) {
newItem->widgetLabel = new QLabel(parentWidget);
} else {
- QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, SLOT(slotEditorDestroyed()));
+ QObject::connect(newItem->widget, &QWidget::destroyed,
+ q_ptr, [this] { slotEditorDestroyed(); });
m_widgetToItem[newItem->widget] = newItem;
}
@@ -296,22 +259,11 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index)
if (!parentItem) {
removeRow(m_mainLayout, row);
- } else if (parentItem->children.count() != 0) {
+ } else if (parentItem->children.size() != 0) {
removeRow(parentItem->layout, row);
} else {
WidgetItem *par = parentItem->parent;
- QGridLayout *l = nullptr;
- int oldRow = -1;
- if (!par) {
- l = m_mainLayout;
- oldRow = m_children.indexOf(parentItem);
- } else {
- l = par->layout;
- oldRow = par->children.indexOf(parentItem);
- if (hasHeader(par))
- oldRow += 2;
- }
-
+ QGridLayout *l = (par ? par->layout : m_mainLayout);
if (parentItem->widget) {
parentItem->widget->hide();
parentItem->widget->setParent(0);
@@ -337,7 +289,7 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index)
void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) const
{
- QMap<QLayoutItem *, QRect> itemToPos;
+ QHash<QLayoutItem *, QRect> itemToPos;
int idx = 0;
while (idx < layout->count()) {
int r, c, rs, cs;
@@ -349,8 +301,7 @@ void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) c
}
}
- const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd();
- for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) {
+ for (auto it = itemToPos.cbegin(), icend = itemToPos.cend(); it != icend; ++it) {
const QRect r = it.value();
layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height());
}
@@ -358,7 +309,7 @@ void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) c
void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const
{
- QMap<QLayoutItem *, QRect> itemToPos;
+ QHash<QLayoutItem *, QRect> itemToPos;
int idx = 0;
while (idx < layout->count()) {
int r, c, rs, cs;
@@ -370,8 +321,7 @@ void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) c
}
}
- const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd();
- for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) {
+ for (auto it = itemToPos.cbegin(), icend = itemToPos.cend(); it != icend; ++it) {
const QRect r = it.value();
layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height());
}
@@ -379,9 +329,7 @@ void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) c
bool QtGroupBoxPropertyBrowserPrivate::hasHeader(WidgetItem *item) const
{
- if (item->widget)
- return true;
- return false;
+ return item->widget;
}
void QtGroupBoxPropertyBrowserPrivate::propertyChanged(QtBrowserItem *index)
@@ -486,8 +434,7 @@ QtGroupBoxPropertyBrowser::QtGroupBoxPropertyBrowser(QWidget *parent)
*/
QtGroupBoxPropertyBrowser::~QtGroupBoxPropertyBrowser()
{
- const QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator icend = d_ptr->m_itemToIndex.constEnd();
- for (QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator it = d_ptr->m_itemToIndex.constBegin(); it != icend; ++it)
+ for (auto it = d_ptr->m_itemToIndex.cbegin(), icend = d_ptr->m_itemToIndex.cend(); it != icend; ++it)
delete it.key();
}
diff --git a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h
index a42b8cf1d..44b790989 100644
--- a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h
+++ b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTGROUPBOXPROPERTYBROWSER_H
#define QTGROUPBOXPROPERTYBROWSER_H
@@ -50,7 +14,6 @@ class QtGroupBoxPropertyBrowser : public QtAbstractPropertyBrowser
{
Q_OBJECT
public:
-
QtGroupBoxPropertyBrowser(QWidget *parent = 0);
~QtGroupBoxPropertyBrowser();
@@ -60,13 +23,9 @@ protected:
void itemChanged(QtBrowserItem *item) override;
private:
-
QScopedPointer<QtGroupBoxPropertyBrowserPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtGroupBoxPropertyBrowser)
Q_DISABLE_COPY_MOVE(QtGroupBoxPropertyBrowser)
- Q_PRIVATE_SLOT(d_func(), void slotUpdate())
- Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed())
-
};
QT_END_NAMESPACE
diff --git a/src/shared/qtpropertybrowser/qtpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtpropertybrowser.cpp
index bc86d2879..2803e2860 100644
--- a/src/shared/qtpropertybrowser/qtpropertybrowser.cpp
+++ b/src/shared/qtpropertybrowser/qtpropertybrowser.cpp
@@ -1,45 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtpropertybrowser.h"
-#include <QtCore/QSet>
-#include <QtCore/QMap>
+#include <QtCore/QHash>
#include <QtGui/QIcon>
#if defined(Q_CC_MSVC)
@@ -161,15 +124,15 @@ QtProperty::QtProperty(QtAbstractPropertyManager *manager)
*/
QtProperty::~QtProperty()
{
- for (QtProperty *property : qAsConst(d_ptr->m_parentItems))
+ for (QtProperty *property : std::as_const(d_ptr->m_parentItems))
property->d_ptr->m_manager->d_ptr->propertyRemoved(this, property);
d_ptr->m_manager->d_ptr->propertyDestroyed(this);
- for (QtProperty *property : qAsConst(d_ptr->m_subItems))
+ for (QtProperty *property : std::as_const(d_ptr->m_subItems))
property->d_ptr->m_parentItems.remove(this);
- for (QtProperty *property : qAsConst(d_ptr->m_parentItems))
+ for (QtProperty *property : std::as_const(d_ptr->m_parentItems))
property->d_ptr->m_subItems.removeAll(this);
}
@@ -424,7 +387,7 @@ void QtProperty::setModified(bool modified)
void QtProperty::addSubProperty(QtProperty *property)
{
QtProperty *after = nullptr;
- if (d_ptr->m_subItems.count() > 0)
+ if (d_ptr->m_subItems.size() > 0)
after = d_ptr->m_subItems.last();
insertSubProperty(property, after);
}
@@ -453,7 +416,7 @@ void QtProperty::insertSubProperty(QtProperty *property,
// traverse all children of item. if this item is a child of item then cannot add.
auto pendingList = property->subProperties();
- QMap<QtProperty *, bool> visited;
+ QHash<QtProperty *, bool> visited;
while (!pendingList.isEmpty()) {
QtProperty *i = pendingList.first();
if (i == this)
@@ -469,7 +432,7 @@ void QtProperty::insertSubProperty(QtProperty *property,
int pos = 0;
int newPos = 0;
QtProperty *properAfterProperty = nullptr;
- while (pos < pendingList.count()) {
+ while (pos < pendingList.size()) {
QtProperty *i = pendingList.at(pos);
if (i == property)
return; // if item is already inserted in this item then cannot add.
@@ -501,7 +464,7 @@ void QtProperty::removeSubProperty(QtProperty *property)
auto pendingList = subProperties();
int pos = 0;
- while (pos < pendingList.count()) {
+ while (pos < pendingList.size()) {
if (pendingList.at(pos) == property) {
d_ptr->m_subItems.removeAt(pos);
property->d_ptr->m_parentItems.remove(this);
@@ -729,7 +692,7 @@ bool QtAbstractPropertyManager::hasValue(const QtProperty *property) const
QIcon QtAbstractPropertyManager::valueIcon(const QtProperty *property) const
{
Q_UNUSED(property);
- return QIcon();
+ return {};
}
/*!
@@ -744,7 +707,7 @@ QIcon QtAbstractPropertyManager::valueIcon(const QtProperty *property) const
QString QtAbstractPropertyManager::valueText(const QtProperty *property) const
{
Q_UNUSED(property);
- return QString();
+ return {};
}
/*!
@@ -1203,10 +1166,11 @@ QtBrowserItem::~QtBrowserItem()
////////////////////////////////////
-typedef QMap<QtAbstractPropertyBrowser *, QMap<QtAbstractPropertyManager *,
- QtAbstractEditorFactoryBase *> > Map1;
-typedef QMap<QtAbstractPropertyManager *, QMap<QtAbstractEditorFactoryBase *,
- QList<QtAbstractPropertyBrowser *> > > Map2;
+using Map1 = QHash<QtAbstractPropertyBrowser *,
+ QHash<QtAbstractPropertyManager *, QtAbstractEditorFactoryBase *>>;
+using Map2 = QHash<QtAbstractPropertyManager *,
+ QHash<QtAbstractEditorFactoryBase *, QList<QtAbstractPropertyBrowser *>>>;
+
Q_GLOBAL_STATIC(Map1, m_viewToManagerToFactory)
Q_GLOBAL_STATIC(Map2, m_managerToFactoryToViews)
@@ -1234,12 +1198,12 @@ public:
void slotPropertyDataChanged(QtProperty *property);
QList<QtProperty *> m_subItems;
- QMap<QtAbstractPropertyManager *, QList<QtProperty *> > m_managerToProperties;
- QMap<QtProperty *, QList<QtProperty *> > m_propertyToParents;
+ QHash<QtAbstractPropertyManager *, QList<QtProperty *> > m_managerToProperties;
+ QHash<QtProperty *, QList<QtProperty *> > m_propertyToParents;
- QMap<QtProperty *, QtBrowserItem *> m_topLevelPropertyToIndex;
+ QHash<QtProperty *, QtBrowserItem *> m_topLevelPropertyToIndex;
QList<QtBrowserItem *> m_topLevelIndexes;
- QMap<QtProperty *, QList<QtBrowserItem *> > m_propertyToIndexes;
+ QHash<QtProperty *, QList<QtBrowserItem *> > m_propertyToIndexes;
QtBrowserItem *m_currentItem;
};
@@ -1264,17 +1228,16 @@ void QtAbstractPropertyBrowserPrivate::insertSubTree(QtProperty *property,
QtAbstractPropertyManager *manager = property->propertyManager();
if (m_managerToProperties[manager].isEmpty()) {
// connect manager's signals
- q_ptr->connect(manager, SIGNAL(propertyInserted(QtProperty *,
- QtProperty *, QtProperty *)),
- q_ptr, SLOT(slotPropertyInserted(QtProperty *,
- QtProperty *, QtProperty *)));
- q_ptr->connect(manager, SIGNAL(propertyRemoved(QtProperty *,
- QtProperty *)),
- q_ptr, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
- q_ptr->connect(manager, SIGNAL(propertyDestroyed(QtProperty*)),
- q_ptr, SLOT(slotPropertyDestroyed(QtProperty*)));
- q_ptr->connect(manager, SIGNAL(propertyChanged(QtProperty*)),
- q_ptr, SLOT(slotPropertyDataChanged(QtProperty*)));
+ q_ptr->connect(manager, &QtAbstractPropertyManager::propertyInserted,
+ q_ptr, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { slotPropertyInserted(property, parent, after); });
+ q_ptr->connect(manager, &QtAbstractPropertyManager::propertyRemoved,
+ q_ptr, [this](QtProperty *property, QtProperty *parent)
+ { slotPropertyRemoved(property, parent); });
+ q_ptr->connect(manager, &QtAbstractPropertyManager::propertyDestroyed,
+ q_ptr, [this](QtProperty *property) { slotPropertyDestroyed(property); });
+ q_ptr->connect(manager, &QtAbstractPropertyManager::propertyChanged,
+ q_ptr, [this](QtProperty *property) { slotPropertyDataChanged(property); });
}
m_managerToProperties[manager].append(property);
m_propertyToParents[property].append(parentProperty);
@@ -1301,17 +1264,10 @@ void QtAbstractPropertyBrowserPrivate::removeSubTree(QtProperty *property,
m_managerToProperties[manager].removeAll(property);
if (m_managerToProperties[manager].isEmpty()) {
// disconnect manager's signals
- q_ptr->disconnect(manager, SIGNAL(propertyInserted(QtProperty *,
- QtProperty *, QtProperty *)),
- q_ptr, SLOT(slotPropertyInserted(QtProperty *,
- QtProperty *, QtProperty *)));
- q_ptr->disconnect(manager, SIGNAL(propertyRemoved(QtProperty *,
- QtProperty *)),
- q_ptr, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
- q_ptr->disconnect(manager, SIGNAL(propertyDestroyed(QtProperty*)),
- q_ptr, SLOT(slotPropertyDestroyed(QtProperty*)));
- q_ptr->disconnect(manager, SIGNAL(propertyChanged(QtProperty*)),
- q_ptr, SLOT(slotPropertyDataChanged(QtProperty*)));
+ q_ptr->disconnect(manager, &QtAbstractPropertyManager::propertyInserted, q_ptr, nullptr);
+ q_ptr->disconnect(manager, &QtAbstractPropertyManager::propertyRemoved, q_ptr, nullptr);
+ q_ptr->disconnect(manager, &QtAbstractPropertyManager::propertyDestroyed, q_ptr, nullptr);
+ q_ptr->disconnect(manager, &QtAbstractPropertyManager::propertyChanged, q_ptr, nullptr);
m_managerToProperties.remove(manager);
}
@@ -1323,7 +1279,7 @@ void QtAbstractPropertyBrowserPrivate::removeSubTree(QtProperty *property,
void QtAbstractPropertyBrowserPrivate::createBrowserIndexes(QtProperty *property, QtProperty *parentProperty, QtProperty *afterProperty)
{
- QMap<QtBrowserItem *, QtBrowserItem *> parentToAfter;
+ QHash<QtBrowserItem *, QtBrowserItem *> parentToAfter;
if (afterProperty) {
const auto it = m_propertyToIndexes.constFind(afterProperty);
if (it == m_propertyToIndexes.constEnd())
@@ -1340,20 +1296,19 @@ void QtAbstractPropertyBrowserPrivate::createBrowserIndexes(QtProperty *property
return;
for (QtBrowserItem *idx : it.value())
- parentToAfter[idx] = 0;
+ parentToAfter[idx] = nullptr;
} else {
- parentToAfter[0] = 0;
+ parentToAfter[nullptr] = nullptr;
}
- const QMap<QtBrowserItem *, QtBrowserItem *>::ConstIterator pcend = parentToAfter.constEnd();
- for (QMap<QtBrowserItem *, QtBrowserItem *>::ConstIterator it = parentToAfter.constBegin(); it != pcend; ++it)
+ for (auto it = parentToAfter.cbegin(), pcend = parentToAfter.cend(); it != pcend; ++it)
createBrowserIndex(property, it.key(), it.value());
}
QtBrowserItem *QtAbstractPropertyBrowserPrivate::createBrowserIndex(QtProperty *property,
QtBrowserItem *parentIndex, QtBrowserItem *afterIndex)
{
- QtBrowserItem *newIndex = new QtBrowserItem(q_ptr, property, parentIndex);
+ auto *newIndex = new QtBrowserItem(q_ptr, property, parentIndex);
if (parentIndex) {
parentIndex->d_ptr->addChild(newIndex, afterIndex);
} else {
@@ -1384,14 +1339,14 @@ void QtAbstractPropertyBrowserPrivate::removeBrowserIndexes(QtProperty *property
toRemove.append(idx);
}
- for (QtBrowserItem *index : qAsConst(toRemove))
+ for (QtBrowserItem *index : std::as_const(toRemove))
removeBrowserIndex(index);
}
void QtAbstractPropertyBrowserPrivate::removeBrowserIndex(QtBrowserItem *index)
{
const auto children = index->children();
- for (int i = children.count(); i > 0; i--) {
+ for (int i = children.size(); i > 0; i--) {
removeBrowserIndex(children.at(i - 1));
}
@@ -1606,7 +1561,7 @@ void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged(QtProperty *prope
\a item of the property as parameters. The passed \a item is
deleted just after this call is finished.
- If the the parent of \a item is 0, the removed \a item was a
+ If the parent of \a item is 0, the removed \a item was a
top level property in this editor.
This function must be reimplemented in derived classes. Note that
@@ -1743,7 +1698,7 @@ void QtAbstractPropertyBrowser::clear()
QtBrowserItem *QtAbstractPropertyBrowser::addProperty(QtProperty *property)
{
QtProperty *afterProperty = nullptr;
- if (d_ptr->m_subItems.count() > 0)
+ if (d_ptr->m_subItems.size() > 0)
afterProperty = d_ptr->m_subItems.last();
return insertProperty(property, afterProperty);
}
@@ -1768,16 +1723,16 @@ QtBrowserItem *QtAbstractPropertyBrowser::insertProperty(QtProperty *property,
QtProperty *afterProperty)
{
if (!property)
- return 0;
+ return nullptr;
// if item is already inserted in this item then cannot add.
auto pendingList = properties();
int pos = 0;
int newPos = 0;
- while (pos < pendingList.count()) {
+ while (pos < pendingList.size()) {
QtProperty *prop = pendingList.at(pos);
if (prop == property)
- return 0;
+ return nullptr;
if (prop == afterProperty) {
newPos = pos + 1;
}
@@ -1811,7 +1766,7 @@ void QtAbstractPropertyBrowser::removeProperty(QtProperty *property)
auto pendingList = properties();
int pos = 0;
- while (pos < pendingList.count()) {
+ while (pos < pendingList.size()) {
if (pendingList.at(pos) == property) {
d_ptr->m_subItems.removeAt(pos); //perhaps this two lines
d_ptr->removeSubTree(property, 0); //should be moved down after propertyRemoved call.
@@ -1858,7 +1813,7 @@ QWidget *QtAbstractPropertyBrowser::createEditor(QtProperty *property,
}
if (!factory)
- return 0;
+ return nullptr;
QWidget *w = factory->createEditor(property, parent);
// Since some editors can be QComboBoxes, and we changed their focus policy in Qt 5
// to make them feel more native on Mac, we need to relax the focus policy to something
diff --git a/src/shared/qtpropertybrowser/qtpropertybrowser.h b/src/shared/qtpropertybrowser/qtpropertybrowser.h
index 697ee4c7d..623ea5d67 100644
--- a/src/shared/qtpropertybrowser/qtpropertybrowser.h
+++ b/src/shared/qtpropertybrowser/qtpropertybrowser.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTPROPERTYBROWSER_H
#define QTPROPERTYBROWSER_H
@@ -105,9 +69,7 @@ public:
QtProperty *addProperty(const QString &name = QString());
Q_SIGNALS:
-
- void propertyInserted(QtProperty *property,
- QtProperty *parent, QtProperty *after);
+ void propertyInserted(QtProperty *property, QtProperty *parent, QtProperty *after);
void propertyChanged(QtProperty *property);
void propertyRemoved(QtProperty *property, QtProperty *parent);
void propertyDestroyed(QtProperty *property);
@@ -148,7 +110,7 @@ public:
explicit QtAbstractEditorFactory(QObject *parent) : QtAbstractEditorFactoryBase(parent) {}
QWidget *createEditor(QtProperty *property, QWidget *parent) override
{
- for (PropertyManager *manager : qAsConst(m_managers)) {
+ for (PropertyManager *manager : std::as_const(m_managers)) {
if (manager == property->propertyManager()) {
return createEditor(manager, property, parent);
}
@@ -161,15 +123,15 @@ public:
return;
m_managers.insert(manager);
connectPropertyManager(manager);
- connect(manager, SIGNAL(destroyed(QObject *)),
- this, SLOT(managerDestroyed(QObject *)));
+ connect(manager, &QObject::destroyed,
+ this, &QtAbstractEditorFactory<PropertyManager>::managerDestroyed);
}
void removePropertyManager(PropertyManager *manager)
{
if (!m_managers.contains(manager))
return;
- disconnect(manager, SIGNAL(destroyed(QObject *)),
- this, SLOT(managerDestroyed(QObject *)));
+ disconnect(manager, &QObject::destroyed,
+ this, &QtAbstractEditorFactory<PropertyManager>::managerDestroyed);
disconnectPropertyManager(manager);
m_managers.remove(manager);
}
@@ -180,7 +142,7 @@ public:
PropertyManager *propertyManager(QtProperty *property) const
{
QtAbstractPropertyManager *manager = property->propertyManager();
- for (PropertyManager *m : qAsConst(m_managers)) {
+ for (PropertyManager *m : std::as_const(m_managers)) {
if (m == manager) {
return m;
}
@@ -194,7 +156,7 @@ protected:
virtual void disconnectPropertyManager(PropertyManager *manager) = 0;
void managerDestroyed(QObject *manager) override
{
- for (PropertyManager *m : qAsConst(m_managers)) {
+ for (PropertyManager *m : std::as_const(m_managers)) {
if (m == manager) {
m_managers.remove(m);
return;
@@ -204,7 +166,7 @@ protected:
private:
void breakConnection(QtAbstractPropertyManager *manager) override
{
- for (PropertyManager *m : qAsConst(m_managers)) {
+ for (PropertyManager *m : std::as_const(m_managers)) {
if (m == manager) {
removePropertyManager(m);
return;
@@ -289,13 +251,6 @@ private:
QScopedPointer<QtAbstractPropertyBrowserPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtAbstractPropertyBrowser)
Q_DISABLE_COPY_MOVE(QtAbstractPropertyBrowser)
- Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *,
- QtProperty *, QtProperty *))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *,
- QtProperty *))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDataChanged(QtProperty *))
-
};
QT_END_NAMESPACE
diff --git a/src/shared/qtpropertybrowser/qtpropertybrowser.qrc b/src/shared/qtpropertybrowser/qtpropertybrowser.qrc
deleted file mode 100644
index a7d37dd10..000000000
--- a/src/shared/qtpropertybrowser/qtpropertybrowser.qrc
+++ /dev/null
@@ -1,23 +0,0 @@
-<RCC version="1.0">
- <qresource prefix="/qt-project.org/qtpropertybrowser">
- <file>images/cursor-arrow.png</file>
- <file>images/cursor-busy.png</file>
- <file>images/cursor-closedhand.png</file>
- <file>images/cursor-cross.png</file>
- <file>images/cursor-forbidden.png</file>
- <file>images/cursor-hand.png</file>
- <file>images/cursor-hsplit.png</file>
- <file>images/cursor-ibeam.png</file>
- <file>images/cursor-openhand.png</file>
- <file>images/cursor-sizeall.png</file>
- <file>images/cursor-sizeb.png</file>
- <file>images/cursor-sizef.png</file>
- <file>images/cursor-sizeh.png</file>
- <file>images/cursor-sizev.png</file>
- <file>images/cursor-uparrow.png</file>
- <file>images/cursor-vsplit.png</file>
- <file>images/cursor-wait.png</file>
- <file>images/cursor-whatsthis.png</file>
- </qresource>
-</RCC>
-
diff --git a/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp b/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp
index 9602b10d0..9d6aca901 100644
--- a/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp
+++ b/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtpropertybrowserutils_p.h"
#include <QtWidgets/QApplication>
@@ -49,46 +13,57 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
+// Make sure icons are removed as soon as QApplication is destroyed, otherwise,
+// handles are leaked on X11.
+static void clearCursorDatabase()
+{
+ QtCursorDatabase::instance()->clear();
+}
+
QtCursorDatabase::QtCursorDatabase()
{
+ qAddPostRoutine(clearCursorDatabase);
+
appendCursor(Qt::ArrowCursor, QCoreApplication::translate("QtCursorDatabase", "Arrow"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-arrow.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-arrow.png"_L1));
appendCursor(Qt::UpArrowCursor, QCoreApplication::translate("QtCursorDatabase", "Up Arrow"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-uparrow.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-uparrow.png"_L1));
appendCursor(Qt::CrossCursor, QCoreApplication::translate("QtCursorDatabase", "Cross"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-cross.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-cross.png"_L1));
appendCursor(Qt::WaitCursor, QCoreApplication::translate("QtCursorDatabase", "Wait"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-wait.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-wait.png"_L1));
appendCursor(Qt::IBeamCursor, QCoreApplication::translate("QtCursorDatabase", "IBeam"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-ibeam.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-ibeam.png"_L1));
appendCursor(Qt::SizeVerCursor, QCoreApplication::translate("QtCursorDatabase", "Size Vertical"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizev.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizev.png"_L1));
appendCursor(Qt::SizeHorCursor, QCoreApplication::translate("QtCursorDatabase", "Size Horizontal"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeh.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeh.png"_L1));
appendCursor(Qt::SizeFDiagCursor, QCoreApplication::translate("QtCursorDatabase", "Size Backslash"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizef.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizef.png"_L1));
appendCursor(Qt::SizeBDiagCursor, QCoreApplication::translate("QtCursorDatabase", "Size Slash"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeb.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeb.png"_L1));
appendCursor(Qt::SizeAllCursor, QCoreApplication::translate("QtCursorDatabase", "Size All"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeall.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeall.png"_L1));
appendCursor(Qt::BlankCursor, QCoreApplication::translate("QtCursorDatabase", "Blank"),
QIcon());
appendCursor(Qt::SplitVCursor, QCoreApplication::translate("QtCursorDatabase", "Split Vertical"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-vsplit.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-vsplit.png"_L1));
appendCursor(Qt::SplitHCursor, QCoreApplication::translate("QtCursorDatabase", "Split Horizontal"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-hsplit.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-hsplit.png"_L1));
appendCursor(Qt::PointingHandCursor, QCoreApplication::translate("QtCursorDatabase", "Pointing Hand"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-hand.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-hand.png"_L1));
appendCursor(Qt::ForbiddenCursor, QCoreApplication::translate("QtCursorDatabase", "Forbidden"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-forbidden.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-forbidden.png"_L1));
appendCursor(Qt::OpenHandCursor, QCoreApplication::translate("QtCursorDatabase", "Open Hand"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-openhand.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-openhand.png"_L1));
appendCursor(Qt::ClosedHandCursor, QCoreApplication::translate("QtCursorDatabase", "Closed Hand"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-closedhand.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-closedhand.png"_L1));
appendCursor(Qt::WhatsThisCursor, QCoreApplication::translate("QtCursorDatabase", "What's This"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-whatsthis.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-whatsthis.png"_L1));
appendCursor(Qt::BusyCursor, QCoreApplication::translate("QtCursorDatabase", "Busy"),
- QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-busy.png")));
+ QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-busy.png"_L1));
}
void QtCursorDatabase::clear()
@@ -103,7 +78,7 @@ void QtCursorDatabase::appendCursor(Qt::CursorShape shape, const QString &name,
{
if (m_cursorShapeToValue.contains(shape))
return;
- const int value = m_cursorNames.count();
+ const int value = m_cursorNames.size();
m_cursorNames.append(name);
m_cursorIcons.insert(value, icon);
m_valueToCursorShape.insert(value, shape);
@@ -125,7 +100,7 @@ QString QtCursorDatabase::cursorToShapeName(const QCursor &cursor) const
int val = cursorToValue(cursor);
if (val >= 0)
return m_cursorNames.at(val);
- return QString();
+ return {};
}
QIcon QtCursorDatabase::cursorToShapeIcon(const QCursor &cursor) const
@@ -149,10 +124,17 @@ QCursor QtCursorDatabase::valueToCursor(int value) const
{
if (m_valueToCursorShape.contains(value))
return QCursor(m_valueToCursorShape[value]);
- return QCursor();
+ return {};
}
#endif
+Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase)
+
+QtCursorDatabase *QtCursorDatabase::instance()
+{
+ return cursorDatabase();
+}
+
QPixmap QtPropertyBrowserUtils::brushValuePixmap(const QBrush &b)
{
QImage img(16, 16, QImage::Format_ARGB32_Premultiplied);
@@ -217,7 +199,7 @@ QString QtPropertyBrowserUtils::dateFormat()
QString format = loc.dateFormat(QLocale::ShortFormat);
// Change dd.MM.yy, MM/dd/yy to 4 digit years
if (format.count(QLatin1Char('y')) == 2)
- format.insert(format.indexOf(QLatin1Char('y')), QLatin1String("yy"));
+ format.insert(format.indexOf(QLatin1Char('y')), "yy"_L1);
return format;
}
@@ -241,14 +223,14 @@ QtBoolEdit::QtBoolEdit(QWidget *parent) :
m_checkBox(new QCheckBox(this)),
m_textVisible(true)
{
- QHBoxLayout *lt = new QHBoxLayout;
+ auto *lt = new QHBoxLayout;
if (QApplication::layoutDirection() == Qt::LeftToRight)
lt->setContentsMargins(4, 0, 0, 0);
else
lt->setContentsMargins(0, 0, 4, 0);
lt->addWidget(m_checkBox);
setLayout(lt);
- connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
+ connect(m_checkBox, &QAbstractButton::toggled, this, &QtBoolEdit::toggled);
setFocusProxy(m_checkBox);
m_checkBox->setText(tr("True"));
}
diff --git a/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h b/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h
index 08de7f0d7..60d19c26d 100644
--- a/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h
+++ b/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -76,6 +40,9 @@ public:
#ifndef QT_NO_CURSOR
QCursor valueToCursor(int value) const;
#endif
+
+ static QtCursorDatabase *instance();
+
private:
void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon);
QStringList m_cursorNames;
diff --git a/src/shared/qtpropertybrowser/qtpropertymanager.cpp b/src/shared/qtpropertybrowser/qtpropertymanager.cpp
index 728b0b1e0..e5ed1bf41 100644
--- a/src/shared/qtpropertybrowser/qtpropertymanager.cpp
+++ b/src/shared/qtpropertybrowser/qtpropertymanager.cpp
@@ -1,68 +1,55 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtpropertymanager.h"
#include "qtpropertybrowserutils_p.h"
+
#include <QtCore/QDateTime>
+#include <QtCore/QHash>
#include <QtCore/QLocale>
#include <QtCore/QMap>
-#include <QtCore/QTimer>
-#include <QtCore/QRegularExpression>
-#include <QtGui/QIcon>
#include <QtCore/QMetaEnum>
+#include <QtCore/QRegularExpression>
+#include <QtCore/QTimer>
#include <QtGui/QFontDatabase>
-#include <QtWidgets/QStyleOption>
-#include <QtWidgets/QStyle>
-#include <QtWidgets/QApplication>
+#include <QtGui/QIcon>
#include <QtGui/QPainter>
+#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
+#include <QtWidgets/QStyle>
+#include <QtWidgets/QStyleOption>
#include <limits>
#include <limits.h>
#include <float.h>
+#include <algorithm>
+#include <utility>
+
#if defined(Q_CC_MSVC)
# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */
#endif
QT_BEGIN_NAMESPACE
+using DisambiguatedTranslation = std::pair<const char *, const char *>;
+
+static const QFont::Weight weightValues[] = {
+ QFont::Thin, QFont::ExtraLight, QFont::Light, QFont::Normal, QFont::Medium, QFont::DemiBold,
+ QFont::Bold, QFont::ExtraBold, QFont::Black
+};
+
+static int indexOfFontWeight(QFont::Weight w)
+{
+ auto it = std::find(std::begin(weightValues), std::end(weightValues), w);
+ return int(it - std::begin(weightValues));
+}
+
+static inline QFont::Weight weightFromIndex(int i)
+{
+ return weightValues[i];
+}
+
template <class PrivateData, class Value>
static void setSimpleMinimumData(PrivateData *data, const Value &minVal)
{
@@ -185,7 +172,7 @@ void orderBorders(QSizeF &minVal, QSizeF &maxVal)
////////
template <class Value, class PrivateData>
-static Value getData(const QMap<const QtProperty *, PrivateData> &propertyMap,
+static Value getData(const QHash<const QtProperty *, PrivateData> &propertyMap,
Value PrivateData::*data,
const QtProperty *property, const Value &defaultValue = Value())
{
@@ -196,28 +183,28 @@ static Value getData(const QMap<const QtProperty *, PrivateData> &propertyMap,
}
template <class Value, class PrivateData>
-static Value getValue(const QMap<const QtProperty *, PrivateData> &propertyMap,
+static Value getValue(const QHash<const QtProperty *, PrivateData> &propertyMap,
const QtProperty *property, const Value &defaultValue = Value())
{
return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue);
}
template <class Value, class PrivateData>
-static Value getMinimum(const QMap<const QtProperty *, PrivateData> &propertyMap,
+static Value getMinimum(const QHash<const QtProperty *, PrivateData> &propertyMap,
const QtProperty *property, const Value &defaultValue = Value())
{
return getData<Value>(propertyMap, &PrivateData::minVal, property, defaultValue);
}
template <class Value, class PrivateData>
-static Value getMaximum(const QMap<const QtProperty *, PrivateData> &propertyMap,
+static Value getMaximum(const QHash<const QtProperty *, PrivateData> &propertyMap,
const QtProperty *property, const Value &defaultValue = Value())
{
return getData<Value>(propertyMap, &PrivateData::maxVal, property, defaultValue);
}
template <class ValueChangeParameter, class Value, class PropertyManager>
-static void setSimpleValue(QMap<const QtProperty *, Value> &propertyMap,
+static void setSimpleValue(QHash<const QtProperty *, Value> &propertyMap,
PropertyManager *manager,
void (PropertyManager::*propertyChangedSignal)(QtProperty *),
void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
@@ -386,33 +373,35 @@ public:
QStringList policyEnumNames() const { return m_policyEnumNames; }
QStringList languageEnumNames() const { return m_languageEnumNames; }
- QStringList countryEnumNames(QLocale::Language language) const { return m_countryEnumNames.value(language); }
+ QStringList territoryEnumNames(QLocale::Language language) const { return m_territoryEnumNames.value(language); }
QSizePolicy::Policy indexToSizePolicy(int index) const;
int sizePolicyToIndex(QSizePolicy::Policy policy) const;
- void indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const;
- void localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const;
+ void indexToLocale(int languageIndex, int territoryIndex, QLocale::Language *language, QLocale::Territory *territory) const;
+ void localeToIndex(QLocale::Language language, QLocale::Territory territory, int *languageIndex, int *territoryIndex) const;
private:
void initLocale();
QStringList m_policyEnumNames;
QStringList m_languageEnumNames;
- QMap<QLocale::Language, QStringList> m_countryEnumNames;
+ QMap<QLocale::Language, QStringList> m_territoryEnumNames;
QMap<int, QLocale::Language> m_indexToLanguage;
QMap<QLocale::Language, int> m_languageToIndex;
- QMap<int, QMap<int, QLocale::Country> > m_indexToCountry;
- QMap<QLocale::Language, QMap<QLocale::Country, int> > m_countryToIndex;
+ QMap<int, QMap<int, QLocale::Territory> > m_indexToTerritory;
+ QMap<QLocale::Language, QMap<QLocale::Territory, int> > m_territoryToIndex;
QMetaEnum m_policyEnum;
};
-static QList<QLocale::Country> sortCountries(const QList<QLocale::Country> &countries)
+static QList<QLocale::Territory> sortedTerritories(const QList<QLocale> &locales)
{
- QMultiMap<QString, QLocale::Country> nameToCountry;
- for (QLocale::Country country : countries)
- nameToCountry.insert(QLocale::countryToString(country), country);
- return nameToCountry.values();
+ QMultiMap<QString, QLocale::Territory> nameToTerritory;
+ for (const QLocale &locale : locales) {
+ const auto territory = locale.territory();
+ nameToTerritory.insert(QLocale::territoryToString(territory), territory);
+ }
+ return nameToTerritory.values();
}
void QtMetaEnumProvider::initLocale()
@@ -431,26 +420,24 @@ void QtMetaEnumProvider::initLocale()
const auto languages = nameToLanguage.values();
for (QLocale::Language language : languages) {
- QList<QLocale::Country> countries;
- countries = QLocale::countriesForLanguage(language);
- if (countries.isEmpty() && language == system.language())
- countries << system.country();
-
- if (!countries.isEmpty() && !m_languageToIndex.contains(language)) {
- countries = sortCountries(countries);
- int langIdx = m_languageEnumNames.count();
+ auto locales = QLocale::matchingLocales(language, QLocale::AnyScript,
+ QLocale::AnyTerritory);
+
+ if (!locales.isEmpty() && !m_languageToIndex.contains(language)) {
+ const auto territories = sortedTerritories(locales);
+ int langIdx = m_languageEnumNames.size();
m_indexToLanguage[langIdx] = language;
m_languageToIndex[language] = langIdx;
- QStringList countryNames;
- int countryIdx = 0;
- for (QLocale::Country country : qAsConst(countries)) {
- countryNames << QLocale::countryToString(country);
- m_indexToCountry[langIdx][countryIdx] = country;
- m_countryToIndex[language][country] = countryIdx;
- ++countryIdx;
+ QStringList territoryNames;
+ int territoryIdx = 0;
+ for (QLocale::Territory territory : territories) {
+ territoryNames << QLocale::territoryToString(territory);
+ m_indexToTerritory[langIdx][territoryIdx] = territory;
+ m_territoryToIndex[language][territory] = territoryIdx;
+ ++territoryIdx;
}
m_languageEnumNames << QLocale::languageToString(language);
- m_countryEnumNames[language] = countryNames;
+ m_territoryEnumNames[language] = territoryNames;
}
}
}
@@ -464,7 +451,7 @@ QtMetaEnumProvider::QtMetaEnumProvider()
m_policyEnum = p.enumerator();
const int keyCount = m_policyEnum.keyCount();
for (int i = 0; i < keyCount; i++)
- m_policyEnumNames << QLatin1String(m_policyEnum.key(i));
+ m_policyEnumNames << QLatin1StringView(m_policyEnum.key(i));
initLocale();
}
@@ -483,35 +470,35 @@ int QtMetaEnumProvider::sizePolicyToIndex(QSizePolicy::Policy policy) const
return -1;
}
-void QtMetaEnumProvider::indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const
+void QtMetaEnumProvider::indexToLocale(int languageIndex, int territoryIndex, QLocale::Language *language, QLocale::Territory *territory) const
{
QLocale::Language l = QLocale::C;
- QLocale::Country c = QLocale::AnyCountry;
+ QLocale::Territory c = QLocale::AnyTerritory;
if (m_indexToLanguage.contains(languageIndex)) {
l = m_indexToLanguage[languageIndex];
- if (m_indexToCountry.contains(languageIndex) && m_indexToCountry[languageIndex].contains(countryIndex))
- c = m_indexToCountry[languageIndex][countryIndex];
+ if (m_indexToTerritory.contains(languageIndex) && m_indexToTerritory[languageIndex].contains(territoryIndex))
+ c = m_indexToTerritory[languageIndex][territoryIndex];
}
if (language)
*language = l;
- if (country)
- *country = c;
+ if (territory)
+ *territory = c;
}
-void QtMetaEnumProvider::localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const
+void QtMetaEnumProvider::localeToIndex(QLocale::Language language, QLocale::Territory territory, int *languageIndex, int *territoryIndex) const
{
int l = -1;
int c = -1;
if (m_languageToIndex.contains(language)) {
l = m_languageToIndex[language];
- if (m_countryToIndex.contains(language) && m_countryToIndex[language].contains(country))
- c = m_countryToIndex[language][country];
+ if (m_territoryToIndex.contains(language) && m_territoryToIndex[language].contains(territory))
+ c = m_territoryToIndex[language][territory];
}
if (languageIndex)
*languageIndex = l;
- if (countryIndex)
- *countryIndex = c;
+ if (territoryIndex)
+ *territoryIndex = c;
}
Q_GLOBAL_STATIC(QtMetaEnumProvider, metaEnumProvider)
@@ -593,8 +580,7 @@ public:
void setMaximumValue(int newMaxVal) { setSimpleMaximumData(this, newMaxVal); }
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
};
/*!
@@ -719,9 +705,9 @@ int QtIntPropertyManager::singleStep(const QtProperty *property) const
*/
QString QtIntPropertyManager::valueText(const QtProperty *property) const
{
- const QtIntPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return QString::number(it.value().val);
}
@@ -738,7 +724,7 @@ QString QtIntPropertyManager::valueText(const QtProperty *property) const
*/
void QtIntPropertyManager::setValue(QtProperty *property, int val)
{
- void (QtIntPropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, int) = 0;
+ void (QtIntPropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, int) = nullptr;
setValueInRange<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(this, d_ptr.data(),
&QtIntPropertyManager::propertyChanged,
&QtIntPropertyManager::valueChanged,
@@ -797,7 +783,7 @@ void QtIntPropertyManager::setMaximum(QtProperty *property, int maxVal)
*/
void QtIntPropertyManager::setRange(QtProperty *property, int minVal, int maxVal)
{
- void (QtIntPropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, int, int, int) = 0;
+ void (QtIntPropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, int, int, int) = nullptr;
setBorderValues<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(this, d_ptr.data(),
&QtIntPropertyManager::propertyChanged,
&QtIntPropertyManager::valueChanged,
@@ -814,7 +800,7 @@ void QtIntPropertyManager::setRange(QtProperty *property, int minVal, int maxVal
*/
void QtIntPropertyManager::setSingleStep(QtProperty *property, int step)
{
- const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -870,8 +856,7 @@ public:
void setMaximumValue(double newMaxVal) { setSimpleMaximumData(this, newMaxVal); }
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
};
/*!
@@ -1017,9 +1002,9 @@ int QtDoublePropertyManager::decimals(const QtProperty *property) const
*/
QString QtDoublePropertyManager::valueText(const QtProperty *property) const
{
- const QtDoublePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return QString::number(it.value().val, 'f', it.value().decimals);
}
@@ -1036,7 +1021,7 @@ QString QtDoublePropertyManager::valueText(const QtProperty *property) const
*/
void QtDoublePropertyManager::setValue(QtProperty *property, double val)
{
- void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, double) = 0;
+ void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, double) = nullptr;
setValueInRange<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr.data(),
&QtDoublePropertyManager::propertyChanged,
&QtDoublePropertyManager::valueChanged,
@@ -1052,7 +1037,7 @@ void QtDoublePropertyManager::setValue(QtProperty *property, double val)
*/
void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step)
{
- const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -1082,7 +1067,7 @@ void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step)
*/
void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec)
{
- const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -1155,7 +1140,7 @@ void QtDoublePropertyManager::setMaximum(QtProperty *property, double maxVal)
*/
void QtDoublePropertyManager::setRange(QtProperty *property, double minVal, double maxVal)
{
- void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, double, double, double) = 0;
+ void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, double, double, double) = nullptr;
setBorderValues<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr.data(),
&QtDoublePropertyManager::propertyChanged,
&QtDoublePropertyManager::valueChanged,
@@ -1193,8 +1178,7 @@ public:
QRegularExpression regExp;
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- QMap<const QtProperty *, Data> m_values;
+ QHash<const QtProperty *, Data> m_values;
};
/*!
@@ -1288,9 +1272,9 @@ QRegularExpression QtStringPropertyManager::regExp(const QtProperty *property) c
*/
QString QtStringPropertyManager::valueText(const QtProperty *property) const
{
- const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return it.value().val;
}
@@ -1306,7 +1290,7 @@ QString QtStringPropertyManager::valueText(const QtProperty *property) const
*/
void QtStringPropertyManager::setValue(QtProperty *property, const QString &val)
{
- const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -1335,7 +1319,7 @@ void QtStringPropertyManager::setValue(QtProperty *property, const QString &val)
*/
void QtStringPropertyManager::setRegExp(QtProperty *property, const QRegularExpression &regExp)
{
- const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -1405,7 +1389,7 @@ class QtBoolPropertyManagerPrivate
public:
QtBoolPropertyManagerPrivate();
- QMap<const QtProperty *, bool> m_values;
+ QHash<const QtProperty *, bool> m_values;
const QIcon m_checkedIcon;
const QIcon m_uncheckedIcon;
};
@@ -1477,9 +1461,9 @@ bool QtBoolPropertyManager::value(const QtProperty *property) const
*/
QString QtBoolPropertyManager::valueText(const QtProperty *property) const
{
- const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
static const QString trueText = tr("True");
static const QString falseText = tr("False");
@@ -1491,9 +1475,9 @@ QString QtBoolPropertyManager::valueText(const QtProperty *property) const
*/
QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const
{
- const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QIcon();
+ return {};
return it.value() ? d_ptr->m_checkedIcon : d_ptr->m_uncheckedIcon;
}
@@ -1551,8 +1535,7 @@ public:
QString m_format;
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- QMap<const QtProperty *, Data> m_values;
+ QHash<const QtProperty *, Data> m_values;
};
QtDatePropertyManagerPrivate::QtDatePropertyManagerPrivate(QtDatePropertyManager *q) :
@@ -1660,9 +1643,9 @@ QDate QtDatePropertyManager::maximum(const QtProperty *property) const
*/
QString QtDatePropertyManager::valueText(const QtProperty *property) const
{
- const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return it.value().val.toString(d_ptr->m_format);
}
@@ -1679,7 +1662,7 @@ QString QtDatePropertyManager::valueText(const QtProperty *property) const
*/
void QtDatePropertyManager::setValue(QtProperty *property, QDate val)
{
- void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, QDate) = 0;
+ void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, QDate) = nullptr;
setValueInRange<QDate, QtDatePropertyManagerPrivate, QtDatePropertyManager, const QDate>(this, d_ptr.data(),
&QtDatePropertyManager::propertyChanged,
&QtDatePropertyManager::valueChanged,
@@ -1738,7 +1721,7 @@ void QtDatePropertyManager::setMaximum(QtProperty *property, QDate maxVal)
*/
void QtDatePropertyManager::setRange(QtProperty *property, QDate minVal, QDate maxVal)
{
- void (QtDatePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, QDate, QDate, QDate) = 0;
+ void (QtDatePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, QDate, QDate, QDate) = nullptr;
setBorderValues<QDate, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate>(this, d_ptr.data(),
&QtDatePropertyManager::propertyChanged,
&QtDatePropertyManager::valueChanged,
@@ -1773,8 +1756,7 @@ public:
const QString m_format;
- typedef QMap<const QtProperty *, QTime> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QTime> m_values;
};
QtTimePropertyManagerPrivate::QtTimePropertyManagerPrivate(QtTimePropertyManager *q) :
@@ -1845,9 +1827,9 @@ QTime QtTimePropertyManager::value(const QtProperty *property) const
*/
QString QtTimePropertyManager::valueText(const QtProperty *property) const
{
- const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return it.value().toString(d_ptr->m_format);
}
@@ -1893,8 +1875,7 @@ public:
const QString m_format;
- typedef QMap<const QtProperty *, QDateTime> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QDateTime> m_values;
};
QtDateTimePropertyManagerPrivate::QtDateTimePropertyManagerPrivate(QtDateTimePropertyManager *q) :
@@ -1961,9 +1942,9 @@ QDateTime QtDateTimePropertyManager::value(const QtProperty *property) const
*/
QString QtDateTimePropertyManager::valueText(const QtProperty *property) const
{
- const QtDateTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return it.value().toString(d_ptr->m_format);
}
@@ -2008,8 +1989,7 @@ public:
QString m_format;
- typedef QMap<const QtProperty *, QKeySequence> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QKeySequence> m_values;
};
/*! \class QtKeySequencePropertyManager
@@ -2072,9 +2052,9 @@ QKeySequence QtKeySequencePropertyManager::value(const QtProperty *property) con
*/
QString QtKeySequencePropertyManager::valueText(const QtProperty *property) const
{
- const QtKeySequencePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return it.value().toString(QKeySequence::NativeText);
}
@@ -2117,8 +2097,7 @@ class QtCharPropertyManagerPrivate
Q_DECLARE_PUBLIC(QtCharPropertyManager)
public:
- typedef QMap<const QtProperty *, QChar> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QChar> m_values;
};
/*! \class QtCharPropertyManager
@@ -2181,9 +2160,9 @@ QChar QtCharPropertyManager::value(const QtProperty *property) const
*/
QString QtCharPropertyManager::valueText(const QtProperty *property) const
{
- const QtCharPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QChar c = it.value();
return c.isNull() ? QString() : QString(c);
}
@@ -2227,54 +2206,47 @@ class QtLocalePropertyManagerPrivate
Q_DECLARE_PUBLIC(QtLocalePropertyManager)
public:
- QtLocalePropertyManagerPrivate();
-
void slotEnumChanged(QtProperty *property, int value);
void slotPropertyDestroyed(QtProperty *property);
- typedef QMap<const QtProperty *, QLocale> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QLocale> m_values;
- QtEnumPropertyManager *m_enumPropertyManager;
+ QtEnumPropertyManager *m_enumPropertyManager = nullptr;
- QMap<const QtProperty *, QtProperty *> m_propertyToLanguage;
- QMap<const QtProperty *, QtProperty *> m_propertyToCountry;
+ QHash<const QtProperty *, QtProperty *> m_propertyToLanguage;
+ QHash<const QtProperty *, QtProperty *> m_propertyToTerritory;
- QMap<const QtProperty *, QtProperty *> m_languageToProperty;
- QMap<const QtProperty *, QtProperty *> m_countryToProperty;
+ QHash<const QtProperty *, QtProperty *> m_languageToProperty;
+ QHash<const QtProperty *, QtProperty *> m_territoryToProperty;
};
-QtLocalePropertyManagerPrivate::QtLocalePropertyManagerPrivate()
-{
-}
-
void QtLocalePropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value)
{
- if (QtProperty *prop = m_languageToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_languageToProperty.value(property, nullptr)) {
const QLocale loc = m_values[prop];
QLocale::Language newLanguage = loc.language();
- QLocale::Country newCountry = loc.country();
+ QLocale::Territory newTerritory = loc.territory();
metaEnumProvider()->indexToLocale(value, 0, &newLanguage, 0);
- QLocale newLoc(newLanguage, newCountry);
+ QLocale newLoc(newLanguage, newTerritory);
q_ptr->setValue(prop, newLoc);
- } else if (QtProperty *prop = m_countryToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_territoryToProperty.value(property, nullptr)) {
const QLocale loc = m_values[prop];
QLocale::Language newLanguage = loc.language();
- QLocale::Country newCountry = loc.country();
- metaEnumProvider()->indexToLocale(m_enumPropertyManager->value(m_propertyToLanguage.value(prop)), value, &newLanguage, &newCountry);
- QLocale newLoc(newLanguage, newCountry);
+ QLocale::Territory newTerritory = loc.territory();
+ metaEnumProvider()->indexToLocale(m_enumPropertyManager->value(m_propertyToLanguage.value(prop)), value, &newLanguage, &newTerritory);
+ QLocale newLoc(newLanguage, newTerritory);
q_ptr->setValue(prop, newLoc);
}
}
void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *subProp = m_languageToProperty.value(property, 0)) {
- m_propertyToLanguage[subProp] = 0;
+ if (QtProperty *subProp = m_languageToProperty.value(property, nullptr)) {
+ m_propertyToLanguage[subProp] = nullptr;
m_languageToProperty.remove(property);
- } else if (QtProperty *subProp = m_countryToProperty.value(property, 0)) {
- m_propertyToCountry[subProp] = 0;
- m_countryToProperty.remove(property);
+ } else if (QtProperty *subProp = m_territoryToProperty.value(property, nullptr)) {
+ m_propertyToTerritory[subProp] = nullptr;
+ m_territoryToProperty.remove(property);
}
}
@@ -2286,7 +2258,7 @@ void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
\brief The QtLocalePropertyManager provides and manages QLocale properties.
- A locale property has nested \e language and \e country
+ A locale property has nested \e language and \e territory
subproperties. The top-level property's value can be retrieved
using the value() function, and set using the setValue() slot.
@@ -2321,11 +2293,10 @@ QtLocalePropertyManager::QtLocalePropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
- connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotEnumChanged(QtProperty*,int)));
-
- connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotEnumChanged(property, value); });
+ connect(d_ptr->m_enumPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -2338,7 +2309,7 @@ QtLocalePropertyManager::~QtLocalePropertyManager()
/*!
Returns the manager that creates the nested \e language
- and \e country subproperties.
+ and \e territory subproperties.
In order to provide editing widgets for the mentioned subproperties
in a property browser widget, this manager must be associated with
@@ -2369,27 +2340,27 @@ QLocale QtLocalePropertyManager::value(const QtProperty *property) const
*/
QString QtLocalePropertyManager::valueText(const QtProperty *property) const
{
- const QtLocalePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QLocale loc = it.value();
int langIdx = 0;
- int countryIdx = 0;
+ int territoryIdx = 0;
const QtMetaEnumProvider *me = metaEnumProvider();
- me->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx);
+ me->localeToIndex(loc.language(), loc.territory(), &langIdx, &territoryIdx);
if (langIdx < 0) {
qWarning("QtLocalePropertyManager::valueText: Unknown language %d", loc.language());
return tr("<Invalid>");
}
const QString languageName = me->languageEnumNames().at(langIdx);
- if (countryIdx < 0) {
- qWarning("QtLocalePropertyManager::valueText: Unknown country %d for %s", loc.country(), qPrintable(languageName));
+ if (territoryIdx < 0) {
+ qWarning("QtLocalePropertyManager::valueText: Unknown territory %d for %s", loc.territory(), qPrintable(languageName));
return languageName;
}
- const QString countryName = me->countryEnumNames(loc.language()).at(countryIdx);
- return tr("%1, %2").arg(languageName, countryName);
+ const QString territoryName = me->territoryEnumNames(loc.language()).at(territoryIdx);
+ return tr("%1, %2").arg(languageName, territoryName);
}
/*!
@@ -2402,7 +2373,7 @@ QString QtLocalePropertyManager::valueText(const QtProperty *property) const
*/
void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &val)
{
- const QtLocalePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -2413,14 +2384,14 @@ void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &val)
it.value() = val;
int langIdx = 0;
- int countryIdx = 0;
- metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx);
+ int territoryIdx = 0;
+ metaEnumProvider()->localeToIndex(val.language(), val.territory(), &langIdx, &territoryIdx);
if (loc.language() != val.language()) {
d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToLanguage.value(property), langIdx);
- d_ptr->m_enumPropertyManager->setEnumNames(d_ptr->m_propertyToCountry.value(property),
- metaEnumProvider()->countryEnumNames(val.language()));
+ d_ptr->m_enumPropertyManager->setEnumNames(d_ptr->m_propertyToTerritory.value(property),
+ metaEnumProvider()->territoryEnumNames(val.language()));
}
- d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToCountry.value(property), countryIdx);
+ d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToTerritory.value(property), territoryIdx);
emit propertyChanged(property);
emit valueChanged(property, val);
@@ -2435,8 +2406,8 @@ void QtLocalePropertyManager::initializeProperty(QtProperty *property)
d_ptr->m_values[property] = val;
int langIdx = 0;
- int countryIdx = 0;
- metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx);
+ int territoryIdx = 0;
+ metaEnumProvider()->localeToIndex(val.language(), val.territory(), &langIdx, &territoryIdx);
QtProperty *languageProp = d_ptr->m_enumPropertyManager->addProperty();
languageProp->setPropertyName(tr("Language"));
@@ -2446,13 +2417,13 @@ void QtLocalePropertyManager::initializeProperty(QtProperty *property)
d_ptr->m_languageToProperty[languageProp] = property;
property->addSubProperty(languageProp);
- QtProperty *countryProp = d_ptr->m_enumPropertyManager->addProperty();
- countryProp->setPropertyName(tr("Country"));
- d_ptr->m_enumPropertyManager->setEnumNames(countryProp, metaEnumProvider()->countryEnumNames(val.language()));
- d_ptr->m_enumPropertyManager->setValue(countryProp, countryIdx);
- d_ptr->m_propertyToCountry[property] = countryProp;
- d_ptr->m_countryToProperty[countryProp] = property;
- property->addSubProperty(countryProp);
+ QtProperty *territoryProp = d_ptr->m_enumPropertyManager->addProperty();
+ territoryProp->setPropertyName(tr("Territory"));
+ d_ptr->m_enumPropertyManager->setEnumNames(territoryProp, metaEnumProvider()->territoryEnumNames(val.language()));
+ d_ptr->m_enumPropertyManager->setValue(territoryProp, territoryIdx);
+ d_ptr->m_propertyToTerritory[property] = territoryProp;
+ d_ptr->m_territoryToProperty[territoryProp] = property;
+ property->addSubProperty(territoryProp);
}
/*!
@@ -2467,12 +2438,12 @@ void QtLocalePropertyManager::uninitializeProperty(QtProperty *property)
}
d_ptr->m_propertyToLanguage.remove(property);
- QtProperty *countryProp = d_ptr->m_propertyToCountry[property];
- if (countryProp) {
- d_ptr->m_countryToProperty.remove(countryProp);
- delete countryProp;
+ QtProperty *territoryProp = d_ptr->m_propertyToTerritory[property];
+ if (territoryProp) {
+ d_ptr->m_territoryToProperty.remove(territoryProp);
+ delete territoryProp;
}
- d_ptr->m_propertyToCountry.remove(property);
+ d_ptr->m_propertyToTerritory.remove(property);
d_ptr->m_values.remove(property);
}
@@ -2488,25 +2459,24 @@ public:
void slotIntChanged(QtProperty *property, int value);
void slotPropertyDestroyed(QtProperty *property);
- typedef QMap<const QtProperty *, QPoint> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QPoint> m_values;
QtIntPropertyManager *m_intPropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToX;
- QMap<const QtProperty *, QtProperty *> m_propertyToY;
+ QHash<const QtProperty *, QtProperty *> m_propertyToX;
+ QHash<const QtProperty *, QtProperty *> m_propertyToY;
- QMap<const QtProperty *, QtProperty *> m_xToProperty;
- QMap<const QtProperty *, QtProperty *> m_yToProperty;
+ QHash<const QtProperty *, QtProperty *> m_xToProperty;
+ QHash<const QtProperty *, QtProperty *> m_yToProperty;
};
void QtPointPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
{
- if (QtProperty *xprop = m_xToProperty.value(property, 0)) {
+ if (QtProperty *xprop = m_xToProperty.value(property, nullptr)) {
QPoint p = m_values[xprop];
p.setX(value);
q_ptr->setValue(xprop, p);
- } else if (QtProperty *yprop = m_yToProperty.value(property, 0)) {
+ } else if (QtProperty *yprop = m_yToProperty.value(property, nullptr)) {
QPoint p = m_values[yprop];
p.setY(value);
q_ptr->setValue(yprop, p);
@@ -2515,11 +2485,11 @@ void QtPointPropertyManagerPrivate::slotIntChanged(QtProperty *property, int val
void QtPointPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_xToProperty.value(property, 0)) {
- m_propertyToX[pointProp] = 0;
+ if (QtProperty *pointProp = m_xToProperty.value(property, nullptr)) {
+ m_propertyToX[pointProp] = nullptr;
m_xToProperty.remove(property);
- } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) {
- m_propertyToY[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_yToProperty.value(property, nullptr)) {
+ m_propertyToY[pointProp] = nullptr;
m_yToProperty.remove(property);
}
}
@@ -2566,10 +2536,10 @@ QtPointPropertyManager::QtPointPropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
- connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotIntChanged(QtProperty*,int)));
- connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); });
+ connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -2613,12 +2583,11 @@ QPoint QtPointPropertyManager::value(const QtProperty *property) const
*/
QString QtPointPropertyManager::valueText(const QtProperty *property) const
{
- const QtPointPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QPoint v = it.value();
- return tr("(%1, %2)").arg(QString::number(v.x()))
- .arg(QString::number(v.y()));
+ return tr("(%1, %2)").arg(v.x()).arg(v.y());
}
/*!
@@ -2631,7 +2600,7 @@ QString QtPointPropertyManager::valueText(const QtProperty *property) const
*/
void QtPointPropertyManager::setValue(QtProperty *property, const QPoint &val)
{
- const QtPointPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -2707,25 +2676,24 @@ public:
void slotDoubleChanged(QtProperty *property, double value);
void slotPropertyDestroyed(QtProperty *property);
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
QtDoublePropertyManager *m_doublePropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToX;
- QMap<const QtProperty *, QtProperty *> m_propertyToY;
+ QHash<const QtProperty *, QtProperty *> m_propertyToX;
+ QHash<const QtProperty *, QtProperty *> m_propertyToY;
- QMap<const QtProperty *, QtProperty *> m_xToProperty;
- QMap<const QtProperty *, QtProperty *> m_yToProperty;
+ QHash<const QtProperty *, QtProperty *> m_xToProperty;
+ QHash<const QtProperty *, QtProperty *> m_yToProperty;
};
void QtPointFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value)
{
- if (QtProperty *prop = m_xToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_xToProperty.value(property, nullptr)) {
QPointF p = m_values[prop].val;
p.setX(value);
q_ptr->setValue(prop, p);
- } else if (QtProperty *prop = m_yToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_yToProperty.value(property, nullptr)) {
QPointF p = m_values[prop].val;
p.setY(value);
q_ptr->setValue(prop, p);
@@ -2734,11 +2702,11 @@ void QtPointFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, dou
void QtPointFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_xToProperty.value(property, 0)) {
- m_propertyToX[pointProp] = 0;
+ if (QtProperty *pointProp = m_xToProperty.value(property, nullptr)) {
+ m_propertyToX[pointProp] = nullptr;
m_xToProperty.remove(property);
- } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) {
- m_propertyToY[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_yToProperty.value(property, nullptr)) {
+ m_propertyToY[pointProp] = nullptr;
m_yToProperty.remove(property);
}
}
@@ -2795,10 +2763,10 @@ QtPointFPropertyManager::QtPointFPropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
- connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotDoubleChanged(QtProperty*,double)));
- connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_doublePropertyManager, &QtDoublePropertyManager::valueChanged, this,
+ [this](QtProperty *property, double value) { d_ptr->slotDoubleChanged(property, value); });
+ connect(d_ptr->m_doublePropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -2852,13 +2820,13 @@ int QtPointFPropertyManager::decimals(const QtProperty *property) const
*/
QString QtPointFPropertyManager::valueText(const QtProperty *property) const
{
- const QtPointFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QPointF v = it.value().val;
const int dec = it.value().decimals;
- return tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec))
- .arg(QString::number(v.y(), 'f', dec));
+ return tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec),
+ QString::number(v.y(), 'f', dec));
}
/*!
@@ -2871,7 +2839,7 @@ QString QtPointFPropertyManager::valueText(const QtProperty *property) const
*/
void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &val)
{
- const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -2897,7 +2865,7 @@ void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &val)
*/
void QtPointFPropertyManager::setDecimals(QtProperty *property, int prec)
{
- const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -2991,25 +2959,24 @@ public:
void setMaximumValue(const QSize &newMaxVal) { setSizeMaximumData(this, newMaxVal); }
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
QtIntPropertyManager *m_intPropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToW;
- QMap<const QtProperty *, QtProperty *> m_propertyToH;
+ QHash<const QtProperty *, QtProperty *> m_propertyToW;
+ QHash<const QtProperty *, QtProperty *> m_propertyToH;
- QMap<const QtProperty *, QtProperty *> m_wToProperty;
- QMap<const QtProperty *, QtProperty *> m_hToProperty;
+ QHash<const QtProperty *, QtProperty *> m_wToProperty;
+ QHash<const QtProperty *, QtProperty *> m_hToProperty;
};
void QtSizePropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
{
- if (QtProperty *prop = m_wToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_wToProperty.value(property, nullptr)) {
QSize s = m_values[prop].val;
s.setWidth(value);
q_ptr->setValue(prop, s);
- } else if (QtProperty *prop = m_hToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_hToProperty.value(property, nullptr)) {
QSize s = m_values[prop].val;
s.setHeight(value);
q_ptr->setValue(prop, s);
@@ -3018,11 +2985,11 @@ void QtSizePropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu
void QtSizePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_wToProperty.value(property, 0)) {
- m_propertyToW[pointProp] = 0;
+ if (QtProperty *pointProp = m_wToProperty.value(property, nullptr)) {
+ m_propertyToW[pointProp] = nullptr;
m_wToProperty.remove(property);
- } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) {
- m_propertyToH[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_hToProperty.value(property, nullptr)) {
+ m_propertyToH[pointProp] = nullptr;
m_hToProperty.remove(property);
}
}
@@ -3105,10 +3072,10 @@ QtSizePropertyManager::QtSizePropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
- connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotIntChanged(QtProperty*,int)));
- connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); });
+ connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -3172,12 +3139,11 @@ QSize QtSizePropertyManager::maximum(const QtProperty *property) const
*/
QString QtSizePropertyManager::valueText(const QtProperty *property) const
{
- const QtSizePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QSize v = it.value().val;
- return tr("%1 x %2").arg(QString::number(v.width()))
- .arg(QString::number(v.height()));
+ return tr("%1 x %2").arg(v.width()).arg(v.height());
}
/*!
@@ -3336,25 +3302,24 @@ public:
void setMaximumValue(const QSizeF &newMaxVal) { setSizeMaximumData(this, newMaxVal); }
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
QtDoublePropertyManager *m_doublePropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToW;
- QMap<const QtProperty *, QtProperty *> m_propertyToH;
+ QHash<const QtProperty *, QtProperty *> m_propertyToW;
+ QHash<const QtProperty *, QtProperty *> m_propertyToH;
- QMap<const QtProperty *, QtProperty *> m_wToProperty;
- QMap<const QtProperty *, QtProperty *> m_hToProperty;
+ QHash<const QtProperty *, QtProperty *> m_wToProperty;
+ QHash<const QtProperty *, QtProperty *> m_hToProperty;
};
void QtSizeFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value)
{
- if (QtProperty *prop = m_wToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_wToProperty.value(property, nullptr)) {
QSizeF s = m_values[prop].val;
s.setWidth(value);
q_ptr->setValue(prop, s);
- } else if (QtProperty *prop = m_hToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_hToProperty.value(property, nullptr)) {
QSizeF s = m_values[prop].val;
s.setHeight(value);
q_ptr->setValue(prop, s);
@@ -3363,11 +3328,11 @@ void QtSizeFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, doub
void QtSizeFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_wToProperty.value(property, 0)) {
- m_propertyToW[pointProp] = 0;
+ if (QtProperty *pointProp = m_wToProperty.value(property, nullptr)) {
+ m_propertyToW[pointProp] = nullptr;
m_wToProperty.remove(property);
- } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) {
- m_propertyToH[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_hToProperty.value(property, nullptr)) {
+ m_propertyToH[pointProp] = nullptr;
m_hToProperty.remove(property);
}
}
@@ -3458,10 +3423,10 @@ QtSizeFPropertyManager::QtSizeFPropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
- connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotDoubleChanged(QtProperty*,double)));
- connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_doublePropertyManager, &QtDoublePropertyManager::valueChanged, this,
+ [this](QtProperty *property, double value) { d_ptr->slotDoubleChanged(property, value); });
+ connect(d_ptr->m_doublePropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -3535,13 +3500,13 @@ QSizeF QtSizeFPropertyManager::maximum(const QtProperty *property) const
*/
QString QtSizeFPropertyManager::valueText(const QtProperty *property) const
{
- const QtSizeFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QSizeF v = it.value().val;
const int dec = it.value().decimals;
- return tr("%1 x %2").arg(QString::number(v.width(), 'f', dec))
- .arg(QString::number(v.height(), 'f', dec));
+ return tr("%1 x %2").arg(QString::number(v.width(), 'f', dec),
+ QString::number(v.height(), 'f', dec));
}
/*!
@@ -3574,7 +3539,7 @@ void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &val)
*/
void QtSizeFPropertyManager::setDecimals(QtProperty *property, int prec)
{
- const QtSizeFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -3728,25 +3693,24 @@ public:
QRect constraint;
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
QtIntPropertyManager *m_intPropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToX;
- QMap<const QtProperty *, QtProperty *> m_propertyToY;
- QMap<const QtProperty *, QtProperty *> m_propertyToW;
- QMap<const QtProperty *, QtProperty *> m_propertyToH;
+ QHash<const QtProperty *, QtProperty *> m_propertyToX;
+ QHash<const QtProperty *, QtProperty *> m_propertyToY;
+ QHash<const QtProperty *, QtProperty *> m_propertyToW;
+ QHash<const QtProperty *, QtProperty *> m_propertyToH;
- QMap<const QtProperty *, QtProperty *> m_xToProperty;
- QMap<const QtProperty *, QtProperty *> m_yToProperty;
- QMap<const QtProperty *, QtProperty *> m_wToProperty;
- QMap<const QtProperty *, QtProperty *> m_hToProperty;
+ QHash<const QtProperty *, QtProperty *> m_xToProperty;
+ QHash<const QtProperty *, QtProperty *> m_yToProperty;
+ QHash<const QtProperty *, QtProperty *> m_wToProperty;
+ QHash<const QtProperty *, QtProperty *> m_hToProperty;
};
void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
{
- if (QtProperty *prop = m_xToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_xToProperty.value(property, nullptr)) {
QRect r = m_values[prop].val;
r.moveLeft(value);
q_ptr->setValue(prop, r);
@@ -3754,7 +3718,7 @@ void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu
QRect r = m_values[prop].val;
r.moveTop(value);
q_ptr->setValue(prop, r);
- } else if (QtProperty *prop = m_wToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_wToProperty.value(property, nullptr)) {
Data data = m_values[prop];
QRect r = data.val;
r.setWidth(value);
@@ -3762,7 +3726,7 @@ void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu
r.moveLeft(data.constraint.left() + data.constraint.width() - r.width());
}
q_ptr->setValue(prop, r);
- } else if (QtProperty *prop = m_hToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_hToProperty.value(property, nullptr)) {
Data data = m_values[prop];
QRect r = data.val;
r.setHeight(value);
@@ -3775,17 +3739,17 @@ void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu
void QtRectPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_xToProperty.value(property, 0)) {
- m_propertyToX[pointProp] = 0;
+ if (QtProperty *pointProp = m_xToProperty.value(property, nullptr)) {
+ m_propertyToX[pointProp] = nullptr;
m_xToProperty.remove(property);
- } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) {
- m_propertyToY[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_yToProperty.value(property, nullptr)) {
+ m_propertyToY[pointProp] = nullptr;
m_yToProperty.remove(property);
- } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) {
- m_propertyToW[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_wToProperty.value(property, nullptr)) {
+ m_propertyToW[pointProp] = nullptr;
m_wToProperty.remove(property);
- } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) {
- m_propertyToH[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_hToProperty.value(property, nullptr)) {
+ m_propertyToH[pointProp] = nullptr;
m_hToProperty.remove(property);
}
}
@@ -3871,10 +3835,10 @@ QtRectPropertyManager::QtRectPropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
- connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotIntChanged(QtProperty*,int)));
- connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); });
+ connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -3928,14 +3892,12 @@ QRect QtRectPropertyManager::constraint(const QtProperty *property) const
*/
QString QtRectPropertyManager::valueText(const QtProperty *property) const
{
- const QtRectPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QRect v = it.value().val;
- return tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x()))
- .arg(QString::number(v.y()))
- .arg(QString::number(v.width()))
- .arg(QString::number(v.height()));
+ return tr("[(%1, %2), %3 x %4]").arg(v.x()) .arg(v.y())
+ .arg(v.width()).arg(v.height());
}
/*!
@@ -3952,7 +3914,7 @@ QString QtRectPropertyManager::valueText(const QtProperty *property) const
*/
void QtRectPropertyManager::setValue(QtProperty *property, const QRect &val)
{
- const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -3997,7 +3959,7 @@ void QtRectPropertyManager::setValue(QtProperty *property, const QRect &val)
*/
void QtRectPropertyManager::setConstraint(QtProperty *property, const QRect &constraint)
{
- const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -4137,33 +4099,32 @@ public:
int decimals{2};
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
QtDoublePropertyManager *m_doublePropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToX;
- QMap<const QtProperty *, QtProperty *> m_propertyToY;
- QMap<const QtProperty *, QtProperty *> m_propertyToW;
- QMap<const QtProperty *, QtProperty *> m_propertyToH;
+ QHash<const QtProperty *, QtProperty *> m_propertyToX;
+ QHash<const QtProperty *, QtProperty *> m_propertyToY;
+ QHash<const QtProperty *, QtProperty *> m_propertyToW;
+ QHash<const QtProperty *, QtProperty *> m_propertyToH;
- QMap<const QtProperty *, QtProperty *> m_xToProperty;
- QMap<const QtProperty *, QtProperty *> m_yToProperty;
- QMap<const QtProperty *, QtProperty *> m_wToProperty;
- QMap<const QtProperty *, QtProperty *> m_hToProperty;
+ QHash<const QtProperty *, QtProperty *> m_xToProperty;
+ QHash<const QtProperty *, QtProperty *> m_yToProperty;
+ QHash<const QtProperty *, QtProperty *> m_wToProperty;
+ QHash<const QtProperty *, QtProperty *> m_hToProperty;
};
void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value)
{
- if (QtProperty *prop = m_xToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_xToProperty.value(property, nullptr)) {
QRectF r = m_values[prop].val;
r.moveLeft(value);
q_ptr->setValue(prop, r);
- } else if (QtProperty *prop = m_yToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_yToProperty.value(property, nullptr)) {
QRectF r = m_values[prop].val;
r.moveTop(value);
q_ptr->setValue(prop, r);
- } else if (QtProperty *prop = m_wToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_wToProperty.value(property, nullptr)) {
Data data = m_values[prop];
QRectF r = data.val;
r.setWidth(value);
@@ -4171,7 +4132,7 @@ void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, doub
r.moveLeft(data.constraint.left() + data.constraint.width() - r.width());
}
q_ptr->setValue(prop, r);
- } else if (QtProperty *prop = m_hToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_hToProperty.value(property, nullptr)) {
Data data = m_values[prop];
QRectF r = data.val;
r.setHeight(value);
@@ -4184,17 +4145,17 @@ void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, doub
void QtRectFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_xToProperty.value(property, 0)) {
- m_propertyToX[pointProp] = 0;
+ if (QtProperty *pointProp = m_xToProperty.value(property, nullptr)) {
+ m_propertyToX[pointProp] = nullptr;
m_xToProperty.remove(property);
- } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) {
- m_propertyToY[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_yToProperty.value(property, nullptr)) {
+ m_propertyToY[pointProp] = nullptr;
m_yToProperty.remove(property);
- } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) {
- m_propertyToW[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_wToProperty.value(property, nullptr)) {
+ m_propertyToW[pointProp] = nullptr;
m_wToProperty.remove(property);
- } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) {
- m_propertyToH[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_hToProperty.value(property, nullptr)) {
+ m_propertyToH[pointProp] = nullptr;
m_hToProperty.remove(property);
}
}
@@ -4290,10 +4251,10 @@ QtRectFPropertyManager::QtRectFPropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
- connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotDoubleChanged(QtProperty*,double)));
- connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_doublePropertyManager, &QtDoublePropertyManager::valueChanged, this,
+ [this](QtProperty *property, double value) { d_ptr->slotDoubleChanged(property, value); });
+ connect(d_ptr->m_doublePropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -4357,15 +4318,15 @@ QRectF QtRectFPropertyManager::constraint(const QtProperty *property) const
*/
QString QtRectFPropertyManager::valueText(const QtProperty *property) const
{
- const QtRectFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QRectF v = it.value().val;
const int dec = it.value().decimals;
- return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x(), 'f', dec))
- .arg(QString::number(v.y(), 'f', dec))
- .arg(QString::number(v.width(), 'f', dec))
- .arg(QString::number(v.height(), 'f', dec)));
+ return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x(), 'f', dec),
+ QString::number(v.y(), 'f', dec),
+ QString::number(v.width(), 'f', dec),
+ QString::number(v.height(), 'f', dec)));
}
/*!
@@ -4382,7 +4343,7 @@ QString QtRectFPropertyManager::valueText(const QtProperty *property) const
*/
void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &val)
{
- const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -4427,7 +4388,7 @@ void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &val)
*/
void QtRectFPropertyManager::setConstraint(QtProperty *property, const QRectF &constraint)
{
- const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -4485,7 +4446,7 @@ void QtRectFPropertyManager::setConstraint(QtProperty *property, const QRectF &c
*/
void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec)
{
- const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -4603,8 +4564,7 @@ public:
QMap<int, QIcon> enumIcons;
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
};
/*!
@@ -4719,16 +4679,16 @@ QMap<int, QIcon> QtEnumPropertyManager::enumIcons(const QtProperty *property) co
*/
QString QtEnumPropertyManager::valueText(const QtProperty *property) const
{
- const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QtEnumPropertyManagerPrivate::Data &data = it.value();
const int v = data.val;
- if (v >= 0 && v < data.enumNames.count())
+ if (v >= 0 && v < data.enumNames.size())
return data.enumNames.at(v);
- return QString();
+ return {};
}
/*!
@@ -4736,9 +4696,9 @@ QString QtEnumPropertyManager::valueText(const QtProperty *property) const
*/
QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const
{
- const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QIcon();
+ return {};
const QtEnumPropertyManagerPrivate::Data &data = it.value();
@@ -4758,16 +4718,16 @@ QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const
*/
void QtEnumPropertyManager::setValue(QtProperty *property, int val)
{
- const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtEnumPropertyManagerPrivate::Data data = it.value();
- if (val >= data.enumNames.count())
+ if (val >= data.enumNames.size())
return;
- if (val < 0 && data.enumNames.count() > 0)
+ if (val < 0 && data.enumNames.size() > 0)
return;
if (val < 0)
@@ -4796,7 +4756,7 @@ void QtEnumPropertyManager::setValue(QtProperty *property, int val)
*/
void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList &enumNames)
{
- const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -4809,7 +4769,7 @@ void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList
data.val = -1;
- if (enumNames.count() > 0)
+ if (enumNames.size() > 0)
data.val = 0;
it.value() = data;
@@ -4830,7 +4790,7 @@ void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList
*/
void QtEnumPropertyManager::setEnumIcons(QtProperty *property, const QMap<int, QIcon> &enumIcons)
{
- const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -4874,20 +4834,19 @@ public:
QStringList flagNames;
};
- typedef QMap<const QtProperty *, Data> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, Data> m_values;
QtBoolPropertyManager *m_boolPropertyManager;
- QMap<const QtProperty *, QList<QtProperty *> > m_propertyToFlags;
+ QHash<const QtProperty *, QList<QtProperty *>> m_propertyToFlags;
- QMap<const QtProperty *, QtProperty *> m_flagToProperty;
+ QHash<const QtProperty *, QtProperty *> m_flagToProperty;
};
void QtFlagPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool value)
{
- QtProperty *prop = m_flagToProperty.value(property, 0);
- if (prop == 0)
+ QtProperty *prop = m_flagToProperty.value(property, nullptr);
+ if (prop == nullptr)
return;
const auto pfit = m_propertyToFlags.constFind(prop);
@@ -4911,8 +4870,8 @@ void QtFlagPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool va
void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- QtProperty *flagProperty = m_flagToProperty.value(property, 0);
- if (flagProperty == 0)
+ QtProperty *flagProperty = m_flagToProperty.value(property, nullptr);
+ if (flagProperty == nullptr)
return;
m_propertyToFlags[flagProperty].replace(m_propertyToFlags[flagProperty].indexOf(property), 0);
@@ -4982,10 +4941,10 @@ QtFlagPropertyManager::QtFlagPropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this);
- connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty*,bool)),
- this, SLOT(slotBoolChanged(QtProperty*,bool)));
- connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_boolPropertyManager, &QtBoolPropertyManager::valueChanged, this,
+ [this](QtProperty *property, bool value) { d_ptr->slotBoolChanged(property, value); });
+ connect(d_ptr->m_boolPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -5039,21 +4998,20 @@ QStringList QtFlagPropertyManager::flagNames(const QtProperty *property) const
*/
QString QtFlagPropertyManager::valueText(const QtProperty *property) const
{
- const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QtFlagPropertyManagerPrivate::Data &data = it.value();
QString str;
int level = 0;
const QChar bar = QLatin1Char('|');
- const QStringList::const_iterator fncend = data.flagNames.constEnd();
- for (QStringList::const_iterator it = data.flagNames.constBegin(); it != fncend; ++it) {
+ for (const auto &name : data.flagNames) {
if (data.val & (1 << level)) {
if (!str.isEmpty())
str += bar;
- str += *it;
+ str += name;
}
level++;
@@ -5076,7 +5034,7 @@ QString QtFlagPropertyManager::valueText(const QtProperty *property) const
*/
void QtFlagPropertyManager::setValue(QtProperty *property, int val)
{
- const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -5085,7 +5043,7 @@ void QtFlagPropertyManager::setValue(QtProperty *property, int val)
if (data.val == val)
return;
- if (val > (1 << data.flagNames.count()) - 1)
+ if (val > (1 << data.flagNames.size()) - 1)
return;
if (val < 0)
@@ -5118,7 +5076,7 @@ void QtFlagPropertyManager::setValue(QtProperty *property, int val)
*/
void QtFlagPropertyManager::setFlagNames(QtProperty *property, const QStringList &flagNames)
{
- const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -5134,7 +5092,7 @@ void QtFlagPropertyManager::setFlagNames(QtProperty *property, const QStringList
const auto pfit = d_ptr->m_propertyToFlags.find(property);
if (pfit != d_ptr->m_propertyToFlags.end()) {
- for (QtProperty *prop : qAsConst(pfit.value())) {
+ for (QtProperty *prop : std::as_const(pfit.value())) {
if (prop) {
delete prop;
d_ptr->m_flagToProperty.remove(prop);
@@ -5174,7 +5132,7 @@ void QtFlagPropertyManager::uninitializeProperty(QtProperty *property)
{
const auto it = d_ptr->m_propertyToFlags.find(property);
if (it != d_ptr->m_propertyToFlags.end()) {
- for (QtProperty *prop : qAsConst(it.value())) {
+ for (QtProperty *prop : std::as_const(it.value())) {
if (prop) {
d_ptr->m_flagToProperty.remove(prop);
delete prop;
@@ -5200,21 +5158,20 @@ public:
void slotEnumChanged(QtProperty *property, int value);
void slotPropertyDestroyed(QtProperty *property);
- typedef QMap<const QtProperty *, QSizePolicy> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QSizePolicy> m_values;
QtIntPropertyManager *m_intPropertyManager;
QtEnumPropertyManager *m_enumPropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToHPolicy;
- QMap<const QtProperty *, QtProperty *> m_propertyToVPolicy;
- QMap<const QtProperty *, QtProperty *> m_propertyToHStretch;
- QMap<const QtProperty *, QtProperty *> m_propertyToVStretch;
+ QHash<const QtProperty *, QtProperty *> m_propertyToHPolicy;
+ QHash<const QtProperty *, QtProperty *> m_propertyToVPolicy;
+ QHash<const QtProperty *, QtProperty *> m_propertyToHStretch;
+ QHash<const QtProperty *, QtProperty *> m_propertyToVStretch;
- QMap<const QtProperty *, QtProperty *> m_hPolicyToProperty;
- QMap<const QtProperty *, QtProperty *> m_vPolicyToProperty;
- QMap<const QtProperty *, QtProperty *> m_hStretchToProperty;
- QMap<const QtProperty *, QtProperty *> m_vStretchToProperty;
+ QHash<const QtProperty *, QtProperty *> m_hPolicyToProperty;
+ QHash<const QtProperty *, QtProperty *> m_vPolicyToProperty;
+ QHash<const QtProperty *, QtProperty *> m_hStretchToProperty;
+ QHash<const QtProperty *, QtProperty *> m_vStretchToProperty;
};
QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate()
@@ -5223,11 +5180,11 @@ QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate()
void QtSizePolicyPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
{
- if (QtProperty *prop = m_hStretchToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_hStretchToProperty.value(property, nullptr)) {
QSizePolicy sp = m_values[prop];
sp.setHorizontalStretch(value);
q_ptr->setValue(prop, sp);
- } else if (QtProperty *prop = m_vStretchToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_vStretchToProperty.value(property, nullptr)) {
QSizePolicy sp = m_values[prop];
sp.setVerticalStretch(value);
q_ptr->setValue(prop, sp);
@@ -5236,11 +5193,11 @@ void QtSizePolicyPropertyManagerPrivate::slotIntChanged(QtProperty *property, in
void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value)
{
- if (QtProperty *prop = m_hPolicyToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_hPolicyToProperty.value(property, nullptr)) {
QSizePolicy sp = m_values[prop];
sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(value));
q_ptr->setValue(prop, sp);
- } else if (QtProperty *prop = m_vPolicyToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_vPolicyToProperty.value(property, nullptr)) {
QSizePolicy sp = m_values[prop];
sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(value));
q_ptr->setValue(prop, sp);
@@ -5249,17 +5206,17 @@ void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(QtProperty *property, i
void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_hStretchToProperty.value(property, 0)) {
- m_propertyToHStretch[pointProp] = 0;
+ if (QtProperty *pointProp = m_hStretchToProperty.value(property, nullptr)) {
+ m_propertyToHStretch[pointProp] = nullptr;
m_hStretchToProperty.remove(property);
- } else if (QtProperty *pointProp = m_vStretchToProperty.value(property, 0)) {
- m_propertyToVStretch[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_vStretchToProperty.value(property, nullptr)) {
+ m_propertyToVStretch[pointProp] = nullptr;
m_vStretchToProperty.remove(property);
- } else if (QtProperty *pointProp = m_hPolicyToProperty.value(property, 0)) {
- m_propertyToHPolicy[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_hPolicyToProperty.value(property, nullptr)) {
+ m_propertyToHPolicy[pointProp] = nullptr;
m_hPolicyToProperty.remove(property);
- } else if (QtProperty *pointProp = m_vPolicyToProperty.value(property, 0)) {
- m_propertyToVPolicy[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_vPolicyToProperty.value(property, nullptr)) {
+ m_propertyToVPolicy[pointProp] = nullptr;
m_vPolicyToProperty.remove(property);
}
}
@@ -5309,16 +5266,16 @@ QtSizePolicyPropertyManager::QtSizePolicyPropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
- connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotIntChanged(QtProperty*,int)));
- d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
- connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotEnumChanged(QtProperty*,int)));
+ connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); });
+ connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
- connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
- connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
+ connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotEnumChanged(property, value); });
+ connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -5377,9 +5334,9 @@ QSizePolicy QtSizePolicyPropertyManager::value(const QtProperty *property) const
*/
QString QtSizePolicyPropertyManager::valueText(const QtProperty *property) const
{
- const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
const QSizePolicy sp = it.value();
const QtMetaEnumProvider *mep = metaEnumProvider();
@@ -5402,7 +5359,7 @@ QString QtSizePolicyPropertyManager::valueText(const QtProperty *property) const
*/
void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &val)
{
- const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -5529,28 +5486,29 @@ public:
QStringList m_familyNames;
- typedef QMap<const QtProperty *, QFont> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QFont> m_values;
QtIntPropertyManager *m_intPropertyManager;
QtEnumPropertyManager *m_enumPropertyManager;
QtBoolPropertyManager *m_boolPropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToFamily;
- QMap<const QtProperty *, QtProperty *> m_propertyToPointSize;
- QMap<const QtProperty *, QtProperty *> m_propertyToBold;
- QMap<const QtProperty *, QtProperty *> m_propertyToItalic;
- QMap<const QtProperty *, QtProperty *> m_propertyToUnderline;
- QMap<const QtProperty *, QtProperty *> m_propertyToStrikeOut;
- QMap<const QtProperty *, QtProperty *> m_propertyToKerning;
-
- QMap<const QtProperty *, QtProperty *> m_familyToProperty;
- QMap<const QtProperty *, QtProperty *> m_pointSizeToProperty;
- QMap<const QtProperty *, QtProperty *> m_boldToProperty;
- QMap<const QtProperty *, QtProperty *> m_italicToProperty;
- QMap<const QtProperty *, QtProperty *> m_underlineToProperty;
- QMap<const QtProperty *, QtProperty *> m_strikeOutToProperty;
- QMap<const QtProperty *, QtProperty *> m_kerningToProperty;
+ QHash<const QtProperty *, QtProperty *> m_propertyToFamily;
+ QHash<const QtProperty *, QtProperty *> m_propertyToPointSize;
+ QHash<const QtProperty *, QtProperty *> m_propertyToBold;
+ QHash<const QtProperty *, QtProperty *> m_propertyToItalic;
+ QHash<const QtProperty *, QtProperty *> m_propertyToUnderline;
+ QHash<const QtProperty *, QtProperty *> m_propertyToStrikeOut;
+ QHash<const QtProperty *, QtProperty *> m_propertyToKerning;
+ QHash<const QtProperty *, QtProperty *> m_propertyToWeight;
+
+ QHash<const QtProperty *, QtProperty *> m_familyToProperty;
+ QHash<const QtProperty *, QtProperty *> m_pointSizeToProperty;
+ QHash<const QtProperty *, QtProperty *> m_boldToProperty;
+ QHash<const QtProperty *, QtProperty *> m_italicToProperty;
+ QHash<const QtProperty *, QtProperty *> m_underlineToProperty;
+ QHash<const QtProperty *, QtProperty *> m_strikeOutToProperty;
+ QHash<const QtProperty *, QtProperty *> m_kerningToProperty;
+ QHash<const QtProperty *, QtProperty *> m_weightToProperty;
bool m_settingValue;
QTimer *m_fontDatabaseChangeTimer;
@@ -5566,7 +5524,7 @@ void QtFontPropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu
{
if (m_settingValue)
return;
- if (QtProperty *prop = m_pointSizeToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_pointSizeToProperty.value(property, nullptr)) {
QFont f = m_values[prop];
f.setPointSize(value);
q_ptr->setValue(prop, f);
@@ -5577,10 +5535,14 @@ void QtFontPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int val
{
if (m_settingValue)
return;
- if (QtProperty *prop = m_familyToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_familyToProperty.value(property, nullptr)) {
QFont f = m_values[prop];
f.setFamily(m_familyNames.at(value));
q_ptr->setValue(prop, f);
+ } else if (auto *prop = m_weightToProperty.value(property, nullptr)) {
+ QFont f = m_values[prop];
+ f.setWeight(weightFromIndex(value));
+ q_ptr->setValue(prop, f);
}
}
@@ -5588,23 +5550,23 @@ void QtFontPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool va
{
if (m_settingValue)
return;
- if (QtProperty *prop = m_boldToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_boldToProperty.value(property, nullptr)) {
QFont f = m_values[prop];
f.setBold(value);
q_ptr->setValue(prop, f);
- } else if (QtProperty *prop = m_italicToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_italicToProperty.value(property, nullptr)) {
QFont f = m_values[prop];
f.setItalic(value);
q_ptr->setValue(prop, f);
- } else if (QtProperty *prop = m_underlineToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_underlineToProperty.value(property, nullptr)) {
QFont f = m_values[prop];
f.setUnderline(value);
q_ptr->setValue(prop, f);
- } else if (QtProperty *prop = m_strikeOutToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_strikeOutToProperty.value(property, nullptr)) {
QFont f = m_values[prop];
f.setStrikeOut(value);
q_ptr->setValue(prop, f);
- } else if (QtProperty *prop = m_kerningToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_kerningToProperty.value(property, nullptr)) {
QFont f = m_values[prop];
f.setKerning(value);
q_ptr->setValue(prop, f);
@@ -5613,37 +5575,41 @@ void QtFontPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool va
void QtFontPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_pointSizeToProperty.value(property, 0)) {
- m_propertyToPointSize[pointProp] = 0;
+ if (QtProperty *pointProp = m_pointSizeToProperty.value(property, nullptr)) {
+ m_propertyToPointSize[pointProp] = nullptr;
m_pointSizeToProperty.remove(property);
- } else if (QtProperty *pointProp = m_familyToProperty.value(property, 0)) {
- m_propertyToFamily[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_familyToProperty.value(property, nullptr)) {
+ m_propertyToFamily[pointProp] = nullptr;
m_familyToProperty.remove(property);
- } else if (QtProperty *pointProp = m_boldToProperty.value(property, 0)) {
- m_propertyToBold[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_boldToProperty.value(property, nullptr)) {
+ m_propertyToBold[pointProp] = nullptr;
m_boldToProperty.remove(property);
- } else if (QtProperty *pointProp = m_italicToProperty.value(property, 0)) {
- m_propertyToItalic[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_italicToProperty.value(property, nullptr)) {
+ m_propertyToItalic[pointProp] = nullptr;
m_italicToProperty.remove(property);
- } else if (QtProperty *pointProp = m_underlineToProperty.value(property, 0)) {
- m_propertyToUnderline[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_underlineToProperty.value(property, nullptr)) {
+ m_propertyToUnderline[pointProp] = nullptr;
m_underlineToProperty.remove(property);
- } else if (QtProperty *pointProp = m_strikeOutToProperty.value(property, 0)) {
- m_propertyToStrikeOut[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_strikeOutToProperty.value(property, nullptr)) {
+ m_propertyToStrikeOut[pointProp] = nullptr;
m_strikeOutToProperty.remove(property);
- } else if (QtProperty *pointProp = m_kerningToProperty.value(property, 0)) {
- m_propertyToKerning[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_kerningToProperty.value(property, nullptr)) {
+ m_propertyToKerning[pointProp] = nullptr;
m_kerningToProperty.remove(property);
+ } else if (QtProperty *weightProp = m_weightToProperty.value(property, nullptr)) {
+ m_propertyToWeight[weightProp] = nullptr;
+ m_weightToProperty.remove(property);
}
}
-void QtFontPropertyManagerPrivate::slotFontDatabaseChanged()
+void QtFontPropertyManagerPrivate::slotFontDatabaseChanged()
{
if (!m_fontDatabaseChangeTimer) {
m_fontDatabaseChangeTimer = new QTimer(q_ptr);
m_fontDatabaseChangeTimer->setInterval(0);
m_fontDatabaseChangeTimer->setSingleShot(true);
- QObject::connect(m_fontDatabaseChangeTimer, SIGNAL(timeout()), q_ptr, SLOT(slotFontDatabaseDelayedChange()));
+ QObject::connect(m_fontDatabaseChangeTimer, &QTimer::timeout, q_ptr,
+ [this] { slotFontDatabaseDelayedChange(); });
}
if (!m_fontDatabaseChangeTimer->isActive())
m_fontDatabaseChangeTimer->start();
@@ -5651,16 +5617,13 @@ void QtFontPropertyManagerPrivate::slotFontDatabaseChanged()
void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange()
{
- typedef QMap<const QtProperty *, QtProperty *> PropertyPropertyMap;
// rescan available font names
const QStringList oldFamilies = m_familyNames;
m_familyNames = QFontDatabase::families();
// Adapt all existing properties
if (!m_propertyToFamily.isEmpty()) {
- PropertyPropertyMap::const_iterator cend = m_propertyToFamily.constEnd();
- for (PropertyPropertyMap::const_iterator it = m_propertyToFamily.constBegin(); it != cend; ++it) {
- QtProperty *familyProp = it.value();
+ for (QtProperty *familyProp : std::as_const(m_propertyToFamily)) {
const int oldIdx = m_enumPropertyManager->value(familyProp);
int newIdx = m_familyNames.indexOf(oldFamilies.at(oldIdx));
if (newIdx < 0)
@@ -5715,24 +5678,26 @@ QtFontPropertyManager::QtFontPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent), d_ptr(new QtFontPropertyManagerPrivate)
{
d_ptr->q_ptr = this;
- QObject::connect(qApp, SIGNAL(fontDatabaseChanged()), this, SLOT(slotFontDatabaseChanged()));
+ QObject::connect(qApp, &QGuiApplication::fontDatabaseChanged, this,
+ [this] { d_ptr->slotFontDatabaseChanged(); });
d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
- connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotIntChanged(QtProperty*,int)));
+ connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); });
+ connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
+
d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
- connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotEnumChanged(QtProperty*,int)));
- d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this);
- connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty*,bool)),
- this, SLOT(slotBoolChanged(QtProperty*,bool)));
+ connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotEnumChanged(property, value); });
+ connect(d_ptr->m_enumPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
- connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
- connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
- connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this);
+ connect(d_ptr->m_boolPropertyManager, &QtBoolPropertyManager::valueChanged, this,
+ [this](QtProperty *property, bool value) { d_ptr->slotBoolChanged(property, value); });
+ connect(d_ptr->m_boolPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -5805,9 +5770,9 @@ QFont QtFontPropertyManager::value(const QtProperty *property) const
*/
QString QtFontPropertyManager::valueText(const QtProperty *property) const
{
- const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return QtPropertyBrowserUtils::fontValueText(it.value());
}
@@ -5817,9 +5782,9 @@ QString QtFontPropertyManager::valueText(const QtProperty *property) const
*/
QIcon QtFontPropertyManager::valueIcon(const QtProperty *property) const
{
- const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QIcon();
+ return {};
return QtPropertyBrowserUtils::fontValueIcon(it.value());
}
@@ -5834,7 +5799,7 @@ QIcon QtFontPropertyManager::valueIcon(const QtProperty *property) const
*/
void QtFontPropertyManager::setValue(QtProperty *property, const QFont &val)
{
- const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -5856,12 +5821,34 @@ void QtFontPropertyManager::setValue(QtProperty *property, const QFont &val)
d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToUnderline[property], val.underline());
d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToStrikeOut[property], val.strikeOut());
d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToKerning[property], val.kerning());
+ d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToWeight[property],
+ indexOfFontWeight(val.weight()));
d_ptr->m_settingValue = settingValue;
emit propertyChanged(property);
emit valueChanged(property, val);
}
+static QStringList fontWeightNames()
+{
+ static const DisambiguatedTranslation weightsC[] = {
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "Thin", "QFont::Weight combo"),
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "ExtraLight", "QFont::Weight combo"),
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "Light", "QFont::Weight combo"),
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "Normal", "QFont::Weight combo"),
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "Medium", "QFont::Weight combo"),
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "DemiBold", "QFont::Weight combo"),
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "Bold", "QFont::Weight combo"),
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "ExtraBold", "QFont::Weight combo"),
+ QT_TRANSLATE_NOOP3("FontPropertyManager", "Black", "QFont::Weight combo")
+ };
+
+ QStringList result;
+ for (const auto &w : weightsC)
+ result.append(QCoreApplication::translate("FontPropertyManager", w.first, w.second));
+ return result;
+}
+
/*!
\reimp
*/
@@ -5892,7 +5879,7 @@ void QtFontPropertyManager::initializeProperty(QtProperty *property)
property->addSubProperty(pointSizeProp);
QtProperty *boldProp = d_ptr->m_boolPropertyManager->addProperty();
- boldProp->setPropertyName(tr("Bold"));
+ boldProp->setPropertyName(tr("Bold", "Bold toggle"));
d_ptr->m_boolPropertyManager->setValue(boldProp, val.bold());
d_ptr->m_propertyToBold[property] = boldProp;
d_ptr->m_boldToProperty[boldProp] = property;
@@ -5925,6 +5912,15 @@ void QtFontPropertyManager::initializeProperty(QtProperty *property)
d_ptr->m_propertyToKerning[property] = kerningProp;
d_ptr->m_kerningToProperty[kerningProp] = property;
property->addSubProperty(kerningProp);
+
+ auto *weightProp = d_ptr->m_enumPropertyManager->addProperty();
+ weightProp->setPropertyName(tr("Weight"));
+ static const QStringList weightNames = fontWeightNames();
+ d_ptr->m_enumPropertyManager->setEnumNames(weightProp, weightNames);
+ d_ptr->m_enumPropertyManager->setValue(weightProp, indexOfFontWeight(val.weight()));
+ d_ptr->m_propertyToWeight[property] = weightProp;
+ d_ptr->m_weightToProperty[weightProp] = property;
+ property->addSubProperty(weightProp);
}
/*!
@@ -5981,6 +5977,11 @@ void QtFontPropertyManager::uninitializeProperty(QtProperty *property)
}
d_ptr->m_propertyToKerning.remove(property);
+ if (auto weightProp = d_ptr->m_propertyToWeight[property]) {
+ d_ptr->m_weightToProperty.remove(weightProp);
+ delete weightProp;
+ }
+
d_ptr->m_values.remove(property);
}
@@ -5995,37 +5996,36 @@ public:
void slotIntChanged(QtProperty *property, int value);
void slotPropertyDestroyed(QtProperty *property);
- typedef QMap<const QtProperty *, QColor> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QColor> m_values;
QtIntPropertyManager *m_intPropertyManager;
- QMap<const QtProperty *, QtProperty *> m_propertyToR;
- QMap<const QtProperty *, QtProperty *> m_propertyToG;
- QMap<const QtProperty *, QtProperty *> m_propertyToB;
- QMap<const QtProperty *, QtProperty *> m_propertyToA;
+ QHash<const QtProperty *, QtProperty *> m_propertyToR;
+ QHash<const QtProperty *, QtProperty *> m_propertyToG;
+ QHash<const QtProperty *, QtProperty *> m_propertyToB;
+ QHash<const QtProperty *, QtProperty *> m_propertyToA;
- QMap<const QtProperty *, QtProperty *> m_rToProperty;
- QMap<const QtProperty *, QtProperty *> m_gToProperty;
- QMap<const QtProperty *, QtProperty *> m_bToProperty;
- QMap<const QtProperty *, QtProperty *> m_aToProperty;
+ QHash<const QtProperty *, QtProperty *> m_rToProperty;
+ QHash<const QtProperty *, QtProperty *> m_gToProperty;
+ QHash<const QtProperty *, QtProperty *> m_bToProperty;
+ QHash<const QtProperty *, QtProperty *> m_aToProperty;
};
void QtColorPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
{
- if (QtProperty *prop = m_rToProperty.value(property, 0)) {
+ if (QtProperty *prop = m_rToProperty.value(property, nullptr)) {
QColor c = m_values[prop];
c.setRed(value);
q_ptr->setValue(prop, c);
- } else if (QtProperty *prop = m_gToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_gToProperty.value(property, nullptr)) {
QColor c = m_values[prop];
c.setGreen(value);
q_ptr->setValue(prop, c);
- } else if (QtProperty *prop = m_bToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_bToProperty.value(property, nullptr)) {
QColor c = m_values[prop];
c.setBlue(value);
q_ptr->setValue(prop, c);
- } else if (QtProperty *prop = m_aToProperty.value(property, 0)) {
+ } else if (QtProperty *prop = m_aToProperty.value(property, nullptr)) {
QColor c = m_values[prop];
c.setAlpha(value);
q_ptr->setValue(prop, c);
@@ -6034,17 +6034,17 @@ void QtColorPropertyManagerPrivate::slotIntChanged(QtProperty *property, int val
void QtColorPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
{
- if (QtProperty *pointProp = m_rToProperty.value(property, 0)) {
- m_propertyToR[pointProp] = 0;
+ if (QtProperty *pointProp = m_rToProperty.value(property, nullptr)) {
+ m_propertyToR[pointProp] = nullptr;
m_rToProperty.remove(property);
- } else if (QtProperty *pointProp = m_gToProperty.value(property, 0)) {
- m_propertyToG[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_gToProperty.value(property, nullptr)) {
+ m_propertyToG[pointProp] = nullptr;
m_gToProperty.remove(property);
- } else if (QtProperty *pointProp = m_bToProperty.value(property, 0)) {
- m_propertyToB[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_bToProperty.value(property, nullptr)) {
+ m_propertyToB[pointProp] = nullptr;
m_bToProperty.remove(property);
- } else if (QtProperty *pointProp = m_aToProperty.value(property, 0)) {
- m_propertyToA[pointProp] = 0;
+ } else if (QtProperty *pointProp = m_aToProperty.value(property, nullptr)) {
+ m_propertyToA[pointProp] = nullptr;
m_aToProperty.remove(property);
}
}
@@ -6093,11 +6093,10 @@ QtColorPropertyManager::QtColorPropertyManager(QObject *parent)
d_ptr->q_ptr = this;
d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
- connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotIntChanged(QtProperty*,int)));
-
- connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
- this, SLOT(slotPropertyDestroyed(QtProperty*)));
+ connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this,
+ [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); });
+ connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this,
+ [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); });
}
/*!
@@ -6142,9 +6141,9 @@ QColor QtColorPropertyManager::value(const QtProperty *property) const
QString QtColorPropertyManager::valueText(const QtProperty *property) const
{
- const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
return QtPropertyBrowserUtils::colorValueText(it.value());
}
@@ -6155,9 +6154,9 @@ QString QtColorPropertyManager::valueText(const QtProperty *property) const
QIcon QtColorPropertyManager::valueIcon(const QtProperty *property) const
{
- const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QIcon();
+ return {};
return QtPropertyBrowserUtils::brushValueIcon(QBrush(it.value()));
}
@@ -6171,7 +6170,7 @@ QIcon QtColorPropertyManager::valueIcon(const QtProperty *property) const
*/
void QtColorPropertyManager::setValue(QtProperty *property, const QColor &val)
{
- const QtColorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
@@ -6268,32 +6267,12 @@ void QtColorPropertyManager::uninitializeProperty(QtProperty *property)
// QtCursorPropertyManager
-// Make sure icons are removed as soon as QApplication is destroyed, otherwise,
-// handles are leaked on X11.
-static void clearCursorDatabase();
-namespace {
-struct CursorDatabase : public QtCursorDatabase
-{
- CursorDatabase()
- {
- qAddPostRoutine(clearCursorDatabase);
- }
-};
-}
-Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase)
-
-static void clearCursorDatabase()
-{
- cursorDatabase()->clear();
-}
-
class QtCursorPropertyManagerPrivate
{
QtCursorPropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtCursorPropertyManager)
public:
- typedef QMap<const QtProperty *, QCursor> PropertyValueMap;
- PropertyValueMap m_values;
+ QHash<const QtProperty *, QCursor> m_values;
};
/*!
@@ -6360,11 +6339,11 @@ QCursor QtCursorPropertyManager::value(const QtProperty *property) const
*/
QString QtCursorPropertyManager::valueText(const QtProperty *property) const
{
- const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QString();
+ return {};
- return cursorDatabase()->cursorToShapeName(it.value());
+ return QtCursorDatabase::instance()->cursorToShapeName(it.value());
}
/*!
@@ -6372,11 +6351,11 @@ QString QtCursorPropertyManager::valueText(const QtProperty *property) const
*/
QIcon QtCursorPropertyManager::valueIcon(const QtProperty *property) const
{
- const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
+ const auto it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
- return QIcon();
+ return {};
- return cursorDatabase()->cursorToShapeIcon(it.value());
+ return QtCursorDatabase::instance()->cursorToShapeIcon(it.value());
}
/*!
@@ -6389,7 +6368,7 @@ QIcon QtCursorPropertyManager::valueIcon(const QtProperty *property) const
void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value)
{
#ifndef QT_NO_CURSOR
- const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
+ const auto it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
diff --git a/src/shared/qtpropertybrowser/qtpropertymanager.h b/src/shared/qtpropertybrowser/qtpropertymanager.h
index d737fb06d..630f48e1c 100644
--- a/src/shared/qtpropertybrowser/qtpropertymanager.h
+++ b/src/shared/qtpropertybrowser/qtpropertymanager.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTPROPERTYMANAGER_H
#define QTPROPERTYMANAGER_H
@@ -346,8 +310,6 @@ private:
QScopedPointer<QtLocalePropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtLocalePropertyManager)
Q_DISABLE_COPY_MOVE(QtLocalePropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtPointPropertyManagerPrivate;
@@ -375,8 +337,6 @@ private:
QScopedPointer<QtPointPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtPointPropertyManager)
Q_DISABLE_COPY_MOVE(QtPointPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtPointFPropertyManagerPrivate;
@@ -407,8 +367,6 @@ private:
QScopedPointer<QtPointFPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtPointFPropertyManager)
Q_DISABLE_COPY_MOVE(QtPointFPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtSizePropertyManagerPrivate;
@@ -442,8 +400,6 @@ private:
QScopedPointer<QtSizePropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtSizePropertyManager)
Q_DISABLE_COPY_MOVE(QtSizePropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtSizeFPropertyManagerPrivate;
@@ -480,8 +436,6 @@ private:
QScopedPointer<QtSizeFPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtSizeFPropertyManager)
Q_DISABLE_COPY_MOVE(QtSizeFPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtRectPropertyManagerPrivate;
@@ -512,8 +466,6 @@ private:
QScopedPointer<QtRectPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtRectPropertyManager)
Q_DISABLE_COPY_MOVE(QtRectPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtRectFPropertyManagerPrivate;
@@ -547,8 +499,6 @@ private:
QScopedPointer<QtRectFPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtRectFPropertyManager)
Q_DISABLE_COPY_MOVE(QtRectFPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtEnumPropertyManagerPrivate;
@@ -611,8 +561,6 @@ private:
QScopedPointer<QtFlagPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtFlagPropertyManager)
Q_DISABLE_COPY_MOVE(QtFlagPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtSizePolicyPropertyManagerPrivate;
@@ -641,9 +589,6 @@ private:
QScopedPointer<QtSizePolicyPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtSizePolicyPropertyManager)
Q_DISABLE_COPY_MOVE(QtSizePolicyPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtFontPropertyManagerPrivate;
@@ -674,12 +619,6 @@ private:
QScopedPointer<QtFontPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtFontPropertyManager)
Q_DISABLE_COPY_MOVE(QtFontPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
- Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseChanged())
- Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseDelayedChange())
};
class QtColorPropertyManagerPrivate;
@@ -708,8 +647,6 @@ private:
QScopedPointer<QtColorPropertyManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtColorPropertyManager)
Q_DISABLE_COPY_MOVE(QtColorPropertyManager)
- Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *))
};
class QtCursorPropertyManagerPrivate;
diff --git a/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp b/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp
index bcf9e1022..073c8a04f 100644
--- a/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp
+++ b/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp
@@ -1,57 +1,33 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qttreepropertybrowser.h"
-#include <QtCore/QSet>
+
+#include <QtCore/QOperatingSystemVersion>
+#include <QtCore/QHash>
+#include <QtGui/QFocusEvent>
#include <QtGui/QIcon>
-#include <QtWidgets/QTreeWidget>
-#include <QtWidgets/QItemDelegate>
-#include <QtWidgets/QHBoxLayout>
-#include <QtWidgets/QHeaderView>
#include <QtGui/QPainter>
+#include <QtGui/QPalette>
+#include <QtGui/QStyleHints>
#include <QtWidgets/QApplication>
-#include <QtGui/QFocusEvent>
+#include <QtWidgets/QHBoxLayout>
+#include <QtWidgets/QHeaderView>
+#include <QtWidgets/QItemDelegate>
#include <QtWidgets/QStyle>
-#include <QtGui/QPalette>
+#include <QtWidgets/QTreeWidget>
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
+static constexpr bool isWindows = QOperatingSystemVersion::currentType() == QOperatingSystemVersion::Windows;
+
+static inline bool isLightTheme()
+{
+ return QGuiApplication::styleHints()->colorScheme() != Qt::ColorScheme::Dark;
+}
+
class QtPropertyEditorView;
class QtTreePropertyBrowserPrivate
@@ -96,10 +72,10 @@ public:
private:
void updateItem(QTreeWidgetItem *item);
- QMap<QtBrowserItem *, QTreeWidgetItem *> m_indexToItem;
- QMap<QTreeWidgetItem *, QtBrowserItem *> m_itemToIndex;
+ QHash<QtBrowserItem *, QTreeWidgetItem *> m_indexToItem;
+ QHash<QTreeWidgetItem *, QtBrowserItem *> m_itemToIndex;
- QMap<QtBrowserItem *, QColor> m_indexToBackgroundColor;
+ QHash<QtBrowserItem *, QColor> m_indexToBackgroundColor;
QtPropertyEditorView *m_treeWidget;
@@ -137,7 +113,7 @@ QtPropertyEditorView::QtPropertyEditorView(QWidget *parent) :
QTreeWidget(parent),
m_editorPrivate(0)
{
- connect(header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(resizeColumnToContents(int)));
+ connect(header(), &QHeaderView::sectionDoubleClicked, this, &QTreeView::resizeColumnToContents);
}
void QtPropertyEditorView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
@@ -250,10 +226,10 @@ private slots:
private:
int indentation(const QModelIndex &index) const;
- typedef QMap<QWidget *, QtProperty *> EditorToPropertyMap;
+ using EditorToPropertyMap = QHash<QWidget *, QtProperty *>;
mutable EditorToPropertyMap m_editorToProperty;
- typedef QMap<QtProperty *, QWidget *> PropertyToEditorMap;
+ using PropertyToEditorMap = QHash<QtProperty *, QWidget *>;
mutable PropertyToEditorMap m_propertyToEditor;
QtTreePropertyBrowserPrivate *m_editorPrivate;
mutable QTreeWidgetItem *m_editedItem;
@@ -278,22 +254,22 @@ int QtPropertyEditorDelegate::indentation(const QModelIndex &index) const
void QtPropertyEditorDelegate::slotEditorDestroyed(QObject *object)
{
- if (QWidget *w = qobject_cast<QWidget *>(object)) {
- const EditorToPropertyMap::iterator it = m_editorToProperty.find(w);
+ if (auto *w = qobject_cast<QWidget *>(object)) {
+ const auto it = m_editorToProperty.find(w);
if (it != m_editorToProperty.end()) {
m_propertyToEditor.remove(it.value());
m_editorToProperty.erase(it);
}
if (m_editedWidget == w) {
- m_editedWidget = 0;
- m_editedItem = 0;
+ m_editedWidget = nullptr;
+ m_editedItem = nullptr;
}
}
}
void QtPropertyEditorDelegate::closeEditor(QtProperty *property)
{
- if (QWidget *w = m_propertyToEditor.value(property, 0))
+ if (QWidget *w = m_propertyToEditor.value(property, nullptr))
w->deleteLater();
}
@@ -307,8 +283,11 @@ QWidget *QtPropertyEditorDelegate::createEditor(QWidget *parent,
QWidget *editor = m_editorPrivate->createEditor(property, parent);
if (editor) {
editor->setAutoFillBackground(true);
+ if (editor->palette().color(editor->backgroundRole()) == Qt::transparent)
+ editor->setBackgroundRole(QPalette::Window);
editor->installEventFilter(const_cast<QtPropertyEditorDelegate *>(this));
- connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
+ connect(editor, &QObject::destroyed,
+ this, &QtPropertyEditorDelegate::slotEditorDestroyed);
m_propertyToEditor[property] = editor;
m_editorToProperty[editor] = property;
m_editedItem = item;
@@ -317,7 +296,7 @@ QWidget *QtPropertyEditorDelegate::createEditor(QWidget *parent,
return editor;
}
}
- return 0;
+ return nullptr;
}
void QtPropertyEditorDelegate::updateEditorGeometry(QWidget *editor,
@@ -347,7 +326,10 @@ void QtPropertyEditorDelegate::paint(QPainter *painter, const QStyleOptionViewIt
QColor c;
if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) {
c = opt.palette.color(QPalette::Dark);
- opt.palette.setColor(QPalette::Text, opt.palette.color(QPalette::BrightText));
+ // Hardcode "white" for Windows/light which is otherwise blue
+ const QColor textColor = isWindows && isLightTheme()
+ ? QColor(Qt::white) : opt.palette.color(QPalette::BrightText);
+ opt.palette.setColor(QPalette::Text, textColor);
} else {
c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index));
if (c.isValid() && (opt.features & QStyleOptionViewItem::Alternate))
@@ -427,7 +409,7 @@ static QIcon drawIndicatorIcon(const QPalette &palette, QStyle *style)
void QtTreePropertyBrowserPrivate::init(QWidget *parent)
{
- QHBoxLayout *layout = new QHBoxLayout(parent);
+ auto *layout = new QHBoxLayout(parent);
layout->setContentsMargins(QMargins());
m_treeWidget = new QtPropertyEditorView(parent);
m_treeWidget->setEditorPrivate(this);
@@ -449,23 +431,27 @@ void QtTreePropertyBrowserPrivate::init(QWidget *parent)
m_expandIcon = drawIndicatorIcon(q_ptr->palette(), q_ptr->style());
- QObject::connect(m_treeWidget, SIGNAL(collapsed(QModelIndex)), q_ptr, SLOT(slotCollapsed(QModelIndex)));
- QObject::connect(m_treeWidget, SIGNAL(expanded(QModelIndex)), q_ptr, SLOT(slotExpanded(QModelIndex)));
- QObject::connect(m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), q_ptr, SLOT(slotCurrentTreeItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
+ QObject::connect(m_treeWidget, &QTreeView::collapsed,
+ q_ptr, [this](const QModelIndex &index) { slotCollapsed(index); });
+ QObject::connect(m_treeWidget, &QTreeView::expanded,
+ q_ptr, [this](const QModelIndex &index) { slotExpanded(index); });
+ QObject::connect(m_treeWidget, &QTreeWidget::currentItemChanged,
+ q_ptr, [this](QTreeWidgetItem *current, QTreeWidgetItem *previous)
+ { slotCurrentTreeItemChanged(current, previous); });
}
QtBrowserItem *QtTreePropertyBrowserPrivate::currentItem() const
{
if (QTreeWidgetItem *treeItem = m_treeWidget->currentItem())
return m_itemToIndex.value(treeItem);
- return 0;
+ return nullptr;
}
void QtTreePropertyBrowserPrivate::setCurrentItem(QtBrowserItem *browserItem, bool block)
{
const bool blocked = block ? m_treeWidget->blockSignals(true) : false;
- if (browserItem == 0)
- m_treeWidget->setCurrentItem(0);
+ if (browserItem == nullptr)
+ m_treeWidget->setCurrentItem(nullptr);
else
m_treeWidget->setCurrentItem(m_indexToItem.value(browserItem));
if (block)
@@ -478,7 +464,7 @@ QtProperty *QtTreePropertyBrowserPrivate::indexToProperty(const QModelIndex &ind
QtBrowserItem *idx = m_itemToIndex.value(item);
if (idx)
return idx->property();
- return 0;
+ return nullptr;
}
QtBrowserItem *QtTreePropertyBrowserPrivate::indexToBrowserItem(const QModelIndex &index) const
@@ -621,14 +607,14 @@ void QtTreePropertyBrowserPrivate::updateItem(QTreeWidgetItem *item)
QColor QtTreePropertyBrowserPrivate::calculatedBackgroundColor(QtBrowserItem *item) const
{
QtBrowserItem *i = item;
- const QMap<QtBrowserItem *, QColor>::const_iterator itEnd = m_indexToBackgroundColor.constEnd();
+ const auto itEnd = m_indexToBackgroundColor.constEnd();
while (i) {
- QMap<QtBrowserItem *, QColor>::const_iterator it = m_indexToBackgroundColor.constFind(i);
+ auto it = m_indexToBackgroundColor.constFind(i);
if (it != itEnd)
return it.value();
i = i->parent();
}
- return QColor();
+ return {};
}
void QtTreePropertyBrowserPrivate::slotCollapsed(const QModelIndex &index)
@@ -668,7 +654,7 @@ QTreeWidgetItem *QtTreePropertyBrowserPrivate::editedItem() const
void QtTreePropertyBrowserPrivate::editItem(QtBrowserItem *browserItem)
{
- if (QTreeWidgetItem *treeItem = m_indexToItem.value(browserItem, 0)) {
+ if (QTreeWidgetItem *treeItem = m_indexToItem.value(browserItem, nullptr)) {
m_treeWidget->setCurrentItem (treeItem, 1);
m_treeWidget->editItem(treeItem, 1);
}
@@ -729,7 +715,9 @@ QtTreePropertyBrowser::QtTreePropertyBrowser(QWidget *parent)
d_ptr->q_ptr = this;
d_ptr->init(this);
- connect(this, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentBrowserItemChanged(QtBrowserItem*)));
+ QObject::connect(this, &QtAbstractPropertyBrowser::currentItemChanged,
+ this, [this](QtBrowserItem *current)
+ { d_ptr->slotCurrentBrowserItemChanged(current); });
}
/*!
diff --git a/src/shared/qtpropertybrowser/qttreepropertybrowser.h b/src/shared/qtpropertybrowser/qttreepropertybrowser.h
index ce2a04f04..f86e7b826 100644
--- a/src/shared/qtpropertybrowser/qttreepropertybrowser.h
+++ b/src/shared/qtpropertybrowser/qttreepropertybrowser.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTTREEPROPERTYBROWSER_H
#define QTTREEPROPERTYBROWSER_H
@@ -58,7 +22,6 @@ class QtTreePropertyBrowser : public QtAbstractPropertyBrowser
Q_PROPERTY(int splitterPosition READ splitterPosition WRITE setSplitterPosition)
Q_PROPERTY(bool propertiesWithoutValueMarked READ propertiesWithoutValueMarked WRITE setPropertiesWithoutValueMarked)
public:
-
enum ResizeMode
{
Interactive,
@@ -105,7 +68,6 @@ public:
void editItem(QtBrowserItem *item);
Q_SIGNALS:
-
void collapsed(QtBrowserItem *item);
void expanded(QtBrowserItem *item);
@@ -115,16 +77,9 @@ protected:
void itemChanged(QtBrowserItem *item) override;
private:
-
QScopedPointer<QtTreePropertyBrowserPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtTreePropertyBrowser)
Q_DISABLE_COPY_MOVE(QtTreePropertyBrowser)
-
- Q_PRIVATE_SLOT(d_func(), void slotCollapsed(const QModelIndex &))
- Q_PRIVATE_SLOT(d_func(), void slotExpanded(const QModelIndex &))
- Q_PRIVATE_SLOT(d_func(), void slotCurrentBrowserItemChanged(QtBrowserItem *))
- Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))
-
};
QT_END_NAMESPACE
diff --git a/src/shared/qtpropertybrowser/qtvariantproperty.cpp b/src/shared/qtpropertybrowser/qtvariantproperty.cpp
index c1a51044c..e3974a8dd 100644
--- a/src/shared/qtpropertybrowser/qtvariantproperty.cpp
+++ b/src/shared/qtpropertybrowser/qtvariantproperty.cpp
@@ -1,48 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtvariantproperty.h"
#include "qtpropertymanager.h"
#include "qteditorfactory.h"
+
#include <QtCore/QVariant>
-#include <QtGui/QIcon>
#include <QtCore/QDate>
+#include <QtCore/QHash>
#include <QtCore/QLocale>
#include <QtCore/QRegularExpression>
@@ -52,6 +17,10 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
+using QtIconMap = QMap<int, QIcon>;
+
class QtEnumPropertyType
{
};
@@ -129,12 +98,13 @@ int QtVariantPropertyManager::iconMapTypeId()
return qMetaTypeId<QtIconMap>();
}
-typedef QMap<const QtProperty *, QtProperty *> PropertyMap;
-Q_GLOBAL_STATIC(PropertyMap, propertyToWrappedProperty)
+using PropertyPropertyMap = QHash<const QtProperty *, QtProperty *>;
+
+Q_GLOBAL_STATIC(PropertyPropertyMap, propertyToWrappedProperty)
static QtProperty *wrappedProperty(QtProperty *property)
{
- return propertyToWrappedProperty()->value(property, 0);
+ return propertyToWrappedProperty()->value(property, nullptr);
}
class QtVariantPropertyPrivate
@@ -338,12 +308,12 @@ public:
QMap<int, QtAbstractPropertyManager *> m_typeToPropertyManager;
QMap<int, QMap<QString, int> > m_typeToAttributeToAttributeType;
- QMap<const QtProperty *, QPair<QtVariantProperty *, int> > m_propertyToType;
+ QHash<const QtProperty *, std::pair<QtVariantProperty *, int>> m_propertyToType;
QMap<int, int> m_typeToValueType;
- QMap<QtProperty *, QtVariantProperty *> m_internalToProperty;
+ QHash<QtProperty *, QtVariantProperty *> m_internalToProperty;
const QString m_constraintAttribute;
const QString m_singleStepAttribute;
@@ -357,15 +327,15 @@ public:
};
QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() :
- m_constraintAttribute(QLatin1String("constraint")),
- m_singleStepAttribute(QLatin1String("singleStep")),
- m_decimalsAttribute(QLatin1String("decimals")),
- m_enumIconsAttribute(QLatin1String("enumIcons")),
- m_enumNamesAttribute(QLatin1String("enumNames")),
- m_flagNamesAttribute(QLatin1String("flagNames")),
- m_maximumAttribute(QLatin1String("maximum")),
- m_minimumAttribute(QLatin1String("minimum")),
- m_regExpAttribute(QLatin1String("regExp"))
+ m_constraintAttribute("constraint"_L1),
+ m_singleStepAttribute("singleStep"_L1),
+ m_decimalsAttribute("decimals"_L1),
+ m_enumIconsAttribute("enumIcons"_L1),
+ m_enumNamesAttribute("enumNames"_L1),
+ m_flagNamesAttribute("flagNames"_L1),
+ m_maximumAttribute("maximum"_L1),
+ m_minimumAttribute("minimum"_L1),
+ m_regExpAttribute("regExp"_L1)
{
}
@@ -427,13 +397,13 @@ void QtVariantPropertyManagerPrivate::slotPropertyInserted(QtProperty *property,
if (m_creatingProperty)
return;
- QtVariantProperty *varParent = m_internalToProperty.value(parent, 0);
+ QtVariantProperty *varParent = m_internalToProperty.value(parent, nullptr);
if (!varParent)
return;
QtVariantProperty *varAfter = nullptr;
if (after) {
- varAfter = m_internalToProperty.value(after, 0);
+ varAfter = m_internalToProperty.value(after, nullptr);
if (!varAfter)
return;
}
@@ -445,7 +415,7 @@ void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty *property,
{
Q_UNUSED(parent);
- QtVariantProperty *varProperty = m_internalToProperty.value(property, 0);
+ QtVariantProperty *varProperty = m_internalToProperty.value(property, nullptr);
if (!varProperty)
return;
@@ -454,7 +424,7 @@ void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty *property,
void QtVariantPropertyManagerPrivate::valueChanged(QtProperty *property, const QVariant &val)
{
- QtVariantProperty *varProp = m_internalToProperty.value(property, 0);
+ QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr);
if (!varProp)
return;
emit q_ptr->valueChanged(varProp, val);
@@ -468,7 +438,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, int
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, int min, int max)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) {
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
}
@@ -476,7 +446,7 @@ void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, int
void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, int step)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr))
emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step));
}
@@ -487,7 +457,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, dou
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, double min, double max)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) {
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
}
@@ -495,13 +465,13 @@ void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, dou
void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, double step)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr))
emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step));
}
void QtVariantPropertyManagerPrivate::slotDecimalsChanged(QtProperty *property, int prec)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr))
emit q_ptr->attributeChanged(varProp, m_decimalsAttribute, QVariant(prec));
}
@@ -517,7 +487,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con
void QtVariantPropertyManagerPrivate::slotRegExpChanged(QtProperty *property, const QRegularExpression &regExp)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr))
emit q_ptr->attributeChanged(varProp, m_regExpAttribute, QVariant(regExp));
}
@@ -528,7 +498,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, QDa
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, QDate min, QDate max)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) {
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
}
@@ -578,7 +548,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSize &min, const QSize &max)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) {
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
}
@@ -591,7 +561,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con
void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSizeF &min, const QSizeF &max)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) {
emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
}
@@ -604,7 +574,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con
void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRect &constraint)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr))
emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint));
}
@@ -615,7 +585,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con
void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRectF &constraint)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr))
emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint));
}
@@ -626,13 +596,13 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con
void QtVariantPropertyManagerPrivate::slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr))
emit q_ptr->attributeChanged(varProp, m_enumNamesAttribute, QVariant(enumNames));
}
void QtVariantPropertyManagerPrivate::slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &enumIcons)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) {
QVariant v;
v.setValue(enumIcons);
emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v);
@@ -658,7 +628,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con
void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames)
{
- if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
+ if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr))
emit q_ptr->attributeChanged(varProp, m_flagNamesAttribute, QVariant(flagNames));
}
@@ -918,20 +888,23 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent)
d_ptr->m_propertyType = 0;
// IntPropertyManager
- QtIntPropertyManager *intPropertyManager = new QtIntPropertyManager(this);
+ auto *intPropertyManager = new QtIntPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::Int] = intPropertyManager;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::Int][d_ptr->m_minimumAttribute] = QMetaType::Int;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::Int][d_ptr->m_maximumAttribute] = QMetaType::Int;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::Int][d_ptr->m_singleStepAttribute] = QMetaType::Int;
d_ptr->m_typeToValueType[QMetaType::Int] = QMetaType::Int;
- connect(intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(intPropertyManager, SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- connect(intPropertyManager, SIGNAL(singleStepChanged(QtProperty*,int)),
- this, SLOT(slotSingleStepChanged(QtProperty*,int)));
+ connect(intPropertyManager, &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(intPropertyManager, &QtIntPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, int min, int max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(intPropertyManager, &QtIntPropertyManager::singleStepChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotSingleStepChanged(property, value); });
// DoublePropertyManager
- QtDoublePropertyManager *doublePropertyManager = new QtDoublePropertyManager(this);
+ auto *doublePropertyManager = new QtDoublePropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::Double] = doublePropertyManager;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::Double][d_ptr->m_minimumAttribute] =
QMetaType::Double;
@@ -942,128 +915,160 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent)
d_ptr->m_typeToAttributeToAttributeType[QMetaType::Double][d_ptr->m_decimalsAttribute] =
QMetaType::Int;
d_ptr->m_typeToValueType[QMetaType::Double] = QMetaType::Double;
- connect(doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotValueChanged(QtProperty*,double)));
- connect(doublePropertyManager, SIGNAL(rangeChanged(QtProperty*,double,double)),
- this, SLOT(slotRangeChanged(QtProperty*,double,double)));
- connect(doublePropertyManager, SIGNAL(singleStepChanged(QtProperty*,double)),
- this, SLOT(slotSingleStepChanged(QtProperty*,double)));
- connect(doublePropertyManager, SIGNAL(decimalsChanged(QtProperty*,int)),
- this, SLOT(slotDecimalsChanged(QtProperty*,int)));
+ connect(doublePropertyManager, &QtDoublePropertyManager::valueChanged,
+ this, [this](QtProperty *property, double value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(doublePropertyManager, &QtDoublePropertyManager::rangeChanged,
+ this, [this](QtProperty *property, double min, double max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(doublePropertyManager, &QtDoublePropertyManager::singleStepChanged,
+ this, [this](QtProperty *property, double value)
+ { d_ptr->slotSingleStepChanged(property, value); });
+ connect(doublePropertyManager, &QtDoublePropertyManager::decimalsChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotDecimalsChanged(property, value); });
// BoolPropertyManager
- QtBoolPropertyManager *boolPropertyManager = new QtBoolPropertyManager(this);
+ auto *boolPropertyManager = new QtBoolPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::Bool] = boolPropertyManager;
d_ptr->m_typeToValueType[QMetaType::Bool] = QMetaType::Bool;
- connect(boolPropertyManager, SIGNAL(valueChanged(QtProperty*,bool)),
- this, SLOT(slotValueChanged(QtProperty*,bool)));
+ connect(boolPropertyManager, &QtBoolPropertyManager::valueChanged,
+ this, [this](QtProperty *property, bool value)
+ { d_ptr->slotValueChanged(property, value); });
// StringPropertyManager
- QtStringPropertyManager *stringPropertyManager = new QtStringPropertyManager(this);
+ auto *stringPropertyManager = new QtStringPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QString] = stringPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QString] = QMetaType::QString;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QString][d_ptr->m_regExpAttribute] =
QMetaType::QRegularExpression;
- connect(stringPropertyManager, SIGNAL(valueChanged(QtProperty*,QString)),
- this, SLOT(slotValueChanged(QtProperty*,QString)));
- connect(stringPropertyManager, SIGNAL(regExpChanged(QtProperty*,QRegularExpression)),
- this, SLOT(slotRegExpChanged(QtProperty*,QRegularExpression)));
+ connect(stringPropertyManager, &QtStringPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QString &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(stringPropertyManager, &QtStringPropertyManager::regExpChanged,
+ this, [this](QtProperty *property, const QRegularExpression &value)
+ { d_ptr->slotRegExpChanged(property, value); });
// DatePropertyManager
- QtDatePropertyManager *datePropertyManager = new QtDatePropertyManager(this);
+ auto *datePropertyManager = new QtDatePropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QDate] = datePropertyManager;
d_ptr->m_typeToValueType[QMetaType::QDate] = QMetaType::QDate;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QDate][d_ptr->m_minimumAttribute] =
QMetaType::QDate;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QDate][d_ptr->m_maximumAttribute] =
QMetaType::QDate;
- connect(datePropertyManager, SIGNAL(valueChanged(QtProperty*,QDate)),
- this, SLOT(slotValueChanged(QtProperty*,QDate)));
- connect(datePropertyManager, SIGNAL(rangeChanged(QtProperty*,QDate,QDate)),
- this, SLOT(slotRangeChanged(QtProperty*,QDate,QDate)));
+ connect(datePropertyManager, &QtDatePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QDate &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(datePropertyManager, &QtDatePropertyManager::rangeChanged,
+ this, [this](QtProperty *property, const QDate &min, const QDate &max)
+ { d_ptr->slotRangeChanged(property, min, max); });
// TimePropertyManager
- QtTimePropertyManager *timePropertyManager = new QtTimePropertyManager(this);
+ auto *timePropertyManager = new QtTimePropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QTime] = timePropertyManager;
d_ptr->m_typeToValueType[QMetaType::QTime] = QMetaType::QTime;
- connect(timePropertyManager, SIGNAL(valueChanged(QtProperty*,QTime)),
- this, SLOT(slotValueChanged(QtProperty*,QTime)));
+ connect(timePropertyManager, &QtTimePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QTime &value)
+ { d_ptr->slotValueChanged(property, value); });
// DateTimePropertyManager
- QtDateTimePropertyManager *dateTimePropertyManager = new QtDateTimePropertyManager(this);
+ auto *dateTimePropertyManager = new QtDateTimePropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QDateTime] = dateTimePropertyManager;
d_ptr->m_typeToValueType[QMetaType::QDateTime] = QMetaType::QDateTime;
- connect(dateTimePropertyManager, SIGNAL(valueChanged(QtProperty*,QDateTime)),
- this, SLOT(slotValueChanged(QtProperty*,QDateTime)));
+ connect(dateTimePropertyManager, &QtDateTimePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QDateTime &value)
+ { d_ptr->slotValueChanged(property, value); });
// KeySequencePropertyManager
- QtKeySequencePropertyManager *keySequencePropertyManager = new QtKeySequencePropertyManager(this);
+ auto *keySequencePropertyManager = new QtKeySequencePropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QKeySequence] = keySequencePropertyManager;
d_ptr->m_typeToValueType[QMetaType::QKeySequence] = QMetaType::QKeySequence;
- connect(keySequencePropertyManager, SIGNAL(valueChanged(QtProperty*,QKeySequence)),
- this, SLOT(slotValueChanged(QtProperty*,QKeySequence)));
+ connect(keySequencePropertyManager, &QtKeySequencePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QKeySequence &value)
+ { d_ptr->slotValueChanged(property, value); });
// CharPropertyManager
- QtCharPropertyManager *charPropertyManager = new QtCharPropertyManager(this);
+ auto *charPropertyManager = new QtCharPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QChar] = charPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QChar] = QMetaType::QChar;
- connect(charPropertyManager, SIGNAL(valueChanged(QtProperty*,QChar)),
- this, SLOT(slotValueChanged(QtProperty*,QChar)));
+ connect(charPropertyManager, &QtCharPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QChar &value)
+ { d_ptr->slotValueChanged(property, value); });
// LocalePropertyManager
- QtLocalePropertyManager *localePropertyManager = new QtLocalePropertyManager(this);
+ auto *localePropertyManager = new QtLocalePropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QLocale] = localePropertyManager;
d_ptr->m_typeToValueType[QMetaType::QLocale] = QMetaType::QLocale;
- connect(localePropertyManager, SIGNAL(valueChanged(QtProperty*,QLocale)),
- this, SLOT(slotValueChanged(QtProperty*,QLocale)));
- connect(localePropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(localePropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(localePropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(localePropertyManager, &QtLocalePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QLocale &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(localePropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(localePropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(localePropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// PointPropertyManager
- QtPointPropertyManager *pointPropertyManager = new QtPointPropertyManager(this);
+ auto *pointPropertyManager = new QtPointPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QPoint] = pointPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QPoint] = QMetaType::QPoint;
- connect(pointPropertyManager, SIGNAL(valueChanged(QtProperty*,QPoint)),
- this, SLOT(slotValueChanged(QtProperty*,QPoint)));
- connect(pointPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(pointPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(pointPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(pointPropertyManager, &QtPointPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QPoint &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(pointPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(pointPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(pointPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// PointFPropertyManager
- QtPointFPropertyManager *pointFPropertyManager = new QtPointFPropertyManager(this);
+ auto *pointFPropertyManager = new QtPointFPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QPointF] = pointFPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QPointF] = QMetaType::QPointF;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QPointF][d_ptr->m_decimalsAttribute] =
QMetaType::Int;
- connect(pointFPropertyManager, SIGNAL(valueChanged(QtProperty*,QPointF)),
- this, SLOT(slotValueChanged(QtProperty*,QPointF)));
- connect(pointFPropertyManager, SIGNAL(decimalsChanged(QtProperty*,int)),
- this, SLOT(slotDecimalsChanged(QtProperty*,int)));
- connect(pointFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotValueChanged(QtProperty*,double)));
- connect(pointFPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(pointFPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(pointFPropertyManager, &QtPointFPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QPointF &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(pointFPropertyManager, &QtPointFPropertyManager::decimalsChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotDecimalsChanged(property, value); });
+ connect(pointFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::valueChanged,
+ this, [this](QtProperty *property, double value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(pointFPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(pointFPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// SizePropertyManager
- QtSizePropertyManager *sizePropertyManager = new QtSizePropertyManager(this);
+ auto *sizePropertyManager = new QtSizePropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QSize] = sizePropertyManager;
d_ptr->m_typeToValueType[QMetaType::QSize] = QMetaType::QSize;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QSize][d_ptr->m_minimumAttribute] =
QMetaType::QSize;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QSize][d_ptr->m_maximumAttribute] =
QMetaType::QSize;
- connect(sizePropertyManager, SIGNAL(valueChanged(QtProperty*,QSize)),
- this, SLOT(slotValueChanged(QtProperty*,QSize)));
- connect(sizePropertyManager, SIGNAL(rangeChanged(QtProperty*,QSize,QSize)),
- this, SLOT(slotRangeChanged(QtProperty*,QSize,QSize)));
- connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- connect(sizePropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(sizePropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(sizePropertyManager, &QtSizePropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QSize &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(sizePropertyManager, &QtSizePropertyManager::rangeChanged,
+ this, [this](QtProperty *property, const QSize &min, const QSize &max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(sizePropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(sizePropertyManager->subIntPropertyManager(), &QtIntPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, int min, int max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(sizePropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(sizePropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// SizeFPropertyManager
- QtSizeFPropertyManager *sizeFPropertyManager = new QtSizeFPropertyManager(this);
+ auto *sizeFPropertyManager = new QtSizeFPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QSizeF] = sizeFPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QSizeF] = QMetaType::QSizeF;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QSizeF][d_ptr->m_minimumAttribute] =
@@ -1072,153 +1077,193 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent)
QMetaType::QSizeF;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QSizeF][d_ptr->m_decimalsAttribute] =
QMetaType::Int;
- connect(sizeFPropertyManager, SIGNAL(valueChanged(QtProperty*,QSizeF)),
- this, SLOT(slotValueChanged(QtProperty*,QSizeF)));
- connect(sizeFPropertyManager, SIGNAL(rangeChanged(QtProperty*,QSizeF,QSizeF)),
- this, SLOT(slotRangeChanged(QtProperty*,QSizeF,QSizeF)));
- connect(sizeFPropertyManager, SIGNAL(decimalsChanged(QtProperty*,int)),
- this, SLOT(slotDecimalsChanged(QtProperty*,int)));
- connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotValueChanged(QtProperty*,double)));
- connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty*,double,double)),
- this, SLOT(slotRangeChanged(QtProperty*,double,double)));
- connect(sizeFPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(sizeFPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(sizeFPropertyManager, &QtSizeFPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QSizeF &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(sizeFPropertyManager, &QtSizeFPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, const QSizeF &min, const QSizeF &max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(sizeFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::valueChanged,
+ this, [this](QtProperty *property, double value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(sizeFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::rangeChanged,
+ this, [this](QtProperty *property, double min, double max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(sizeFPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(sizeFPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// RectPropertyManager
- QtRectPropertyManager *rectPropertyManager = new QtRectPropertyManager(this);
+ auto *rectPropertyManager = new QtRectPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QRect] = rectPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QRect] = QMetaType::QRect;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QRect][d_ptr->m_constraintAttribute] =
QMetaType::QRect;
- connect(rectPropertyManager, SIGNAL(valueChanged(QtProperty*,QRect)),
- this, SLOT(slotValueChanged(QtProperty*,QRect)));
- connect(rectPropertyManager, SIGNAL(constraintChanged(QtProperty*,QRect)),
- this, SLOT(slotConstraintChanged(QtProperty*,QRect)));
- connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- connect(rectPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(rectPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(rectPropertyManager, &QtRectPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QRect &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(rectPropertyManager, &QtRectPropertyManager::constraintChanged,
+ this, [this](QtProperty *property, const QRect &value)
+ { d_ptr->slotConstraintChanged(property, value); });
+ connect(rectPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(rectPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, int min, int max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(rectPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(rectPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// RectFPropertyManager
- QtRectFPropertyManager *rectFPropertyManager = new QtRectFPropertyManager(this);
+ auto *rectFPropertyManager = new QtRectFPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QRectF] = rectFPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QRectF] = QMetaType::QRectF;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QRectF][d_ptr->m_constraintAttribute] =
QMetaType::QRectF;
d_ptr->m_typeToAttributeToAttributeType[QMetaType::QRectF][d_ptr->m_decimalsAttribute] =
QMetaType::Int;
- connect(rectFPropertyManager, SIGNAL(valueChanged(QtProperty*,QRectF)),
- this, SLOT(slotValueChanged(QtProperty*,QRectF)));
- connect(rectFPropertyManager, SIGNAL(constraintChanged(QtProperty*,QRectF)),
- this, SLOT(slotConstraintChanged(QtProperty*,QRectF)));
- connect(rectFPropertyManager, SIGNAL(decimalsChanged(QtProperty*,int)),
- this, SLOT(slotDecimalsChanged(QtProperty*,int)));
- connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*,double)),
- this, SLOT(slotValueChanged(QtProperty*,double)));
- connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty*,double,double)),
- this, SLOT(slotRangeChanged(QtProperty*,double,double)));
- connect(rectFPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(rectFPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(rectFPropertyManager, &QtRectFPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QRectF &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(rectFPropertyManager, &QtRectFPropertyManager::constraintChanged,
+ this, [this](QtProperty *property, const QRectF &value)
+ { d_ptr->slotConstraintChanged(property, value); });
+ connect(rectFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::valueChanged,
+ this, [this](QtProperty *property, double value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(rectFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::rangeChanged,
+ this, [this](QtProperty *property, double min, double max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(rectFPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(rectFPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// ColorPropertyManager
- QtColorPropertyManager *colorPropertyManager = new QtColorPropertyManager(this);
+ auto *colorPropertyManager = new QtColorPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QColor] = colorPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QColor] = QMetaType::QColor;
- connect(colorPropertyManager, SIGNAL(valueChanged(QtProperty*,QColor)),
- this, SLOT(slotValueChanged(QtProperty*,QColor)));
- connect(colorPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(colorPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(colorPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(colorPropertyManager, &QtColorPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QColor &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(colorPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(colorPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(colorPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// EnumPropertyManager
int enumId = enumTypeId();
- QtEnumPropertyManager *enumPropertyManager = new QtEnumPropertyManager(this);
+ auto *enumPropertyManager = new QtEnumPropertyManager(this);
d_ptr->m_typeToPropertyManager[enumId] = enumPropertyManager;
d_ptr->m_typeToValueType[enumId] = QMetaType::Int;
d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumNamesAttribute] =
QMetaType::QStringList;
d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumIconsAttribute] =
iconMapTypeId();
- connect(enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(enumPropertyManager, SIGNAL(enumNamesChanged(QtProperty*,QStringList)),
- this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList)));
- connect(enumPropertyManager, SIGNAL(enumIconsChanged(QtProperty*,QMap<int,QIcon>)),
- this, SLOT(slotEnumIconsChanged(QtProperty*,QMap<int,QIcon>)));
+ connect(enumPropertyManager, &QtEnumPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(enumPropertyManager, &QtEnumPropertyManager::enumNamesChanged,
+ this, [this](QtProperty *property, const QStringList &value)
+ { d_ptr->slotEnumNamesChanged(property, value); });
+ connect(enumPropertyManager, &QtEnumPropertyManager::enumIconsChanged,
+ this, [this](QtProperty *property, const QMap<int,QIcon> &value)
+ { d_ptr->slotEnumIconsChanged(property, value); });
// SizePolicyPropertyManager
- QtSizePolicyPropertyManager *sizePolicyPropertyManager = new QtSizePolicyPropertyManager(this);
+ auto *sizePolicyPropertyManager = new QtSizePolicyPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QSizePolicy] = sizePolicyPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QSizePolicy] = QMetaType::QSizePolicy;
- connect(sizePolicyPropertyManager, SIGNAL(valueChanged(QtProperty*,QSizePolicy)),
- this, SLOT(slotValueChanged(QtProperty*,QSizePolicy)));
- connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- connect(sizePolicyPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(sizePolicyPropertyManager->subEnumPropertyManager(),
- SIGNAL(enumNamesChanged(QtProperty*,QStringList)),
- this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList)));
- connect(sizePolicyPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(sizePolicyPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(sizePolicyPropertyManager, &QtSizePolicyPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QSizePolicy &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(sizePolicyPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(sizePolicyPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, int min, int max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(sizePolicyPropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(sizePolicyPropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::enumNamesChanged,
+ this, [this](QtProperty *property, const QStringList &value)
+ { d_ptr->slotEnumNamesChanged(property, value); });
+ connect(sizePolicyPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(sizePolicyPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// FontPropertyManager
- QtFontPropertyManager *fontPropertyManager = new QtFontPropertyManager(this);
+ auto *fontPropertyManager = new QtFontPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QFont] = fontPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QFont] = QMetaType::QFont;
- connect(fontPropertyManager, SIGNAL(valueChanged(QtProperty*,QFont)),
- this, SLOT(slotValueChanged(QtProperty*,QFont)));
- connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*,int,int)),
- this, SLOT(slotRangeChanged(QtProperty*,int,int)));
- connect(fontPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(fontPropertyManager->subEnumPropertyManager(),
- SIGNAL(enumNamesChanged(QtProperty*,QStringList)),
- this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList)));
- connect(fontPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty*,bool)),
- this, SLOT(slotValueChanged(QtProperty*,bool)));
- connect(fontPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(fontPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(fontPropertyManager, &QtFontPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QFont &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(fontPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(fontPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::rangeChanged,
+ this, [this](QtProperty *property, int min, int max)
+ { d_ptr->slotRangeChanged(property, min, max); });
+ connect(fontPropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::valueChanged,
+ this, [this](QtProperty *property, int value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(fontPropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::enumNamesChanged,
+ this, [this](QtProperty *property, const QStringList &value)
+ { d_ptr->slotEnumNamesChanged(property, value); });
+ connect(fontPropertyManager->subBoolPropertyManager(), &QtBoolPropertyManager::valueChanged,
+ this, [this](QtProperty *property, bool value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(fontPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(fontPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// CursorPropertyManager
- QtCursorPropertyManager *cursorPropertyManager = new QtCursorPropertyManager(this);
+ auto *cursorPropertyManager = new QtCursorPropertyManager(this);
d_ptr->m_typeToPropertyManager[QMetaType::QCursor] = cursorPropertyManager;
d_ptr->m_typeToValueType[QMetaType::QCursor] = QMetaType::QCursor;
- connect(cursorPropertyManager, SIGNAL(valueChanged(QtProperty*,QCursor)),
- this, SLOT(slotValueChanged(QtProperty*,QCursor)));
+ connect(cursorPropertyManager, &QtCursorPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QCursor &value)
+ { d_ptr->slotValueChanged(property, value); });
// FlagPropertyManager
int flagId = flagTypeId();
- QtFlagPropertyManager *flagPropertyManager = new QtFlagPropertyManager(this);
+ auto *flagPropertyManager = new QtFlagPropertyManager(this);
d_ptr->m_typeToPropertyManager[flagId] = flagPropertyManager;
d_ptr->m_typeToValueType[flagId] = QMetaType::Int;
d_ptr->m_typeToAttributeToAttributeType[flagId][d_ptr->m_flagNamesAttribute] =
QMetaType::QStringList;
- connect(flagPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
- this, SLOT(slotValueChanged(QtProperty*,int)));
- connect(flagPropertyManager, SIGNAL(flagNamesChanged(QtProperty*,QStringList)),
- this, SLOT(slotFlagNamesChanged(QtProperty*,QStringList)));
- connect(flagPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty*,bool)),
- this, SLOT(slotValueChanged(QtProperty*,bool)));
- connect(flagPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*)));
- connect(flagPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)),
- this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*)));
+ connect(flagPropertyManager, &QtFlagPropertyManager::valueChanged,
+ this, [this](QtProperty *property, const QColor &value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(flagPropertyManager, &QtFlagPropertyManager::flagNamesChanged,
+ this, [this](QtProperty *property, const QStringList &value)
+ { d_ptr->slotFlagNamesChanged(property, value); });
+ connect(flagPropertyManager->subBoolPropertyManager(), &QtBoolPropertyManager::valueChanged,
+ this, [this](QtProperty *property, bool value)
+ { d_ptr->slotValueChanged(property, value); });
+ connect(flagPropertyManager, &QtAbstractPropertyManager::propertyInserted,
+ this, [this](QtProperty *property, QtProperty *parent, QtProperty *after)
+ { d_ptr->slotPropertyInserted(property, parent, after); });
+ connect(flagPropertyManager, &QtAbstractPropertyManager::propertyRemoved,
+ this, [this](QtProperty *property, QtProperty *parent)
+ { d_ptr->slotPropertyRemoved(property, parent); });
// FlagPropertyManager
int groupId = groupTypeId();
- QtGroupPropertyManager *groupPropertyManager = new QtGroupPropertyManager(this);
+ auto *groupPropertyManager = new QtGroupPropertyManager(this);
d_ptr->m_typeToPropertyManager[groupId] = groupPropertyManager;
d_ptr->m_typeToValueType[groupId] = QMetaType::UnknownType;
}
@@ -1241,7 +1286,7 @@ QtVariantPropertyManager::~QtVariantPropertyManager()
*/
QtVariantProperty *QtVariantPropertyManager::variantProperty(const QtProperty *property) const
{
- const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property);
+ const auto it = d_ptr->m_propertyToType.constFind(property);
if (it == d_ptr->m_propertyToType.constEnd())
return 0;
return it.value().first;
@@ -1302,60 +1347,60 @@ QtVariantProperty *QtVariantPropertyManager::addProperty(int propertyType, const
*/
QVariant QtVariantPropertyManager::value(const QtProperty *property) const
{
- QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
- if (internProp == 0)
- return QVariant();
+ QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr);
+ if (internProp == nullptr)
+ return {};
QtAbstractPropertyManager *manager = internProp->propertyManager();
- if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
+ if (auto *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
return intManager->value(internProp);
- } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
+ } else if (auto *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
return doubleManager->value(internProp);
- } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
+ } else if (auto *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
return boolManager->value(internProp);
- } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
+ } else if (auto *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
return stringManager->value(internProp);
- } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
+ } else if (auto *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
return dateManager->value(internProp);
- } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) {
+ } else if (auto *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) {
return timeManager->value(internProp);
- } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) {
+ } else if (auto *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) {
return dateTimeManager->value(internProp);
- } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) {
+ } else if (auto *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) {
return QVariant::fromValue(keySequenceManager->value(internProp));
- } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) {
+ } else if (auto *charManager = qobject_cast<QtCharPropertyManager *>(manager)) {
return charManager->value(internProp);
- } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) {
+ } else if (auto *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) {
return localeManager->value(internProp);
- } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) {
+ } else if (auto *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) {
return pointManager->value(internProp);
- } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
+ } else if (auto *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
return pointFManager->value(internProp);
- } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
+ } else if (auto *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
return sizeManager->value(internProp);
- } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
+ } else if (auto *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
return sizeFManager->value(internProp);
- } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
+ } else if (auto *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
return rectManager->value(internProp);
- } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
+ } else if (auto *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
return rectFManager->value(internProp);
- } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) {
+ } else if (auto *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) {
return colorManager->value(internProp);
- } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
+ } else if (auto *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
return enumManager->value(internProp);
} else if (QtSizePolicyPropertyManager *sizePolicyManager =
qobject_cast<QtSizePolicyPropertyManager *>(manager)) {
return sizePolicyManager->value(internProp);
- } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) {
+ } else if (auto *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) {
return fontManager->value(internProp);
#ifndef QT_NO_CURSOR
- } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) {
+ } else if (auto *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) {
return cursorManager->value(internProp);
#endif
- } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
+ } else if (auto *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
return flagManager->value(internProp);
}
- return QVariant();
+ return {};
}
/*!
@@ -1388,7 +1433,7 @@ int QtVariantPropertyManager::valueType(int propertyType) const
*/
int QtVariantPropertyManager::propertyType(const QtProperty *property) const
{
- const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property);
+ const auto it = d_ptr->m_propertyToType.constFind(property);
if (it == d_ptr->m_propertyToType.constEnd())
return 0;
return it.value().second;
@@ -1408,32 +1453,31 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co
{
int propType = propertyType(property);
if (!propType)
- return QVariant();
+ return {};
- QMap<int, QMap<QString, int> >::ConstIterator it =
- d_ptr->m_typeToAttributeToAttributeType.find(propType);
+ const auto it = d_ptr->m_typeToAttributeToAttributeType.constFind(propType);
if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
- return QVariant();
+ return {};
- QMap<QString, int> attributes = it.value();
- QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute);
+ const QMap<QString, int> &attributes = it.value();
+ const auto itAttr = attributes.constFind(attribute);
if (itAttr == attributes.constEnd())
- return QVariant();
+ return {};
- QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
- if (internProp == 0)
- return QVariant();
+ QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr);
+ if (internProp == nullptr)
+ return {};
QtAbstractPropertyManager *manager = internProp->propertyManager();
- if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
+ if (auto *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
return intManager->maximum(internProp);
if (attribute == d_ptr->m_minimumAttribute)
return intManager->minimum(internProp);
if (attribute == d_ptr->m_singleStepAttribute)
return intManager->singleStep(internProp);
- return QVariant();
- } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
+ return {};
+ } else if (auto *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
return doubleManager->maximum(internProp);
if (attribute == d_ptr->m_minimumAttribute)
@@ -1442,46 +1486,46 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co
return doubleManager->singleStep(internProp);
if (attribute == d_ptr->m_decimalsAttribute)
return doubleManager->decimals(internProp);
- return QVariant();
- } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
+ return {};
+ } else if (auto *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
if (attribute == d_ptr->m_regExpAttribute)
return stringManager->regExp(internProp);
- return QVariant();
- } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
+ return {};
+ } else if (auto *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
return dateManager->maximum(internProp);
if (attribute == d_ptr->m_minimumAttribute)
return dateManager->minimum(internProp);
- return QVariant();
- } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
+ return {};
+ } else if (auto *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
if (attribute == d_ptr->m_decimalsAttribute)
return pointFManager->decimals(internProp);
- return QVariant();
- } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
+ return {};
+ } else if (auto *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
return sizeManager->maximum(internProp);
if (attribute == d_ptr->m_minimumAttribute)
return sizeManager->minimum(internProp);
- return QVariant();
- } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
+ return {};
+ } else if (auto *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
return sizeFManager->maximum(internProp);
if (attribute == d_ptr->m_minimumAttribute)
return sizeFManager->minimum(internProp);
if (attribute == d_ptr->m_decimalsAttribute)
return sizeFManager->decimals(internProp);
- return QVariant();
- } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
+ return {};
+ } else if (auto *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
if (attribute == d_ptr->m_constraintAttribute)
return rectManager->constraint(internProp);
- return QVariant();
- } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
+ return {};
+ } else if (auto *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
if (attribute == d_ptr->m_constraintAttribute)
return rectFManager->constraint(internProp);
if (attribute == d_ptr->m_decimalsAttribute)
return rectFManager->decimals(internProp);
- return QVariant();
- } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
+ return {};
+ } else if (auto *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
if (attribute == d_ptr->m_enumNamesAttribute)
return enumManager->enumNames(internProp);
if (attribute == d_ptr->m_enumIconsAttribute) {
@@ -1489,13 +1533,13 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co
v.setValue(enumManager->enumIcons(internProp));
return v;
}
- return QVariant();
- } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
+ return {};
+ } else if (auto *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
if (attribute == d_ptr->m_flagNamesAttribute)
return flagManager->flagNames(internProp);
- return QVariant();
+ return {};
}
- return QVariant();
+ return {};
}
/*!
@@ -1505,10 +1549,9 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co
*/
QStringList QtVariantPropertyManager::attributes(int propertyType) const
{
- QMap<int, QMap<QString, int> >::ConstIterator it =
- d_ptr->m_typeToAttributeToAttributeType.find(propertyType);
+ const auto it = d_ptr->m_typeToAttributeToAttributeType.constFind(propertyType);
if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
- return QStringList();
+ return {};
return it.value().keys();
}
@@ -1524,13 +1567,12 @@ QStringList QtVariantPropertyManager::attributes(int propertyType) const
*/
int QtVariantPropertyManager::attributeType(int propertyType, const QString &attribute) const
{
- QMap<int, QMap<QString, int> >::ConstIterator it =
- d_ptr->m_typeToAttributeToAttributeType.find(propertyType);
+ const auto it = d_ptr->m_typeToAttributeToAttributeType.constFind(propertyType);
if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
return 0;
- QMap<QString, int> attributes = it.value();
- QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute);
+ const QMap<QString, int> &attributes = it.value();
+ const auto itAttr = attributes.constFind(attribute);
if (itAttr == attributes.constEnd())
return 0;
return itAttr.value();
@@ -1559,79 +1601,79 @@ void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &va
if (propType != valType && !val.canConvert(QMetaType(valType)))
return;
- QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
- if (internProp == 0)
+ QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr);
+ if (internProp == nullptr)
return;
QtAbstractPropertyManager *manager = internProp->propertyManager();
- if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
+ if (auto *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
intManager->setValue(internProp, qvariant_cast<int>(val));
return;
- } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
+ } else if (auto *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
doubleManager->setValue(internProp, qvariant_cast<double>(val));
return;
- } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
+ } else if (auto *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
boolManager->setValue(internProp, qvariant_cast<bool>(val));
return;
- } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
+ } else if (auto *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
stringManager->setValue(internProp, qvariant_cast<QString>(val));
return;
- } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
+ } else if (auto *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
dateManager->setValue(internProp, qvariant_cast<QDate>(val));
return;
- } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) {
+ } else if (auto *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) {
timeManager->setValue(internProp, qvariant_cast<QTime>(val));
return;
- } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) {
+ } else if (auto *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) {
dateTimeManager->setValue(internProp, qvariant_cast<QDateTime>(val));
return;
- } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) {
+ } else if (auto *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) {
keySequenceManager->setValue(internProp, qvariant_cast<QKeySequence>(val));
return;
- } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) {
+ } else if (auto *charManager = qobject_cast<QtCharPropertyManager *>(manager)) {
charManager->setValue(internProp, qvariant_cast<QChar>(val));
return;
- } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) {
+ } else if (auto *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) {
localeManager->setValue(internProp, qvariant_cast<QLocale>(val));
return;
- } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) {
+ } else if (auto *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) {
pointManager->setValue(internProp, qvariant_cast<QPoint>(val));
return;
- } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
+ } else if (auto *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
pointFManager->setValue(internProp, qvariant_cast<QPointF>(val));
return;
- } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
+ } else if (auto *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
sizeManager->setValue(internProp, qvariant_cast<QSize>(val));
return;
- } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
+ } else if (auto *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
sizeFManager->setValue(internProp, qvariant_cast<QSizeF>(val));
return;
- } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
+ } else if (auto *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
rectManager->setValue(internProp, qvariant_cast<QRect>(val));
return;
- } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
+ } else if (auto *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
rectFManager->setValue(internProp, qvariant_cast<QRectF>(val));
return;
- } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) {
+ } else if (auto *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) {
colorManager->setValue(internProp, qvariant_cast<QColor>(val));
return;
- } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
+ } else if (auto *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
enumManager->setValue(internProp, qvariant_cast<int>(val));
return;
} else if (QtSizePolicyPropertyManager *sizePolicyManager =
qobject_cast<QtSizePolicyPropertyManager *>(manager)) {
sizePolicyManager->setValue(internProp, qvariant_cast<QSizePolicy>(val));
return;
- } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) {
+ } else if (auto *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) {
fontManager->setValue(internProp, qvariant_cast<QFont>(val));
return;
#ifndef QT_NO_CURSOR
- } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) {
+ } else if (auto *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) {
cursorManager->setValue(internProp, qvariant_cast<QCursor>(val));
return;
#endif
- } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
+ } else if (auto *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
flagManager->setValue(internProp, qvariant_cast<int>(val));
return;
}
@@ -1663,12 +1705,12 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property,
!value.canConvert(QMetaType(attrType)))
return;
- QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
- if (internProp == 0)
+ QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr);
+ if (internProp == nullptr)
return;
QtAbstractPropertyManager *manager = internProp->propertyManager();
- if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
+ if (auto *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
intManager->setMaximum(internProp, qvariant_cast<int>(value));
else if (attribute == d_ptr->m_minimumAttribute)
@@ -1676,7 +1718,7 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property,
else if (attribute == d_ptr->m_singleStepAttribute)
intManager->setSingleStep(internProp, qvariant_cast<int>(value));
return;
- } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
+ } else if (auto *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
doubleManager->setMaximum(internProp, qvariant_cast<double>(value));
if (attribute == d_ptr->m_minimumAttribute)
@@ -1686,27 +1728,27 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property,
if (attribute == d_ptr->m_decimalsAttribute)
doubleManager->setDecimals(internProp, qvariant_cast<int>(value));
return;
- } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
+ } else if (auto *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
if (attribute == d_ptr->m_regExpAttribute)
stringManager->setRegExp(internProp, qvariant_cast<QRegularExpression>(value));
return;
- } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
+ } else if (auto *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
dateManager->setMaximum(internProp, qvariant_cast<QDate>(value));
if (attribute == d_ptr->m_minimumAttribute)
dateManager->setMinimum(internProp, qvariant_cast<QDate>(value));
return;
- } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
+ } else if (auto *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
if (attribute == d_ptr->m_decimalsAttribute)
pointFManager->setDecimals(internProp, qvariant_cast<int>(value));
return;
- } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
+ } else if (auto *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
sizeManager->setMaximum(internProp, qvariant_cast<QSize>(value));
if (attribute == d_ptr->m_minimumAttribute)
sizeManager->setMinimum(internProp, qvariant_cast<QSize>(value));
return;
- } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
+ } else if (auto *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
if (attribute == d_ptr->m_maximumAttribute)
sizeFManager->setMaximum(internProp, qvariant_cast<QSizeF>(value));
if (attribute == d_ptr->m_minimumAttribute)
@@ -1714,23 +1756,23 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property,
if (attribute == d_ptr->m_decimalsAttribute)
sizeFManager->setDecimals(internProp, qvariant_cast<int>(value));
return;
- } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
+ } else if (auto *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
if (attribute == d_ptr->m_constraintAttribute)
rectManager->setConstraint(internProp, qvariant_cast<QRect>(value));
return;
- } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
+ } else if (auto *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
if (attribute == d_ptr->m_constraintAttribute)
rectFManager->setConstraint(internProp, qvariant_cast<QRectF>(value));
if (attribute == d_ptr->m_decimalsAttribute)
rectFManager->setDecimals(internProp, qvariant_cast<int>(value));
return;
- } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
+ } else if (auto *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
if (attribute == d_ptr->m_enumNamesAttribute)
enumManager->setEnumNames(internProp, qvariant_cast<QStringList>(value));
if (attribute == d_ptr->m_enumIconsAttribute)
enumManager->setEnumIcons(internProp, qvariant_cast<QtIconMap>(value));
return;
- } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
+ } else if (auto *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
if (attribute == d_ptr->m_flagNamesAttribute)
flagManager->setFlagNames(internProp, qvariant_cast<QStringList>(value));
return;
@@ -1752,7 +1794,7 @@ bool QtVariantPropertyManager::hasValue(const QtProperty *property) const
*/
QString QtVariantPropertyManager::valueText(const QtProperty *property) const
{
- const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
+ const QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr);
return internProp ? internProp->valueText() : QString();
}
@@ -1761,7 +1803,7 @@ QString QtVariantPropertyManager::valueText(const QtProperty *property) const
*/
QIcon QtVariantPropertyManager::valueIcon(const QtProperty *property) const
{
- const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
+ const QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr);
return internProp ? internProp->valueIcon() : QIcon();
}
@@ -1774,8 +1816,7 @@ void QtVariantPropertyManager::initializeProperty(QtProperty *property)
if (!varProp)
return;
- QMap<int, QtAbstractPropertyManager *>::ConstIterator it =
- d_ptr->m_typeToPropertyManager.find(d_ptr->m_propertyType);
+ const auto it = d_ptr->m_typeToPropertyManager.constFind(d_ptr->m_propertyType);
if (it != d_ptr->m_typeToPropertyManager.constEnd()) {
QtProperty *internProp = nullptr;
if (!d_ptr->m_creatingSubProperties) {
@@ -1800,11 +1841,11 @@ void QtVariantPropertyManager::initializeProperty(QtProperty *property)
*/
void QtVariantPropertyManager::uninitializeProperty(QtProperty *property)
{
- const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::iterator type_it = d_ptr->m_propertyToType.find(property);
+ const auto type_it = d_ptr->m_propertyToType.find(property);
if (type_it == d_ptr->m_propertyToType.end())
return;
- PropertyMap::iterator it = propertyToWrappedProperty()->find(property);
+ const auto it = propertyToWrappedProperty()->find(property);
if (it != propertyToWrappedProperty()->end()) {
QtProperty *internProp = it.value();
if (internProp) {
@@ -1826,8 +1867,8 @@ QtProperty *QtVariantPropertyManager::createProperty()
if (!d_ptr->m_creatingProperty)
return 0;
- QtVariantProperty *property = new QtVariantProperty(this);
- d_ptr->m_propertyToType.insert(property, qMakePair(property, d_ptr->m_propertyType));
+ auto *property = new QtVariantProperty(this);
+ d_ptr->m_propertyToType.insert(property, {property, d_ptr->m_propertyType});
return property;
}
@@ -1854,7 +1895,7 @@ public:
QtColorEditorFactory *m_colorEditorFactory;
QtFontEditorFactory *m_fontEditorFactory;
- QMap<QtAbstractEditorFactoryBase *, int> m_factoryToType;
+ QHash<QtAbstractEditorFactoryBase *, int> m_factoryToType;
QMap<int, QtAbstractEditorFactoryBase *> m_typeToFactory;
};
@@ -2100,7 +2141,7 @@ QWidget *QtVariantEditorFactory::createEditor(QtVariantPropertyManager *manager,
QWidget *parent)
{
const int propType = manager->propertyType(property);
- QtAbstractEditorFactoryBase *factory = d_ptr->m_typeToFactory.value(propType, 0);
+ QtAbstractEditorFactoryBase *factory = d_ptr->m_typeToFactory.value(propType, nullptr);
if (!factory)
return 0;
return factory->createEditor(wrappedProperty(property), parent);
diff --git a/src/shared/qtpropertybrowser/qtvariantproperty.h b/src/shared/qtpropertybrowser/qtvariantproperty.h
index 77bc52681..5fe231744 100644
--- a/src/shared/qtpropertybrowser/qtvariantproperty.h
+++ b/src/shared/qtpropertybrowser/qtvariantproperty.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTVARIANTPROPERTY_H
#define QTVARIANTPROPERTY_H
@@ -48,8 +12,6 @@ QT_BEGIN_NAMESPACE
class QRegularExpression;
-typedef QMap<int, QIcon> QtIconMap;
-
class QtVariantPropertyManager;
class QtVariantProperty : public QtProperty
@@ -112,43 +74,6 @@ protected:
QtProperty *createProperty() override;
private:
QScopedPointer<class QtVariantPropertyManagerPrivate> d_ptr;
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int))
- Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double))
- Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double))
- Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &))
- Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegularExpression &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, QDate))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, QDate, QDate))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, QTime))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &))
- Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &))
- Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &))
- Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &))
- Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &))
- Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &))
- Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &))
- Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &))
-
- Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))
- Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *))
Q_DECLARE_PRIVATE(QtVariantPropertyManager)
Q_DISABLE_COPY_MOVE(QtVariantPropertyManager)
};
@@ -172,6 +97,4 @@ private:
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QIcon)
-Q_DECLARE_METATYPE(QtIconMap)
#endif
diff --git a/src/shared/qttoolbardialog/qttoolbardialog.cpp b/src/shared/qttoolbardialog/qttoolbardialog.cpp
index 4136a42c4..622f23e82 100644
--- a/src/shared/qttoolbardialog/qttoolbardialog.cpp
+++ b/src/shared/qttoolbardialog/qttoolbardialog.cpp
@@ -1,59 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qttoolbardialog.h"
#include "ui_qttoolbardialog.h"
-#include <QtWidgets/QToolBar>
-#include <QtWidgets/QMainWindow>
-#include <QtWidgets/QHeaderView>
-#include <QtWidgets/QPushButton>
-
+#include <QtCore/QMap>
+#include <QtCore/QHash>
+#include <QtCore/QSet>
#include <QtGui/QAction>
#include <QtGui/QtEvents>
-
-#include <QtCore/QSet>
+#include <QtWidgets/QMainWindow>
+#include <QtWidgets/QPushButton>
+#include <QtWidgets/QToolBar>
#include <algorithm>
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
class QtFullToolBarManagerPrivate;
class QtFullToolBarManager : public QObject
@@ -88,7 +53,7 @@ public:
void removeDefaultToolBar(QToolBar *toolBar);
// NULL on action list means separator.
- QMap<QToolBar *, QList<QAction *> > defaultToolBars() const;
+ QHash<QToolBar *, QList<QAction *>> defaultToolBars() const;
bool isDefaultToolBar(QToolBar *toolBar) const;
QToolBar *createToolBar(const QString &toolBarName);
@@ -96,10 +61,10 @@ public:
QList<QAction *> actions(QToolBar *toolBar) const;
- void setToolBars(const QMap<QToolBar *, QList<QAction *> > &actions);
+ void setToolBars(const QHash<QToolBar *, QList<QAction *>> &actions);
void setToolBar(QToolBar *toolBar, const QList<QAction *> &actions);
- QMap<QToolBar *, QList<QAction *> > toolBarsActions() const;
+ QHash<QToolBar *, QList<QAction *>> toolBarsActions() const;
QByteArray saveState(int version = 0) const;
bool restoreState(const QByteArray &state, int version = 0);
@@ -134,7 +99,7 @@ class QtFullToolBarManagerPrivate
public:
QToolBar *toolBarWidgetAction(QAction *action) const;
- void removeWidgetActions(const QMap<QToolBar *, QList<QAction *> > &actions);
+ void removeWidgetActions(const QHash<QToolBar *, QList<QAction *>> &actions);
enum {
VersionMarker = 0xff,
@@ -149,17 +114,17 @@ public:
QToolBar *toolBarByName(const QString &toolBarName) const;
- QMap<QString, QList<QAction *> > categoryToActions;
- QMap<QAction *, QString> actionToCategory;
+ QHash<QString, QList<QAction *>> categoryToActions;
+ QHash<QAction *, QString> actionToCategory;
QSet<QAction *> allActions;
- QMap<QAction *, QToolBar *> widgetActions;
+ QHash<QAction *, QToolBar *> widgetActions;
QSet<QAction *> regularActions;
- QMap<QAction *, QList<QToolBar *> > actionToToolBars;
+ QHash<QAction *, QList<QToolBar *>> actionToToolBars;
- QMap<QToolBar *, QList<QAction *> > toolBars;
- QMap<QToolBar *, QList<QAction *> > toolBarsWithSeparators;
- QMap<QToolBar *, QList<QAction *> > defaultToolBars;
+ QHash<QToolBar *, QList<QAction *>> toolBars;
+ QHash<QToolBar *, QList<QAction *>> toolBarsWithSeparators;
+ QHash<QToolBar *, QList<QAction *>> defaultToolBars;
QList<QToolBar *> customToolBars;
QMainWindow *theMainWindow{nullptr};
@@ -172,7 +137,7 @@ QToolBar *QtFullToolBarManagerPrivate::toolBarWidgetAction(QAction *action) cons
return 0;
}
-void QtFullToolBarManagerPrivate::removeWidgetActions(const QMap<QToolBar *, QList<QAction *> >
+void QtFullToolBarManagerPrivate::removeWidgetActions(const QHash<QToolBar *, QList<QAction *>>
&actions)
{
auto itToolBar = actions.constBegin();
@@ -195,7 +160,7 @@ void QtFullToolBarManagerPrivate::removeWidgetActions(const QMap<QToolBar *, QLi
toolBars.insert(toolBar, newActions);
toolBarsWithSeparators.insert(toolBar, newActionsWithSeparators);
- for (QAction *oldAction : qAsConst(removedActions)) {
+ for (QAction *oldAction : std::as_const(removedActions)) {
widgetActions.insert(oldAction, 0);
actionToToolBars[oldAction].removeAll(toolBar);
}
@@ -347,7 +312,7 @@ bool QtFullToolBarManagerPrivate::restoreState(QDataStream &stream) const
q_ptr->setToolBar(toolBar, actions);
}
}
- for (QToolBar *toolBar : qAsConst(oldCustomToolBars))
+ for (QToolBar *toolBar : std::as_const(oldCustomToolBars))
q_ptr->deleteToolBar(toolBar);
return true;
}
@@ -464,10 +429,7 @@ QList<QAction *> QtFullToolBarManager::categoryActions(const QString &category)
QString QtFullToolBarManager::actionCategory(QAction *action) const
{
- QMap<QAction *, QString>::ConstIterator it = d_ptr->actionToCategory.find(action);
- if (it != d_ptr->actionToCategory.constEnd())
- return it.value();
- return QString();
+ return d_ptr->actionToCategory.value(action, {});
}
void QtFullToolBarManager::addAction(QAction *action, const QString &category)
@@ -478,8 +440,7 @@ void QtFullToolBarManager::addAction(QAction *action, const QString &category)
return;
if (d_ptr->allActions.contains(action))
return;
- if (QLatin1String(action->metaObject()->className()) ==
- QLatin1String("QToolBarWidgetAction"))
+ if (qstrcmp(action->metaObject()->className(), "QToolBarWidgetAction") == 0)
d_ptr->widgetActions.insert(action, 0);
else
d_ptr->regularActions.insert(action);
@@ -584,7 +545,7 @@ void QtFullToolBarManager::removeDefaultToolBar(QToolBar *toolBar)
}
}
-QMap<QToolBar *, QList<QAction *> > QtFullToolBarManager::defaultToolBars() const
+QHash<QToolBar *, QList<QAction *>> QtFullToolBarManager::defaultToolBars() const
{
return d_ptr->defaultToolBars;
}
@@ -602,7 +563,7 @@ QToolBar *QtFullToolBarManager::createToolBar(const QString &toolBarName)
return 0;
QToolBar *toolBar = new QToolBar(toolBarName, mainWindow());
int i = 1;
- const QString prefix = QLatin1String("_Custom_Toolbar_%1");
+ const QString prefix = "_Custom_Toolbar_%1"_L1;
QString name = prefix.arg(i);
while (d_ptr->toolBarByName(name))
name = prefix.arg(++i);
@@ -634,7 +595,7 @@ QList<QAction *> QtFullToolBarManager::actions(QToolBar *toolBar) const
return QList<QAction *>();
}
-void QtFullToolBarManager::setToolBars(const QMap<QToolBar *, QList<QAction *> > &actions)
+void QtFullToolBarManager::setToolBars(const QHash<QToolBar *, QList<QAction *>> &actions)
{
auto it = actions.constBegin();
while (it != actions.constEnd()) {
@@ -653,7 +614,7 @@ void QtFullToolBarManager::setToolBar(QToolBar *toolBar, const QList<QAction *>
if (actions == d_ptr->toolBars[toolBar])
return;
- QMap<QToolBar *, QList<QAction *> > toRemove;
+ QHash<QToolBar *, QList<QAction *>> toRemove;
QList<QAction *> newActions;
for (QAction *action : actions) {
@@ -683,7 +644,7 @@ void QtFullToolBarManager::setToolBar(QToolBar *toolBar, const QList<QAction *>
}
QList<QAction *> newActionsWithSeparators;
- for (QAction *action : qAsConst(newActions)) {
+ for (QAction *action : std::as_const(newActions)) {
QAction *newAction = nullptr;
if (!action)
newAction = toolBar->insertSeparator(0);
@@ -698,7 +659,7 @@ void QtFullToolBarManager::setToolBar(QToolBar *toolBar, const QList<QAction *>
d_ptr->toolBarsWithSeparators.insert(toolBar, newActionsWithSeparators);
}
-QMap<QToolBar *, QList<QAction *> > QtFullToolBarManager::toolBarsActions() const
+QHash<QToolBar *, QList<QAction *>> QtFullToolBarManager::toolBarsActions() const
{
return d_ptr->toolBars;
}
@@ -996,8 +957,8 @@ public:
void clearOld();
void fillNew();
QtFullToolBarManager *toolBarManager;
- QMap<ToolBarItem *, QList<QAction *> > currentState;
- QMap<QToolBar *, ToolBarItem *> toolBarItems;
+ QHash<ToolBarItem *, QList<QAction *>> currentState;
+ QHash<QToolBar *, ToolBarItem *> toolBarItems;
QSet<ToolBarItem *> createdItems;
QSet<ToolBarItem *> removedItems;
@@ -1005,20 +966,20 @@ public:
// static
QTreeWidgetItem *currentAction;
- QMap<QAction *, QTreeWidgetItem *> actionToItem;
- QMap<QTreeWidgetItem *, QAction *> itemToAction;
+ QHash<QAction *, QTreeWidgetItem *> actionToItem;
+ QHash<QTreeWidgetItem *, QAction *> itemToAction;
// dynamic
ToolBarItem *currentToolBar;
- QMap<ToolBarItem *, QListWidgetItem *> toolBarToItem;
- QMap<QListWidgetItem *, ToolBarItem *> itemToToolBar;
+ QHash<ToolBarItem *, QListWidgetItem *> toolBarToItem;
+ QHash<QListWidgetItem *, ToolBarItem *> itemToToolBar;
// dynamic
- QMap<QAction *, QListWidgetItem *> actionToCurrentItem;
- QMap<QListWidgetItem *, QAction *> currentItemToAction;
+ QHash<QAction *, QListWidgetItem *> actionToCurrentItem;
+ QHash<QListWidgetItem *, QAction *> currentItemToAction;
- QMap<QAction *, ToolBarItem *> widgetActionToToolBar;
- QMap<ToolBarItem *, QSet<QAction *> > toolBarToWidgetActions;
+ QHash<QAction *, ToolBarItem *> widgetActionToToolBar;
+ QHash<ToolBarItem *, QSet<QAction *>> toolBarToWidgetActions;
QString separatorText;
Ui::QtToolBarDialog ui;
@@ -1100,7 +1061,7 @@ void QtToolBarDialogPrivate::fillNew()
item = new QTreeWidgetItem(categoryItem);
item->setText(0, action->text());
item->setIcon(0, action->icon());
- item->setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic);
+ item->setTextAlignment(0, Qt::Alignment(Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic));
actionToItem.insert(action, item);
itemToAction.insert(item, action);
if (toolBarManager->isWidgetAction(action)) {
@@ -1219,7 +1180,7 @@ void QtToolBarDialogPrivate::removeToolBar(ToolBarItem *item)
int row = ui.toolBarList->row(i);
const auto itToolBar = toolBarToWidgetActions.find(item);
if (itToolBar != toolBarToWidgetActions.end()) {
- for (QAction *action : qAsConst(itToolBar.value()))
+ for (QAction *action : std::as_const(itToolBar.value()))
widgetActionToToolBar.insert(action, 0);
toolBarToWidgetActions.erase(itToolBar);
}
@@ -1263,7 +1224,7 @@ void QtToolBarDialogPrivate::defaultClicked()
const auto tbwit = toolBarToWidgetActions.find(toolBarItem);
if (tbwit != toolBarToWidgetActions.end()) {
- for (QAction *action : qAsConst(tbwit.value()))
+ for (QAction *action : std::as_const(tbwit.value()))
widgetActionToToolBar.insert(action, 0);
toolBarToWidgetActions.erase(tbwit);
}
@@ -1426,7 +1387,7 @@ void QtToolBarDialogPrivate::rightClicked()
} else {
item = new QListWidgetItem(action->text());
item->setIcon(action->icon());
- item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic);
+ item->setTextAlignment(Qt::Alignment(Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic));
currentItemToAction.insert(item, action);
actionToCurrentItem.insert(action, item);
if (widgetActionToToolBar.contains(action)) {
@@ -1507,7 +1468,7 @@ void QtToolBarDialogPrivate::currentToolBarChanged(QListWidgetItem *current)
QListWidgetItem *item = new QListWidgetItem(actionName, ui.currentToolBarList);
if (action) {
item->setIcon(action->icon());
- item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic);
+ item->setTextAlignment(Qt::Alignment(Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic));
actionToCurrentItem.insert(action, item);
if (widgetActionToToolBar.contains(action))
item->setData(Qt::ForegroundRole, QColor(Qt::blue));
@@ -1724,40 +1685,43 @@ QtToolBarDialog::QtToolBarDialog(QWidget *parent, Qt::WindowFlags flags)
d_ptr->ui.actionTree->setRootIsDecorated(false);
d_ptr->ui.actionTree->header()->hide();
- d_ptr->ui.upButton->setIcon(QIcon(QLatin1String(":/qt-project.org/qttoolbardialog/images/up.png")));
- d_ptr->ui.downButton->setIcon(QIcon(QLatin1String(":/qt-project.org/qttoolbardialog/images/down.png")));
- d_ptr->ui.leftButton->setIcon(QIcon(QLatin1String(":/qt-project.org/qttoolbardialog/images/back.png")));
- d_ptr->ui.rightButton->setIcon(QIcon(QLatin1String(":/qt-project.org/qttoolbardialog/images/forward.png")));
- d_ptr->ui.newButton->setIcon(QIcon(QLatin1String(":/qt-project.org/qttoolbardialog/images/plus.png")));
- d_ptr->ui.removeButton->setIcon(QIcon(QLatin1String(":/qt-project.org/qttoolbardialog/images/minus.png")));
-
- connect(d_ptr->ui.newButton, SIGNAL(clicked()), this, SLOT(newClicked()));
- connect(d_ptr->ui.removeButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
- connect(d_ptr->ui.renameButton, SIGNAL(clicked()), this, SLOT(renameClicked()));
- connect(d_ptr->ui.upButton, SIGNAL(clicked()), this, SLOT(upClicked()));
- connect(d_ptr->ui.downButton, SIGNAL(clicked()), this, SLOT(downClicked()));
- connect(d_ptr->ui.leftButton, SIGNAL(clicked()), this, SLOT(leftClicked()));
- connect(d_ptr->ui.rightButton, SIGNAL(clicked()), this, SLOT(rightClicked()));
-
- connect(d_ptr->ui.buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), this, SLOT(defaultClicked()));
- connect(d_ptr->ui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(okClicked()));
- connect(d_ptr->ui.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(applyClicked()));
- connect(d_ptr->ui.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(cancelClicked()));
-
- connect(d_ptr->ui.actionTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
- this, SLOT(currentActionChanged(QTreeWidgetItem*)));
- connect(d_ptr->ui.toolBarList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
- this, SLOT(currentToolBarChanged(QListWidgetItem*)));
- connect(d_ptr->ui.currentToolBarList,
- SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
- this, SLOT(currentToolBarActionChanged(QListWidgetItem*)));
-
- connect(d_ptr->ui.actionTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
- this, SLOT(rightClicked()));
- connect(d_ptr->ui.currentToolBarList, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
- this, SLOT(leftClicked()));
- connect(d_ptr->ui.toolBarList, SIGNAL(itemChanged(QListWidgetItem*)),
- this, SLOT(toolBarRenamed(QListWidgetItem*)));
+ d_ptr->ui.upButton->setIcon(QIcon(":/qt-project.org/qttoolbardialog/images/up.png"_L1));
+ d_ptr->ui.downButton->setIcon(QIcon(":/qt-project.org/qttoolbardialog/images/down.png"_L1));
+ d_ptr->ui.leftButton->setIcon(QIcon(":/qt-project.org/qttoolbardialog/images/back.png"_L1));
+ d_ptr->ui.rightButton->setIcon(QIcon(":/qt-project.org/qttoolbardialog/images/forward.png"_L1));
+ d_ptr->ui.newButton->setIcon(QIcon(":/qt-project.org/qttoolbardialog/images/plus.png"_L1));
+ d_ptr->ui.removeButton->setIcon(QIcon(":/qt-project.org/qttoolbardialog/images/minus.png"_L1));
+
+ connect(d_ptr->ui.newButton, &QAbstractButton::clicked, this, [this] { d_ptr->newClicked(); });
+ connect(d_ptr->ui.removeButton, &QAbstractButton::clicked, this, [this] { d_ptr->removeClicked(); });
+ connect(d_ptr->ui.renameButton, &QAbstractButton::clicked, this, [this] { d_ptr->renameClicked(); });
+ connect(d_ptr->ui.upButton, &QAbstractButton::clicked, this, [this] { d_ptr->upClicked(); });
+ connect(d_ptr->ui.downButton, &QAbstractButton::clicked, this, [this] { d_ptr->downClicked(); });
+ connect(d_ptr->ui.leftButton, &QAbstractButton::clicked, this, [this] { d_ptr->leftClicked(); });
+ connect(d_ptr->ui.rightButton, &QAbstractButton::clicked, this, [this] { d_ptr->rightClicked(); });
+
+ connect(d_ptr->ui.buttonBox->button(QDialogButtonBox::RestoreDefaults),
+ &QAbstractButton::clicked, this, [this] { d_ptr->defaultClicked(); });
+ connect(d_ptr->ui.buttonBox->button(QDialogButtonBox::Ok),
+ &QAbstractButton::clicked, this, [this] { d_ptr->okClicked(); });
+ connect(d_ptr->ui.buttonBox->button(QDialogButtonBox::Apply),
+ &QAbstractButton::clicked, this, [this] { d_ptr->applyClicked(); });
+ connect(d_ptr->ui.buttonBox->button(QDialogButtonBox::Cancel),
+ &QAbstractButton::clicked, this, [this] { d_ptr->cancelClicked(); });
+
+ connect(d_ptr->ui.actionTree, &QTreeWidget::currentItemChanged,
+ this, [this](QTreeWidgetItem *current) { d_ptr->currentActionChanged(current); });
+ connect(d_ptr->ui.currentToolBarList, &QListWidget::currentItemChanged,
+ this, [this](QListWidgetItem *current) { d_ptr->currentToolBarActionChanged(current); });
+ connect(d_ptr->ui.toolBarList, &QListWidget::currentItemChanged,
+ this, [this](QListWidgetItem *current) { d_ptr->currentToolBarChanged(current); });
+
+ connect(d_ptr->ui.actionTree, &QTreeWidget::itemDoubleClicked,
+ this, [this] { d_ptr->rightClicked(); });
+ connect(d_ptr->ui.currentToolBarList, &QListWidget::itemDoubleClicked,
+ this, [this] { d_ptr->leftClicked(); });
+ connect(d_ptr->ui.toolBarList, &QListWidget::itemChanged,
+ this, [this](QListWidgetItem *current) { d_ptr->toolBarRenamed(current); });
}
/*!
diff --git a/src/shared/qttoolbardialog/qttoolbardialog.h b/src/shared/qttoolbardialog/qttoolbardialog.h
index 28e08dd4e..3a283a0ec 100644
--- a/src/shared/qttoolbardialog/qttoolbardialog.h
+++ b/src/shared/qttoolbardialog/qttoolbardialog.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
@@ -113,22 +77,6 @@ private:
QScopedPointer<QtToolBarDialogPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtToolBarDialog)
Q_DISABLE_COPY_MOVE(QtToolBarDialog)
-
- Q_PRIVATE_SLOT(d_func(), void newClicked())
- Q_PRIVATE_SLOT(d_func(), void removeClicked())
- Q_PRIVATE_SLOT(d_func(), void defaultClicked())
- Q_PRIVATE_SLOT(d_func(), void okClicked())
- Q_PRIVATE_SLOT(d_func(), void applyClicked())
- Q_PRIVATE_SLOT(d_func(), void cancelClicked())
- Q_PRIVATE_SLOT(d_func(), void upClicked())
- Q_PRIVATE_SLOT(d_func(), void downClicked())
- Q_PRIVATE_SLOT(d_func(), void leftClicked())
- Q_PRIVATE_SLOT(d_func(), void rightClicked())
- Q_PRIVATE_SLOT(d_func(), void renameClicked())
- Q_PRIVATE_SLOT(d_func(), void toolBarRenamed(QListWidgetItem *))
- Q_PRIVATE_SLOT(d_func(), void currentActionChanged(QTreeWidgetItem *))
- Q_PRIVATE_SLOT(d_func(), void currentToolBarChanged(QListWidgetItem *))
- Q_PRIVATE_SLOT(d_func(), void currentToolBarActionChanged(QListWidgetItem *))
};
QT_END_NAMESPACE
diff --git a/src/shared/qttoolbardialog/qttoolbardialog.qrc b/src/shared/qttoolbardialog/qttoolbardialog.qrc
deleted file mode 100644
index efd3825fa..000000000
--- a/src/shared/qttoolbardialog/qttoolbardialog.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<RCC version="1.0">
- <qresource prefix="/qt-project.org/qttoolbardialog">
- <file>images/up.png</file>
- <file>images/down.png</file>
- <file>images/forward.png</file>
- <file>images/back.png</file>
- <file>images/plus.png</file>
- <file>images/minus.png</file>
- </qresource>
-</RCC>
diff --git a/src/shared/winutils/elfreader.cpp b/src/shared/winutils/elfreader.cpp
deleted file mode 100644
index f375f5841..000000000
--- a/src/shared/winutils/elfreader.cpp
+++ /dev/null
@@ -1,440 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "elfreader.h"
-
-#include <QDir>
-
-QT_BEGIN_NAMESPACE
-
-/* This is a copy of the ELF reader contained in Qt Creator (src/libs/utils),
- * extended by the dependencies() function to read out the dependencies of a dynamic executable. */
-
-quint16 getHalfWord(const unsigned char *&s, const ElfData &context)
-{
- quint16 res;
- if (context.endian == Elf_ELFDATA2MSB)
- res = qFromBigEndian<quint16>(s);
- else
- res = qFromLittleEndian<quint16>(s);
- s += 2;
- return res;
-}
-
-quint32 getWord(const unsigned char *&s, const ElfData &context)
-{
- quint32 res;
- if (context.endian == Elf_ELFDATA2MSB)
- res = qFromBigEndian<quint32>(s);
- else
- res = qFromLittleEndian<quint32>(s);
- s += 4;
- return res;
-}
-
-quint64 getAddress(const unsigned char *&s, const ElfData &context)
-{
- quint64 res;
- if (context.elfclass == Elf_ELFCLASS32) {
- if (context.endian == Elf_ELFDATA2MSB)
- res = qFromBigEndian<quint32>(s);
- else
- res = qFromLittleEndian<quint32>(s);
- s += 4;
- } else {
- if (context.endian == Elf_ELFDATA2MSB)
- res = qFromBigEndian<quint64>(s);
- else
- res = qFromLittleEndian<quint64>(s);
- s += 8;
- }
- return res;
-}
-
-quint64 getOffset(const unsigned char *&s, const ElfData &context)
-{
- return getAddress(s, context);
-}
-
-static void parseSectionHeader(const uchar *s, ElfSectionHeader *sh, const ElfData &context)
-{
- sh->index = getWord(s, context);
- sh->type = getWord(s, context);
- sh->flags = quint32(getOffset(s, context));
- sh->addr = getAddress(s, context);
- sh->offset = getOffset(s, context);
- sh->size = getOffset(s, context);
-}
-
-static void parseProgramHeader(const uchar *s, ElfProgramHeader *sh, const ElfData &context)
-{
- sh->type = getWord(s, context);
- sh->offset = getOffset(s, context);
- /* p_vaddr = */ getAddress(s, context);
- /* p_paddr = */ getAddress(s, context);
- sh->filesz = getWord(s, context);
- sh->memsz = getWord(s, context);
-}
-
-class ElfMapper
-{
-public:
- ElfMapper(const ElfReader *reader) : file(reader->m_binary) {}
-
- bool map()
- {
- if (!file.open(QIODevice::ReadOnly))
- return false;
-
- fdlen = quint64(file.size());
- ustart = file.map(0, qint64(fdlen));
- if (ustart == 0) {
- // Try reading the data into memory instead.
- raw = file.readAll();
- start = raw.constData();
- fdlen = quint64(raw.size());
- }
- return true;
- }
-
-public:
- QFile file;
- QByteArray raw;
- union { const char *start; const uchar *ustart; };
- quint64 fdlen;
-};
-
-ElfReader::ElfReader(const QString &binary)
- : m_binary(binary)
-{
-}
-
-ElfData ElfReader::readHeaders()
-{
- readIt();
- return m_elfData;
-}
-
-static inline QString msgInvalidElfObject(const QString &binary, const QString &why)
-{
- return QStringLiteral("'%1' is an invalid ELF object (%2)")
- .arg(QDir::toNativeSeparators(binary), why);
-}
-
-ElfReader::Result ElfReader::readIt()
-{
- if (!m_elfData.sectionHeaders.isEmpty())
- return Ok;
- if (!m_elfData.programHeaders.isEmpty())
- return Ok;
-
- ElfMapper mapper(this);
- if (!mapper.map())
- return Corrupt;
-
- const quint64 fdlen = mapper.fdlen;
-
- if (fdlen < 64) {
- m_errorString = QStringLiteral("'%1' is not an ELF object (file too small)").arg(QDir::toNativeSeparators(m_binary));
- return NotElf;
- }
-
- if (strncmp(mapper.start, "\177ELF", 4) != 0) {
- m_errorString = QStringLiteral("'%1' is not an ELF object").arg(QDir::toNativeSeparators(m_binary));
- return NotElf;
- }
-
- // 32 or 64 bit
- m_elfData.elfclass = ElfClass(mapper.start[4]);
- const bool is64Bit = m_elfData.elfclass == Elf_ELFCLASS64;
- if (m_elfData.elfclass != Elf_ELFCLASS32 && m_elfData.elfclass != Elf_ELFCLASS64) {
- m_errorString = msgInvalidElfObject(m_binary, QStringLiteral("odd cpu architecture"));
- return Corrupt;
- }
-
- // int bits = (data[4] << 5);
- // If you remove this check to read ELF objects of a different arch,
- // please make sure you modify the typedefs
- // to match the _plugin_ architecture.
- // if ((sizeof(void*) == 4 && bits != 32)
- // || (sizeof(void*) == 8 && bits != 64)) {
- // if (errorString)
- // *errorString = QLibrary::QStringLiteral("'%1' is an invalid ELF object (%2)")
- // .arg(m_binary).arg(QLatin1String("wrong cpu architecture"));
- // return Corrupt;
- // }
-
- // Read Endianhness.
- m_elfData.endian = ElfEndian(mapper.ustart[5]);
- if (m_elfData.endian != Elf_ELFDATA2LSB && m_elfData.endian != Elf_ELFDATA2MSB) {
- m_errorString = msgInvalidElfObject(m_binary, QStringLiteral("odd endianness"));
- return Corrupt;
- }
-
- const uchar *data = mapper.ustart + 16; // e_ident
- m_elfData.elftype = ElfType(getHalfWord(data, m_elfData));
- m_elfData.elfmachine = ElfMachine(getHalfWord(data, m_elfData));
- /* e_version = */ getWord(data, m_elfData);
- m_elfData.entryPoint = getAddress(data, m_elfData);
-
- quint64 e_phoff = getOffset(data, m_elfData);
- quint64 e_shoff = getOffset(data, m_elfData);
- /* e_flags = */ getWord(data, m_elfData);
-
- quint32 e_shsize = getHalfWord(data, m_elfData);
-
- if (e_shsize > fdlen) {
- m_errorString = msgInvalidElfObject(m_binary, QStringLiteral("unexpected e_shsize"));
- return Corrupt;
- }
-
- quint32 e_phentsize = getHalfWord(data, m_elfData);
- if (e_phentsize != (is64Bit ? 56 : 32)) {
- m_errorString = msgInvalidElfObject(m_binary, QStringLiteral("invalid structure"));
- return ElfReader::Corrupt;
- }
- quint32 e_phnum = getHalfWord(data, m_elfData);
-
- quint32 e_shentsize = getHalfWord(data, m_elfData);
-
- if (e_shentsize % 4) {
- m_errorString = msgInvalidElfObject(m_binary, QStringLiteral("unexpected e_shentsize"));
- return Corrupt;
- }
-
- quint32 e_shnum = getHalfWord(data, m_elfData);
- quint32 e_shtrndx = getHalfWord(data, m_elfData);
- if (data != mapper.ustart + (is64Bit ? 64 : 52)) {
- m_errorString = msgInvalidElfObject(m_binary, QStringLiteral("unexpected e_phentsize"));
- return ElfReader::Corrupt;
- }
-
- if (quint64(e_shnum) * e_shentsize > fdlen) {
- const QString reason = QStringLiteral("announced %1 sections, each %2 bytes, exceed file size").arg(e_shnum).arg(e_shentsize);
- m_errorString = msgInvalidElfObject(m_binary, reason);
- return Corrupt;
- }
-
- quint64 soff = e_shoff + e_shentsize * e_shtrndx;
-
-// if ((soff + e_shentsize) > fdlen || soff % 4 || soff == 0) {
-// m_errorString = QLibrary::QStringLiteral("'%1' is an invalid ELF object (%2)")
-// .arg(m_binary)
-// .arg(QLatin1String("shstrtab section header seems to be at %1"))
-// .arg(QString::number(soff, 16));
-// return Corrupt;
-// }
-
- if (e_shoff) {
- ElfSectionHeader strtab;
- parseSectionHeader(mapper.ustart + soff, &strtab, m_elfData);
- const quint64 stringTableFileOffset = strtab.offset;
- if (quint32(stringTableFileOffset + e_shentsize) >= fdlen
- || stringTableFileOffset == 0) {
- const QString reason = QStringLiteral("string table seems to be at 0x%1").arg(soff, 0, 16);
- m_errorString = msgInvalidElfObject(m_binary, reason);
- return Corrupt;
- }
-
- for (quint32 i = 0; i < e_shnum; ++i) {
- const uchar *s = mapper.ustart + e_shoff + i * e_shentsize;
- ElfSectionHeader sh;
- parseSectionHeader(s, &sh, m_elfData);
-
- if (stringTableFileOffset + sh.index > fdlen) {
- const QString reason = QStringLiteral("section name %1 of %2 behind end of file")
- .arg(i).arg(e_shnum);
- m_errorString = msgInvalidElfObject(m_binary, reason);
- return Corrupt;
- }
-
- sh.name = mapper.start + stringTableFileOffset + sh.index;
- if (sh.name == ".gdb_index") {
- m_elfData.symbolsType = FastSymbols;
- } else if (sh.name == ".debug_info") {
- m_elfData.symbolsType = PlainSymbols;
- } else if (sh.name == ".gnu_debuglink") {
- m_elfData.debugLink = QByteArray(mapper.start + sh.offset);
- m_elfData.symbolsType = LinkedSymbols;
- } else if (sh.name == ".note.gnu.build-id") {
- m_elfData.symbolsType = BuildIdSymbols;
- if (sh.size > 16)
- m_elfData.buildId = QByteArray(mapper.start + sh.offset + 16,
- int(sh.size) - 16).toHex();
- }
- m_elfData.sectionHeaders.append(sh);
- }
- }
-
- if (e_phoff) {
- for (quint32 i = 0; i < e_phnum; ++i) {
- const uchar *s = mapper.ustart + e_phoff + i * e_phentsize;
- ElfProgramHeader ph;
- parseProgramHeader(s, &ph, m_elfData);
- m_elfData.programHeaders.append(ph);
- }
- }
- return Ok;
-}
-
-QByteArray ElfReader::readSection(const QByteArray &name)
-{
- readIt();
- int i = m_elfData.indexOf(name);
- if (i == -1)
- return QByteArray();
-
- ElfMapper mapper(this);
- if (!mapper.map())
- return QByteArray();
-
- const ElfSectionHeader &section = m_elfData.sectionHeaders.at(i);
- return QByteArray(mapper.start + section.offset, int(section.size));
-}
-
-static QByteArray cutout(const char *s)
-{
- QByteArray res(s, 80);
- const int pos = res.indexOf('\0');
- if (pos != -1)
- res.resize(pos - 1);
- return res;
-}
-
-QByteArray ElfReader::readCoreName(bool *isCore)
-{
- *isCore = false;
-
- readIt();
-
- ElfMapper mapper(this);
- if (!mapper.map())
- return QByteArray();
-
- if (m_elfData.elftype != Elf_ET_CORE)
- return QByteArray();
-
- *isCore = true;
-
- for (int i = 0, n = m_elfData.sectionHeaders.size(); i != n; ++i)
- if (m_elfData.sectionHeaders.at(i).type == Elf_SHT_NOTE) {
- const ElfSectionHeader &header = m_elfData.sectionHeaders.at(i);
- return cutout(mapper.start + header.offset + 0x40);
- }
-
- for (int i = 0, n = m_elfData.programHeaders.size(); i != n; ++i)
- if (m_elfData.programHeaders.at(i).type == Elf_PT_NOTE) {
- const ElfProgramHeader &header = m_elfData.programHeaders.at(i);
- return cutout(mapper.start + header.offset + 0xec);
- }
-
- return QByteArray();
-}
-
-int ElfData::indexOf(const QByteArray &name) const
-{
- for (int i = 0, n = sectionHeaders.size(); i != n; ++i)
- if (sectionHeaders.at(i).name == name)
- return i;
- return -1;
-}
-
-/* Helpers for reading out the .dynamic section containing the dependencies.
- * The ".dynamic" section is an array of
- * typedef struct {
- * Elf32_Sword d_tag;
- * union {
- * Elf32_Word d_val;
- * dElf32_Addr d_ptr;
- * } d_un;
- * } Elf32_Dyn
- * with entries where a tag DT_NEEDED indicates that m_val is an offset into
- * the string table ".dynstr". The documentation states that entries with the
- * tag DT_STRTAB contain an offset for the string table to be used, but that
- * has been found not to contain valid entries. */
-
-enum DynamicSectionTags {
- DT_NULL = 0,
- DT_NEEDED = 1,
- DT_STRTAB = 5,
- DT_SONAME = 14,
- DT_RPATH = 15
-};
-
-QList<QByteArray> ElfReader::dependencies()
-{
- QList<QByteArray> result;
-
- ElfMapper mapper(this);
- if (!mapper.map()) {
- m_errorString = QStringLiteral("Mapper failure");
- return result;
- }
- quint64 dynStrOffset = 0;
- quint64 dynamicOffset = 0;
- quint64 dynamicSize = 0;
-
- const QList<ElfSectionHeader> &headers = readHeaders().sectionHeaders;
- for (const ElfSectionHeader &eh : headers) {
- if (eh.name == QByteArrayLiteral(".dynstr")) {
- dynStrOffset = eh.offset;
- } else if (eh.name == QByteArrayLiteral(".dynamic")) {
- dynamicOffset = eh.offset;
- dynamicSize = eh.size;
- }
- if (dynStrOffset && dynamicOffset)
- break;
- }
-
- if (!dynStrOffset || !dynamicOffset) {
- m_errorString = QStringLiteral("Not a dynamically linked executable.");
- return result;
- }
-
- const unsigned char *dynamicData = mapper.ustart + dynamicOffset;
- const unsigned char *dynamicDataEnd = dynamicData + dynamicSize;
- while (dynamicData < dynamicDataEnd) {
- const quint32 tag = getWord(dynamicData, m_elfData);
- if (tag == DT_NULL)
- break;
- if (m_elfData.elfclass == Elf_ELFCLASS64)
- dynamicData += sizeof(quint32); // padding to d_val/d_ptr.
- if (tag == DT_NEEDED) {
- const quint32 offset = getWord(dynamicData, m_elfData);
- if (m_elfData.elfclass == Elf_ELFCLASS64)
- dynamicData += sizeof(quint32); // past d_ptr.
- const char *name = mapper.start + dynStrOffset + offset;
- result.push_back(name);
- } else {
- dynamicData += m_elfData.elfclass == Elf_ELFCLASS64 ? 8 : 4;
- }
- }
- return result;
-}
-
-QT_END_NAMESPACE
diff --git a/src/shared/winutils/elfreader.h b/src/shared/winutils/elfreader.h
deleted file mode 100644
index d84f5a060..000000000
--- a/src/shared/winutils/elfreader.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef ELFREADER_H
-#define ELFREADER_H
-
-#include <QtCore/QList>
-#include <QtCore/QString>
-#include <QtCore/QtEndian>
-
-QT_BEGIN_NAMESPACE
-
-enum ElfProgramHeaderType
-{
- Elf_PT_NULL = 0,
- Elf_PT_LOAD = 1,
- Elf_PT_DYNAMIC = 2,
- Elf_PT_INTERP = 3,
- Elf_PT_NOTE = 4,
- Elf_PT_SHLIB = 5,
- Elf_PT_PHDR = 6,
- Elf_PT_TLS = 7,
- Elf_PT_NUM = 8
-};
-
-enum ElfSectionHeaderType
-{
- Elf_SHT_NULL = 0,
- Elf_SHT_PROGBITS = 1,
- Elf_SHT_SYMTAB = 2,
- Elf_SHT_STRTAB = 3,
- Elf_SHT_RELA = 4,
- Elf_SHT_HASH = 5,
- Elf_SHT_DYNAMIC = 6,
- Elf_SHT_NOTE = 7,
- Elf_SHT_NOBITS = 8,
- Elf_SHT_REL = 9,
- Elf_SHT_SHLIB = 10,
- Elf_SHT_DYNSYM = 11,
- Elf_SHT_INIT_ARRAY = 14,
- Elf_SHT_FINI_ARRAY = 15,
- Elf_SHT_PREINIT_ARRAY = 16,
- Elf_SHT_GROUP = 17,
- Elf_SHT_SYMTAB_SHNDX = 18
-};
-
-enum ElfEndian
-{
- Elf_ELFDATANONE = 0,
- Elf_ELFDATA2LSB = 1,
- Elf_ELFDATA2MSB = 2,
- Elf_ELFDATANUM = 3
-};
-
-enum ElfClass
-{
- Elf_ELFCLASS32 = 1,
- Elf_ELFCLASS64 = 2
-};
-
-enum ElfType
-{
- Elf_ET_NONE = 0,
- Elf_ET_REL = 1,
- Elf_ET_EXEC = 2,
- Elf_ET_DYN = 3,
- Elf_ET_CORE = 4
-};
-
-enum ElfMachine
-{
- Elf_EM_386 = 3,
- Elf_EM_ARM = 40,
- Elf_EM_X86_64 = 62
-};
-
-enum DebugSymbolsType
-{
- UnknownSymbols = 0, // Unknown.
- NoSymbols = 1, // No usable symbols.
- LinkedSymbols = 2, // Link to symols available.
- BuildIdSymbols = 4, // BuildId available.
- PlainSymbols = 8, // Ordinary symbols available.
- FastSymbols = 16 // Dwarf index available.
-};
-
-class ElfSectionHeader
-{
-public:
- QByteArray name;
- quint32 index;
- quint32 type;
- quint32 flags;
- quint64 offset;
- quint64 size;
- quint64 addr;
-};
-
-class ElfProgramHeader
-{
-public:
- quint32 name;
- quint32 type;
- quint64 offset;
- quint64 filesz;
- quint64 memsz;
-};
-
-class ElfData
-{
-public:
- ElfData() : symbolsType(UnknownSymbols) {}
- int indexOf(const QByteArray &name) const;
-
-public:
- ElfEndian endian;
- ElfType elftype;
- ElfMachine elfmachine;
- ElfClass elfclass;
- quint64 entryPoint;
- QByteArray debugLink;
- QByteArray buildId;
- DebugSymbolsType symbolsType;
- QList<ElfSectionHeader> sectionHeaders;
- QList<ElfProgramHeader> programHeaders;
-};
-
-class ElfReader
-{
-public:
- explicit ElfReader(const QString &binary);
- enum Result { Ok, NotElf, Corrupt };
-
- ElfData readHeaders();
- QByteArray readSection(const QByteArray &sectionName);
- QString errorString() const { return m_errorString; }
- QByteArray readCoreName(bool *isCore);
- QList<QByteArray> dependencies();
-
-private:
- friend class ElfMapper;
- Result readIt();
-
- QString m_binary;
- QString m_errorString;
- ElfData m_elfData;
-};
-
-QT_END_NAMESPACE
-
-#endif // ELFREADER_H
diff --git a/src/shared/winutils/qmlutils.cpp b/src/shared/winutils/qmlutils.cpp
deleted file mode 100644
index 6eebf6d86..000000000
--- a/src/shared/winutils/qmlutils.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlutils.h"
-#include "utils.h"
-
-#include <QtCore/QDir>
-#include <QtCore/QFileInfo>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QJsonDocument>
-#include <QtCore/QJsonObject>
-#include <QtCore/QJsonArray>
-#include <QtCore/QJsonParseError>
-
-QT_BEGIN_NAMESPACE
-
-bool operator==(const QmlImportScanResult::Module &m1, const QmlImportScanResult::Module &m2)
-{
- return m1.className.isEmpty() ? m1.name == m2.name : m1.className == m2.className;
-}
-
-// Return install path (cp -r semantics)
-QString QmlImportScanResult::Module::installPath(const QString &root) const
-{
- QString result = root;
- const int lastSlashPos = relativePath.lastIndexOf(QLatin1Char('/'));
- if (lastSlashPos != -1) {
- result += QLatin1Char('/');
- result += QStringView{relativePath}.left(lastSlashPos);
- }
- return result;
-}
-
-static QString qmlDirectoryRecursion(Platform platform, const QString &path)
-{
- QDir dir(path);
- if (!dir.entryList(QStringList(QStringLiteral("*.qml")), QDir::Files, QDir::NoSort).isEmpty())
- return dir.path();
- const QFileInfoList &subDirs = dir.entryInfoList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
- for (const QFileInfo &subDirFi : subDirs) {
- if (!isBuildDirectory(platform, subDirFi.fileName())) {
- const QString subPath = qmlDirectoryRecursion(platform, subDirFi.absoluteFilePath());
- if (!subPath.isEmpty())
- return subPath;
- }
- }
- return QString();
-}
-
-// Find a directory containing QML files in the project
-QString findQmlDirectory(Platform platform, const QString &startDirectoryName)
-{
- QDir startDirectory(startDirectoryName);
- if (isBuildDirectory(platform, startDirectory.dirName()))
- startDirectory.cdUp();
- return qmlDirectoryRecursion(platform, startDirectory.path());
-}
-
-static void findFileRecursion(const QDir &directory, Platform platform,
- DebugMatchMode debugMatchMode, QStringList *matches)
-{
- const QStringList &dlls = findSharedLibraries(directory, platform, debugMatchMode);
- for (const QString &dll : dlls)
- matches->append(directory.filePath(dll));
- const QFileInfoList &subDirs = directory.entryInfoList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
- for (const QFileInfo &subDirFi : subDirs) {
- QDir subDirectory(subDirFi.absoluteFilePath());
- if (subDirectory.isReadable())
- findFileRecursion(subDirectory, platform, debugMatchMode, matches);
- }
-}
-
-QmlImportScanResult runQmlImportScanner(const QString &directory, const QStringList &qmlImportPaths,
- bool usesWidgets, int platform, DebugMatchMode debugMatchMode,
- QString *errorMessage)
-{
- Q_UNUSED(usesWidgets);
- QmlImportScanResult result;
- QStringList arguments;
- for (const QString &importPath : qmlImportPaths)
- arguments << QStringLiteral("-importPath") << importPath;
- arguments << QStringLiteral("-rootPath") << directory;
- unsigned long exitCode;
- QByteArray stdOut;
- QByteArray stdErr;
- const QString binary = QStringLiteral("qmlimportscanner");
- if (!runProcess(binary, arguments, QDir::currentPath(), &exitCode, &stdOut, &stdErr, errorMessage))
- return result;
- if (exitCode) {
- *errorMessage = binary + QStringLiteral(" returned ") + QString::number(exitCode)
- + QStringLiteral(": ") + QString::fromLocal8Bit(stdErr);
- return result;
- }
- QJsonParseError jsonParseError{};
- const QJsonDocument data = QJsonDocument::fromJson(stdOut, &jsonParseError);
- if (data.isNull() ) {
- *errorMessage = binary + QStringLiteral(" returned invalid JSON output: ")
- + jsonParseError.errorString() + QStringLiteral(" :\"")
- + QString::fromLocal8Bit(stdOut) + QLatin1Char('"');
- return result;
- }
- const QJsonArray array = data.array();
- const int childCount = array.count();
- for (int c = 0; c < childCount; ++c) {
- const QJsonObject object = array.at(c).toObject();
- if (object.value(QStringLiteral("type")).toString() == QLatin1String("module")) {
- const QString path = object.value(QStringLiteral("path")).toString();
- if (!path.isEmpty()) {
- QmlImportScanResult::Module module;
- module.name = object.value(QStringLiteral("name")).toString();
- module.className = object.value(QStringLiteral("classname")).toString();
- module.sourcePath = path;
- module.relativePath = object.value(QStringLiteral("relativePath")).toString();
- result.modules.append(module);
- findFileRecursion(QDir(path), Platform(platform), debugMatchMode, &result.plugins);
- }
- }
- }
- result.ok = true;
- return result;
-}
-
-void QmlImportScanResult::append(const QmlImportScanResult &other)
-{
- for (const QmlImportScanResult::Module &module : other.modules) {
- if (std::find(modules.cbegin(), modules.cend(), module) == modules.cend())
- modules.append(module);
- }
- for (const QString &plugin : other.plugins) {
- if (!plugins.contains(plugin))
- plugins.append(plugin);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/shared/winutils/qmlutils.h b/src/shared/winutils/qmlutils.h
deleted file mode 100644
index 572be7cab..000000000
--- a/src/shared/winutils/qmlutils.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLUTILS_H
-#define QMLUTILS_H
-
-#include "utils.h"
-
-#include <QStringList>
-
-QT_BEGIN_NAMESPACE
-
-QString findQmlDirectory(Platform platform, const QString &startDirectoryName);
-
-struct QmlImportScanResult {
- struct Module {
- QString installPath(const QString &root) const;
-
- QString name;
- QString className;
- QString sourcePath;
- QString relativePath;
- };
-
- void append(const QmlImportScanResult &other);
-
- bool ok = false;
- QList<Module> modules;
- QStringList plugins;
-};
-
-bool operator==(const QmlImportScanResult::Module &m1, const QmlImportScanResult::Module &m2);
-
-QmlImportScanResult runQmlImportScanner(const QString &directory, const QStringList &qmlImportPaths,
- bool usesWidgets, int platform, DebugMatchMode debugMatchMode,
- QString *errorMessage);
-
-QT_END_NAMESPACE
-
-#endif // QMLUTILS_H
diff --git a/src/shared/winutils/utils.cpp b/src/shared/winutils/utils.cpp
deleted file mode 100644
index df56cd3da..000000000
--- a/src/shared/winutils/utils.cpp
+++ /dev/null
@@ -1,1006 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "utils.h"
-#include "elfreader.h"
-
-#include <QtCore/QString>
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
-#include <QtCore/QTemporaryFile>
-#include <QtCore/QScopedPointer>
-#include <QtCore/QScopedArrayPointer>
-#include <QtCore/QStandardPaths>
-#if defined(Q_OS_WIN)
-# include <QtCore/qt_windows.h>
-# include <shlwapi.h>
-# include <delayimp.h>
-#else // Q_OS_WIN
-# include <sys/wait.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-# include <unistd.h>
-# include <stdlib.h>
-# include <string.h>
-# include <errno.h>
-# include <fcntl.h>
-#endif // !Q_OS_WIN
-
-QT_BEGIN_NAMESPACE
-
-int optVerboseLevel = 1;
-
-bool isBuildDirectory(Platform platform, const QString &dirName)
-{
- return (platform.testFlag(Msvc) || platform.testFlag(ClangMsvc))
- && (dirName == QLatin1String("debug") || dirName == QLatin1String("release"));
-}
-
-// Create a symbolic link by changing to the source directory to make sure the
-// link uses relative paths only (QFile::link() otherwise uses the absolute path).
-bool createSymbolicLink(const QFileInfo &source, const QString &target, QString *errorMessage)
-{
- const QString oldDirectory = QDir::currentPath();
- if (!QDir::setCurrent(source.absolutePath())) {
- *errorMessage = QStringLiteral("Unable to change to directory %1.").arg(QDir::toNativeSeparators(source.absolutePath()));
- return false;
- }
- QFile file(source.fileName());
- const bool success = file.link(target);
- QDir::setCurrent(oldDirectory);
- if (!success) {
- *errorMessage = QString::fromLatin1("Failed to create symbolic link %1 -> %2: %3")
- .arg(QDir::toNativeSeparators(source.absoluteFilePath()),
- QDir::toNativeSeparators(target), file.errorString());
- return false;
- }
- return true;
-}
-
-bool createDirectory(const QString &directory, QString *errorMessage)
-{
- const QFileInfo fi(directory);
- if (fi.isDir())
- return true;
- if (fi.exists()) {
- *errorMessage = QString::fromLatin1("%1 already exists and is not a directory.").
- arg(QDir::toNativeSeparators(directory));
- return false;
- }
- if (optVerboseLevel)
- std::wcout << "Creating " << QDir::toNativeSeparators(directory) << "...\n";
- QDir dir;
- if (!dir.mkpath(directory)) {
- *errorMessage = QString::fromLatin1("Could not create directory %1.").
- arg(QDir::toNativeSeparators(directory));
- return false;
- }
- return true;
-}
-
-// Find shared libraries matching debug/Platform in a directory, return relative names.
-QStringList findSharedLibraries(const QDir &directory, Platform platform,
- DebugMatchMode debugMatchMode,
- const QString &prefix)
-{
- QString nameFilter = prefix;
- if (nameFilter.isEmpty())
- nameFilter += QLatin1Char('*');
- if (debugMatchMode == MatchDebug && platformHasDebugSuffix(platform))
- nameFilter += QLatin1Char('d');
- nameFilter += sharedLibrarySuffix(platform);
- QStringList result;
- QString errorMessage;
- const QFileInfoList &dlls = directory.entryInfoList(QStringList(nameFilter), QDir::Files);
- for (const QFileInfo &dllFi : dlls) {
- const QString dllPath = dllFi.absoluteFilePath();
- bool matches = true;
- if (debugMatchMode != MatchDebugOrRelease && (platform & WindowsBased)) {
- bool debugDll;
- if (readPeExecutable(dllPath, &errorMessage, 0, 0, &debugDll,
- (platform == WindowsDesktopMinGW))) {
- matches = debugDll == (debugMatchMode == MatchDebug);
- } else {
- std::wcerr << "Warning: Unable to read " << QDir::toNativeSeparators(dllPath)
- << ": " << errorMessage;
- }
- } // Windows
- if (matches)
- result += dllFi.fileName();
- } // for
- return result;
-}
-
-#ifdef Q_OS_WIN
-QString winErrorMessage(unsigned long error)
-{
- QString rc = QString::fromLatin1("#%1: ").arg(error);
- char16_t *lpMsgBuf;
-
- const DWORD len = FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, error, 0, reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, NULL);
- if (len) {
- rc = QString::fromUtf16(lpMsgBuf, int(len));
- LocalFree(lpMsgBuf);
- } else {
- rc += QString::fromLatin1("<unknown error>");
- }
- return rc;
-}
-
-// Case-Normalize file name via GetShortPathNameW()/GetLongPathNameW()
-QString normalizeFileName(const QString &name)
-{
- wchar_t shortBuffer[MAX_PATH];
- const QString nativeFileName = QDir::toNativeSeparators(name);
- if (!GetShortPathNameW(reinterpret_cast<LPCWSTR>(nativeFileName.utf16()), shortBuffer, MAX_PATH))
- return name;
- wchar_t result[MAX_PATH];
- if (!GetLongPathNameW(shortBuffer, result, MAX_PATH))
- return name;
- return QDir::fromNativeSeparators(QString::fromWCharArray(result));
-}
-
-// Find a tool binary in the Windows SDK 8
-QString findSdkTool(const QString &tool)
-{
- QStringList paths = QString::fromLocal8Bit(qgetenv("PATH")).split(QLatin1Char(';'));
- const QByteArray sdkDir = qgetenv("WindowsSdkDir");
- if (!sdkDir.isEmpty())
- paths.prepend(QDir::cleanPath(QString::fromLocal8Bit(sdkDir)) + QLatin1String("/Tools/x64"));
- return QStandardPaths::findExecutable(tool, paths);
-}
-
-// runProcess helper: Create a temporary file for stdout/stderr redirection.
-static HANDLE createInheritableTemporaryFile()
-{
- wchar_t path[MAX_PATH];
- if (!GetTempPath(MAX_PATH, path))
- return INVALID_HANDLE_VALUE;
- wchar_t name[MAX_PATH];
- if (!GetTempFileName(path, L"temp", 0, name)) // Creates file.
- return INVALID_HANDLE_VALUE;
- SECURITY_ATTRIBUTES securityAttributes;
- ZeroMemory(&securityAttributes, sizeof(securityAttributes));
- securityAttributes.nLength = sizeof(securityAttributes);
- securityAttributes.bInheritHandle = TRUE;
- return CreateFile(name, GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
- TRUNCATE_EXISTING,
- FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL);
-}
-
-// runProcess helper: Rewind and read out a temporary file for stdout/stderr.
-static inline void readTemporaryProcessFile(HANDLE handle, QByteArray *result)
-{
- if (SetFilePointer(handle, 0, 0, FILE_BEGIN) == 0xFFFFFFFF)
- return;
- char buf[1024];
- DWORD bytesRead;
- while (ReadFile(handle, buf, sizeof(buf), &bytesRead, NULL) && bytesRead)
- result->append(buf, int(bytesRead));
- CloseHandle(handle);
-}
-
-static inline void appendToCommandLine(const QString &argument, QString *commandLine)
-{
- const bool needsQuote = argument.contains(QLatin1Char(' '));
- if (!commandLine->isEmpty())
- commandLine->append(QLatin1Char(' '));
- if (needsQuote)
- commandLine->append(QLatin1Char('"'));
- commandLine->append(argument);
- if (needsQuote)
- commandLine->append(QLatin1Char('"'));
-}
-
-// runProcess: Run a command line process (replacement for QProcess which
-// does not exist in the bootstrap library).
-bool runProcess(const QString &binary, const QStringList &args,
- const QString &workingDirectory,
- unsigned long *exitCode, QByteArray *stdOut, QByteArray *stdErr,
- QString *errorMessage)
-{
- if (exitCode)
- *exitCode = 0;
-
- STARTUPINFO si;
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
-
- STARTUPINFO myInfo;
- GetStartupInfo(&myInfo);
- si.hStdInput = myInfo.hStdInput;
- si.hStdOutput = myInfo.hStdOutput;
- si.hStdError = myInfo.hStdError;
-
- PROCESS_INFORMATION pi;
- ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
- const QChar backSlash = QLatin1Char('\\');
- QString nativeWorkingDir = QDir::toNativeSeparators(workingDirectory.isEmpty() ? QDir::currentPath() : workingDirectory);
- if (!nativeWorkingDir.endsWith(backSlash))
- nativeWorkingDir += backSlash;
-
- if (stdOut) {
- si.hStdOutput = createInheritableTemporaryFile();
- if (si.hStdOutput == INVALID_HANDLE_VALUE) {
- if (errorMessage)
- *errorMessage = QStringLiteral("Error creating stdout temporary file");
- return false;
- }
- si.dwFlags |= STARTF_USESTDHANDLES;
- }
-
- if (stdErr) {
- si.hStdError = createInheritableTemporaryFile();
- if (si.hStdError == INVALID_HANDLE_VALUE) {
- if (errorMessage)
- *errorMessage = QStringLiteral("Error creating stderr temporary file");
- return false;
- }
- si.dwFlags |= STARTF_USESTDHANDLES;
- }
-
- // Create a copy of the command line which CreateProcessW can modify.
- QString commandLine;
- appendToCommandLine(binary, &commandLine);
- for (const QString &a : args)
- appendToCommandLine(a, &commandLine);
- if (optVerboseLevel > 1)
- std::wcout << "Running: " << commandLine << '\n';
-
- QScopedArrayPointer<wchar_t> commandLineW(new wchar_t[commandLine.size() + 1]);
- commandLine.toWCharArray(commandLineW.data());
- commandLineW[commandLine.size()] = 0;
- if (!CreateProcessW(0, commandLineW.data(), 0, 0, /* InheritHandles */ TRUE, 0, 0,
- reinterpret_cast<LPCWSTR>(nativeWorkingDir.utf16()), &si, &pi)) {
- if (stdOut)
- CloseHandle(si.hStdOutput);
- if (stdErr)
- CloseHandle(si.hStdError);
- if (errorMessage)
- *errorMessage = QStringLiteral("CreateProcessW failed: ") + winErrorMessage(GetLastError());
- return false;
- }
-
- WaitForSingleObject(pi.hProcess, INFINITE);
- CloseHandle(pi.hThread);
- if (exitCode)
- GetExitCodeProcess(pi.hProcess, exitCode);
- CloseHandle(pi.hProcess);
-
- if (stdOut)
- readTemporaryProcessFile(si.hStdOutput, stdOut);
- if (stdErr)
- readTemporaryProcessFile(si.hStdError, stdErr);
- return true;
-}
-
-#else // Q_OS_WIN
-
-static inline char *encodeFileName(const QString &f)
-{
- const QByteArray encoded = QFile::encodeName(f);
- char *result = new char[encoded.size() + 1];
- strcpy(result, encoded.constData());
- return result;
-}
-
-static inline char *tempFilePattern()
-{
- QString path = QDir::tempPath();
- if (!path.endsWith(QLatin1Char('/')))
- path += QLatin1Char('/');
- path += QStringLiteral("tmpXXXXXX");
- return encodeFileName(path);
-}
-
-static inline QByteArray readOutRedirectFile(int fd)
-{
- enum { bufSize = 256 };
-
- QByteArray result;
- if (!lseek(fd, 0, 0)) {
- char buf[bufSize];
- while (true) {
- const ssize_t rs = read(fd, buf, bufSize);
- if (rs <= 0)
- break;
- result.append(buf, int(rs));
- }
- }
- close(fd);
- return result;
-}
-
-// runProcess: Run a command line process (replacement for QProcess which
-// does not exist in the bootstrap library).
-bool runProcess(const QString &binary, const QStringList &args,
- const QString &workingDirectory,
- unsigned long *exitCode, QByteArray *stdOut, QByteArray *stdErr,
- QString *errorMessage)
-{
- QScopedArrayPointer<char> stdOutFileName;
- QScopedArrayPointer<char> stdErrFileName;
-
- int stdOutFile = 0;
- if (stdOut) {
- stdOutFileName.reset(tempFilePattern());
- stdOutFile = mkstemp(stdOutFileName.data());
- if (stdOutFile < 0) {
- *errorMessage = QStringLiteral("mkstemp() failed: ") + QString::fromLocal8Bit(strerror(errno));
- return false;
- }
- }
-
- int stdErrFile = 0;
- if (stdErr) {
- stdErrFileName.reset(tempFilePattern());
- stdErrFile = mkstemp(stdErrFileName.data());
- if (stdErrFile < 0) {
- *errorMessage = QStringLiteral("mkstemp() failed: ") + QString::fromLocal8Bit(strerror(errno));
- return false;
- }
- }
-
- const pid_t pID = fork();
-
- if (pID < 0) {
- *errorMessage = QStringLiteral("Fork failed: ") + QString::fromLocal8Bit(strerror(errno));
- return false;
- }
-
- if (!pID) { // Child
- if (stdOut) {
- dup2(stdOutFile, STDOUT_FILENO);
- close(stdOutFile);
- }
- if (stdErr) {
- dup2(stdErrFile, STDERR_FILENO);
- close(stdErrFile);
- }
-
- if (!workingDirectory.isEmpty() && !QDir::setCurrent(workingDirectory)) {
- std::wcerr << "Failed to change working directory to " << workingDirectory << ".\n";
- ::_exit(-1);
- }
-
- char **argv = new char *[args.size() + 2]; // Create argv.
- char **ap = argv;
- *ap++ = encodeFileName(binary);
- for (const QString &a : qAsConst(args))
- *ap++ = encodeFileName(a);
- *ap = 0;
-
- execvp(argv[0], argv);
- ::_exit(-1);
- }
-
- int status;
- pid_t waitResult;
-
- do {
- waitResult = waitpid(pID, &status, 0);
- } while (waitResult == -1 && errno == EINTR);
-
- if (stdOut) {
- *stdOut = readOutRedirectFile(stdOutFile);
- unlink(stdOutFileName.data());
- }
- if (stdErr) {
- *stdErr = readOutRedirectFile(stdErrFile);
- unlink(stdErrFileName.data());
- }
-
- if (waitResult < 0) {
- *errorMessage = QStringLiteral("Wait failed: ") + QString::fromLocal8Bit(strerror(errno));
- return false;
- }
- if (!WIFEXITED(status)) {
- *errorMessage = binary + QStringLiteral(" did not exit cleanly.");
- return false;
- }
- if (exitCode)
- *exitCode = WEXITSTATUS(status);
- return true;
-}
-
-#endif // !Q_OS_WIN
-
-// Find a file in the path using ShellAPI. This can be used to locate DLLs which
-// QStandardPaths cannot do.
-QString findInPath(const QString &file)
-{
-#if defined(Q_OS_WIN)
- if (file.size() < MAX_PATH - 1) {
- wchar_t buffer[MAX_PATH];
- file.toWCharArray(buffer);
- buffer[file.size()] = 0;
- if (PathFindOnPath(buffer, NULL))
- return QDir::cleanPath(QString::fromWCharArray(buffer));
- }
- return QString();
-#else // Q_OS_WIN
- return QStandardPaths::findExecutable(file);
-#endif // !Q_OS_WIN
-}
-
-const char *qmakeInfixKey = "QT_INFIX";
-
-QMap<QString, QString> queryQMakeAll(const QString &qmakeBinary, QString *errorMessage)
-{
- const QString binary = !qmakeBinary.isEmpty() ? qmakeBinary : QStringLiteral("qmake");
- QByteArray stdOut;
- QByteArray stdErr;
- unsigned long exitCode = 0;
- if (!runProcess(binary, QStringList(QStringLiteral("-query")), QString(), &exitCode, &stdOut, &stdErr, errorMessage))
- return QMap<QString, QString>();
- if (exitCode) {
- *errorMessage = binary + QStringLiteral(" returns ") + QString::number(exitCode)
- + QStringLiteral(": ") + QString::fromLocal8Bit(stdErr);
- return QMap<QString, QString>();
- }
- const QString output = QString::fromLocal8Bit(stdOut).trimmed().remove(QLatin1Char('\r'));
- QMap<QString, QString> result;
- const int size = output.size();
- for (int pos = 0; pos < size; ) {
- const int colonPos = output.indexOf(QLatin1Char(':'), pos);
- if (colonPos < 0)
- break;
- int endPos = output.indexOf(QLatin1Char('\n'), colonPos + 1);
- if (endPos < 0)
- endPos = size;
- const QString key = output.mid(pos, colonPos - pos);
- const QString value = output.mid(colonPos + 1, endPos - colonPos - 1);
- result.insert(key, value);
- pos = endPos + 1;
- }
- QFile qconfigPriFile(result.value(QStringLiteral("QT_HOST_DATA")) + QStringLiteral("/mkspecs/qconfig.pri"));
- if (qconfigPriFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- while (true) {
- const QByteArray line = qconfigPriFile.readLine();
- if (line.isEmpty())
- break;
- if (line.startsWith("QT_LIBINFIX")) {
- const int pos = line.indexOf('=');
- if (pos >= 0) {
- const QString infix = QString::fromUtf8(line.right(line.size() - pos - 1).trimmed());
- if (!infix.isEmpty())
- result.insert(QLatin1String(qmakeInfixKey), infix);
- }
- break;
- }
- }
- } else {
- std::wcerr << "Warning: Unable to read " << QDir::toNativeSeparators(qconfigPriFile.fileName())
- << ": " << qconfigPriFile.errorString()<< '\n';
- }
- return result;
-}
-
-// Update a file or directory.
-bool updateFile(const QString &sourceFileName, const QStringList &nameFilters,
- const QString &targetDirectory, unsigned flags, JsonOutput *json, QString *errorMessage)
-{
- const QFileInfo sourceFileInfo(sourceFileName);
- const QString targetFileName = targetDirectory + QLatin1Char('/') + sourceFileInfo.fileName();
- if (optVerboseLevel > 1)
- std::wcout << "Checking " << sourceFileName << ", " << targetFileName<< '\n';
-
- if (!sourceFileInfo.exists()) {
- *errorMessage = QString::fromLatin1("%1 does not exist.").arg(QDir::toNativeSeparators(sourceFileName));
- return false;
- }
-
- if (sourceFileInfo.isSymLink()) {
- *errorMessage = QString::fromLatin1("Symbolic links are not supported (%1).")
- .arg(QDir::toNativeSeparators(sourceFileName));
- return false;
- }
-
- const QFileInfo targetFileInfo(targetFileName);
-
- if (sourceFileInfo.isDir()) {
- if (targetFileInfo.exists()) {
- if (!targetFileInfo.isDir()) {
- *errorMessage = QString::fromLatin1("%1 already exists and is not a directory.")
- .arg(QDir::toNativeSeparators(targetFileName));
- return false;
- } // Not a directory.
- } else { // exists.
- QDir d(targetDirectory);
- if (optVerboseLevel)
- std::wcout << "Creating " << QDir::toNativeSeparators(targetFileName) << ".\n";
- if (!(flags & SkipUpdateFile) && !d.mkdir(sourceFileInfo.fileName())) {
- *errorMessage = QString::fromLatin1("Cannot create directory %1 under %2.")
- .arg(sourceFileInfo.fileName(), QDir::toNativeSeparators(targetDirectory));
- return false;
- }
- }
- // Recurse into directory
- QDir dir(sourceFileName);
- const QFileInfoList allEntries = dir.entryInfoList(nameFilters, QDir::Files)
- + dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
- for (const QFileInfo &entryFi : allEntries) {
- if (!updateFile(entryFi.absoluteFilePath(), nameFilters, targetFileName, flags, json, errorMessage))
- return false;
- }
- return true;
- } // Source is directory.
-
- if (targetFileInfo.exists()) {
- if (!(flags & ForceUpdateFile)
- && targetFileInfo.lastModified() >= sourceFileInfo.lastModified()) {
- if (optVerboseLevel)
- std::wcout << sourceFileInfo.fileName() << " is up to date.\n";
- if (json)
- json->addFile(sourceFileName, targetDirectory);
- return true;
- }
- QFile targetFile(targetFileName);
- if (!(flags & SkipUpdateFile) && !targetFile.remove()) {
- *errorMessage = QString::fromLatin1("Cannot remove existing file %1: %2")
- .arg(QDir::toNativeSeparators(targetFileName), targetFile.errorString());
- return false;
- }
- } // target exists
- QFile file(sourceFileName);
- if (optVerboseLevel)
- std::wcout << "Updating " << sourceFileInfo.fileName() << ".\n";
- if (!(flags & SkipUpdateFile) && !file.copy(targetFileName)) {
- *errorMessage = QString::fromLatin1("Cannot copy %1 to %2: %3")
- .arg(QDir::toNativeSeparators(sourceFileName),
- QDir::toNativeSeparators(targetFileName),
- file.errorString());
- return false;
- }
- if (json)
- json->addFile(sourceFileName, targetDirectory);
- return true;
-}
-
-bool readElfExecutable(const QString &elfExecutableFileName, QString *errorMessage,
- QStringList *dependentLibraries, unsigned *wordSize,
- bool *isDebug)
-{
- ElfReader elfReader(elfExecutableFileName);
- const ElfData data = elfReader.readHeaders();
- if (data.sectionHeaders.isEmpty()) {
- *errorMessage = QStringLiteral("Unable to read ELF binary \"")
- + QDir::toNativeSeparators(elfExecutableFileName) + QStringLiteral("\": ")
- + elfReader.errorString();
- return false;
- }
- if (wordSize)
- *wordSize = data.elfclass == Elf_ELFCLASS64 ? 64 : 32;
- if (dependentLibraries) {
- dependentLibraries->clear();
- const QList<QByteArray> libs = elfReader.dependencies();
- if (libs.isEmpty()) {
- *errorMessage = QStringLiteral("Unable to read dependenices of ELF binary \"")
- + QDir::toNativeSeparators(elfExecutableFileName) + QStringLiteral("\": ")
- + elfReader.errorString();
- return false;
- }
- for (const QByteArray &l : libs)
- dependentLibraries->push_back(QString::fromLocal8Bit(l));
- }
- if (isDebug)
- *isDebug = data.symbolsType != UnknownSymbols && data.symbolsType != NoSymbols;
- return true;
-}
-
-#ifdef Q_OS_WIN
-
-static inline QString stringFromRvaPtr(const void *rvaPtr)
-{
- return QString::fromLocal8Bit(static_cast<const char *>(rvaPtr));
-}
-
-// Helper for reading out PE executable files: Find a section header for an RVA
-// (IMAGE_NT_HEADERS64, IMAGE_NT_HEADERS32).
-template <class ImageNtHeader>
-const IMAGE_SECTION_HEADER *findSectionHeader(DWORD rva, const ImageNtHeader *nTHeader)
-{
- const IMAGE_SECTION_HEADER *section = IMAGE_FIRST_SECTION(nTHeader);
- const IMAGE_SECTION_HEADER *sectionEnd = section + nTHeader->FileHeader.NumberOfSections;
- for ( ; section < sectionEnd; ++section)
- if (rva >= section->VirtualAddress && rva < (section->VirtualAddress + section->Misc.VirtualSize))
- return section;
- return 0;
-}
-
-// Helper for reading out PE executable files: convert RVA to pointer (IMAGE_NT_HEADERS64, IMAGE_NT_HEADERS32).
-template <class ImageNtHeader>
-inline const void *rvaToPtr(DWORD rva, const ImageNtHeader *nTHeader, const void *imageBase)
-{
- const IMAGE_SECTION_HEADER *sectionHdr = findSectionHeader(rva, nTHeader);
- if (!sectionHdr)
- return 0;
- const DWORD delta = sectionHdr->VirtualAddress - sectionHdr->PointerToRawData;
- return static_cast<const char *>(imageBase) + rva - delta;
-}
-
-// Helper for reading out PE executable files: return word size of a IMAGE_NT_HEADERS64, IMAGE_NT_HEADERS32
-template <class ImageNtHeader>
-inline unsigned ntHeaderWordSize(const ImageNtHeader *header)
-{
- // defines IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_NT_OPTIONAL_HDR64_MAGIC
- enum { imageNtOptionlHeader32Magic = 0x10b, imageNtOptionlHeader64Magic = 0x20b };
- if (header->OptionalHeader.Magic == imageNtOptionlHeader32Magic)
- return 32;
- if (header->OptionalHeader.Magic == imageNtOptionlHeader64Magic)
- return 64;
- return 0;
-}
-
-// Helper for reading out PE executable files: Retrieve the NT image header of an
-// executable via the legacy DOS header.
-static IMAGE_NT_HEADERS *getNtHeader(void *fileMemory, QString *errorMessage)
-{
- IMAGE_DOS_HEADER *dosHeader = static_cast<PIMAGE_DOS_HEADER>(fileMemory);
- // Check DOS header consistency
- if (IsBadReadPtr(dosHeader, sizeof(IMAGE_DOS_HEADER))
- || dosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
- *errorMessage = QString::fromLatin1("DOS header check failed.");
- return 0;
- }
- // Retrieve NT header
- char *ntHeaderC = static_cast<char *>(fileMemory) + dosHeader->e_lfanew;
- IMAGE_NT_HEADERS *ntHeaders = reinterpret_cast<IMAGE_NT_HEADERS *>(ntHeaderC);
- // check NT header consistency
- if (IsBadReadPtr(ntHeaders, sizeof(ntHeaders->Signature))
- || ntHeaders->Signature != IMAGE_NT_SIGNATURE
- || IsBadReadPtr(&ntHeaders->FileHeader, sizeof(IMAGE_FILE_HEADER))) {
- *errorMessage = QString::fromLatin1("NT header check failed.");
- return 0;
- }
- // Check magic
- if (!ntHeaderWordSize(ntHeaders)) {
- *errorMessage = QString::fromLatin1("NT header check failed; magic %1 is invalid.").
- arg(ntHeaders->OptionalHeader.Magic);
- return 0;
- }
- // Check section headers
- IMAGE_SECTION_HEADER *sectionHeaders = IMAGE_FIRST_SECTION(ntHeaders);
- if (IsBadReadPtr(sectionHeaders, ntHeaders->FileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER))) {
- *errorMessage = QString::fromLatin1("NT header section header check failed.");
- return 0;
- }
- return ntHeaders;
-}
-
-// Helper for reading out PE executable files: Read out import sections from
-// IMAGE_NT_HEADERS64, IMAGE_NT_HEADERS32.
-template <class ImageNtHeader>
-inline QStringList readImportSections(const ImageNtHeader *ntHeaders, const void *base, QString *errorMessage)
-{
- // Get import directory entry RVA and read out
- const DWORD importsStartRVA = ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
- if (!importsStartRVA) {
- *errorMessage = QString::fromLatin1("Failed to find IMAGE_DIRECTORY_ENTRY_IMPORT entry.");
- return QStringList();
- }
- const IMAGE_IMPORT_DESCRIPTOR *importDesc = static_cast<const IMAGE_IMPORT_DESCRIPTOR *>(rvaToPtr(importsStartRVA, ntHeaders, base));
- if (!importDesc) {
- *errorMessage = QString::fromLatin1("Failed to find IMAGE_IMPORT_DESCRIPTOR entry.");
- return QStringList();
- }
- QStringList result;
- for ( ; importDesc->Name; ++importDesc)
- result.push_back(stringFromRvaPtr(rvaToPtr(importDesc->Name, ntHeaders, base)));
-
- // Read delay-loaded DLLs, see http://msdn.microsoft.com/en-us/magazine/cc301808.aspx .
- // Check on grAttr bit 1 whether this is the format using RVA's > VS 6
- if (const DWORD delayedImportsStartRVA = ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress) {
- const ImgDelayDescr *delayedImportDesc = static_cast<const ImgDelayDescr *>(rvaToPtr(delayedImportsStartRVA, ntHeaders, base));
- for ( ; delayedImportDesc->rvaDLLName && (delayedImportDesc->grAttrs & 1); ++delayedImportDesc)
- result.push_back(stringFromRvaPtr(rvaToPtr(delayedImportDesc->rvaDLLName, ntHeaders, base)));
- }
-
- return result;
-}
-
-// Check for MSCV runtime (MSVCP90D.dll/MSVCP90.dll, MSVCP120D.dll/MSVCP120.dll,
-// VCRUNTIME140D.DLL/VCRUNTIME140.DLL (VS2015) or msvcp120d_app.dll/msvcp120_app.dll).
-enum MsvcDebugRuntimeResult { MsvcDebugRuntime, MsvcReleaseRuntime, NoMsvcRuntime };
-
-static inline MsvcDebugRuntimeResult checkMsvcDebugRuntime(const QStringList &dependentLibraries)
-{
- for (const QString &lib : dependentLibraries) {
- int pos = 0;
- if (lib.startsWith(QLatin1String("MSVCR"), Qt::CaseInsensitive)
- || lib.startsWith(QLatin1String("MSVCP"), Qt::CaseInsensitive)
- || lib.startsWith(QLatin1String("VCRUNTIME"), Qt::CaseInsensitive)) {
- int lastDotPos = lib.lastIndexOf(QLatin1Char('.'));
- pos = -1 == lastDotPos ? 0 : lastDotPos - 1;
- }
-
- if (pos > 0 && lib.contains(QLatin1String("_app"), Qt::CaseInsensitive))
- pos -= 4;
-
- if (pos) {
- return lib.at(pos).toLower() == QLatin1Char('d')
- ? MsvcDebugRuntime : MsvcReleaseRuntime;
- }
- }
- return NoMsvcRuntime;
-}
-
-template <class ImageNtHeader>
-inline void determineDebugAndDependentLibs(const ImageNtHeader *nth, const void *fileMemory,
- bool isMinGW,
- QStringList *dependentLibrariesIn,
- bool *isDebugIn, QString *errorMessage)
-{
- const bool hasDebugEntry = nth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size;
- QStringList dependentLibraries;
- if (dependentLibrariesIn || (isDebugIn != nullptr && hasDebugEntry && !isMinGW))
- dependentLibraries = readImportSections(nth, fileMemory, errorMessage);
-
- if (dependentLibrariesIn)
- *dependentLibrariesIn = dependentLibraries;
- if (isDebugIn != nullptr) {
- if (isMinGW) {
- // Use logic that's used e.g. in objdump / pfd library
- *isDebugIn = !(nth->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED);
- } else {
- // When an MSVC debug entry is present, check whether the debug runtime
- // is actually used to detect -release / -force-debug-info builds.
- *isDebugIn = hasDebugEntry && checkMsvcDebugRuntime(dependentLibraries) != MsvcReleaseRuntime;
- }
- }
-}
-
-// Read a PE executable and determine dependent libraries, word size
-// and debug flags.
-bool readPeExecutable(const QString &peExecutableFileName, QString *errorMessage,
- QStringList *dependentLibrariesIn, unsigned *wordSizeIn,
- bool *isDebugIn, bool isMinGW, unsigned short *machineArchIn)
-{
- bool result = false;
- HANDLE hFile = NULL;
- HANDLE hFileMap = NULL;
- void *fileMemory = 0;
-
- if (dependentLibrariesIn)
- dependentLibrariesIn->clear();
- if (wordSizeIn)
- *wordSizeIn = 0;
- if (isDebugIn)
- *isDebugIn = false;
-
- do {
- // Create a memory mapping of the file
- hFile = CreateFile(reinterpret_cast<const WCHAR*>(peExecutableFileName.utf16()), GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile == INVALID_HANDLE_VALUE || hFile == NULL) {
- *errorMessage = QString::fromLatin1("Cannot open '%1': %2").arg(peExecutableFileName, winErrorMessage(GetLastError()));
- break;
- }
-
- hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
- if (hFileMap == NULL) {
- *errorMessage = QString::fromLatin1("Cannot create file mapping of '%1': %2").arg(peExecutableFileName, winErrorMessage(GetLastError()));
- break;
- }
-
- fileMemory = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0);
- if (!fileMemory) {
- *errorMessage = QString::fromLatin1("Cannot map '%1': %2").arg(peExecutableFileName, winErrorMessage(GetLastError()));
- break;
- }
-
- const IMAGE_NT_HEADERS *ntHeaders = getNtHeader(fileMemory, errorMessage);
- if (!ntHeaders)
- break;
-
- const unsigned wordSize = ntHeaderWordSize(ntHeaders);
- if (wordSizeIn)
- *wordSizeIn = wordSize;
- if (wordSize == 32) {
- determineDebugAndDependentLibs(reinterpret_cast<const IMAGE_NT_HEADERS32 *>(ntHeaders),
- fileMemory, isMinGW, dependentLibrariesIn, isDebugIn, errorMessage);
- } else {
- determineDebugAndDependentLibs(reinterpret_cast<const IMAGE_NT_HEADERS64 *>(ntHeaders),
- fileMemory, isMinGW, dependentLibrariesIn, isDebugIn, errorMessage);
- }
-
- if (machineArchIn)
- *machineArchIn = ntHeaders->FileHeader.Machine;
-
- result = true;
- if (optVerboseLevel > 1) {
- std::wcout << __FUNCTION__ << ": " << QDir::toNativeSeparators(peExecutableFileName)
- << ' ' << wordSize << " bit";
- if (isMinGW)
- std::wcout << ", MinGW";
- if (dependentLibrariesIn) {
- std::wcout << ", dependent libraries: ";
- if (optVerboseLevel > 2)
- std::wcout << dependentLibrariesIn->join(QLatin1Char(' '));
- else
- std::wcout << dependentLibrariesIn->size();
- }
- if (isDebugIn)
- std::wcout << (*isDebugIn ? ", debug" : ", release");
- std::wcout << '\n';
- }
- } while (false);
-
- if (fileMemory)
- UnmapViewOfFile(fileMemory);
-
- if (hFileMap != NULL)
- CloseHandle(hFileMap);
-
- if (hFile != NULL && hFile != INVALID_HANDLE_VALUE)
- CloseHandle(hFile);
-
- return result;
-}
-
-QString findD3dCompiler(Platform platform, const QString &qtBinDir, unsigned wordSize)
-{
- const QString prefix = QStringLiteral("D3Dcompiler_");
- const QString suffix = QLatin1String(windowsSharedLibrarySuffix);
- // Get the DLL from Kit 8.0 onwards
- const QString kitDir = QString::fromLocal8Bit(qgetenv("WindowsSdkDir"));
- if (!kitDir.isEmpty()) {
- QString redistDirPath = QDir::cleanPath(kitDir) + QStringLiteral("/Redist/D3D/");
- if (platform.testFlag(ArmBased)) {
- redistDirPath += QStringLiteral("arm");
- } else {
- redistDirPath += wordSize == 32 ? QStringLiteral("x86") : QStringLiteral("x64");
- }
- QDir redistDir(redistDirPath);
- if (redistDir.exists()) {
- const QFileInfoList files = redistDir.entryInfoList(QStringList(prefix + QLatin1Char('*') + suffix), QDir::Files);
- if (!files.isEmpty())
- return files.front().absoluteFilePath();
- }
- }
- QStringList candidateVersions;
- for (int i = 47 ; i >= 40 ; --i)
- candidateVersions.append(prefix + QString::number(i) + suffix);
- // Check the bin directory of the Qt SDK (in case it is shadowed by the
- // Windows system directory in PATH).
- for (const QString &candidate : qAsConst(candidateVersions)) {
- const QFileInfo fi(qtBinDir + QLatin1Char('/') + candidate);
- if (fi.isFile())
- return fi.absoluteFilePath();
- }
- // Find the latest D3D compiler DLL in path (Windows 8.1 has d3dcompiler_47).
- if (platform.testFlag(IntelBased)) {
- QString errorMessage;
- unsigned detectedWordSize;
- for (const QString &candidate : qAsConst(candidateVersions)) {
- const QString dll = findInPath(candidate);
- if (!dll.isEmpty()
- && readPeExecutable(dll, &errorMessage, 0, &detectedWordSize, 0)
- && detectedWordSize == wordSize) {
- return dll;
- }
- }
- }
- return QString();
-}
-
-#else // Q_OS_WIN
-
-bool readPeExecutable(const QString &, QString *errorMessage,
- QStringList *, unsigned *, bool *, bool, unsigned short *)
-{
- *errorMessage = QStringLiteral("Not implemented.");
- return false;
-}
-
-QString findD3dCompiler(Platform, const QString &, unsigned)
-{
- return QString();
-}
-
-#endif // !Q_OS_WIN
-
-// Search for "qt_prfxpath=xxxx" in \a path, and replace it with "qt_prfxpath=."
-bool patchQtCore(const QString &path, QString *errorMessage)
-{
- if (optVerboseLevel)
- std::wcout << "Patching " << QFileInfo(path).fileName() << "...\n";
-
- QFile file(path);
- if (!file.open(QIODevice::ReadOnly)) {
- *errorMessage = QString::fromLatin1("Unable to patch %1: %2").arg(
- QDir::toNativeSeparators(path), file.errorString());
- return false;
- }
- const QByteArray oldContent = file.readAll();
-
- if (oldContent.isEmpty()) {
- *errorMessage = QString::fromLatin1("Unable to patch %1: Could not read file content").arg(
- QDir::toNativeSeparators(path));
- return false;
- }
- file.close();
-
- QByteArray content = oldContent;
-
- QByteArray prfxpath("qt_prfxpath=");
- int startPos = content.indexOf(prfxpath);
- if (startPos == -1) {
- *errorMessage = QString::fromLatin1(
- "Unable to patch %1: Could not locate pattern \"qt_prfxpath=\"").arg(
- QDir::toNativeSeparators(path));
- return false;
- }
- startPos += prfxpath.length();
- int endPos = content.indexOf(char(0), startPos);
- if (endPos == -1) {
- *errorMessage = QString::fromLatin1("Unable to patch %1: Internal error").arg(
- QDir::toNativeSeparators(path));
- return false;
- }
-
- QByteArray replacement = QByteArray(endPos - startPos, char(0));
- replacement[0] = '.';
- content.replace(startPos, endPos - startPos, replacement);
- if (content == oldContent)
- return true;
-
- if (!file.open(QIODevice::WriteOnly)
- || (file.write(content) != content.size())) {
- *errorMessage = QString::fromLatin1("Unable to patch %1: Could not write to file: %2").arg(
- QDir::toNativeSeparators(path), file.errorString());
- return false;
- }
- return true;
-}
-
-#ifdef Q_OS_WIN
-QString getArchString(unsigned short machineArch)
-{
- switch (machineArch) {
- case IMAGE_FILE_MACHINE_I386:
- return QStringLiteral("x86");
- case IMAGE_FILE_MACHINE_ARM:
- return QStringLiteral("arm");
- case IMAGE_FILE_MACHINE_AMD64:
- return QStringLiteral("x64");
- case IMAGE_FILE_MACHINE_ARM64:
- return QStringLiteral("arm64");
- default:
- break;
- }
- return QString();
-}
-#endif // Q_OS_WIN
-
-QT_END_NAMESPACE
diff --git a/src/shared/winutils/utils.h b/src/shared/winutils/utils.h
deleted file mode 100644
index 768a6bbbb..000000000
--- a/src/shared/winutils/utils.h
+++ /dev/null
@@ -1,404 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef UTILS_H
-#define UTILS_H
-
-#include <QStringList>
-#include <QMap>
-#include <QtCore/QFile>
-#include <QtCore/QDir>
-#include <QtCore/QDateTime>
-#include <QtCore/QJsonArray>
-#include <QtCore/QJsonObject>
-#include <QtCore/QJsonDocument>
-
-#include <iostream>
-
-QT_BEGIN_NAMESPACE
-
-enum PlatformFlag {
- // OS
- WindowsBased = 0x00001,
- UnixBased = 0x00002,
- // CPU
- IntelBased = 0x00010,
- ArmBased = 0x00020,
- // Compiler
- Msvc = 0x00100,
- MinGW = 0x00200,
- ClangMsvc = 0x00400,
- ClangMinGW = 0x00800,
- // Platforms
- WindowsDesktopMsvc = WindowsBased + IntelBased + Msvc,
- WindowsDesktopMinGW = WindowsBased + IntelBased + MinGW,
- WindowsDesktopClangMsvc = WindowsBased + IntelBased + ClangMsvc,
- WindowsDesktopClangMinGW = WindowsBased + IntelBased + ClangMinGW,
- Unix = UnixBased,
- UnknownPlatform
-};
-
-Q_DECLARE_FLAGS(Platform, PlatformFlag)
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(Platform)
-
-inline bool platformHasDebugSuffix(Platform p) // Uses 'd' debug suffix
-{
- return p.testFlag(Msvc) || p.testFlag(ClangMsvc);
-}
-
-enum ListOption {
- ListNone = 0,
- ListSource,
- ListTarget,
- ListRelative,
- ListMapping
-};
-
-inline std::wostream &operator<<(std::wostream &str, const QString &s)
-{
-#ifdef Q_OS_WIN
- str << reinterpret_cast<const wchar_t *>(s.utf16());
-#else
- str << s.toStdWString();
-#endif
- return str;
-}
-
-// Container class for JSON output
-class JsonOutput
-{
- using SourceTargetMapping = QPair<QString, QString>;
- using SourceTargetMappings = QList<SourceTargetMapping>;
-
-public:
- void addFile(const QString &source, const QString &target)
- {
- m_files.append(SourceTargetMapping(source, target));
- }
-
- void removeTargetDirectory(const QString &targetDirectory)
- {
- for (int i = m_files.size() - 1; i >= 0; --i) {
- if (m_files.at(i).second == targetDirectory)
- m_files.removeAt(i);
- }
- }
-
- QByteArray toJson() const
- {
- QJsonObject document;
- QJsonArray files;
- for (const SourceTargetMapping &mapping : m_files) {
- QJsonObject object;
- object.insert(QStringLiteral("source"), QDir::toNativeSeparators(mapping.first));
- object.insert(QStringLiteral("target"), QDir::toNativeSeparators(mapping.second));
- files.append(object);
- }
- document.insert(QStringLiteral("files"), files);
- return QJsonDocument(document).toJson();
- }
- QByteArray toList(ListOption option, const QDir &base) const
- {
- QByteArray list;
- for (const SourceTargetMapping &mapping : m_files) {
- const QString source = QDir::toNativeSeparators(mapping.first);
- const QString fileName = QFileInfo(mapping.first).fileName();
- const QString target = QDir::toNativeSeparators(mapping.second) + QDir::separator() + fileName;
- switch (option) {
- case ListNone:
- break;
- case ListSource:
- list += source.toUtf8() + '\n';
- break;
- case ListTarget:
- list += target.toUtf8() + '\n';
- break;
- case ListRelative:
- list += QDir::toNativeSeparators(base.relativeFilePath(target)).toUtf8() + '\n';
- break;
- case ListMapping:
- list += '"' + source.toUtf8() + "\" \"" + QDir::toNativeSeparators(base.relativeFilePath(target)).toUtf8() + "\"\n";
- break;
- }
- }
- return list;
- }
-private:
- SourceTargetMappings m_files;
-};
-
-#ifdef Q_OS_WIN
-QString normalizeFileName(const QString &name);
-QString winErrorMessage(unsigned long error);
-QString findSdkTool(const QString &tool);
-#else // !Q_OS_WIN
-inline QString normalizeFileName(const QString &name) { return name; }
-#endif // !Q_OS_WIN
-
-static const char windowsSharedLibrarySuffix[] = ".dll";
-static const char unixSharedLibrarySuffix[] = ".so";
-
-inline QString sharedLibrarySuffix(Platform platform) { return QLatin1String((platform & WindowsBased) ? windowsSharedLibrarySuffix : unixSharedLibrarySuffix); }
-bool isBuildDirectory(Platform platform, const QString &dirName);
-
-bool createSymbolicLink(const QFileInfo &source, const QString &target, QString *errorMessage);
-bool createDirectory(const QString &directory, QString *errorMessage);
-QString findInPath(const QString &file);
-
-extern const char *qmakeInfixKey; // Fake key containing the libinfix
-
-QMap<QString, QString> queryQMakeAll(const QString &qmakeBinary, QString *errorMessage);
-
-enum DebugMatchMode {
- MatchDebug,
- MatchRelease,
- MatchDebugOrRelease
-};
-
-QStringList findSharedLibraries(const QDir &directory, Platform platform,
- DebugMatchMode debugMatchMode,
- const QString &prefix = QString());
-
-bool updateFile(const QString &sourceFileName, const QStringList &nameFilters,
- const QString &targetDirectory, unsigned flags, JsonOutput *json, QString *errorMessage);
-bool runProcess(const QString &binary, const QStringList &args,
- const QString &workingDirectory = QString(),
- unsigned long *exitCode = 0, QByteArray *stdOut = 0, QByteArray *stdErr = 0,
- QString *errorMessage = 0);
-
-bool readPeExecutable(const QString &peExecutableFileName, QString *errorMessage,
- QStringList *dependentLibraries = 0, unsigned *wordSize = 0,
- bool *isDebug = 0, bool isMinGW = false, unsigned short *machineArch = nullptr);
-bool readElfExecutable(const QString &elfExecutableFileName, QString *errorMessage,
- QStringList *dependentLibraries = 0, unsigned *wordSize = 0,
- bool *isDebug = 0);
-
-inline bool readExecutable(const QString &executableFileName, Platform platform,
- QString *errorMessage, QStringList *dependentLibraries = 0,
- unsigned *wordSize = 0, bool *isDebug = 0, unsigned short *machineArch = nullptr)
-{
- return platform == Unix ?
- readElfExecutable(executableFileName, errorMessage, dependentLibraries, wordSize, isDebug) :
- readPeExecutable(executableFileName, errorMessage, dependentLibraries, wordSize, isDebug,
- (platform == WindowsDesktopMinGW), machineArch);
-}
-
-#ifdef Q_OS_WIN
-# if !defined(IMAGE_FILE_MACHINE_ARM64)
-# define IMAGE_FILE_MACHINE_ARM64 0xAA64
-# endif
-QString getArchString (unsigned short machineArch);
-#endif // Q_OS_WIN
-
-// Return dependent modules of executable files.
-
-inline QStringList findDependentLibraries(const QString &executableFileName, Platform platform, QString *errorMessage)
-{
- QStringList result;
- readExecutable(executableFileName, platform, errorMessage, &result);
- return result;
-}
-
-QString findD3dCompiler(Platform platform, const QString &qtBinDir, unsigned wordSize);
-
-bool patchQtCore(const QString &path, QString *errorMessage);
-
-extern int optVerboseLevel;
-
-// Recursively update a file or directory, matching DirectoryFileEntryFunction against the QDir
-// to obtain the files.
-enum UpdateFileFlag {
- ForceUpdateFile = 0x1,
- SkipUpdateFile = 0x2,
- RemoveEmptyQmlDirectories = 0x4,
- SkipQmlDesignerSpecificsDirectories = 0x8
-};
-
-template <class DirectoryFileEntryFunction>
-bool updateFile(const QString &sourceFileName,
- DirectoryFileEntryFunction directoryFileEntryFunction,
- const QString &targetDirectory,
- unsigned flags,
- JsonOutput *json,
- QString *errorMessage)
-{
- const QFileInfo sourceFileInfo(sourceFileName);
- const QString targetFileName = targetDirectory + QLatin1Char('/') + sourceFileInfo.fileName();
- if (optVerboseLevel > 1)
- std::wcout << "Checking " << sourceFileName << ", " << targetFileName << '\n';
-
- if (!sourceFileInfo.exists()) {
- *errorMessage = QString::fromLatin1("%1 does not exist.").arg(QDir::toNativeSeparators(sourceFileName));
- return false;
- }
-
- const QFileInfo targetFileInfo(targetFileName);
-
- if (sourceFileInfo.isSymLink()) {
- const QString sourcePath = sourceFileInfo.symLinkTarget();
- const QString relativeSource = QDir(sourceFileInfo.absolutePath()).relativeFilePath(sourcePath);
- if (relativeSource.contains(QLatin1Char('/'))) {
- *errorMessage = QString::fromLatin1("Symbolic links across directories are not supported (%1).")
- .arg(QDir::toNativeSeparators(sourceFileName));
- return false;
- }
-
- // Update the linked-to file
- if (!updateFile(sourcePath, directoryFileEntryFunction, targetDirectory, flags, json, errorMessage))
- return false;
-
- if (targetFileInfo.exists()) {
- if (!targetFileInfo.isSymLink()) {
- *errorMessage = QString::fromLatin1("%1 already exists and is not a symbolic link.")
- .arg(QDir::toNativeSeparators(targetFileName));
- return false;
- } // Not a symlink
- const QString relativeTarget = QDir(targetFileInfo.absolutePath()).relativeFilePath(targetFileInfo.symLinkTarget());
- if (relativeSource == relativeTarget) // Exists and points to same entry: happy.
- return true;
- QFile existingTargetFile(targetFileName);
- if (!(flags & SkipUpdateFile) && !existingTargetFile.remove()) {
- *errorMessage = QString::fromLatin1("Cannot remove existing symbolic link %1: %2")
- .arg(QDir::toNativeSeparators(targetFileName), existingTargetFile.errorString());
- return false;
- }
- } // target symbolic link exists
- return createSymbolicLink(QFileInfo(targetDirectory + QLatin1Char('/') + relativeSource), sourceFileInfo.fileName(), errorMessage);
- } // Source is symbolic link
-
- if (sourceFileInfo.isDir()) {
- if ((flags & SkipQmlDesignerSpecificsDirectories) && sourceFileInfo.fileName() == QLatin1String("designer")) {
- if (optVerboseLevel)
- std::wcout << "Skipping " << QDir::toNativeSeparators(sourceFileName) << ".\n";
- return true;
- }
- bool created = false;
- if (targetFileInfo.exists()) {
- if (!targetFileInfo.isDir()) {
- *errorMessage = QString::fromLatin1("%1 already exists and is not a directory.")
- .arg(QDir::toNativeSeparators(targetFileName));
- return false;
- } // Not a directory.
- } else { // exists.
- QDir d(targetDirectory);
- if (optVerboseLevel)
- std::wcout << "Creating " << targetFileName << ".\n";
- if (!(flags & SkipUpdateFile)) {
- created = d.mkdir(sourceFileInfo.fileName());
- if (!created) {
- *errorMessage = QString::fromLatin1("Cannot create directory %1 under %2.")
- .arg(sourceFileInfo.fileName(), QDir::toNativeSeparators(targetDirectory));
- return false;
- }
- }
- }
- // Recurse into directory
- QDir dir(sourceFileName);
-
- const QStringList allEntries = directoryFileEntryFunction(dir) + dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
- for (const QString &entry : allEntries)
- if (!updateFile(sourceFileName + QLatin1Char('/') + entry, directoryFileEntryFunction, targetFileName, flags, json, errorMessage))
- return false;
- // Remove empty directories, for example QML import folders for which the filter did not match.
- if (created && (flags & RemoveEmptyQmlDirectories)) {
- QDir d(targetFileName);
- const QStringList entries = d.entryList(QStringList(), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
- if (entries.isEmpty() || (entries.size() == 1 && entries.first() == QLatin1String("qmldir"))) {
- if (!d.removeRecursively()) {
- *errorMessage = QString::fromLatin1("Cannot remove empty directory %1.")
- .arg(QDir::toNativeSeparators(targetFileName));
- return false;
- }
- if (json)
- json->removeTargetDirectory(targetFileName);
- }
- }
- return true;
- } // Source is directory.
-
- if (targetFileInfo.exists()) {
- if (!(flags & ForceUpdateFile)
- && targetFileInfo.lastModified() >= sourceFileInfo.lastModified()) {
- if (optVerboseLevel)
- std::wcout << sourceFileInfo.fileName() << " is up to date.\n";
- if (json)
- json->addFile(sourceFileName, targetDirectory);
- return true;
- }
- QFile targetFile(targetFileName);
- if (!(flags & SkipUpdateFile) && !targetFile.remove()) {
- *errorMessage = QString::fromLatin1("Cannot remove existing file %1: %2")
- .arg(QDir::toNativeSeparators(targetFileName), targetFile.errorString());
- return false;
- }
- } // target exists
- QFile file(sourceFileName);
- if (optVerboseLevel)
- std::wcout << "Updating " << sourceFileInfo.fileName() << ".\n";
- if (!(flags & SkipUpdateFile)) {
- if (!file.copy(targetFileName)) {
- *errorMessage = QString::fromLatin1("Cannot copy %1 to %2: %3")
- .arg(QDir::toNativeSeparators(sourceFileName),
- QDir::toNativeSeparators(targetFileName),
- file.errorString());
- return false;
- }
- if (!(file.permissions() & QFile::WriteUser)) { // QTBUG-40152, clear inherited read-only attribute
- QFile targetFile(targetFileName);
- if (!targetFile.setPermissions(targetFile.permissions() | QFile::WriteUser)) {
- *errorMessage = QString::fromLatin1("Cannot set write permission on %1: %2")
- .arg(QDir::toNativeSeparators(targetFileName), file.errorString());
- return false;
- }
- } // Check permissions
- } // !SkipUpdateFile
- if (json)
- json->addFile(sourceFileName, targetDirectory);
- return true;
-}
-
-// Base class to filter files by name filters functions to be passed to updateFile().
-class NameFilterFileEntryFunction {
-public:
- explicit NameFilterFileEntryFunction(const QStringList &nameFilters) : m_nameFilters(nameFilters) {}
- QStringList operator()(const QDir &dir) const { return dir.entryList(m_nameFilters, QDir::Files); }
-
-private:
- const QStringList m_nameFilters;
-};
-
-// Convenience for all files.
-inline bool updateFile(const QString &sourceFileName, const QString &targetDirectory, unsigned flags, JsonOutput *json, QString *errorMessage)
-{
- return updateFile(sourceFileName, NameFilterFileEntryFunction(QStringList()), targetDirectory, flags, json, errorMessage);
-}
-
-QT_END_NAMESPACE
-
-#endif // UTILS_H