From 59a003faafe53a155e4a46725ef41b1b7dca4b75 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 3 Dec 2012 15:57:13 +0100 Subject: dumpcpp: compile with QT_NO_CAST_TO_ASCII Change-Id: I96750ea25c6b4499dccf55509510c076bc4ad371 Reviewed-by: Friedemann Kleint Reviewed-by: Miikka Heikkinen --- tools/dumpcpp/dumpcpp.pro | 1 + tools/dumpcpp/main.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/dumpcpp/dumpcpp.pro b/tools/dumpcpp/dumpcpp.pro index 3917298..9dd6d27 100644 --- a/tools/dumpcpp/dumpcpp.pro +++ b/tools/dumpcpp/dumpcpp.pro @@ -1,4 +1,5 @@ QT += axcontainer widgets core-private +DEFINES += QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNINGS SOURCES = main.cpp diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp index c1553e9..63a031a 100644 --- a/tools/dumpcpp/main.cpp +++ b/tools/dumpcpp/main.cpp @@ -473,7 +473,7 @@ void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaOb out << endl; out << indent << "{" << endl; - if (slotType != QStringLiteral("void")) { + if (slotType != QByteArrayLiteral("void")) { out << indent << " " << slotType << " qax_result"; if (slotType.endsWith('*')) out << " = 0"; @@ -491,7 +491,7 @@ void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaOb } } out << indent << " void *_a[] = {"; - if (slotType != QStringLiteral("void")) + if (slotType != QByteArrayLiteral("void")) out << "(void*)&qax_result"; else out << "0"; @@ -502,7 +502,7 @@ void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaOb out << "};" << endl; out << indent << " qt_metacall(QMetaObject::InvokeMetaMethod, " << islot << ", _a);" << endl; - if (slotType != QStringLiteral("void")) + if (slotType != QByteArrayLiteral("void")) out << indent << " return qax_result;" << endl; out << indent << "}" << endl; } @@ -981,7 +981,7 @@ bool generateTypeLibrary(const QByteArray &typeLib, const QByteArray &outname, O libName = QString::fromWCharArray(nameString); SysFreeString(nameString); if (!nameSpace.isEmpty()) - libName = QString(nameSpace); + libName = QString::fromLocal8Bit(nameSpace); QString libVersion(QLatin1String("1.0")); -- cgit v1.2.3 From c2bff97edd30d9031112b8d926ccc97a25ae1a9c Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 12 Dec 2012 22:09:46 +0100 Subject: sync.profile: Point dependencies to 'refs/heads/dev' We should test dev branches against dev branches only by default. At some point we should automate the merges from release->stable->dev and/or decide how to handle possible conflicts. This is good enough for the time being. Change-Id: Id328f169004a6cb69078b58801885b00581fee33 Reviewed-by: Thiago Macieira Reviewed-by: Miikka Heikkinen --- sync.profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sync.profile b/sync.profile index 62e92bc..edc6286 100644 --- a/sync.profile +++ b/sync.profile @@ -12,5 +12,5 @@ # - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch) # %dependencies = ( - "qtbase" => "refs/heads/master", + "qtbase" => "refs/heads/dev", ); -- cgit v1.2.3 From df3356e74d52f3b61a0cfa85b7689fb0b34d3528 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 17 Dec 2012 10:35:13 +0100 Subject: Testcon: Fix includes. Replace module includes by per-class includes. Change-Id: I5c70aa194b4066ef14082af79f396a635bf8475f Reviewed-by: Miikka Heikkinen Reviewed-by: Andreas Holzammer --- tools/testcon/ambientproperties.cpp | 5 ++++- tools/testcon/changeproperties.cpp | 9 ++++++--- tools/testcon/controlinfo.cpp | 2 +- tools/testcon/mainwindow.cpp | 13 ++++++++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tools/testcon/ambientproperties.cpp b/tools/testcon/ambientproperties.cpp index ea0ceaa..47fb72e 100644 --- a/tools/testcon/ambientproperties.cpp +++ b/tools/testcon/ambientproperties.cpp @@ -41,7 +41,10 @@ #include "ambientproperties.h" -#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/tools/testcon/changeproperties.cpp b/tools/testcon/changeproperties.cpp index e5e5033..d523267 100644 --- a/tools/testcon/changeproperties.cpp +++ b/tools/testcon/changeproperties.cpp @@ -41,9 +41,12 @@ #include "changeproperties.h" -#include -#include -#include +#include +#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/tools/testcon/controlinfo.cpp b/tools/testcon/controlinfo.cpp index cbbe916..a338c57 100644 --- a/tools/testcon/controlinfo.cpp +++ b/tools/testcon/controlinfo.cpp @@ -41,7 +41,7 @@ #include "controlinfo.h" -#include +#include QT_BEGIN_NAMESPACE diff --git a/tools/testcon/mainwindow.cpp b/tools/testcon/mainwindow.cpp index 9b28558..065f518 100644 --- a/tools/testcon/mainwindow.cpp +++ b/tools/testcon/mainwindow.cpp @@ -46,9 +46,16 @@ #include "controlinfo.h" #include "docuwindow.h" -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE -- cgit v1.2.3 From e6420ab03d2d13bbe2ff6d6cff52991e3fe1a243 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Jan 2013 12:04:54 +0100 Subject: Fix compiler warnings of MinGW in Active Qt. - Assigned/unused values - Unused code - Constructor order - Comparing different enumeration types Change-Id: I2cc0db554ed87296689303bbbb1978afa2c532b9 Reviewed-by: Joerg Bornemann --- src/activeqt/container/qaxbase.cpp | 2 +- src/activeqt/control/qaxserverbase.cpp | 81 ++++------------------------------ src/activeqt/shared/qaxtypes.cpp | 4 +- 3 files changed, 11 insertions(+), 76 deletions(-) diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index 52f0169..c64342b 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -3682,7 +3682,7 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v) QByteArray type = d->metaobj->paramType(signature, p, &out); QVariant::Type vt = QVariant::nameToType(type); QVariant qvar; - if (vt != QVariant::UserType && vt != QMetaType::QVariant) + if (vt != QVariant::UserType && vt != int(QMetaType::QVariant)) qvar = QVariant(vt, v[p + 1]); if (!qvar.isValid()) { diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index 73a7679..c26c7ff 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -1008,9 +1008,13 @@ QAxServerBase::QAxServerBase(const QString &classname, IUnknown *outerUnknown) Constructs a QAxServerBase object wrapping \a o. */ QAxServerBase::QAxServerBase(QObject *o) -: aggregatedObject(0), ref(0), ole_ref(0), - m_hWnd(0), hmenuShared(0), hwndMenuOwner(0), - m_outerUnknown(0) + : aggregatedObject(0) + , m_hWnd(0) + , hmenuShared(0) + , hwndMenuOwner(0) + , ref(0) + , ole_ref(0) + , m_outerUnknown(0) { init(); @@ -1832,76 +1836,6 @@ void QAxServerBase::updateMask() DeleteObject(hrgn); } -static bool checkHRESULT(HRESULT hres) -{ - const char *name = 0; - Q_UNUSED(name); - switch(hres) { - case S_OK: - return true; - case DISP_E_BADPARAMCOUNT: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Bad parameter count", name); -#endif - return false; - case DISP_E_BADVARTYPE: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Bad variant type", name); -#endif - return false; - case DISP_E_EXCEPTION: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Exception thrown by server", name); -#endif - return false; - case DISP_E_MEMBERNOTFOUND: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Member not found", name); -#endif - return false; - case DISP_E_NONAMEDARGS: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: No named arguments", name); -#endif - return false; - case DISP_E_OVERFLOW: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Overflow", name); -#endif - return false; - case DISP_E_PARAMNOTFOUND: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Parameter not found", name); -#endif - return false; - case DISP_E_TYPEMISMATCH: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Type mismatch", name); -#endif - return false; - case DISP_E_UNKNOWNINTERFACE: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Unknown interface", name); -#endif - return false; - case DISP_E_UNKNOWNLCID: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Unknown locale ID", name); -#endif - return false; - case DISP_E_PARAMNOTOPTIONAL: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Non-optional parameter missing", name); -#endif - return false; - default: -#if defined(QT_CHECK_STATE) - qWarning("QAxBase: Error calling IDispatch member %s: Unknown error", name); -#endif - return false; - } -} - static inline QByteArray paramType(const QByteArray &ptype, bool *out) { *out = ptype.endsWith('&') || ptype.endsWith("**"); @@ -2974,6 +2908,7 @@ HRESULT WINAPI QAxServerBase::Load(IPropertyBag *bag, IErrorLog * /*log*/) updateGeometry(); + Q_UNUSED(error) return /*error ? E_FAIL :*/ S_OK; } diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp index 1d72abc..88dba73 100644 --- a/src/activeqt/shared/qaxtypes.cpp +++ b/src/activeqt/shared/qaxtypes.cpp @@ -243,7 +243,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type QVariant qvar = var; // "type" is the expected type, so coerce if necessary QVariant::Type proptype = typeName.isEmpty() ? QVariant::Invalid : QVariant::nameToType(typeName); - if ((proptype == QVariant::UserType || proptype == QMetaType::QVariant) && !typeName.isEmpty()) { + if ((proptype == QVariant::UserType || proptype == int(QMetaType::QVariant)) && !typeName.isEmpty()) { if (typeName == "short" || typeName == "char") proptype = QVariant::Int; else if (typeName == "float") @@ -251,7 +251,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type } if (proptype != QVariant::Invalid && proptype != QVariant::UserType - && proptype != QMetaType::QVariant + && proptype != int(QMetaType::QVariant) && proptype != qvar.type()) { if (qvar.canConvert(proptype)) qvar.convert(proptype); -- cgit v1.2.3 From c31e5dfc55ce6f6f2761076881c90d57c4b99b70 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Jan 2013 12:10:16 +0100 Subject: Check return values of CoInitialize(). Change-Id: I97e94517e1fb1af89d992db9c1a8c15aba5f8425 Reviewed-by: Joerg Bornemann --- src/activeqt/control/qaxservermain.cpp | 28 +++++++++++++++------------- tools/dumpcpp/main.cpp | 5 ++++- tools/dumpdoc/main.cpp | 5 ++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/activeqt/control/qaxservermain.cpp b/src/activeqt/control/qaxservermain.cpp index c79a9e1..f6f7502 100644 --- a/src/activeqt/control/qaxservermain.cpp +++ b/src/activeqt/control/qaxservermain.cpp @@ -252,19 +252,21 @@ EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, } if (run) { - HRESULT hRes = CoInitialize(0); - - int argc; - QVector argv(8); - qWinMain(hInstance, hPrevInstance, unprocessed.data(), nShowCmd, argc, argv); - qAxInit(); - if (runServer) - QAxFactory::startServer(); - nRet = ::main(argc, argv.data()); - QAxFactory::stopServer(); - qAxCleanup(); - CoUninitialize(); - + if (SUCCEEDED(CoInitialize(0))) { + int argc; + QVector argv(8); + qWinMain(hInstance, hPrevInstance, unprocessed.data(), nShowCmd, argc, argv); + qAxInit(); + if (runServer) + QAxFactory::startServer(); + nRet = ::main(argc, argv.data()); + QAxFactory::stopServer(); + qAxCleanup(); + CoUninitialize(); + } else { + qErrnoWarning("CoInitialize() failed."); + nRet = -1; + } } return nRet; diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp index a7a44b1..6d3dd54 100644 --- a/tools/dumpcpp/main.cpp +++ b/tools/dumpcpp/main.cpp @@ -1494,7 +1494,10 @@ int main(int argc, char **argv) { qax_dispatchEqualsIDispatch = false; - CoInitialize(0); + if (FAILED(CoInitialize(0))) { + qErrnoWarning("CoInitialize() failed."); + return -1; + } uint category = DefaultObject; diff --git a/tools/dumpdoc/main.cpp b/tools/dumpdoc/main.cpp index bb3bcf1..6996e15 100644 --- a/tools/dumpdoc/main.cpp +++ b/tools/dumpdoc/main.cpp @@ -48,7 +48,10 @@ QT_USE_NAMESPACE int main(int argc, char **argv) { - CoInitialize(0); + if (FAILED(CoInitialize(0))) { + qErrnoWarning("CoInitialize() failed."); + return -1; + } enum State { Default = 0, -- cgit v1.2.3 From a5d94eb2207d5134343a05f830b6ff062553205f Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sun, 27 Jan 2013 00:34:45 +0100 Subject: Remove QT_{BEGIN,END}_HEADER macro usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro was made empty in qtbase/ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Ifbece10f535a54baf4230ffcbc11ce0c1972d740 Reviewed-by: Laszlo Papp Reviewed-by: Jędrzej Nowacki --- src/activeqt/container/qaxbase.h | 4 ---- src/activeqt/container/qaxobject.h | 4 ---- src/activeqt/container/qaxscript.h | 4 ---- src/activeqt/container/qaxselect.h | 4 ---- src/activeqt/container/qaxwidget.h | 4 ---- src/activeqt/control/qaxaggregated.h | 4 ---- src/activeqt/control/qaxbindable.h | 4 ---- src/activeqt/control/qaxfactory.h | 4 ---- src/activeqt/shared/qaxtypefunctions.h | 4 ---- src/activeqt/shared/qaxtypes.h | 4 ---- 10 files changed, 40 deletions(-) diff --git a/src/activeqt/container/qaxbase.h b/src/activeqt/container/qaxbase.h index 7e54d99..a3bef2e 100644 --- a/src/activeqt/container/qaxbase.h +++ b/src/activeqt/container/qaxbase.h @@ -49,8 +49,6 @@ struct IUnknown; struct IDispatch; -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -231,6 +229,4 @@ Q_DECLARE_METATYPE(IDispatch*) #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXBASE_H diff --git a/src/activeqt/container/qaxobject.h b/src/activeqt/container/qaxobject.h index 4991c63..f5da6ac 100644 --- a/src/activeqt/container/qaxobject.h +++ b/src/activeqt/container/qaxobject.h @@ -43,8 +43,6 @@ #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -97,6 +95,4 @@ Q_DECLARE_METATYPE(QAxObject*) #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXOBJECT_H diff --git a/src/activeqt/container/qaxscript.h b/src/activeqt/container/qaxscript.h index 285ca9c..6be44b4 100644 --- a/src/activeqt/container/qaxscript.h +++ b/src/activeqt/container/qaxscript.h @@ -45,8 +45,6 @@ struct IActiveScript; -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -242,6 +240,4 @@ inline void QAxScriptManager::addObject(QObject *object) QT_END_NAMESPACE #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXSCRIPT_H diff --git a/src/activeqt/container/qaxselect.h b/src/activeqt/container/qaxselect.h index 68bef5b..8feed38 100644 --- a/src/activeqt/container/qaxselect.h +++ b/src/activeqt/container/qaxselect.h @@ -42,8 +42,6 @@ #define QAXSELECT_H #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -70,6 +68,4 @@ private: QT_END_NAMESPACE #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXSELECT_H diff --git a/src/activeqt/container/qaxwidget.h b/src/activeqt/container/qaxwidget.h index 1002b10..f7c9d0d 100644 --- a/src/activeqt/container/qaxwidget.h +++ b/src/activeqt/container/qaxwidget.h @@ -44,8 +44,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -119,6 +117,4 @@ template <> inline QAxWidget *qobject_cast(QObject *o) QT_END_NAMESPACE #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXWIDGET_H diff --git a/src/activeqt/control/qaxaggregated.h b/src/activeqt/control/qaxaggregated.h index a0e031f..f5749ee 100644 --- a/src/activeqt/control/qaxaggregated.h +++ b/src/activeqt/control/qaxaggregated.h @@ -45,8 +45,6 @@ struct IUnknown; -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -87,6 +85,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QAXAGGREGATED_H diff --git a/src/activeqt/control/qaxbindable.h b/src/activeqt/control/qaxbindable.h index b1d659e..b2512f4 100644 --- a/src/activeqt/control/qaxbindable.h +++ b/src/activeqt/control/qaxbindable.h @@ -45,8 +45,6 @@ struct IUnknown; -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -81,6 +79,4 @@ private: QT_END_NAMESPACE #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXBINDABLE_H diff --git a/src/activeqt/control/qaxfactory.h b/src/activeqt/control/qaxfactory.h index 727d258..6c9c49d 100644 --- a/src/activeqt/control/qaxfactory.h +++ b/src/activeqt/control/qaxfactory.h @@ -50,8 +50,6 @@ struct IUnknown; struct IDispatch; -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -307,6 +305,4 @@ Q_DECLARE_METATYPE(IDispatch*) #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXFACTORY_H diff --git a/src/activeqt/shared/qaxtypefunctions.h b/src/activeqt/shared/qaxtypefunctions.h index 7bd61c9..03f215c 100644 --- a/src/activeqt/shared/qaxtypefunctions.h +++ b/src/activeqt/shared/qaxtypefunctions.h @@ -49,8 +49,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -91,6 +89,4 @@ QT_END_NAMESPACE #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXTYPEFUNCTIONS_P_H diff --git a/src/activeqt/shared/qaxtypes.h b/src/activeqt/shared/qaxtypes.h index 692a50d..528d312 100644 --- a/src/activeqt/shared/qaxtypes.h +++ b/src/activeqt/shared/qaxtypes.h @@ -43,8 +43,6 @@ #include "qaxtypefunctions.h" -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT @@ -76,6 +74,4 @@ inline QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName QT_END_NAMESPACE #endif // QT_NO_WIN_ACTIVEQT -QT_END_HEADER - #endif // QAXTYPES_H -- cgit v1.2.3 From c4ca96871280f9dd896d62fe5ea3e01b79b106e6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 8 Feb 2013 12:40:51 +0100 Subject: Improve QAxSelect dialog. - Add filter widget from tools (slightly modified to contain the image as XPM). Add filter model, wire signals accordingly, add handling for the case none is selected (disabling the "Ok"-button). - Use QDialogButtonBox instead of Buttons - Remove obsolete context help button. - Maintain "Binary compatibility" by replacing the QScopedPointer of the UI by a private class. Change-Id: I1f4740cab6845525e0a71a3096feb2f2a4b2172a Reviewed-by: Miikka Heikkinen Reviewed-by: Joerg Bornemann --- src/activeqt/container/container.pro | 2 + src/activeqt/container/filterwidget.cpp | 321 ++++++++++++++++++++++++++++++++ src/activeqt/container/filterwidget_p.h | 151 +++++++++++++++ src/activeqt/container/qaxselect.cpp | 74 ++++++-- src/activeqt/container/qaxselect.h | 13 +- src/activeqt/container/qaxselect.ui | 201 +++++++------------- 6 files changed, 611 insertions(+), 151 deletions(-) create mode 100644 src/activeqt/container/filterwidget.cpp create mode 100644 src/activeqt/container/filterwidget_p.h diff --git a/src/activeqt/container/container.pro b/src/activeqt/container/container.pro index 3972e5b..1c42144 100644 --- a/src/activeqt/container/container.pro +++ b/src/activeqt/container/container.pro @@ -9,6 +9,7 @@ HEADERS = ../control/qaxaggregated.h \ qaxobject.h \ qaxscript.h \ qaxselect.h \ + filterwidget_p.h \ ../shared/qaxtypes.h SOURCES = qaxbase.cpp \ @@ -18,6 +19,7 @@ SOURCES = qaxbase.cpp \ qaxscript.cpp \ qaxscriptwrapper.cpp \ qaxselect.cpp \ + filterwidget.cpp \ ../shared/qaxtypes.cpp FORMS = qaxselect.ui diff --git a/src/activeqt/container/filterwidget.cpp b/src/activeqt/container/filterwidget.cpp new file mode 100644 index 0000000..0e6912a --- /dev/null +++ b/src/activeqt/container/filterwidget.cpp @@ -0,0 +1,321 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the ActiveQt framework 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filterwidget_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +enum { debugFilter = 0 }; + +/* XPM */ +static const char *cleartext_xpm[] = { +"16 16 53 1", +" c None", +". c #2B2B2B", +"+ c #2D2D2D", +"@ c #2F2F2F", +"# c #323232", +"$ c #373737", +"% c #3C3C3C", +"& c #3E3E3E", +"* c #363636", +"= c #404040", +"- c #494949", +"; c #4E4E4E", +"> c #525252", +", c #444444", +"' c #4F4F4F", +") c #9C9C9C", +"! c #6B6B6B", +"~ c #626262", +"{ c #333333", +"] c #414141", +"^ c #9B9B9B", +"/ c #FFFFFF", +"( c #E5E5E5", +"_ c #737373", +": c #3A3A3A", +"< c #4A4A4A", +"[ c #555555", +"} c #5D5D5D", +"| c #E0E0E0", +"1 c #E7E7E7", +"2 c #3F3F3F", +"3 c #5A5A5A", +"4 c #4B4B4B", +"5 c #E2E2E2", +"6 c #424242", +"7 c #5E5E5E", +"8 c #5B5B5B", +"9 c #505050", +"0 c #6A6A6A", +"a c #E3E3E3", +"b c #4D4D4D", +"c c #545454", +"d c #999999", +"e c #DEDEDE", +"f c #474747", +"g c #878787", +"h c #434343", +"i c #414140", +"j c #454545", +"k c #484848", +"l c #484949", +"m c #484748", +"n c #444544", +" ", +" .+@@+. ", +" #$%&&%$# ", +" *=-;>>;-=* ", +" $,')!~~!)',$ ", +" {]'^/(__(/^']{ ", +" :<[}|/11/|}[<: ", +" 2'3>45//54>3'2 ", +" 6>}785//587}>6 ", +" ]930a/||/a039] ", +" &bcd/e%%e/dcb& ", +" f;6gh]ihg6;f ", +" -f=j99j=f- ", +" ksetDuration(160); + animation->setEndValue(1.0); + animation->start(QAbstractAnimation::DeleteWhenStopped); + } else { + QPropertyAnimation *animation = new QPropertyAnimation(this, "fader"); + animation->setDuration(160); + animation->setEndValue(0.0); + animation->start(QAbstractAnimation::DeleteWhenStopped); + } +} + +bool HintLineEdit::refuseFocus() const +{ + return m_refuseFocus; +} + +void HintLineEdit::setRefuseFocus(bool v) +{ + if (v == m_refuseFocus) + return; + m_refuseFocus = v; + setFocusPolicy(m_refuseFocus ? Qt::NoFocus : m_defaultFocusPolicy); +} + +void HintLineEdit::mousePressEvent(QMouseEvent *e) +{ + if (debugFilter) + qDebug() << Q_FUNC_INFO; + // Explicitly focus on click. + if (m_refuseFocus && !hasFocus()) + setFocus(Qt::OtherFocusReason); + QLineEdit::mousePressEvent(e); +} + +void HintLineEdit::focusInEvent(QFocusEvent *e) +{ + if (debugFilter) + qDebug() << Q_FUNC_INFO; + if (m_refuseFocus) { + // Refuse the focus if the mouse is outside. In addition to the mouse + // press logic, this prevents a re-focusing which occurs once + // we actually have focus + const Qt::FocusReason reason = e->reason(); + if (reason == Qt::ActiveWindowFocusReason || reason == Qt::PopupFocusReason) { + const QPoint mousePos = mapFromGlobal(QCursor::pos()); + const bool refuse = !geometry().contains(mousePos); + if (debugFilter) + qDebug() << Q_FUNC_INFO << refuse; + if (refuse) { + e->ignore(); + return; + } + } + } + + QLineEdit::focusInEvent(e); +} + +// ------------------- FilterWidget +FilterWidget::FilterWidget(QWidget *parent, LayoutMode lm) : + QWidget(parent), + m_editor(new HintLineEdit(this)), + m_button(new IconButton(m_editor)), + m_buttonwidth(0) +{ + m_editor->setPlaceholderText(tr("Filter")); + + // Let the style determine minimum height for our widget + QSize size(ICONBUTTON_SIZE + 6, ICONBUTTON_SIZE + 2); + + // Note KDE does not reserve space for the highlight color + if (style()->inherits("OxygenStyle")) + size = size.expandedTo(QSize(24, 0)); + + // Make room for clear icon + QMargins margins = m_editor->textMargins(); + if (layoutDirection() == Qt::LeftToRight) + margins.setRight(size.width()); + else + margins.setLeft(size.width()); + + m_editor->setTextMargins(margins); + + QHBoxLayout *l = new QHBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + if (lm == LayoutAlignRight) + l->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum)); + + l->addWidget(m_editor); + + // KDE has custom icons for this. Notice that icon namings are counter intuitive + // If these icons are not available we use the freedesktop standard name before + // falling back to a bundled resource + QIcon icon = QIcon::fromTheme(layoutDirection() == Qt::LeftToRight ? + QStringLiteral("edit-clear-locationbar-rtl") : + QStringLiteral("edit-clear-locationbar-ltr"), + QIcon::fromTheme(QStringLiteral("edit-clear"), + QIcon(QPixmap(cleartext_xpm)))); + Q_ASSERT(!icon.availableSizes().isEmpty()); + m_button->setIcon(icon); + m_button->setToolTip(tr("Clear text")); + connect(m_button, SIGNAL(clicked()), this, SLOT(reset())); + connect(m_editor, SIGNAL(textChanged(QString)), this, SLOT(checkButton(QString))); + connect(m_editor, SIGNAL(textEdited(QString)), this, SIGNAL(filterChanged(QString))); +} + +QString FilterWidget::text() const +{ + return m_editor->text(); +} + +void FilterWidget::checkButton(const QString &text) +{ + if (m_oldText.isEmpty() || text.isEmpty()) + m_button->animateShow(!m_editor->text().isEmpty()); + m_oldText = text; +} + +void FilterWidget::reset() +{ + if (debugFilter) + qDebug() << Q_FUNC_INFO; + + if (!m_editor->text().isEmpty()) { + // Editor has lost focus once this is pressed + m_editor->clear(); + emit filterChanged(QString()); + } +} + +void FilterWidget::resizeEvent(QResizeEvent *) +{ + QRect contentRect = m_editor->rect(); + if (layoutDirection() == Qt::LeftToRight) { + const int iconoffset = m_editor->textMargins().right() + 4; + m_button->setGeometry(contentRect.adjusted(m_editor->width() - iconoffset, 0, 0, 0)); + } else { + const int iconoffset = m_editor->textMargins().left() + 4; + m_button->setGeometry(contentRect.adjusted(0, 0, -m_editor->width() + iconoffset, 0)); + } +} + +bool FilterWidget::refuseFocus() const +{ + return m_editor->refuseFocus(); +} + +void FilterWidget::setRefuseFocus(bool v) +{ + m_editor->setRefuseFocus(v); +} + +QT_END_NAMESPACE diff --git a/src/activeqt/container/filterwidget_p.h b/src/activeqt/container/filterwidget_p.h new file mode 100644 index 0000000..48c555e --- /dev/null +++ b/src/activeqt/container/filterwidget_p.h @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the ActiveQt framework 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of Qt Designer. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#ifndef FILTERWIDGET_H +#define FILTERWIDGET_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QToolButton; + +/* Note: This a copy of the filter widget found in the qtools repository + * which was modified to contain cleartext.png as inline XPM image data + * and to have LayoutAlignNone as default parameter in the constructor to + * to suit the QAxSelect dialog's needs. + * + * This widget should never have initial focus + * (ie, be the first widget of a dialog, otherwise the hint cannot be displayed. + * For situations, where it is the only focusable control (widget box), + * there is a special "refuseFocus()" mode, in which it clears the focus + * policy and focuses explicitly on click (note that setting Qt::ClickFocus + * is not sufficient for that as an ActivationFocus will occur). */ + +#define ICONBUTTON_SIZE 16 + +class HintLineEdit : public QLineEdit { + Q_OBJECT +public: + explicit HintLineEdit(QWidget *parent = 0); + + bool refuseFocus() const; + void setRefuseFocus(bool v); + +protected: + virtual void mousePressEvent(QMouseEvent *event); + virtual void focusInEvent(QFocusEvent *e); + +private: + const Qt::FocusPolicy m_defaultFocusPolicy; + bool m_refuseFocus; +}; + +// IconButton: This is a simple helper class that represents clickable icons + +class IconButton: public QToolButton +{ + Q_OBJECT + Q_PROPERTY(float fader READ fader WRITE setFader) +public: + IconButton(QWidget *parent); + void paintEvent(QPaintEvent *event); + float fader() { return m_fader; } + void setFader(float value) { m_fader = value; update(); } + void animateShow(bool visible); + +private: + float m_fader; +}; + +// FilterWidget: For filtering item views, with reset button Uses HintLineEdit. + +class FilterWidget : public QWidget +{ + Q_OBJECT +public: + enum LayoutMode { + // For use in toolbars: Expand to the right + LayoutAlignRight, + // No special alignment + LayoutAlignNone + }; + + explicit FilterWidget(QWidget *parent = 0, LayoutMode lm = LayoutAlignNone); + + QString text() const; + void resizeEvent(QResizeEvent *); + bool refuseFocus() const; // see HintLineEdit + void setRefuseFocus(bool v); + +signals: + void filterChanged(const QString &); + +public slots: + void reset(); + +private slots: + void checkButton(const QString &text); + +private: + HintLineEdit *m_editor; + IconButton *m_button; + int m_buttonwidth; + QString m_oldText; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/activeqt/container/qaxselect.cpp b/src/activeqt/container/qaxselect.cpp index abfdf76..cfd9d69 100644 --- a/src/activeqt/container/qaxselect.cpp +++ b/src/activeqt/container/qaxselect.cpp @@ -43,6 +43,10 @@ #ifndef QT_NO_WIN_ACTIVEQT #include "ui_qaxselect.h" +#include +#include +#include + #include QT_BEGIN_NAMESPACE @@ -121,6 +125,26 @@ QVariant ControlList::data(const QModelIndex &index, int role) const return QVariant(); } +class QAxSelectPrivate { +public: + inline QString clsidAt(const QModelIndex &index) const + { + if (index.isValid()) { + const QModelIndex sourceIndex = filterModel->mapToSource(index); + if (sourceIndex.isValid()) + return sourceIndex.data(Qt::UserRole).toString(); + } + return QString(); + } + + inline QPushButton *okButton() const { return selectUi.buttonBox->button(QDialogButtonBox::Ok); } + + inline void setOkButtonEnabled(bool enabled) { okButton()->setEnabled(enabled); } + + Ui::QAxSelect selectUi; + QSortFilterProxyModel *filterModel; +}; + /*! \class QAxSelect \brief The QAxSelect class provides a selection dialog for registered COM components. @@ -141,22 +165,36 @@ QVariant ControlList::data(const QModelIndex &index, int role) const optionally specified with \a parent and \a flags parameters, respectively. */ QAxSelect::QAxSelect(QWidget *parent, Qt::WindowFlags flags) -: QDialog(parent, flags), selectUi(new Ui::QAxSelect) + : QDialog(parent, flags) + , d(new QAxSelectPrivate) { + setWindowFlags(windowFlags() &~ Qt::WindowContextHelpButtonHint); + d->selectUi.setupUi(this); + d->setOkButtonEnabled(false); + #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(Qt::WaitCursor); #endif - selectUi->setupUi(this); - selectUi->ActiveXList->setModel(new ControlList(this)); - connect(selectUi->ActiveXList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(on_ActiveXList_clicked(QModelIndex))); + + d->filterModel = new QSortFilterProxyModel(this); + d->filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + d->filterModel->setSourceModel(new ControlList(this)); + d->selectUi.ActiveXList->setModel(d->filterModel); + + connect(d->selectUi.ActiveXList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), + this, SLOT(onActiveXListCurrentChanged(QModelIndex))); + connect(d->selectUi.ActiveXList, SIGNAL(activated(QModelIndex)), + this, SLOT(onActiveXListActivated())); + #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif - selectUi->ActiveXList->setFocus(); + d->selectUi.ActiveXList->setFocus(); - connect(selectUi->buttonOk, SIGNAL(clicked()), this, SLOT(accept())); - connect(selectUi->buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(d->selectUi.buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(d->selectUi.buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(d->selectUi.filterLineEdit, SIGNAL(filterChanged(QString)), + this, SLOT(onFilterLineEditChanged(QString))); } /*! @@ -173,21 +211,25 @@ QAxSelect::~QAxSelect() */ QString QAxSelect::clsid() const { - return selectUi->ActiveX->text(); + return d->selectUi.ActiveX->text().trimmed(); } -void QAxSelect::on_ActiveXList_clicked(const QModelIndex &index) +void QAxSelect::onActiveXListCurrentChanged(const QModelIndex &index) { - QVariant clsid = selectUi->ActiveXList->model()->data(index, Qt::UserRole); - selectUi->ActiveX->setText(clsid.toString()); + const QString newClsid = d->clsidAt(index); + d->selectUi.ActiveX->setText(newClsid); + d->setOkButtonEnabled(!newClsid.isEmpty()); } -void QAxSelect::on_ActiveXList_doubleClicked(const QModelIndex &index) +void QAxSelect::onActiveXListActivated() { - QVariant clsid = selectUi->ActiveXList->model()->data(index, Qt::UserRole); - selectUi->ActiveX->setText(clsid.toString()); + if (!clsid().isEmpty()) + d->okButton()->animateClick(); +} - accept(); +void QAxSelect::onFilterLineEditChanged(const QString &text) +{ + d->filterModel->setFilterFixedString(text); } QT_END_NAMESPACE diff --git a/src/activeqt/container/qaxselect.h b/src/activeqt/container/qaxselect.h index 8feed38..80ccd82 100644 --- a/src/activeqt/container/qaxselect.h +++ b/src/activeqt/container/qaxselect.h @@ -46,9 +46,8 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_WIN_ACTIVEQT -namespace Ui { - class QAxSelect; -} +class QAxSelectPrivate; +class QModelIndex; class QAxSelect : public QDialog { @@ -59,10 +58,12 @@ public: QString clsid() const; private Q_SLOTS: - void on_ActiveXList_clicked(const QModelIndex &index); - void on_ActiveXList_doubleClicked(const QModelIndex &index); + void onActiveXListCurrentChanged(const QModelIndex &); + void onActiveXListActivated(); + void onFilterLineEditChanged(const QString &); + private: - QScopedPointer selectUi; + QScopedPointer d; }; QT_END_NAMESPACE diff --git a/src/activeqt/container/qaxselect.ui b/src/activeqt/container/qaxselect.ui index 945c8dd..700286d 100644 --- a/src/activeqt/container/qaxselect.ui +++ b/src/activeqt/container/qaxselect.ui @@ -39,136 +39,79 @@ ** $QT_END_LICENSE$ ** ********************************************************************* - - - QAxSelect - - - - 0 - 0 - 439 - 326 - - - - Select ActiveX Control - - - true - - - - unnamed - - - 11 - - + QAxSelect + + + + 0 + 0 + 439 + 326 + + + + Select ActiveX Control + + + true + + + + + + + + + + + + + 6 - - - - - unnamed - - - 0 - - - 6 - - - - - buttonOk - - - OK - - - true - - - true - - - - - - - buttonCancel - - - &Cancel - - - true - - - - - - - - 20 - 0 - - - - Expanding - - - Vertical - - - - - - - - - ActiveXList - + + + 0 + + + + + COM &Object: + + + ActiveX + - - - - - unnamed - - - 0 - - - 6 - - - - - TextLabel1 - - - COM &Object: - - - ActiveX - - - - - - - ActiveX - - - - - + + + + + + - - - - qaxwidget.h - + + + + + Qt::Vertical + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + FilterWidget + QWidget +
filterwidget_p.h
+
+
+ + qaxwidget.h + + + -- cgit v1.2.3