diff options
Diffstat (limited to 'src/plugins')
45 files changed, 172 insertions, 2038 deletions
diff --git a/src/plugins/platforms/android/.prev_CMakeLists.txt b/src/plugins/platforms/android/.prev_CMakeLists.txt index 4cb966004e..7b21613fb9 100644 --- a/src/plugins/platforms/android/.prev_CMakeLists.txt +++ b/src/plugins/platforms/android/.prev_CMakeLists.txt @@ -69,6 +69,11 @@ qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_vulkan Qt::VulkanSupportPrivate ) +qt_extend_target(QAndroidIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_android_style_assets SOURCES extract.cpp diff --git a/src/plugins/platforms/android/CMakeLists.txt b/src/plugins/platforms/android/CMakeLists.txt index 970c0de870..4d1f83053b 100644 --- a/src/plugins/platforms/android/CMakeLists.txt +++ b/src/plugins/platforms/android/CMakeLists.txt @@ -78,6 +78,11 @@ qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_vulkan Qt::VulkanSupportPrivate ) +qt_extend_target(QAndroidIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_android_style_assets SOURCES extract.cpp diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro index 61cac51633..8ea78f7cba 100644 --- a/src/plugins/platforms/android/android.pro +++ b/src/plugins/platforms/android/android.pro @@ -9,6 +9,8 @@ QT += \ qtConfig(vulkan): QT += vulkan_support-private +qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private + OTHER_FILES += $$PWD/android.json INCLUDEPATH += \ diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index e0c437be27..ae584965e6 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -43,6 +43,9 @@ #include <QtGui/private/qguiapplication_p.h> #include <QGuiApplication> #include <QOpenGLContext> +#if QT_CONFIG(opengl) +#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h> +#endif #include <QThread> #include <QOffscreenSurface> @@ -275,7 +278,12 @@ QPlatformBackingStore *QAndroidPlatformIntegration::createPlatformBackingStore(Q { if (!QtAndroid::activity()) return nullptr; - return new QAndroidPlatformBackingStore(window); + + auto *backingStore = new QAndroidPlatformBackingStore(window); +#if QT_CONFIG(opengl) + backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore)); +#endif // QT_CONFIG(opengl) + return backingStore; } QPlatformOpenGLContext *QAndroidPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const diff --git a/src/plugins/platforms/cocoa/.prev_CMakeLists.txt b/src/plugins/platforms/cocoa/.prev_CMakeLists.txt index 27cace4eb9..1491340b65 100644 --- a/src/plugins/platforms/cocoa/.prev_CMakeLists.txt +++ b/src/plugins/platforms/cocoa/.prev_CMakeLists.txt @@ -107,6 +107,11 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager qcocoasessionmanager.cpp qcocoasessionmanager.h ) +qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets SOURCES qpaintengine_mac.mm qpaintengine_mac_p.h @@ -114,7 +119,7 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets Qt::WidgetsPrivate ) -#### Keys ignored in scope 7:.:.:cocoa.pro:TARGET Qt::Widgets: +#### Keys ignored in scope 8:.:.:cocoa.pro:TARGET Qt::Widgets: # QT_FOR_CONFIG = "widgets" qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets @@ -141,5 +146,5 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_fontdialog AND TAR qcocoafontdialoghelper.h qcocoafontdialoghelper.mm ) -#### Keys ignored in scope 12:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +#### Keys ignored in scope 13:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: # PLUGIN_EXTENDS = "-" diff --git a/src/plugins/platforms/cocoa/CMakeLists.txt b/src/plugins/platforms/cocoa/CMakeLists.txt index 27b646d293..9e8b162aec 100644 --- a/src/plugins/platforms/cocoa/CMakeLists.txt +++ b/src/plugins/platforms/cocoa/CMakeLists.txt @@ -111,6 +111,11 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager qcocoasessionmanager.cpp qcocoasessionmanager.h ) +qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets SOURCES qpaintengine_mac.mm qpaintengine_mac_p.h @@ -118,7 +123,7 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets Qt::WidgetsPrivate ) -#### Keys ignored in scope 7:.:.:cocoa.pro:TARGET Qt::Widgets: +#### Keys ignored in scope 8:.:.:cocoa.pro:TARGET Qt::Widgets: # QT_FOR_CONFIG = "widgets" qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets @@ -145,5 +150,5 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_fontdialog AND TAR qcocoafontdialoghelper.h qcocoafontdialoghelper.mm ) -#### Keys ignored in scope 12:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +#### Keys ignored in scope 13:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: # PLUGIN_EXTENDS = "-" diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index a919963cf4..953346c56e 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -101,6 +101,8 @@ QT += \ qtConfig(vulkan): QT += vulkan_support-private +qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private + CONFIG += no_app_extension_api_only qtHaveModule(widgets) { diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index a77b97f538..b2698b05fe 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -68,6 +68,10 @@ #include <QtFontDatabaseSupport/private/qfontengine_coretext_p.h> +#if QT_CONFIG(opengl) +#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h> +#endif + #ifdef QT_WIDGETS_LIB #include <QtWidgets/qtwidgetsglobal.h> #if QT_CONFIG(filedialog) @@ -324,10 +328,16 @@ QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *wi return nullptr; } + QPlatformBackingStore *backingStore = nullptr; if (platformWindow->view().layer) - return new QCALayerBackingStore(window); + backingStore = new QCALayerBackingStore(window); else - return new QNSWindowBackingStore(window); + backingStore = new QNSWindowBackingStore(window); + +#if QT_CONFIG(opengl) + backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore)); +#endif + return backingStore; } QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const diff --git a/src/plugins/platforms/ios/.prev_CMakeLists.txt b/src/plugins/platforms/ios/.prev_CMakeLists.txt index f23cf8c300..d7ff160ee0 100644 --- a/src/plugins/platforms/ios/.prev_CMakeLists.txt +++ b/src/plugins/platforms/ios/.prev_CMakeLists.txt @@ -1,12 +1,12 @@ # Generated from ios.pro. ##################################################################### -## qios Plugin: +## QIOSIntegrationPlugin Plugin: ##################################################################### -add_qt_plugin(qios +add_qt_plugin(QIOSIntegrationPlugin + OUTPUT_NAME qios TYPE platforms - CLASS_NAME QIOSIntegrationPlugin SOURCES plugin.mm qiosapplicationdelegate.h qiosapplicationdelegate.mm @@ -26,37 +26,30 @@ add_qt_plugin(qios qioswindow.h qioswindow.mm quiaccessibilityelement.h quiaccessibilityelement.mm quiview.h quiview.mm - LIBRARIES - Qt::ClipboardSupportPrivate - Qt::CorePrivate - Qt::FontDatabaseSupportPrivate - Qt::GraphicsSupportPrivate - Qt::GuiPrivate PUBLIC_LIBRARIES ${FWAudioToolbox} ${FWFoundation} ${FWQuartzCore} ${FWUIKit} - Qt::ClipboardSupport - Qt::Core - Qt::FontDatabaseSupport - Qt::GraphicsSupport - Qt::Gui + Qt::ClipboardSupportPrivate + Qt::CorePrivate + Qt::FontDatabaseSupportPrivate + Qt::GraphicsSupportPrivate + Qt::GuiPrivate ) #### Keys ignored in scope 2:.:.:kernel.pro:<TRUE>: # OTHER_FILES = "quiview_textinput.mm" "quiview_accessibility.mm" -# PLUGIN_CLASS_NAME = "QIOSIntegrationPlugin" -# PLUGIN_TYPE = "platforms" -# _LOADED = "qt_plugin" ## Scopes: ##################################################################### -#### Keys ignored in scope 3:.:.:kernel.pro:QT_FEATURE_shared: -# CONFIG = "static" +extend_target(QIOSIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) -extend_target(qios CONDITION NOT APPLE_TVOS +extend_target(QIOSIntegrationPlugin CONDITION NOT APPLE_TVOS SOURCES qiosclipboard.h qiosclipboard.mm qiosfiledialog.h qiosfiledialog.mm @@ -67,15 +60,6 @@ extend_target(qios CONDITION NOT APPLE_TVOS ${FWAssetsLibrary} ) -#### Keys ignored in scope 5:.:.:kernel.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +#### Keys ignored in scope 6:.:.:kernel.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: # PLUGIN_EXTENDS = "-" add_subdirectory(optional) - - if(QT_FEATURE_shared) - endif() - - if(NOT APPLE_TVOS) - endif() - - if(NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN) - endif() diff --git a/src/plugins/platforms/ios/CMakeLists.txt b/src/plugins/platforms/ios/CMakeLists.txt index d8912866b0..d7ff160ee0 100644 --- a/src/plugins/platforms/ios/CMakeLists.txt +++ b/src/plugins/platforms/ios/CMakeLists.txt @@ -44,6 +44,11 @@ add_qt_plugin(QIOSIntegrationPlugin ## Scopes: ##################################################################### +extend_target(QIOSIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + extend_target(QIOSIntegrationPlugin CONDITION NOT APPLE_TVOS SOURCES qiosclipboard.h qiosclipboard.mm @@ -55,6 +60,6 @@ extend_target(QIOSIntegrationPlugin CONDITION NOT APPLE_TVOS ${FWAssetsLibrary} ) -#### Keys ignored in scope 5:.:.:kernel.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +#### Keys ignored in scope 6:.:.:kernel.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: # PLUGIN_EXTENDS = "-" add_subdirectory(optional) diff --git a/src/plugins/platforms/ios/kernel.pro b/src/plugins/platforms/ios/kernel.pro index 71257d09f7..01e0105223 100644 --- a/src/plugins/platforms/ios/kernel.pro +++ b/src/plugins/platforms/ios/kernel.pro @@ -9,6 +9,8 @@ QT += \ core-private gui-private \ clipboard_support-private fontdatabase_support-private graphics_support-private +qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private + LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AudioToolbox OBJECTIVE_SOURCES = \ diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 9eca0eaad3..d724e65717 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -65,6 +65,10 @@ #import <AudioToolbox/AudioServices.h> +#if QT_CONFIG(opengl) +#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h> +#endif + #include <QtDebug> QT_BEGIN_NAMESPACE @@ -186,7 +190,11 @@ QPlatformWindow *QIOSIntegration::createPlatformWindow(QWindow *window) const // Used when the QWindow's surface type is set by the client to QSurface::RasterSurface QPlatformBackingStore *QIOSIntegration::createPlatformBackingStore(QWindow *window) const { - return new QIOSBackingStore(window); + auto *backingStore = new QIOSBackingStore(window); +#if QT_CONFIG(opengl) + backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore)); +#endif + return backingStore; } // Used when the QWindow's surface type is set by the client to QSurface::OpenGLSurface diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 6bf0d69770..74890ead82 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -36,7 +36,6 @@ #include <QtGui/private/qwindow_p.h> #include <QtGui/qopenglcontext.h> #include <QtGui/qopenglfunctions.h> -#include <QtGui/qopengltextureblitter.h> #include <QtGui/qoffscreensurface.h> #include <QtGui/qpainter.h> #include <private/qpixmapcache_p.h> diff --git a/src/plugins/platforms/wasm/qwasmcompositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h index 6b59d87a0a..250d244c9f 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.h +++ b/src/plugins/platforms/wasm/qwasmcompositor.h @@ -33,7 +33,7 @@ #include <QtGui/qregion.h> #include <qpa/qplatformwindow.h> -#include <QtGui/qopengltextureblitter.h> +#include <QtOpenGL/qopengltextureblitter.h> #include <QtGui/qpalette.h> #include <QtGui/qpainter.h> @@ -43,7 +43,6 @@ class QWasmWindow; class QWasmScreen; class QOpenGLContext; class QOpenGLTexture; -class QOpenGLTextureBlitter; class QWasmCompositedWindow { diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index fd53cd0bae..ce83ad4e2f 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -41,6 +41,7 @@ #include "qwasmwindow.h" #ifndef QT_NO_OPENGL # include "qwasmbackingstore.h" +# include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h> #endif #include "qwasmfontdatabase.h" #if defined(Q_OS_UNIX) @@ -185,6 +186,7 @@ QPlatformBackingStore *QWasmIntegration::createPlatformBackingStore(QWindow *win #ifndef QT_NO_OPENGL QWasmCompositor *compositor = QWasmScreen::get(window->screen())->compositor(); QWasmBackingStore *backingStore = new QWasmBackingStore(compositor, window); + backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore)); m_backingStores.insert(window, backingStore); return backingStore; #else diff --git a/src/plugins/platforms/wasm/wasm.pro b/src/plugins/platforms/wasm/wasm.pro index c8b28fb37d..1aee4a3e58 100644 --- a/src/plugins/platforms/wasm/wasm.pro +++ b/src/plugins/platforms/wasm/wasm.pro @@ -4,6 +4,8 @@ QT += \ core-private gui-private \ eventdispatcher_support-private fontdatabase_support-private egl_support-private +qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private + # Avoid X11 header collision, use generic EGL native types DEFINES += QT_EGL_NO_X11 diff --git a/src/plugins/platforms/windows/.prev_CMakeLists.txt b/src/plugins/platforms/windows/.prev_CMakeLists.txt index 462e83ac56..57b7fede9f 100644 --- a/src/plugins/platforms/windows/.prev_CMakeLists.txt +++ b/src/plugins/platforms/windows/.prev_CMakeLists.txt @@ -86,6 +86,11 @@ qt_add_resource(QWindowsIntegrationPlugin "openglblacklists" ## Scopes: ##################################################################### +qt_extend_target(QWindowsIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility SOURCES uiautomation/qwindowsuiaaccessibility.cpp uiautomation/qwindowsuiaaccessibility.h @@ -117,7 +122,7 @@ qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_vulkan Qt::VulkanSupportPrivate ) -#### Keys ignored in scope 4:.:.:windows.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +#### Keys ignored in scope 5:.:.:windows.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: # PLUGIN_EXTENDS = "-" qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_dynamicgl AND NOT QT_FEATURE_opengles2 diff --git a/src/plugins/platforms/windows/CMakeLists.txt b/src/plugins/platforms/windows/CMakeLists.txt index 0481246384..0c903d8757 100644 --- a/src/plugins/platforms/windows/CMakeLists.txt +++ b/src/plugins/platforms/windows/CMakeLists.txt @@ -87,6 +87,11 @@ qt_add_resource(QWindowsIntegrationPlugin "openglblacklists" ## Scopes: ##################################################################### +qt_extend_target(QWindowsIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility SOURCES uiautomation/qwindowsuiaaccessibility.cpp uiautomation/qwindowsuiaaccessibility.h @@ -118,7 +123,7 @@ qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_vulkan Qt::VulkanSupportPrivate ) -#### Keys ignored in scope 4:.:.:windows.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +#### Keys ignored in scope 5:.:.:windows.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: # PLUGIN_EXTENDS = "-" qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_dynamicgl AND NOT QT_FEATURE_opengles2 diff --git a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp index c88f669eb5..7e9595321a 100644 --- a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp @@ -45,6 +45,10 @@ #include <QtCore/qdebug.h> #include <QtGui/private/qpixmap_raster_p.h> +#if QT_CONFIG(opengl) +#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h> +#endif + QT_BEGIN_NAMESPACE class QWindowsGdiIntegrationPrivate @@ -73,7 +77,11 @@ QPlatformPixmap *QWindowsGdiIntegration::createPlatformPixmap(QPlatformPixmap::P QPlatformBackingStore *QWindowsGdiIntegration::createPlatformBackingStore(QWindow *window) const { - return new QWindowsBackingStore(window); + auto *backingStore = new QWindowsBackingStore(window); +#ifndef QT_NO_OPENGL + backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore)); +#endif + return backingStore; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 4b4047ac0c..77340387d8 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -48,6 +48,9 @@ #include "qwindowsscreen.h" #include "qwindowstheme.h" #include "qwindowsservices.h" +#ifdef QT_USE_DIRECTWRITE3 +#include <QtFontDatabaseSupport/private/qwindowsdirectwritefontdatabase_p.h> +#endif #ifndef QT_NO_FREETYPE # include <QtFontDatabaseSupport/private/qwindowsfontdatabase_ft_p.h> #endif @@ -187,7 +190,9 @@ static inline unsigned parseOptions(const QStringList ¶mList, unsigned options = 0; for (const QString ¶m : paramList) { if (param.startsWith(u"fontengine=")) { - if (param.endsWith(u"freetype")) { + if (param.endsWith(u"directwrite")) { + options |= QWindowsIntegration::FontDatabaseDirectWrite; + } else if (param.endsWith(u"freetype")) { options |= QWindowsIntegration::FontDatabaseFreeType; } else if (param.endsWith(u"native")) { options |= QWindowsIntegration::FontDatabaseNative; @@ -504,14 +509,17 @@ QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext() QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const { if (!d->m_fontDatabase) { -#ifdef QT_NO_FREETYPE - d->m_fontDatabase = new QWindowsFontDatabase(); -#else // QT_NO_FREETYPE +#ifdef QT_USE_DIRECTWRITE3 + if (d->m_options & QWindowsIntegration::FontDatabaseDirectWrite) + d->m_fontDatabase = new QWindowsDirectWriteFontDatabase; + else +#endif +#ifndef QT_NO_FREETYPE if (d->m_options & QWindowsIntegration::FontDatabaseFreeType) d->m_fontDatabase = new QWindowsFontDatabaseFT; else - d->m_fontDatabase = new QWindowsFontDatabase; #endif // QT_NO_FREETYPE + d->m_fontDatabase = new QWindowsFontDatabase(); } return d->m_fontDatabase; } diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index 1f16d13769..165472ad40 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -72,7 +72,8 @@ public: DetectAltGrModifier = 0x800, RtlEnabled = 0x1000, DarkModeWindowFrames = 0x2000, - DarkModeStyle = 0x4000 + DarkModeStyle = 0x4000, + FontDatabaseDirectWrite = 0x8000 }; explicit QWindowsIntegration(const QStringList ¶mList); diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro index 50a3bb41a9..8a27bd2770 100644 --- a/src/plugins/platforms/windows/windows.pro +++ b/src/plugins/platforms/windows/windows.pro @@ -5,6 +5,8 @@ QT += \ eventdispatcher_support-private \ fontdatabase_support-private theme_support-private +qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private + qtConfig(accessibility): QT += accessibility_support-private qtConfig(vulkan): QT += vulkan_support-private diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp index 27d3746933..dd8cd80fd9 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.cpp +++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp @@ -53,6 +53,9 @@ #if QT_CONFIG(accessibility) # include "uiautomation/qwinrtuiaaccessibility.h" #endif +#if QT_CONFIG(opengl) +#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h> +#endif #include <QtGui/QOffscreenSurface> #include <QtGui/QOpenGLContext> @@ -205,7 +208,11 @@ QPlatformWindow *QWinRTIntegration::createPlatformWindow(QWindow *window) const QPlatformBackingStore *QWinRTIntegration::createPlatformBackingStore(QWindow *window) const { - return new QWinRTBackingStore(window); + auto *backingStore = new QWinRTBackingStore(window); +#if QT_CONFIG(opengl) + backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore)); +#endif + return backingStore; } QPlatformOpenGLContext *QWinRTIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 43dc8f074c..7ac49f73c4 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -6,6 +6,8 @@ QT += \ core-private gui-private \ fontdatabase_support-private egl_support-private +qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private + DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__ QMAKE_USE_PRIVATE += d3d11 ws2_32 diff --git a/src/plugins/platforms/xcb/.prev_CMakeLists.txt b/src/plugins/platforms/xcb/.prev_CMakeLists.txt index e15d45aa63..427997fc66 100644 --- a/src/plugins/platforms/xcb/.prev_CMakeLists.txt +++ b/src/plugins/platforms/xcb/.prev_CMakeLists.txt @@ -66,6 +66,11 @@ qt_add_module(XcbQpa ## Scopes: ##################################################################### +qt_extend_target(XcbQpa CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + qt_extend_target(XcbQpa CONDITION TARGET Qt::LinuxAccessibilitySupportPrivate PUBLIC_LIBRARIES Qt::LinuxAccessibilitySupportPrivate @@ -150,12 +155,12 @@ qt_add_plugin(QXcbIntegrationPlugin Qt::XcbQpaPrivate ) -#### Keys ignored in scope 19:.:.:xcb-plugin.pro:<TRUE>: +#### Keys ignored in scope 20:.:.:xcb-plugin.pro:<TRUE>: # OTHER_FILES = "xcb.json" "README" ## Scopes: ##################################################################### -#### Keys ignored in scope 21:.:.:xcb-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +#### Keys ignored in scope 22:.:.:xcb-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: # PLUGIN_EXTENDS = "-" add_subdirectory(gl_integrations) diff --git a/src/plugins/platforms/xcb/CMakeLists.txt b/src/plugins/platforms/xcb/CMakeLists.txt index 1bb8d7f53f..d422d69891 100644 --- a/src/plugins/platforms/xcb/CMakeLists.txt +++ b/src/plugins/platforms/xcb/CMakeLists.txt @@ -89,6 +89,11 @@ qt_add_module(XcbQpa ## Scopes: ##################################################################### +qt_extend_target(XcbQpa CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + qt_extend_target(XcbQpa CONDITION TARGET Qt::LinuxAccessibilitySupportPrivate PUBLIC_LIBRARIES Qt::LinuxAccessibilitySupportPrivate @@ -190,13 +195,13 @@ qt_add_plugin(QXcbIntegrationPlugin Qt::XcbQpaPrivate ) -#### Keys ignored in scope 19:.:.:xcb-plugin.pro:<TRUE>: +#### Keys ignored in scope 20:.:.:xcb-plugin.pro:<TRUE>: # OTHER_FILES = "xcb.json" "README" ## Scopes: ##################################################################### -#### Keys ignored in scope 21:.:.:xcb-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +#### Keys ignored in scope 22:.:.:xcb-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: # PLUGIN_EXTENDS = "-" add_subdirectory(gl_integrations) if(OFF) diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 3fd989e1f9..cea0511822 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -61,6 +61,9 @@ #include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h> #include <QtServiceSupport/private/qgenericunixservices_p.h> +#if QT_CONFIG(opengl) +#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h> +#endif #include <stdio.h> @@ -288,16 +291,23 @@ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLCont QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *window) const { - const bool isTrayIconWindow = QXcbWindow::isTrayIconWindow(window); - if (isTrayIconWindow) - return new QXcbSystemTrayBackingStore(window); + QPlatformBackingStore *backingStore = nullptr; + const bool isTrayIconWindow = QXcbWindow::isTrayIconWindow(window); + if (isTrayIconWindow) { + backingStore = new QXcbSystemTrayBackingStore(window); #if QT_CONFIG(xcb_native_painting) - if (nativePaintingEnabled()) - return new QXcbNativeBackingStore(window); + } else if (nativePaintingEnabled()) { + backingStore = new QXcbNativeBackingStore(window); #endif - - return new QXcbBackingStore(window); + } else { + backingStore = new QXcbBackingStore(window); + } + Q_ASSERT(backingStore); +#ifndef QT_NO_OPENGL + backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore)); +#endif + return backingStore; } QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro index a5d05faa9c..1f651e7697 100644 --- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro +++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro @@ -9,6 +9,9 @@ QT += \ edid_support-private \ xkbcommon_support-private +qtHaveModule(platformcompositor_support-private): \ + QT += platformcompositor_support-private + qtHaveModule(linuxaccessibility_support-private): \ QT += linuxaccessibility_support-private diff --git a/src/plugins/sqldrivers/README b/src/plugins/sqldrivers/README index 26418c5e36..7da95fe53c 100644 --- a/src/plugins/sqldrivers/README +++ b/src/plugins/sqldrivers/README @@ -1,4 +1,4 @@ -Please note that the DB2, MySQL, Oracle and TDS client drivers are not +Please note that the DB2, MySQL and Oracle client drivers are not distributed with the Qt Open Source Editions. This is because the client libraries are distributed under a license which diff --git a/src/plugins/sqldrivers/configure.cmake b/src/plugins/sqldrivers/configure.cmake index c8005e16a7..7cf0763da1 100644 --- a/src/plugins/sqldrivers/configure.cmake +++ b/src/plugins/sqldrivers/configure.cmake @@ -44,15 +44,7 @@ qt_feature("sql-psql" PRIVATE LABEL "PostgreSQL" CONDITION PostgreSQL_FOUND ) -qt_feature("sql-sqlite2" PRIVATE - LABEL "SQLite2" - CONDITION libs.sqlite2 OR FIXME -) qt_feature("sql-sqlite" PRIVATE LABEL "SQLite" CONDITION QT_FEATURE_datestring AND SQLite3_FOUND ) -qt_feature("sql-tds" PRIVATE - LABEL "TDS (Sybase)" - CONDITION QT_FEATURE_datestring AND libs.tds OR FIXME -) diff --git a/src/plugins/sqldrivers/configure.json b/src/plugins/sqldrivers/configure.json index 94cf2dd4a5..f738e58a00 100644 --- a/src/plugins/sqldrivers/configure.json +++ b/src/plugins/sqldrivers/configure.json @@ -7,9 +7,7 @@ "commandline": { "assignments": { - "MYSQL_PATH": "mysql.prefix", - "SYBASE": "tds.prefix", - "SYBASE_LIBS": "tds.libs" + "MYSQL_PATH": "mysql.prefix" }, "options": { "mysql_config": "string", @@ -22,17 +20,13 @@ "sql-odbc": "boolean", "sql-psql": "boolean", "sql-sqlite": "boolean", - "sql-sqlite2": "boolean", - "sql-tds": "boolean", "plugin-sql-db2": { "type": "void", "name": "sql-db2" }, "plugin-sql-ibase": { "type": "void", "name": "sql-ibase" }, "plugin-sql-mysql": { "type": "void", "name": "sql-mysql" }, "plugin-sql-oci": { "type": "void", "name": "sql-oci" }, "plugin-sql-odbc": { "type": "void", "name": "sql-odbc" }, "plugin-sql-psql": { "type": "void", "name": "sql-psql" }, - "plugin-sql-sqlite": { "type": "void", "name": "sql-sqlite" }, - "plugin-sql-sqlite2": { "type": "void", "name": "sql-sqlite2" }, - "plugin-sql-tds": { "type": "void", "name": "sql-tds" } + "plugin-sql-sqlite": { "type": "void", "name": "sql-sqlite" } } }, @@ -94,15 +88,6 @@ { "type": "psqlEnv", "libs": "-lpq", "condition": "!config.win32" } ] }, - "tds": { - "label": "TDS (Sybase)", - "test": {}, - "headers": [ "sybfront.h", "sybdb.h" ], - "sources": [ - { "type": "sybaseEnv", "libs": "-lNTWDBLIB", "condition": "config.win32" }, - { "type": "sybaseEnv", "libs": "-lsybdb", "condition": "!config.win32" } - ] - }, "oci": { "label": "OCI (Oracle)", "test": {}, @@ -132,14 +117,6 @@ { "libs": "-lodbc", "condition": "!config.win32 && !config.darwin" } ] }, - "sqlite2": { - "label": "SQLite (version 2)", - "test": {}, - "headers": "sqlite.h", - "sources": [ - "-lsqlite" - ] - }, "sqlite3": { "label": "SQLite (version 3)", "export": "sqlite", @@ -191,11 +168,6 @@ "condition": "libs.psql", "output": [ "privateFeature" ] }, - "sql-sqlite2": { - "label": "SQLite2", - "condition": "libs.sqlite2", - "output": [ "privateFeature" ] - }, "sql-sqlite": { "label": "SQLite", "condition": "features.datestring", @@ -206,11 +178,6 @@ "autoDetect": false, "condition": "features.sql-sqlite && libs.sqlite3", "output": [ "privateFeature" ] - }, - "sql-tds": { - "label": "TDS (Sybase)", - "condition": "features.datestring && libs.tds", - "output": [ "privateFeature" ] } }, @@ -227,7 +194,7 @@ "section": "Qt Sql Drivers", "entries": [ "sql-db2", "sql-ibase", "sql-mysql", "sql-oci", "sql-odbc", "sql-psql", - "sql-sqlite2", "sql-sqlite", "system-sqlite", "sql-tds" + "sql-sqlite", "system-sqlite" ] } ] diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp index 7bacb59994..ae213365b7 100644 --- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp +++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp @@ -1913,15 +1913,8 @@ void QIBaseDriver::qHandleEventNotification(void *updatedResultBuffer) isc_event_counts(counts, eBuffer->bufferLength, eBuffer->eventBuffer, eBuffer->resultBuffer); if (counts[0]) { - if (eBuffer->subscriptionState == QIBaseEventBuffer::Subscribed) { -#if QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - emit notification(i.key()); -QT_WARNING_POP -#endif + if (eBuffer->subscriptionState == QIBaseEventBuffer::Subscribed) emit notification(i.key(), QSqlDriver::UnknownSource, QVariant()); - } else if (eBuffer->subscriptionState == QIBaseEventBuffer::Starting) eBuffer->subscriptionState = QIBaseEventBuffer::Subscribed; diff --git a/src/plugins/sqldrivers/sqldrivers.pro b/src/plugins/sqldrivers/sqldrivers.pro index 8a9ae46f82..f1db8f65a2 100644 --- a/src/plugins/sqldrivers/sqldrivers.pro +++ b/src/plugins/sqldrivers/sqldrivers.pro @@ -8,9 +8,7 @@ sqldrivers_standalone { qtConfig(sql-psql) : SUBDIRS += psql qtConfig(sql-mysql) : SUBDIRS += mysql qtConfig(sql-odbc) : SUBDIRS += odbc -qtConfig(sql-tds) : SUBDIRS += tds qtConfig(sql-oci) : SUBDIRS += oci qtConfig(sql-db2) : SUBDIRS += db2 qtConfig(sql-sqlite) : SUBDIRS += sqlite -qtConfig(sql-sqlite2) : SUBDIRS += sqlite2 qtConfig(sql-ibase) : SUBDIRS += ibase diff --git a/src/plugins/sqldrivers/sqlite2/README b/src/plugins/sqldrivers/sqlite2/README deleted file mode 100644 index 899361a6f5..0000000000 --- a/src/plugins/sqldrivers/sqlite2/README +++ /dev/null @@ -1,6 +0,0 @@ -You will need the SQLite development headers and libraries installed -before compiling this plugin. - -See the Qt SQL documentation for more information on compiling Qt SQL -driver plugins (sql-driver.html). - diff --git a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp deleted file mode 100644 index b7bcd044ab..0000000000 --- a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp +++ /dev/null @@ -1,615 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSql module 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$ -** -****************************************************************************/ - -#include "qsql_sqlite2_p.h" - -#include <qcoreapplication.h> -#include <qvariant.h> -#include <qdatetime.h> -#include <qfile.h> -#include <qsqlerror.h> -#include <qsqlfield.h> -#include <qsqlindex.h> -#include <qsqlquery.h> -#include <QtSql/private/qsqlcachedresult_p.h> -#include <QtSql/private/qsqldriver_p.h> -#include <qstringlist.h> -#include <qvector.h> - -#if !defined Q_OS_WIN -# include <unistd.h> -#endif -#include <sqlite.h> - -typedef struct sqlite_vm sqlite_vm; - -Q_DECLARE_OPAQUE_POINTER(sqlite_vm*) -Q_DECLARE_METATYPE(sqlite_vm*) - -Q_DECLARE_OPAQUE_POINTER(sqlite*) -Q_DECLARE_METATYPE(sqlite*) - -QT_BEGIN_NAMESPACE - -static QVariant::Type nameToType(const QString& typeName) -{ - QString tName = typeName.toUpper(); - if (tName.startsWith(QLatin1String("INT"))) - return QVariant::Int; - if (tName.startsWith(QLatin1String("FLOAT")) || tName.startsWith(QLatin1String("NUMERIC"))) - return QVariant::Double; - if (tName.startsWith(QLatin1String("BOOL"))) - return QVariant::Bool; - // SQLite is typeless - consider everything else as string - return QVariant::String; -} - -class QSQLite2DriverPrivate : public QSqlDriverPrivate -{ - Q_DECLARE_PUBLIC(QSQLite2Driver) - -public: - QSQLite2DriverPrivate(); - sqlite *access; - bool utf8; -}; - -QSQLite2DriverPrivate::QSQLite2DriverPrivate() : QSqlDriverPrivate(), access(0) -{ - utf8 = (qstrcmp(sqlite_encoding, "UTF-8") == 0); - dbmsType = QSqlDriver::SQLite; -} - -class QSQLite2ResultPrivate; - -class QSQLite2Result : public QSqlCachedResult -{ - Q_DECLARE_PRIVATE(QSQLite2Result) - friend class QSQLite2Driver; - -public: - explicit QSQLite2Result(const QSQLite2Driver* db); - ~QSQLite2Result(); - QVariant handle() const override; - -protected: - bool gotoNext(QSqlCachedResult::ValueCache &row, int idx) override; - bool reset(const QString &query) override; - int size() override; - int numRowsAffected() override; - QSqlRecord record() const override; - void detachFromResultSet() override; - void virtual_hook(int id, void *data) override; -}; - -class QSQLite2ResultPrivate: public QSqlCachedResultPrivate -{ - Q_DECLARE_PUBLIC(QSQLite2Result) - -public: - Q_DECLARE_SQLDRIVER_PRIVATE(QSQLite2Driver); - QSQLite2ResultPrivate(QSQLite2Result *q, const QSQLite2Driver *drv); - void cleanup(); - bool fetchNext(QSqlCachedResult::ValueCache &values, int idx, bool initialFetch); - bool isSelect(); - // initializes the recordInfo and the cache - void init(const char **cnames, int numCols); - void finalize(); - - // and we have too keep our own struct for the data (sqlite works via - // callback. - const char *currentTail; - sqlite_vm *currentMachine; - - bool skippedStatus; // the status of the fetchNext() that's skipped - bool skipRow; // skip the next fetchNext()? - QSqlRecord rInf; - QVector<QVariant> firstRow; -}; - -QSQLite2ResultPrivate::QSQLite2ResultPrivate(QSQLite2Result *q, const QSQLite2Driver *drv) - : QSqlCachedResultPrivate(q, drv), - currentTail(0), - currentMachine(0), - skippedStatus(false), - skipRow(false) -{ -} - -void QSQLite2ResultPrivate::cleanup() -{ - Q_Q(QSQLite2Result); - finalize(); - rInf.clear(); - currentTail = 0; - currentMachine = 0; - skippedStatus = false; - skipRow = false; - q->setAt(QSql::BeforeFirstRow); - q->setActive(false); - q->cleanup(); -} - -void QSQLite2ResultPrivate::finalize() -{ - Q_Q(QSQLite2Result); - if (!currentMachine) - return; - - char* err = 0; - int res = sqlite_finalize(currentMachine, &err); - if (err) { - q->setLastError(QSqlError(QCoreApplication::translate("QSQLite2Result", - "Unable to fetch results"), QString::fromLatin1(err), - QSqlError::StatementError, - res != -1 ? QString::number(res) : QString())); - sqlite_freemem(err); - } - currentMachine = 0; -} - -// called on first fetch -void QSQLite2ResultPrivate::init(const char **cnames, int numCols) -{ - Q_Q(QSQLite2Result); - if (!cnames) - return; - - rInf.clear(); - if (numCols <= 0) - return; - q->init(numCols); - - for (int i = 0; i < numCols; ++i) { - const char* lastDot = strrchr(cnames[i], '.'); - const char* fieldName = lastDot ? lastDot + 1 : cnames[i]; - - //remove quotations around the field name if any - QString fieldStr = QString::fromLatin1(fieldName); - QLatin1Char quote('\"'); - if ( fieldStr.length() > 2 && fieldStr.startsWith(quote) && fieldStr.endsWith(quote)) { - fieldStr = fieldStr.mid(1); - fieldStr.chop(1); - } - rInf.append(QSqlField(fieldStr, - nameToType(QString::fromLatin1(cnames[i+numCols])))); - } -} - -bool QSQLite2ResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int idx, bool initialFetch) -{ - Q_Q(QSQLite2Result); - // may be caching. - const char **fvals; - const char **cnames; - int colNum; - int res; - int i; - - if (skipRow) { - // already fetched - Q_ASSERT(!initialFetch); - skipRow = false; - for(int i=0;i<firstRow.count(); i++) - values[i] = firstRow[i]; - return skippedStatus; - } - skipRow = initialFetch; - - if (!currentMachine) - return false; - - // keep trying while busy, wish I could implement this better. - while ((res = sqlite_step(currentMachine, &colNum, &fvals, &cnames)) == SQLITE_BUSY) { - // sleep instead requesting result again immidiately. -#if defined Q_OS_WIN - Sleep(1000); -#else - sleep(1); -#endif - } - - if(initialFetch) { - firstRow.clear(); - firstRow.resize(colNum); - } - - switch(res) { - case SQLITE_ROW: - // check to see if should fill out columns - if (rInf.isEmpty()) - // must be first call. - init(cnames, colNum); - if (!fvals) - return false; - if (idx < 0 && !initialFetch) - return true; - for (i = 0; i < colNum; ++i) - values[i + idx] = drv_d_func()->utf8 ? QString::fromUtf8(fvals[i]) : QString::fromLatin1(fvals[i]); - return true; - case SQLITE_DONE: - if (rInf.isEmpty()) - // must be first call. - init(cnames, colNum); - q->setAt(QSql::AfterLastRow); - return false; - case SQLITE_ERROR: - case SQLITE_MISUSE: - default: - // something wrong, don't get col info, but still return false - finalize(); // finalize to get the error message. - q->setAt(QSql::AfterLastRow); - return false; - } - return false; -} - -QSQLite2Result::QSQLite2Result(const QSQLite2Driver* db) - : QSqlCachedResult(*new QSQLite2ResultPrivate(this, db)) -{ -} - -QSQLite2Result::~QSQLite2Result() -{ - Q_D(QSQLite2Result); - d->cleanup(); -} - -void QSQLite2Result::virtual_hook(int id, void *data) -{ - QSqlCachedResult::virtual_hook(id, data); -} - -/* - Execute \a query. -*/ -bool QSQLite2Result::reset (const QString& query) -{ - Q_D(QSQLite2Result); - // this is where we build a query. - if (!driver()) - return false; - if (!driver()-> isOpen() || driver()->isOpenError()) - return false; - - d->cleanup(); - - // Um, ok. callback based so.... pass private static function for this. - setSelect(false); - char *err = 0; - int res = sqlite_compile(d->drv_d_func()->access, - d->drv_d_func()->utf8 ? query.toUtf8().constData() - : query.toLatin1().constData(), - &(d->currentTail), - &(d->currentMachine), - &err); - if (res != SQLITE_OK || err) { - setLastError(QSqlError(QCoreApplication::translate("QSQLite2Result", - "Unable to execute statement"), QString::fromLatin1(err), - QSqlError::StatementError, res)); - sqlite_freemem(err); - } - //if (*d->currentTail != '\000' then there is more sql to eval - if (!d->currentMachine) { - setActive(false); - return false; - } - // we have to fetch one row to find out about - // the structure of the result set - d->skippedStatus = d->fetchNext(d->firstRow, 0, true); - if (lastError().isValid()) { - setSelect(false); - setActive(false); - return false; - } - setSelect(!d->rInf.isEmpty()); - setActive(true); - return true; -} - -bool QSQLite2Result::gotoNext(QSqlCachedResult::ValueCache& row, int idx) -{ - Q_D(QSQLite2Result); - return d->fetchNext(row, idx, false); -} - -int QSQLite2Result::size() -{ - return -1; -} - -int QSQLite2Result::numRowsAffected() -{ - Q_D(QSQLite2Result); - return sqlite_changes(d->drv_d_func()->access); -} - -QSqlRecord QSQLite2Result::record() const -{ - Q_D(const QSQLite2Result); - if (!isActive() || !isSelect()) - return QSqlRecord(); - return d->rInf; -} - -void QSQLite2Result::detachFromResultSet() -{ - Q_D(QSQLite2Result); - d->finalize(); -} - -QVariant QSQLite2Result::handle() const -{ - Q_D(const QSQLite2Result); - return QVariant::fromValue(d->currentMachine); -} - -///////////////////////////////////////////////////////// - -QSQLite2Driver::QSQLite2Driver(QObject *parent) - : QSqlDriver(*new QSQLite2DriverPrivate, parent) -{ -} - -QSQLite2Driver::QSQLite2Driver(sqlite *connection, QObject *parent) - : QSqlDriver(*new QSQLite2DriverPrivate, parent) -{ - Q_D(QSQLite2Driver); - d->access = connection; - setOpen(true); - setOpenError(false); -} - - -QSQLite2Driver::~QSQLite2Driver() -{ -} - -bool QSQLite2Driver::hasFeature(DriverFeature f) const -{ - Q_D(const QSQLite2Driver); - switch (f) { - case Transactions: - case SimpleLocking: - return true; - case Unicode: - return d->utf8; - default: - return false; - } -} - -/* - SQLite dbs have no user name, passwords, hosts or ports. - just file names. -*/ -bool QSQLite2Driver::open(const QString & db, const QString &, const QString &, const QString &, int, const QString &) -{ - Q_D(QSQLite2Driver); - if (isOpen()) - close(); - - if (db.isEmpty()) - return false; - - char* err = 0; - d->access = sqlite_open(QFile::encodeName(db), 0, &err); - if (err) { - setLastError(QSqlError(tr("Error opening database"), QString::fromLatin1(err), - QSqlError::ConnectionError)); - sqlite_freemem(err); - err = 0; - } - - if (d->access) { - setOpen(true); - setOpenError(false); - return true; - } - setOpenError(true); - return false; -} - -void QSQLite2Driver::close() -{ - Q_D(QSQLite2Driver); - if (isOpen()) { - sqlite_close(d->access); - d->access = 0; - setOpen(false); - setOpenError(false); - } -} - -QSqlResult *QSQLite2Driver::createResult() const -{ - return new QSQLite2Result(this); -} - -bool QSQLite2Driver::beginTransaction() -{ - Q_D(QSQLite2Driver); - if (!isOpen() || isOpenError()) - return false; - - char* err; - int res = sqlite_exec(d->access, "BEGIN", 0, this, &err); - - if (res == SQLITE_OK) - return true; - - setLastError(QSqlError(tr("Unable to begin transaction"), - QString::fromLatin1(err), QSqlError::TransactionError, res)); - sqlite_freemem(err); - return false; -} - -bool QSQLite2Driver::commitTransaction() -{ - Q_D(QSQLite2Driver); - if (!isOpen() || isOpenError()) - return false; - - char* err; - int res = sqlite_exec(d->access, "COMMIT", 0, this, &err); - - if (res == SQLITE_OK) - return true; - - setLastError(QSqlError(tr("Unable to commit transaction"), - QString::fromLatin1(err), QSqlError::TransactionError, res)); - sqlite_freemem(err); - return false; -} - -bool QSQLite2Driver::rollbackTransaction() -{ - Q_D(QSQLite2Driver); - if (!isOpen() || isOpenError()) - return false; - - char* err; - int res = sqlite_exec(d->access, "ROLLBACK", 0, this, &err); - - if (res == SQLITE_OK) - return true; - - setLastError(QSqlError(tr("Unable to rollback transaction"), - QString::fromLatin1(err), QSqlError::TransactionError, res)); - sqlite_freemem(err); - return false; -} - -QStringList QSQLite2Driver::tables(QSql::TableType type) const -{ - QStringList res; - if (!isOpen()) - return res; - - QSqlQuery q(createResult()); - q.setForwardOnly(true); - if ((type & QSql::Tables) && (type & QSql::Views)) - q.exec(QLatin1String("SELECT name FROM sqlite_master WHERE type='table' OR type='view'")); - else if (type & QSql::Tables) - q.exec(QLatin1String("SELECT name FROM sqlite_master WHERE type='table'")); - else if (type & QSql::Views) - q.exec(QLatin1String("SELECT name FROM sqlite_master WHERE type='view'")); - - if (q.isActive()) { - while(q.next()) - res.append(q.value(0).toString()); - } - - if (type & QSql::SystemTables) { - // there are no internal tables beside this one: - res.append(QLatin1String("sqlite_master")); - } - - return res; -} - -QSqlIndex QSQLite2Driver::primaryIndex(const QString &tblname) const -{ - QSqlRecord rec(record(tblname)); // expensive :( - - if (!isOpen()) - return QSqlIndex(); - - QSqlQuery q(createResult()); - q.setForwardOnly(true); - QString table = tblname; - if (isIdentifierEscaped(table, QSqlDriver::TableName)) - table = stripDelimiters(table, QSqlDriver::TableName); - // finrst find a UNIQUE INDEX - q.exec(QLatin1String("PRAGMA index_list('") + table + QLatin1String("');")); - QString indexname; - while(q.next()) { - if (q.value(2).toInt()==1) { - indexname = q.value(1).toString(); - break; - } - } - if (indexname.isEmpty()) - return QSqlIndex(); - - q.exec(QLatin1String("PRAGMA index_info('") + indexname + QLatin1String("');")); - - QSqlIndex index(table, indexname); - while(q.next()) { - QString name = q.value(2).toString(); - QVariant::Type type = QVariant::Invalid; - if (rec.contains(name)) - type = rec.field(name).type(); - index.append(QSqlField(name, type, tblname)); - } - return index; -} - -QSqlRecord QSQLite2Driver::record(const QString &tbl) const -{ - if (!isOpen()) - return QSqlRecord(); - QString table = tbl; - if (isIdentifierEscaped(tbl, QSqlDriver::TableName)) - table = stripDelimiters(table, QSqlDriver::TableName); - - QSqlQuery q(createResult()); - q.setForwardOnly(true); - q.exec(QLatin1String("SELECT * FROM ") + tbl + QLatin1String(" LIMIT 1")); - return q.record(); -} - -QVariant QSQLite2Driver::handle() const -{ - Q_D(const QSQLite2Driver); - return QVariant::fromValue(d->access); -} - -QString QSQLite2Driver::escapeIdentifier(const QString &identifier, IdentifierType /*type*/) const -{ - QString res = identifier; - if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) { - res.replace(QLatin1Char('"'), QLatin1String("\"\"")); - res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); - res.replace(QLatin1Char('.'), QLatin1String("\".\"")); - } - return res; -} - -QT_END_NAMESPACE diff --git a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h deleted file mode 100644 index 57db0a4d47..0000000000 --- a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSql module 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$ -** -****************************************************************************/ - -#ifndef QSQL_SQLITE2_H -#define QSQL_SQLITE2_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtSql/qsqldriver.h> - -#if defined (Q_OS_WIN32) -# include <QtCore/qt_windows.h> -#endif - -struct sqlite; - -#ifdef QT_PLUGIN -#define Q_EXPORT_SQLDRIVER_SQLITE2 -#else -#define Q_EXPORT_SQLDRIVER_SQLITE2 Q_SQL_EXPORT -#endif - -QT_BEGIN_NAMESPACE - -class QSqlResult; -class QSQLite2DriverPrivate; - -class Q_EXPORT_SQLDRIVER_SQLITE2 QSQLite2Driver : public QSqlDriver -{ - friend class QSQLite2ResultPrivate; - Q_DECLARE_PRIVATE(QSQLite2Driver) - Q_OBJECT -public: - explicit QSQLite2Driver(QObject *parent = nullptr); - explicit QSQLite2Driver(sqlite *connection, QObject *parent = nullptr); - ~QSQLite2Driver(); - bool hasFeature(DriverFeature f) const override; - bool open(const QString &db, - const QString &user, - const QString &password, - const QString &host, - int port, - const QString &connOpts) override; - bool open(const QString &db, - const QString &user, - const QString &password, - const QString &host, - int port) { return open(db, user, password, host, port, QString()); } - void close() override; - QSqlResult *createResult() const override; - bool beginTransaction() override; - bool commitTransaction() override; - bool rollbackTransaction() override; - QStringList tables(QSql::TableType) const override; - - QSqlRecord record(const QString &tablename) const override; - QSqlIndex primaryIndex(const QString &table) const override; - QVariant handle() const override; - QString escapeIdentifier(const QString &identifier, IdentifierType) const override; -}; - -QT_END_NAMESPACE - -#endif // QSQL_SQLITE2_H diff --git a/src/plugins/sqldrivers/sqlite2/smain.cpp b/src/plugins/sqldrivers/sqlite2/smain.cpp deleted file mode 100644 index 7d971d6e5a..0000000000 --- a/src/plugins/sqldrivers/sqlite2/smain.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins 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$ -** -****************************************************************************/ - -#include <qsqldriverplugin.h> -#include <qstringlist.h> -#include "qsql_sqlite2_p.h" - -QT_BEGIN_NAMESPACE - -// ### Qt6: remove, obsolete since 5.14 -class QSQLite2DriverPlugin : public QSqlDriverPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "sqlite2.json") - -public: - QSQLite2DriverPlugin(); - - QSqlDriver* create(const QString &); -}; - -QSQLite2DriverPlugin::QSQLite2DriverPlugin() - : QSqlDriverPlugin() -{ -} - -QSqlDriver* QSQLite2DriverPlugin::create(const QString &name) -{ - if (name == QLatin1String("QSQLITE2")) { - QSQLite2Driver* driver = new QSQLite2Driver(); - return driver; - } - return 0; -} - -QT_END_NAMESPACE - -#include "smain.moc" diff --git a/src/plugins/sqldrivers/sqlite2/sqlite2.json b/src/plugins/sqldrivers/sqlite2/sqlite2.json deleted file mode 100644 index 47bdae4d60..0000000000 --- a/src/plugins/sqldrivers/sqlite2/sqlite2.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "QSQLITE2" ] -} diff --git a/src/plugins/sqldrivers/sqlite2/sqlite2.pro b/src/plugins/sqldrivers/sqlite2/sqlite2.pro deleted file mode 100644 index 721facb5b8..0000000000 --- a/src/plugins/sqldrivers/sqlite2/sqlite2.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = qsqlite2 - -HEADERS += $$PWD/qsql_sqlite2_p.h -SOURCES += $$PWD/qsql_sqlite2.cpp $$PWD/smain.cpp - -QMAKE_USE += sqlite2 - -OTHER_FILES += sqlite2.json - -PLUGIN_CLASS_NAME = QSQLite2DriverPlugin -include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/tds/README b/src/plugins/sqldrivers/tds/README deleted file mode 100644 index 3d27ed46d2..0000000000 --- a/src/plugins/sqldrivers/tds/README +++ /dev/null @@ -1,6 +0,0 @@ -You will need the dblib development headers and libraries installed before -compiling this plugin. - -See the Qt SQL documentation for more information on compiling Qt SQL -driver plugins (sql-driver.html). - diff --git a/src/plugins/sqldrivers/tds/main.cpp b/src/plugins/sqldrivers/tds/main.cpp deleted file mode 100644 index 18efb22ea4..0000000000 --- a/src/plugins/sqldrivers/tds/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins 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$ -** -****************************************************************************/ - -#define Q_UUIDIMPL -#include <qsqldriverplugin.h> -#include <qstringlist.h> -#ifdef Q_OS_WIN32 // We assume that MS SQL Server is used. Set Q_USE_SYBASE to force Sybase. -// Conflicting declarations of LPCBYTE in sqlfront.h and winscard.h -#define _WINSCARD_H_ -#include <windows.h> -#endif -#include "qsql_tds_p.h" - -QT_BEGIN_NAMESPACE - - -// ### Qt6: remove, obsolete since 4.7 -class QTDSDriverPlugin : public QSqlDriverPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "tds.json") - -public: - QTDSDriverPlugin(); - - QSqlDriver* create(const QString &); -}; - -QTDSDriverPlugin::QTDSDriverPlugin() - : QSqlDriverPlugin() -{ -} - -QSqlDriver* QTDSDriverPlugin::create(const QString &name) -{ - if (name == QLatin1String("QTDS") || name == QLatin1String("QTDS7")) { - QTDSDriver* driver = new QTDSDriver(); - return driver; - } - return 0; -} - -QT_END_NAMESPACE - -#include "main.moc" diff --git a/src/plugins/sqldrivers/tds/qsql_tds.cpp b/src/plugins/sqldrivers/tds/qsql_tds.cpp deleted file mode 100644 index 9c8d242028..0000000000 --- a/src/plugins/sqldrivers/tds/qsql_tds.cpp +++ /dev/null @@ -1,881 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSql module 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$ -** -****************************************************************************/ - -#include "qsql_tds_p.h" - -#include <qglobal.h> -#ifdef Q_OS_WIN32 // We assume that MS SQL Server is used. Set Q_USE_SYBASE to force Sybase. -// Conflicting declarations of LPCBYTE in sqlfront.h and winscard.h -#define _WINSCARD_H_ -#include <windows.h> -#else -#define Q_USE_SYBASE -#endif - -#include <qvariant.h> -#include <qdatetime.h> -#include <qhash.h> -#include <qregexp.h> -#include <qsqlerror.h> -#include <qsqlfield.h> -#include <qsqlindex.h> -#include <qsqlquery.h> -#include <QtSql/private/qsqlcachedresult_p.h> -#include <QtSql/private/qsqldriver_p.h> -#include <qstringlist.h> -#include <qvector.h> - -#include <stdlib.h> - -Q_DECLARE_OPAQUE_POINTER(LOGINREC*) -Q_DECLARE_OPAQUE_POINTER(DBPROCESS*) - -QT_BEGIN_NAMESPACE - -#ifdef DBNTWIN32 -#define QMSGHANDLE DBMSGHANDLE_PROC -#define QERRHANDLE DBERRHANDLE_PROC -#define QTDSCHAR SQLCHAR -#define QTDSDATETIME4 SQLDATETIM4 -#define QTDSDATETIME SQLDATETIME -#define QTDSDATETIME_N SQLDATETIMN -#define QTDSDECIMAL SQLDECIMAL -#define QTDSFLT4 SQLFLT4 -#define QTDSFLT8 SQLFLT8 -#define QTDSFLT8_N SQLFLTN -#define QTDSINT1 SQLINT1 -#define QTDSINT2 SQLINT2 -#define QTDSINT4 SQLINT4 -#define QTDSINT4_N SQLINTN -#define QTDSMONEY4 SQLMONEY4 -#define QTDSMONEY SQLMONEY -#define QTDSMONEY_N SQLMONEYN -#define QTDSNUMERIC SQLNUMERIC -#define QTDSTEXT SQLTEXT -#define QTDSVARCHAR SQLVARCHAR -#define QTDSBIT SQLBIT -#define QTDSBINARY SQLBINARY -#define QTDSVARBINARY SQLVARBINARY -#define QTDSIMAGE SQLIMAGE -#else -#define QMSGHANDLE MHANDLEFUNC -#define QERRHANDLE EHANDLEFUNC -#define QTDSCHAR SYBCHAR -#define QTDSDATETIME4 SYBDATETIME4 -#define QTDSDATETIME SYBDATETIME -#define QTDSDATETIME_N SYBDATETIMN -#define QTDSDECIMAL SYBDECIMAL -#define QTDSFLT8 SYBFLT8 -#define QTDSFLT8_N SYBFLTN -#define QTDSFLT4 SYBREAL -#define QTDSINT1 SYBINT1 -#define QTDSINT2 SYBINT2 -#define QTDSINT4 SYBINT4 -#define QTDSINT4_N SYBINTN -#define QTDSMONEY4 SYBMONEY4 -#define QTDSMONEY SYBMONEY -#define QTDSMONEY_N SYBMONEYN -#define QTDSNUMERIC SYBNUMERIC -#define QTDSTEXT SYBTEXT -#define QTDSVARCHAR SYBVARCHAR -#define QTDSBIT SYBBIT -#define QTDSBINARY SYBBINARY -#define QTDSVARBINARY SYBVARBINARY -#define QTDSIMAGE SYBIMAGE -// magic numbers not defined anywhere in Sybase headers -#define QTDSDECIMAL_2 55 -#define QTDSNUMERIC_2 63 -#endif //DBNTWIN32 - -#define TDS_CURSOR_SIZE 50 - -// workaround for FreeTDS -#ifndef CS_PUBLIC -#define CS_PUBLIC -#endif - -QSqlError qMakeError(const QString& err, QSqlError::ErrorType type, int errNo = -1) -{ - return QSqlError(QLatin1String("QTDS: ") + err, QString(), type, - errNo != -1 ? QString::number(errNo) : QString()); -} - -class QTDSDriverPrivate : public QSqlDriverPrivate -{ - Q_DECLARE_PUBLIC(QTDSDriver) - -public: - QTDSDriverPrivate() : QSqlDriverPrivate(), login(0), initialized(false) { dbmsType = QSqlDriver::Sybase; } - LOGINREC* login; // login information - QString hostName; - QString db; - bool initialized; -}; - -struct QTDSColumnData -{ - void *data; - DBINT nullbind; -}; -Q_DECLARE_TYPEINFO(QTDSColumnData, Q_MOVABLE_TYPE); - -class QTDSResultPrivate; - -class QTDSResult : public QSqlCachedResult -{ - Q_DECLARE_PRIVATE(QTDSResult) - -public: - explicit QTDSResult(const QTDSDriver* db); - ~QTDSResult(); - QVariant handle() const override; - -protected: - void cleanup(); - bool reset(const QString &query) override; - int size() override; - int numRowsAffected() override; - bool gotoNext(QSqlCachedResult::ValueCache &values, int index) override; - QSqlRecord record() const override; -}; - -class QTDSResultPrivate: public QSqlCachedResultPrivate -{ - Q_DECLARE_PUBLIC(QTDSResult) - -public: - Q_DECLARE_SQLDRIVER_PRIVATE(QTDSDriver) - QTDSResultPrivate(QTDSResult *q, const QTDSDriver *drv) - : QSqlCachedResultPrivate(q, drv), - login(0), - dbproc(0) {} - LOGINREC* login; // login information - DBPROCESS* dbproc; // connection from app to server - QSqlError lastError; - void addErrorMsg(QString& errMsg) { errorMsgs.append(errMsg); } - QString getErrorMsgs() { return errorMsgs.join(QLatin1String("\n")); } - void clearErrorMsgs() { errorMsgs.clear(); } - QVector<QTDSColumnData> buffer; - QSqlRecord rec; - -private: - QStringList errorMsgs; -}; - -typedef QHash<DBPROCESS *, QTDSResultPrivate *> QTDSErrorHash; -Q_GLOBAL_STATIC(QTDSErrorHash, errs) - -extern "C" { -static int CS_PUBLIC qTdsMsgHandler (DBPROCESS* dbproc, - DBINT msgno, - int msgstate, - int severity, - char* msgtext, - char* srvname, - char* /*procname*/, - int line) -{ - QTDSResultPrivate* p = errs()->value(dbproc); - - if (!p) { -// ### umm... temporary disabled since this throws a lot of warnings... -// qWarning("QTDSDriver warning (%d): [%s] from server [%s]", msgstate, msgtext, srvname); - return INT_CANCEL; - } - - if (severity > 0) { - QString errMsg = QString::fromLatin1("%1 (Msg %2, Level %3, State %4, Server %5, Line %6)") - .arg(QString::fromLatin1(msgtext)) - .arg(msgno) - .arg(severity) - .arg(msgstate) - .arg(QString::fromLatin1(srvname)) - .arg(line); - p->addErrorMsg(errMsg); - if (severity > 10) { - // Severe messages are really errors in the sense of lastError - errMsg = p->getErrorMsgs(); - p->lastError = qMakeError(errMsg, QSqlError::UnknownError, msgno); - p->clearErrorMsgs(); - } - } - - return INT_CANCEL; -} - -static int CS_PUBLIC qTdsErrHandler(DBPROCESS* dbproc, - int /*severity*/, - int dberr, - int /*oserr*/, - char* dberrstr, - char* oserrstr) -{ - QTDSResultPrivate* p = errs()->value(dbproc); - if (!p) { - qWarning("QTDSDriver error (%d): [%s] [%s]", dberr, dberrstr, oserrstr); - return INT_CANCEL; - } - /* - * If the process is dead or NULL and - * we are not in the middle of logging in... - */ - if((dbproc == NULL || DBDEAD(dbproc))) { - qWarning("QTDSDriver error (%d): [%s] [%s]", dberr, dberrstr, oserrstr); - return INT_CANCEL; - } - - const QString errMsg = QLatin1String(dberrstr) + QLatin1Char(' ') - + QLatin1String(oserrstr) + QLatin1Char('\n') - + p->getErrorMsgs(); - p->lastError = qMakeError(errMsg, QSqlError::UnknownError, dberr); - p->clearErrorMsgs(); - - return INT_CANCEL ; -} - -} //extern "C" - - -QVariant::Type qDecodeTDSType(int type) -{ - QVariant::Type t = QVariant::Invalid; - switch (type) { - case QTDSCHAR: - case QTDSTEXT: - case QTDSVARCHAR: - t = QVariant::String; - break; - case QTDSINT1: - case QTDSINT2: - case QTDSINT4: - case QTDSINT4_N: - case QTDSBIT: - t = QVariant::Int; - break; - case QTDSFLT4: - case QTDSFLT8: - case QTDSFLT8_N: - case QTDSMONEY4: - case QTDSMONEY: - case QTDSDECIMAL: - case QTDSNUMERIC: -#ifdef QTDSNUMERIC_2 - case QTDSNUMERIC_2: -#endif -#ifdef QTDSDECIMAL_2 - case QTDSDECIMAL_2: -#endif - case QTDSMONEY_N: - t = QVariant::Double; - break; - case QTDSDATETIME4: - case QTDSDATETIME: - case QTDSDATETIME_N: - t = QVariant::DateTime; - break; - case QTDSBINARY: - case QTDSVARBINARY: - case QTDSIMAGE: - t = QVariant::ByteArray; - break; - default: - t = QVariant::Invalid; - break; - } - return t; -} - -QVariant::Type qFieldType(QTDSResultPrivate* d, int i) -{ - QVariant::Type type = qDecodeTDSType(dbcoltype(d->dbproc, i+1)); - return type; -} - - -QTDSResult::QTDSResult(const QTDSDriver* db) - : QSqlCachedResult(*new QTDSResultPrivate(this, db)) -{ - Q_D(QTDSResult); - d->login = d->drv_d_func()->login; - - d->dbproc = dbopen(d->login, const_cast<char*>(d->drv_d_func()->hostName.toLatin1().constData())); - if (!d->dbproc) - return; - if (dbuse(d->dbproc, const_cast<char*>(d->drv_d_func()->db.toLatin1().constData())) == FAIL) - return; - - // insert d in error handler dict - errs()->insert(d->dbproc, d); - dbcmd(d->dbproc, "set quoted_identifier on"); - dbsqlexec(d->dbproc); -} - -QTDSResult::~QTDSResult() -{ - Q_D(QTDSResult); - cleanup(); - if (d->dbproc) - dbclose(d->dbproc); - errs()->remove(d->dbproc); -} - -void QTDSResult::cleanup() -{ - Q_D(QTDSResult); - d->clearErrorMsgs(); - d->rec.clear(); - for (int i = 0; i < d->buffer.size(); ++i) - free(d->buffer.at(i).data); - d->buffer.clear(); - // "can" stands for "cancel"... very clever. - dbcanquery(d->dbproc); - dbfreebuf(d->dbproc); - - QSqlCachedResult::cleanup(); -} - -QVariant QTDSResult::handle() const -{ - Q_D(const QTDSResult); - return QVariant(qRegisterMetaType<DBPROCESS *>("DBPROCESS*"), &d->dbproc); -} - -static inline bool qIsNull(const QTDSColumnData &p) -{ - return p.nullbind == -1; -} - -bool QTDSResult::gotoNext(QSqlCachedResult::ValueCache &values, int index) -{ - Q_D(QTDSResult); - STATUS stat = dbnextrow(d->dbproc); - if (stat == NO_MORE_ROWS) { - setAt(QSql::AfterLastRow); - return false; - } - if ((stat == FAIL) || (stat == BUF_FULL)) { - setLastError(d->lastError); - return false; - } - - if (index < 0) - return true; - - for (int i = 0; i < d->rec.count(); ++i) { - int idx = index + i; - switch (d->rec.field(i).type()) { - case QVariant::DateTime: - if (qIsNull(d->buffer.at(i))) { - values[idx] = QVariant(QVariant::DateTime); - } else { - DBDATETIME *bdt = (DBDATETIME*) d->buffer.at(i).data; - QDate date = QDate::fromString(QLatin1String("1900-01-01"), Qt::ISODate); - QTime time = QTime::fromString(QLatin1String("00:00:00"), Qt::ISODate); - values[idx] = QDateTime(date.addDays(bdt->dtdays), time.addMSecs(int(bdt->dttime / 0.3))); - } - break; - case QVariant::Int: - if (qIsNull(d->buffer.at(i))) - values[idx] = QVariant(QVariant::Int); - else - values[idx] = *((int*)d->buffer.at(i).data); - break; - case QVariant::Double: - case QVariant::String: - if (qIsNull(d->buffer.at(i))) - values[idx] = QVariant(QVariant::String); - else - values[idx] = QString::fromLocal8Bit((const char*)d->buffer.at(i).data).trimmed(); - break; - case QVariant::ByteArray: { - if (qIsNull(d->buffer.at(i))) - values[idx] = QVariant(QVariant::ByteArray); - else - values[idx] = QByteArray((const char*)d->buffer.at(i).data); - break; - } - default: - // should never happen, and we already fired - // a warning while binding. - values[idx] = QVariant(); - break; - } - } - - return true; -} - -bool QTDSResult::reset (const QString& query) -{ - Q_D(QTDSResult); - cleanup(); - if (!driver() || !driver()-> isOpen() || driver()->isOpenError()) - return false; - setActive(false); - setAt(QSql::BeforeFirstRow); - if (dbcmd(d->dbproc, const_cast<char*>(query.toLocal8Bit().constData())) == FAIL) { - setLastError(d->lastError); - return false; - } - - if (dbsqlexec(d->dbproc) == FAIL) { - setLastError(d->lastError); - dbfreebuf(d->dbproc); - return false; - } - if (dbresults(d->dbproc) != SUCCEED) { - setLastError(d->lastError); - dbfreebuf(d->dbproc); - return false; - } - - setSelect((DBCMDROW(d->dbproc) == SUCCEED)); // decide whether or not we are dealing with a SELECT query - int numCols = dbnumcols(d->dbproc); - if (numCols > 0) { - d->buffer.resize(numCols); - init(numCols); - } - for (int i = 0; i < numCols; ++i) { - int dbType = dbcoltype(d->dbproc, i+1); - QVariant::Type vType = qDecodeTDSType(dbType); - QSqlField f(QString::fromLatin1(dbcolname(d->dbproc, i+1)), vType); - f.setSqlType(dbType); - f.setLength(dbcollen(d->dbproc, i+1)); - d->rec.append(f); - - RETCODE ret = -1; - void* p = 0; - switch (vType) { - case QVariant::Int: - p = malloc(4); - ret = dbbind(d->dbproc, i+1, INTBIND, (DBINT) 4, (unsigned char *)p); - break; - case QVariant::Double: - // use string binding to prevent loss of precision - p = malloc(50); - ret = dbbind(d->dbproc, i+1, STRINGBIND, 50, (unsigned char *)p); - break; - case QVariant::String: - p = malloc(dbcollen(d->dbproc, i+1) + 1); - ret = dbbind(d->dbproc, i+1, STRINGBIND, DBINT(dbcollen(d->dbproc, i+1) + 1), (unsigned char *)p); - break; - case QVariant::DateTime: - p = malloc(8); - ret = dbbind(d->dbproc, i+1, DATETIMEBIND, (DBINT) 8, (unsigned char *)p); - break; - case QVariant::ByteArray: - p = malloc(dbcollen(d->dbproc, i+1) + 1); - ret = dbbind(d->dbproc, i+1, BINARYBIND, DBINT(dbcollen(d->dbproc, i+1) + 1), (unsigned char *)p); - break; - default: //don't bind the field since we do not support it - qWarning("QTDSResult::reset: Unsupported type for field \"%s\"", dbcolname(d->dbproc, i+1)); - break; - } - if (ret == SUCCEED) { - d->buffer[i].data = p; - ret = dbnullbind(d->dbproc, i+1, &d->buffer[i].nullbind); - } else { - d->buffer[i].data = 0; - d->buffer[i].nullbind = 0; - free(p); - } - if ((ret != SUCCEED) && (ret != -1)) { - setLastError(d->lastError); - return false; - } - } - - setActive(true); - return true; -} - -int QTDSResult::size() -{ - return -1; -} - -int QTDSResult::numRowsAffected() -{ - Q_D(const QTDSResult); -#ifdef DBNTWIN32 - if (dbiscount(d->dbproc)) { - return DBCOUNT(d->dbproc); - } - return -1; -#else - return DBCOUNT(d->dbproc); -#endif -} - -QSqlRecord QTDSResult::record() const -{ - Q_D(const QTDSResult); - return d->rec; -} - -/////////////////////////////////////////////////////////////////// - -QTDSDriver::QTDSDriver(QObject* parent) - : QSqlDriver(*new QTDSDriverPrivate, parent) -{ - init(); -} - -QTDSDriver::QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent) - : QSqlDriver(*new QTDSDriverPrivate, parent) -{ - Q_D(QTDSDriver); - init(); - d->login = rec; - d->hostName = host; - d->db = db; - if (rec) { - setOpen(true); - setOpenError(false); - } -} - -QVariant QTDSDriver::handle() const -{ - Q_D(const QTDSDriver); - return QVariant(qRegisterMetaType<LOGINREC *>("LOGINREC*"), &d->login); -} - -void QTDSDriver::init() -{ - Q_D(QTDSDriver); - d->initialized = (dbinit() == SUCCEED); - // the following two code-lines will fail compilation on some FreeTDS versions - // just comment them out if you have FreeTDS (you won't get any errors and warnings then) - dberrhandle((QERRHANDLE)qTdsErrHandler); - dbmsghandle((QMSGHANDLE)qTdsMsgHandler); -} - -QTDSDriver::~QTDSDriver() -{ - dberrhandle(0); - dbmsghandle(0); - // dbexit also calls dbclose if necessary - dbexit(); -} - -bool QTDSDriver::hasFeature(DriverFeature f) const -{ - switch (f) { - case Transactions: - case QuerySize: - case Unicode: - case SimpleLocking: - case EventNotifications: - case MultipleResultSets: - return false; - case BLOB: - return true; - default: - return false; - } -} - -bool QTDSDriver::open(const QString & db, - const QString & user, - const QString & password, - const QString & host, - int /*port*/, - const QString& /*connOpts*/) -{ - Q_D(QTDSDriver); - if (isOpen()) - close(); - if (!d->initialized) { - setOpenError(true); - return false; - } - d->login = dblogin(); - if (!d->login) { - setOpenError(true); - return false; - } - DBSETLPWD(d->login, const_cast<char*>(password.toLocal8Bit().constData())); - DBSETLUSER(d->login, const_cast<char*>(user.toLocal8Bit().constData())); - - // Now, try to open and use the database. If this fails, return false. - DBPROCESS* dbproc; - - dbproc = dbopen(d->login, const_cast<char*>(host.toLatin1().constData())); - if (!dbproc) { - setLastError(qMakeError(tr("Unable to open connection"), QSqlError::ConnectionError, -1)); - setOpenError(true); - return false; - } - if (dbuse(dbproc, const_cast<char*>(db.toLatin1().constData())) == FAIL) { - setLastError(qMakeError(tr("Unable to use database"), QSqlError::ConnectionError, -1)); - setOpenError(true); - return false; - } - dbclose( dbproc ); - - setOpen(true); - setOpenError(false); - d->hostName = host; - d->db = db; - return true; -} - -void QTDSDriver::close() -{ - Q_D(QTDSDriver); - if (isOpen()) { -#ifdef Q_USE_SYBASE - dbloginfree(d->login); -#else - dbfreelogin(d->login); -#endif - d->login = 0; - setOpen(false); - setOpenError(false); - } -} - -QSqlResult *QTDSDriver::createResult() const -{ - return new QTDSResult(this); -} - -bool QTDSDriver::beginTransaction() -{ - return false; -/* - if (!isOpen()) { - qWarning("QTDSDriver::beginTransaction: Database not open"); - return false; - } - if (dbcmd(d->dbproc, "BEGIN TRANSACTION") == FAIL) { - setLastError(d->lastError); - dbfreebuf(d->dbproc); - return false; - } - if (dbsqlexec(d->dbproc) == FAIL) { - setLastError(d->lastError); - dbfreebuf(d->dbproc); - return false; - } - while(dbresults(d->dbproc) == NO_MORE_RESULTS) {} - dbfreebuf(d->dbproc); - inTransaction = true; - return true; -*/ -} - -bool QTDSDriver::commitTransaction() -{ - return false; -/* - if (!isOpen()) { - qWarning("QTDSDriver::commitTransaction: Database not open"); - return false; - } - if (dbcmd(d->dbproc, "COMMIT TRANSACTION") == FAIL) { - setLastError(d->lastError); - dbfreebuf(d->dbproc); - return false; - } - if (dbsqlexec(d->dbproc) == FAIL) { - setLastError(d->lastError); - dbfreebuf(d->dbproc); - return false; - } - while(dbresults(d->dbproc) == NO_MORE_RESULTS) {} - dbfreebuf(d->dbproc); - inTransaction = false; - return true; -*/ -} - -bool QTDSDriver::rollbackTransaction() -{ - return false; -/* - if (!isOpen()) { - qWarning("QTDSDriver::rollbackTransaction: Database not open"); - return false; - } - if (dbcmd(d->dbproc, "ROLLBACK TRANSACTION") == FAIL) { - setLastError(d->lastError); - dbfreebuf(d->dbproc); - return false; - } - if (dbsqlexec(d->dbproc) == FAIL) { - setLastError(d->lastError); - dbfreebuf(d->dbproc); - return false; - } - while(dbresults(d->dbproc) == NO_MORE_RESULTS) {} - dbfreebuf(d->dbproc); - inTransaction = false; - return true; -*/ -} - -QSqlRecord QTDSDriver::record(const QString& tablename) const -{ - QSqlRecord info; - if (!isOpen()) - return info; - QSqlQuery t(createResult()); - t.setForwardOnly(true); - - QString table = tablename; - if (isIdentifierEscaped(table, QSqlDriver::TableName)) - table = stripDelimiters(table, QSqlDriver::TableName); - - QString stmt (QLatin1String("select name, type, length, prec from syscolumns " - "where id = (select id from sysobjects where name = '%1')")); - t.exec(stmt.arg(table)); - while (t.next()) { - QSqlField f(t.value(0).toString().simplified(), qDecodeTDSType(t.value(1).toInt()), tablename); - f.setLength(t.value(2).toInt()); - f.setPrecision(t.value(3).toInt()); - f.setSqlType(t.value(1).toInt()); - info.append(f); - } - return info; -} - -QStringList QTDSDriver::tables(QSql::TableType type) const -{ - QStringList list; - - if (!isOpen()) - return list; - - QStringList typeFilter; - - if (type & QSql::Tables) - typeFilter += QLatin1String("type='U'"); - if (type & QSql::SystemTables) - typeFilter += QLatin1String("type='S'"); - if (type & QSql::Views) - typeFilter += QLatin1String("type='V'"); - - if (typeFilter.isEmpty()) - return list; - - QSqlQuery t(createResult()); - t.setForwardOnly(true); - t.exec(QLatin1String("select name from sysobjects where ") + typeFilter.join(QLatin1String(" or "))); - while (t.next()) - list.append(t.value(0).toString().simplified()); - - return list; -} - -QString QTDSDriver::formatValue(const QSqlField &field, - bool trim) const -{ - QString r; - if (field.isNull()) - r = QLatin1String("NULL"); - else if (field.type() == QVariant::DateTime) { - if (field.value().toDateTime().isValid()){ - r = field.value().toDateTime().toString(u"yyyyMMdd hh:mm:ss"); - r.prepend(QLatin1String("'")); - r.append(QLatin1String("'")); - } else - r = QLatin1String("NULL"); - } else if (field.type() == QVariant::ByteArray) { - QByteArray ba = field.value().toByteArray(); - QString res; - static const char hexchars[] = "0123456789abcdef"; - for (int i = 0; i < ba.size(); ++i) { - uchar s = (uchar) ba[i]; - res += QLatin1Char(hexchars[s >> 4]); - res += QLatin1Char(hexchars[s & 0x0f]); - } - r = QLatin1String("0x") + res; - } else { - r = QSqlDriver::formatValue(field, trim); - } - return r; -} - -QSqlIndex QTDSDriver::primaryIndex(const QString& tablename) const -{ - QSqlRecord rec = record(tablename); - - QString table = tablename; - if (isIdentifierEscaped(table, QSqlDriver::TableName)) - table = stripDelimiters(table, QSqlDriver::TableName); - - QSqlIndex idx(table); - if ((!isOpen()) || (table.isEmpty())) - return QSqlIndex(); - - QSqlQuery t(createResult()); - t.setForwardOnly(true); - t.exec(QString::fromLatin1("sp_helpindex '%1'").arg(table)); - if (t.next()) { - QStringList fNames = t.value(2).toString().simplified().split(QLatin1Char(',')); - QRegExp regx(QLatin1String("\\s*(\\S+)(?:\\s+(DESC|desc))?\\s*")); - for(QStringList::Iterator it = fNames.begin(); it != fNames.end(); ++it) { - regx.indexIn(*it); - QSqlField f(regx.cap(1), rec.field(regx.cap(1)).type(), tablename); - if (regx.cap(2).toLower() == QLatin1String("desc")) { - idx.append(f, true); - } else { - idx.append(f, false); - } - } - idx.setName(t.value(0).toString().simplified()); - } - return idx; -} - -QString QTDSDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const -{ - Q_UNUSED(type) - QString res = identifier; - if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) { - res.replace(QLatin1Char('"'), QLatin1String("\"\"")); - res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); - res.replace(QLatin1Char('.'), QLatin1String("\".\"")); - } - return res; -} - -QT_END_NAMESPACE diff --git a/src/plugins/sqldrivers/tds/qsql_tds_p.h b/src/plugins/sqldrivers/tds/qsql_tds_p.h deleted file mode 100644 index b72fababbb..0000000000 --- a/src/plugins/sqldrivers/tds/qsql_tds_p.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSql module 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$ -** -****************************************************************************/ - -#ifndef QSQL_TDS_H -#define QSQL_TDS_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtSql/qsqldriver.h> - -#ifdef Q_OS_WIN32 -#define WIN32_LEAN_AND_MEAN -#ifndef Q_USE_SYBASE -#define DBNTWIN32 // indicates 32bit windows dblib -#endif -#include <winsock2.h> -#include <QtCore/qt_windows.h> -#include <sqlfront.h> -#include <sqldb.h> -#define CS_PUBLIC -#else -#include <sybfront.h> -#include <sybdb.h> -#endif //Q_OS_WIN32 - -#ifdef QT_PLUGIN -#define Q_EXPORT_SQLDRIVER_TDS -#else -#define Q_EXPORT_SQLDRIVER_TDS Q_SQL_EXPORT -#endif - -QT_BEGIN_NAMESPACE - -class QSqlResult; -class QTDSDriverPrivate; - -class Q_EXPORT_SQLDRIVER_TDS QTDSDriver : public QSqlDriver -{ - Q_DECLARE_PRIVATE(QTDSDriver) - Q_OBJECT - friend class QTDSResultPrivate; -public: - explicit QTDSDriver(QObject* parent = nullptr); - QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent = nullptr); - ~QTDSDriver(); - bool hasFeature(DriverFeature f) const override; - bool open(const QString &db, - const QString &user, - const QString &password, - const QString &host, - int port, - const QString &connOpts) override; - void close() override; - QStringList tables(QSql::TableType) const override; - QSqlResult *createResult() const override; - QSqlRecord record(const QString &tablename) const override; - QSqlIndex primaryIndex(const QString &tablename) const override; - - QString formatValue(const QSqlField &field, - bool trimStrings) const override; - QVariant handle() const override; - - QString escapeIdentifier(const QString &identifier, IdentifierType type) const override; - -protected: - bool beginTransaction() override; - bool commitTransaction() override; - bool rollbackTransaction() override; -private: - void init(); -}; - -QT_END_NAMESPACE - -#endif // QSQL_TDS_H diff --git a/src/plugins/sqldrivers/tds/tds.json b/src/plugins/sqldrivers/tds/tds.json deleted file mode 100644 index 35955db9fa..0000000000 --- a/src/plugins/sqldrivers/tds/tds.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "QTDS7", "QTDS" ] -} diff --git a/src/plugins/sqldrivers/tds/tds.pro b/src/plugins/sqldrivers/tds/tds.pro deleted file mode 100644 index 67bc0f5c48..0000000000 --- a/src/plugins/sqldrivers/tds/tds.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = qsqltds - -HEADERS += $$PWD/qsql_tds_p.h -SOURCES += $$PWD/qsql_tds.cpp $$PWD/main.cpp - -QMAKE_USE += tds - -OTHER_FILES += tds.json - -PLUGIN_CLASS_NAME = QTDSDriverPlugin -include(../qsqldriverbase.pri) |