diff --git a/mkspecs/features/ios/qt.prf b/mkspecs/features/ios/qt.prf index f89cb0c287..79bc9a8f46 100644 --- a/mkspecs/features/ios/qt.prf +++ b/mkspecs/features/ios/qt.prf @@ -27,13 +27,9 @@ equals(TEMPLATE, app):contains(QT, gui(-private)?) { # get rid of this step completely and just pass -e _qtmn to the # linker, taking advantage of the new LC_MAIN load command. - # We use xcodebuild to resolve the location of the crt1 object file - # as we know that it lives in the same location as the c library. - c_library_path = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -find-library c 2>/dev/null") - - # We also know that iOS 3.1 and up uses crt1.3.1.o (technically not + # We know that iOS 3.1 and up uses crt1.3.1.o (technically not # true for simulator, but the SDK has a symlink to the correct file). - original_crt_path = $$dirname(c_library_path)/crt1.3.1.o + original_crt_path = "$(SDK_DIR)/usr/lib/crt1.3.1.o" xcode_objects_path = "$(OBJECT_FILE_DIR_$(CURRENT_VARIANT))/$(CURRENT_ARCH)" custom_crt_filename = "crt1_qt.o" diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index b8e6d05728..719507c61d 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -1804,7 +1804,10 @@ ProjectBuilderMakefileGenerator::writeSettings(const QString &var, const ProStri for(int i = 0; i < indent_level; ++i) newline += "\t"; - ret += var + " = "; + static QRegExp allowedVariableCharacters("^[a-zA-Z0-9_]*$"); + ret += var.contains(allowedVariableCharacters) ? var : quotedStringLiteral(var); + + ret += " = "; if(flags & SettingsAsList) { ret += "(" + newline; diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index a2ebe1e410..10ef523e15 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -91,7 +91,7 @@ enum ExpandFunc { E_INVALID = 0, E_MEMBER, E_FIRST, E_LAST, E_SIZE, E_CAT, E_FROMFILE, E_EVAL, E_LIST, E_SPRINTF, E_FORMAT_NUMBER, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION, E_FIND, E_SYSTEM, E_UNIQUE, E_REVERSE, E_QUOTE, E_ESCAPE_EXPAND, - E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE, + E_UPPER, E_LOWER, E_TITLE, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE, E_REPLACE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS, E_SHADOWED, E_ABSOLUTE_PATH, E_RELATIVE_PATH, E_CLEAN_PATH, E_SYSTEM_PATH, E_SHELL_PATH, E_SYSTEM_QUOTE, E_SHELL_QUOTE @@ -134,6 +134,7 @@ void QMakeEvaluator::initFunctionStatics() { "escape_expand", E_ESCAPE_EXPAND }, { "upper", E_UPPER }, { "lower", E_LOWER }, + { "title", E_TITLE }, { "re_escape", E_RE_ESCAPE }, { "val_escape", E_VAL_ESCAPE }, { "files", E_FILES }, @@ -803,9 +804,16 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( break; case E_UPPER: case E_LOWER: + case E_TITLE: for (int i = 0; i < args.count(); ++i) { QString rstr = args.at(i).toQString(m_tmp1); - rstr = (func_t == E_UPPER) ? rstr.toUpper() : rstr.toLower(); + if (func_t == E_UPPER) { + rstr = rstr.toUpper(); + } else { + rstr = rstr.toLower(); + if (func_t == E_TITLE && rstr.length() > 0) + rstr[0] = rstr.at(0).toTitleCase(); + } ret << (rstr.isSharedWith(m_tmp1) ? args.at(i) : ProString(rstr).setSource(args.at(i))); } break; diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 244654786d..f5bfe7e029 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -204,9 +204,9 @@ public class QtNative m_displayMetricsXDpi, m_displayMetricsYDpi, m_displayMetricsScaledDensity); - if (params.length() > 0) + if (params.length() > 0 && !params.startsWith("\t")) params = "\t" + params; - startQtApplication(f.getAbsolutePath() + "\t" + params, environment); + startQtApplication(f.getAbsolutePath() + params, environment); m_started = true; } return res; diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index a6d013b11a..a23a6a7cda 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -310,8 +310,8 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress) QVariant QVariantAnimationPrivate::valueAt(qreal step) const { QVariantAnimation::KeyValues::const_iterator result = - qBinaryFind(keyValues.begin(), keyValues.end(), qMakePair(step, QVariant()), animationValueLessThan); - if (result != keyValues.constEnd()) + std::lower_bound(keyValues.constBegin(), keyValues.constEnd(), qMakePair(step, QVariant()), animationValueLessThan); + if (result != keyValues.constEnd() && !animationValueLessThan(qMakePair(step, QVariant()), *result)) return result->second; return QVariant(); diff --git a/src/corelib/codecs/qeuckrcodec.cpp b/src/corelib/codecs/qeuckrcodec.cpp index 20ba1e85d6..873b782378 100644 --- a/src/corelib/codecs/qeuckrcodec.cpp +++ b/src/corelib/codecs/qeuckrcodec.cpp @@ -70,6 +70,8 @@ #include "qeuckrcodec_p.h" #include "cp949codetbl_p.h" +#include + QT_BEGIN_NAMESPACE #ifndef QT_NO_BIG_CODECS @@ -3383,8 +3385,8 @@ QByteArray QCP949Codec::convertFromUnicode(const QChar *uc, int len, ConverterSt *cursor++ = (j >> 8) | 0x80; *cursor++ = (j & 0xff) | 0x80; } else { - const unsigned short *ptr = qBinaryFind(cp949_icode_to_unicode, cp949_icode_to_unicode + 8822, ch); - if (ptr == cp949_icode_to_unicode + 8822) { + const unsigned short *ptr = std::lower_bound(cp949_icode_to_unicode, cp949_icode_to_unicode + 8822, ch); + if (ptr == cp949_icode_to_unicode + 8822 || ch < *ptr) { // Error *cursor++ = replacement; ++invalid; diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index 2cadea59c1..ba84dd109e 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -115,6 +115,9 @@ // Image Text //#define QT_NO_IMAGE_TEXT +// QKeySequenceEdit +//#define QT_NO_KEYSEQUENCEEDIT + // QLCDNumber //#define QT_NO_LCDNUMBER @@ -306,6 +309,11 @@ #define QT_NO_IMAGEFORMATPLUGIN #endif +// QKeySequenceEdit +#if !defined(QT_NO_KEYSEQUENCEEDIT) && (defined(QT_NO_SHORTCUT)) +#define QT_NO_KEYSEQUENCEEDIT +#endif + // QLocalServer #if !defined(QT_NO_LOCALSERVER) && (defined(QT_NO_TEMPORARYFILE)) #define QT_NO_LOCALSERVER diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 1cd11ad667..4d564b09c3 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -184,14 +184,14 @@ static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) Q_DECL OutputDebugStringW(emergency_bufL); # else if (qWinLogToStderr()) { - fprintf(stderr, "%s", emergency_buf); + fprintf(stderr, "%s\n", emergency_buf); fflush(stderr); } else { OutputDebugStringA(emergency_buf); } # endif #else - fprintf(stderr, "%s", emergency_buf); + fprintf(stderr, "%s\n", emergency_buf); fflush(stderr); #endif diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index e959faccd2..ee95e590f9 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -42,6 +42,7 @@ #include "qurl_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -1461,10 +1462,10 @@ static void mapToLowerCase(QString *str, int from) ++i; } } - const NameprepCaseFoldingEntry *entry = qBinaryFind(NameprepCaseFolding, - NameprepCaseFolding + N, - uc); - if ((entry - NameprepCaseFolding) != N) { + const NameprepCaseFoldingEntry *entry = std::lower_bound(NameprepCaseFolding, + NameprepCaseFolding + N, + uc); + if ((entry != NameprepCaseFolding + N) && !(uc < *entry)) { int l = 1; while (l < 4 && entry->mapping[l]) ++l; diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index ff17a52a75..d99bba93ee 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1680,6 +1680,8 @@ struct UCS2Pair { ushort u2; }; +inline bool operator<(const UCS2Pair &ligature1, const UCS2Pair &ligature2) +{ return ligature1.u1 < ligature2.u1; } inline bool operator<(ushort u1, const UCS2Pair &ligature) { return u1 < ligature.u1; } inline bool operator<(const UCS2Pair &ligature, ushort u1) @@ -1690,6 +1692,8 @@ struct UCS2SurrogatePair { UCS2Pair p2; }; +inline bool operator<(const UCS2SurrogatePair &ligature1, const UCS2SurrogatePair &ligature2) +{ return QChar::surrogateToUcs4(ligature1.p1.u1, ligature1.p1.u2) < QChar::surrogateToUcs4(ligature2.p1.u1, ligature2.p1.u2); } inline bool operator<(uint u1, const UCS2SurrogatePair &ligature) { return u1 < QChar::surrogateToUcs4(ligature.p1.u1, ligature.p1.u2); } inline bool operator<(const UCS2SurrogatePair &ligature, uint u1) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ac9639385a..d64d929d5a 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -4898,7 +4898,7 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) break; case Qt::TimeZone: #ifndef QT_BOOTSTRAPPED - spec = QStringLiteral(" Qt::TimeZone ") + date.timeZone().id(); + spec = QStringLiteral(" Qt::TimeZone ") + QString::fromLatin1(date.timeZone().id()); break; #endif // QT_BOOTSTRAPPED case Qt::LocalTime: diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index c0cd419c53..ef2dba5700 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -2883,6 +2883,8 @@ static const struct CategoriesRangeMapEntry { { "YijingHexagramSymbols", 0x4DC0, 0x4DFF } }; +inline bool operator<(const CategoriesRangeMapEntry &entry1, const CategoriesRangeMapEntry &entry2) +{ return qstrcmp(entry1.name, entry2.name) < 0; } inline bool operator<(const char *name, const CategoriesRangeMapEntry &entry) { return qstrcmp(name, entry.name) < 0; } inline bool operator<(const CategoriesRangeMapEntry &entry, const char *name) diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp index f5f2b28b88..cdd0aba102 100644 --- a/src/corelib/tools/qtimezone.cpp +++ b/src/corelib/tools/qtimezone.cpp @@ -47,6 +47,8 @@ #include +#include + QT_BEGIN_NAMESPACE // Create default time zone using appropriate backend @@ -781,7 +783,7 @@ QList QTimeZone::availableTimeZoneIds() QSet set = QUtcTimeZonePrivate().availableTimeZoneIds() + global_tz->backend->availableTimeZoneIds(); QList list = set.toList(); - qSort(list); + std::sort(list.begin(), list.end()); return list; } @@ -801,7 +803,7 @@ QList QTimeZone::availableTimeZoneIds(QLocale::Country country) QSet set = QUtcTimeZonePrivate().availableTimeZoneIds(country) + global_tz->backend->availableTimeZoneIds(country); QList list = set.toList(); - qSort(list); + std::sort(list.begin(), list.end()); return list; } @@ -817,7 +819,7 @@ QList QTimeZone::availableTimeZoneIds(int offsetSeconds) QSet set = QUtcTimeZonePrivate().availableTimeZoneIds(offsetSeconds) + global_tz->backend->availableTimeZoneIds(offsetSeconds); QList list = set.toList(); - qSort(list); + std::sort(list.begin(), list.end()); return list; } diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index e38bea3181..e043a4cd15 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -120,7 +120,7 @@ SOURCES += \ tools/qstring_mac.mm } else:blackberry { - SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_blackberry.cpp + SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_blackberry.cpp tools/qtimezoneprivate_tz.cpp HEADERS += tools/qlocale_blackberry.h } else:unix:SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp tools/qtimezoneprivate_tz.cpp diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 3bd8ca92b4..528bd4ebb1 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -49,10 +49,7 @@ #include #include -#if defined(Q_CC_BOR) -// needed for qsort() because of a std namespace problem on Borland -#include "qplatformdefs.h" -#endif +#include QT_BEGIN_NAMESPACE @@ -752,8 +749,8 @@ inline bool operator<(const XPMRGBData &data, const char *name) static inline bool qt_get_named_xpm_rgb(const char *name_no_space, QRgb *rgb) { - const XPMRGBData *r = qBinaryFind(xpmRgbTbl, xpmRgbTbl + xpmRgbTblSize, name_no_space); - if (r != xpmRgbTbl + xpmRgbTblSize) { + const XPMRGBData *r = std::lower_bound(xpmRgbTbl, xpmRgbTbl + xpmRgbTblSize, name_no_space); + if ((r != xpmRgbTbl + xpmRgbTblSize) && !(name_no_space < *r)) { *rgb = r->value; return true; } else { diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 9464d97932..16324b3659 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -60,6 +60,8 @@ #include #endif +#include + QT_BEGIN_NAMESPACE #if defined(Q_OS_MACX) @@ -107,8 +109,8 @@ static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntrie QChar qt_macSymbolForQtKey(int key) { - const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key); - if (i == MacSpecialKeyEntriesEnd) + const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key); + if ((i == MacSpecialKeyEntriesEnd) || (key < *i)) return QChar(); ushort macSymbol = i->macSymbol; if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta) diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index b913f5338c..3f6326fcbe 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -40,15 +40,11 @@ ****************************************************************************/ #include "qglobal.h" - -#if defined(Q_CC_BOR) -// needed for qsort() because of a std namespace problem on Borland -#include "qplatformdefs.h" -#endif - #include "qrgb.h" #include "qstringlist.h" +#include + QT_BEGIN_NAMESPACE static inline int h2i(char hex) @@ -301,8 +297,8 @@ inline bool operator<(const RGBData &data, const char *name) static bool get_named_rgb(const char *name_no_space, QRgb *rgb) { QByteArray name = QByteArray(name_no_space).toLower(); - const RGBData *r = qBinaryFind(rgbTbl, rgbTbl + rgbTblSize, name.constData()); - if (r != rgbTbl + rgbTblSize) { + const RGBData *r = std::lower_bound(rgbTbl, rgbTbl + rgbTblSize, name.constData()); + if ((r != rgbTbl + rgbTblSize) && !(name.constData() < *r)) { *rgb = r->value; return true; } diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index b486ec05fa..7a96fbe88b 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -51,6 +51,8 @@ #include #include "private/qfunctions_p.h" +#include + #ifndef QT_NO_CSSPARSER QT_BEGIN_NAMESPACE @@ -358,8 +360,8 @@ Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCssKnownValue &prop, const QStrin static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues) { const QCssKnownValue *end = &start[numValues - 1]; - const QCssKnownValue *prop = qBinaryFind(start, end, name); - if (prop == end) + const QCssKnownValue *prop = std::lower_bound(start, end, name); + if ((prop == end) || (name < *prop)) return 0; return prop->id; } diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 810b51b9c4..b3889a02a4 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1880,4 +1880,13 @@ QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosit return engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, t); } +QTestFontEngine::QTestFontEngine(int size) + : QFontEngineBox(size) +{} + +QFontEngine::Type QTestFontEngine::type() const +{ + return TestFontEngine; +} + QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 1a6862898d..d3faef93bb 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -434,8 +434,8 @@ protected: class QTestFontEngine : public QFontEngineBox { public: - QTestFontEngine(int size) : QFontEngineBox(size) {} - virtual Type type() const { return TestFontEngine; } + QTestFontEngine(int size); + virtual Type type() const; }; QT_END_NAMESPACE diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index 01ae5888e2..152e15a54d 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -101,8 +101,8 @@ QByteArray QFontSubset::glyphName(unsigned short unicode, bool symbol) // map from latin1 to symbol unicode = symbol_map[unicode]; - const AGLEntry *r = qBinaryFind(unicode_to_agl_map, unicode_to_agl_map + unicode_to_agl_map_size, unicode); - if (r != unicode_to_agl_map + unicode_to_agl_map_size) + const AGLEntry *r = std::lower_bound(unicode_to_agl_map, unicode_to_agl_map + unicode_to_agl_map_size, unicode); + if ((r != unicode_to_agl_map + unicode_to_agl_map_size) && !(unicode < *r)) return glyph_names + r->index; char buffer[8]; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 241ed21a10..e571e8da8a 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2969,7 +2969,10 @@ void QTextEngine::resolveAdditionalFormats() const } while (endIt != addFormatSortedByEnd.constEnd() && specialData->addFormats.at(*endIt).start + specialData->addFormats.at(*endIt).length < end) { - currentFormats.remove(qBinaryFind(currentFormats, *endIt) - currentFormats.begin()); + int *currentFormatIterator = std::lower_bound(currentFormats.begin(), currentFormats.end(), *endIt); + if (*endIt < *currentFormatIterator) + currentFormatIterator = currentFormats.end(); + currentFormats.remove(currentFormatIterator - currentFormats.begin()); ++endIt; } QTextCharFormat format; diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index e99ba49107..c177fa0810 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -55,6 +55,8 @@ #include "qfont_p.h" #include "private/qfunctions_p.h" +#include + #ifndef QT_NO_TEXTHTMLPARSER QT_BEGIN_NAMESPACE @@ -336,8 +338,8 @@ static QChar resolveEntity(const QString &entity) { const QTextHtmlEntity *start = &entities[0]; const QTextHtmlEntity *end = &entities[MAX_ENTITY]; - const QTextHtmlEntity *e = qBinaryFind(start, end, entity); - if (e == end) + const QTextHtmlEntity *e = std::lower_bound(start, end, entity); + if (e == end || (entity < *e)) return QChar(); return e->code; } @@ -456,8 +458,8 @@ static const QTextHtmlElement *lookupElementHelper(const QString &element) { const QTextHtmlElement *start = &elements[0]; const QTextHtmlElement *end = &elements[Html_NumElements]; - const QTextHtmlElement *e = qBinaryFind(start, end, element); - if (e == end) + const QTextHtmlElement *e = std::lower_bound(start, end, element); + if ((e == end) || (element < *e)) return 0; return e; } diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index a56f8060e0..879c3ddc70 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -393,10 +393,10 @@ int QTextTablePrivate::findCellIndex(int fragment) const { QFragmentFindHelper helper(pieceTable->fragmentMap().position(fragment), pieceTable->fragmentMap()); - QList::ConstIterator it = qBinaryFind(cells.begin(), cells.end(), helper); - if (it == cells.end()) + QList::ConstIterator it = std::lower_bound(cells.constBegin(), cells.constEnd(), helper); + if ((it == cells.constEnd()) || (helper < *it)) return -1; - return it - cells.begin(); + return it - cells.constBegin(); } void QTextTablePrivate::fragmentAdded(QChar type, uint fragment) @@ -1048,8 +1048,9 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) // find the position at which to insert the contents of the merged cells QFragmentFindHelper helper(origCellPosition, p->fragmentMap()); - QList::Iterator it = qBinaryFind(d->cells.begin(), d->cells.end(), helper); + QList::Iterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); Q_ASSERT(it != d->cells.end()); + Q_ASSERT(!(helper < *it)); Q_ASSERT(*it == cellFragment); const int insertCellIndex = it - d->cells.begin(); int insertFragment = d->cells.value(insertCellIndex + 1, d->fragment_end); @@ -1080,8 +1081,9 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) if (firstCellIndex == -1) { QFragmentFindHelper helper(pos, p->fragmentMap()); - QList::Iterator it = qBinaryFind(d->cells.begin(), d->cells.end(), helper); + QList::Iterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); Q_ASSERT(it != d->cells.end()); + Q_ASSERT(!(helper < *it)); Q_ASSERT(*it == fragment); firstCellIndex = cellIndex = it - d->cells.begin(); } diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 901efbfb39..197a2058af 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -325,16 +325,16 @@ QChar qt_mac_qtKey2CocoaKey(Qt::Key key) std::sort(rev_entries.begin(), rev_entries.end(), qtKey2CocoaKeySortLessThan); } const QVector::iterator i - = qBinaryFind(rev_entries.begin(), rev_entries.end(), key); - if (i == rev_entries.end()) + = std::lower_bound(rev_entries.begin(), rev_entries.end(), key); + if ((i == rev_entries.end()) || (key < *i)) return QChar(); return i->cocoaKey; } Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode) { - const KeyPair *i = qBinaryFind(entries, end, keyCode); - if (i == end) + const KeyPair *i = std::lower_bound(entries, end, keyCode); + if ((i == end) || (keyCode < *i)) return Qt::Key(keyCode.toUpper().unicode()); return i->qtKey; } diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 8967445f59..05bf657c1f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -200,6 +200,7 @@ public: // for QNSView bool m_frameStrutEventsEnabled; bool m_isExposed; int m_registerTouchCount; + bool m_resizableTransientParent; static const int NoAlertRequest; NSInteger m_alertRequest; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 5fc2975a9d..671214f424 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -211,6 +211,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_frameStrutEventsEnabled(false) , m_isExposed(false) , m_registerTouchCount(0) + , m_resizableTransientParent(false) , m_alertRequest(NoAlertRequest) { #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG @@ -317,12 +318,14 @@ void QCocoaWindow::setVisible(bool visible) parentCocoaWindow->m_activePopupWindow = window(); // QTBUG-30266: a window should not be resizable while a transient popup is open // Since this isn't a native popup, the window manager doesn't close the popup when you click outside + NSUInteger parentStyleMask = [parentCocoaWindow->m_nsWindow styleMask]; + if ((m_resizableTransientParent = (parentStyleMask & NSResizableWindowMask)) #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 - && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask)) + && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 + && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask) #endif - [parentCocoaWindow->m_nsWindow setStyleMask: - (parentCocoaWindow->windowStyleMask(parentCocoaWindow->m_windowFlags) & ~NSResizableWindowMask)]; + ) + [parentCocoaWindow->m_nsWindow setStyleMask:parentStyleMask & ~NSResizableWindowMask]; } } @@ -398,13 +401,14 @@ void QCocoaWindow::setVisible(bool visible) [m_contentView setHidden:YES]; } if (parentCocoaWindow && window()->type() == Qt::Popup + && m_resizableTransientParent #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask) #endif ) // QTBUG-30266: a window should not be resizable while a transient popup is open - [parentCocoaWindow->m_nsWindow setStyleMask:parentCocoaWindow->windowStyleMask(parentCocoaWindow->m_windowFlags)]; + [parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask]; } } diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index c8d0f823f6..dbeec5f5f2 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -150,9 +150,9 @@ - (void)updateTouchList:(NSSet *)touches withState:(Qt::TouchPointState)state { - QPlatformScreen *screen = QGuiApplication::primaryScreen()->handle(); - QRect applicationRect = fromPortraitToPrimary(fromCGRect(self.window.screen.applicationFrame), screen); - + // We deliver touch events with global coordinates. But global in this respect means + // the coordinate system where this QWindow lives. And that is our superview. + CGSize parentSize = self.superview.frame.size; foreach (UITouch *uiTouch, m_activeTouches.keys()) { QWindowSystemInterface::TouchPoint &touchPoint = m_activeTouches[uiTouch]; if (![touches containsObject:uiTouch]) { @@ -160,15 +160,9 @@ } else { touchPoint.state = state; touchPoint.pressure = (state == Qt::TouchPointReleased) ? 0.0 : 1.0; - - // Find the touch position relative to the window. Then calculate the screen - // position by subtracting the position of the applicationRect (since UIWindow - // does not take that into account when reporting its own frame): - QRect touchInWindow = QRect(fromCGPoint([uiTouch locationInView:nil]), QSize(0, 0)); - QRect touchInScreen = fromPortraitToPrimary(touchInWindow, screen); - QPoint touchPos = touchInScreen.topLeft() - applicationRect.topLeft(); + QPoint touchPos = fromCGPoint([uiTouch locationInView:self.superview]); touchPoint.area = QRectF(touchPos, QSize(0, 0)); - touchPoint.normalPosition = QPointF(touchPos.x() / applicationRect.width(), touchPos.y() / applicationRect.height()); + touchPoint.normalPosition = QPointF(touchPos.x() / parentSize.width, touchPos.y() / parentSize.height); } } } diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index a0f2c1812f..9170c774b4 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -955,7 +955,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_rowDescription(long row, BS *description = 0; if (QAccessibleTableInterface *tableIface = tableInterface()) { - const QString qtDesc = tableIface->columnDescription(row); + const QString qtDesc = tableIface->rowDescription(row); if (!qtDesc.isEmpty()) *description = QStringToBSTR(qtDesc); } diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index c724bde4fa..643ffef192 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -50,6 +50,8 @@ #endif #include +#include + QT_BEGIN_NAMESPACE extern double qt_multiplierForUnit(QPrinter::Unit unit, int resolution); @@ -517,15 +519,15 @@ void QCUPSSupport::setPagesPerSheetLayout(QPrinter *printer, const PagesPerShee QStringList cupsOptions = cupsOptionsList(printer); static const char *pagesPerSheetData[] = { "1", "2", "4", "6", "9", "16", 0 }; static const char *pageLayoutData[] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl", 0}; - setCupsOption(cupsOptions, QStringLiteral("number-up"), pagesPerSheetData[pagesPerSheet]); - setCupsOption(cupsOptions, QStringLiteral("number-up-layout"), pageLayoutData[pagesPerSheetLayout]); + setCupsOption(cupsOptions, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet])); + setCupsOption(cupsOptions, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout])); setCupsOptions(printer, cupsOptions); } void QCUPSSupport::setPageRange(QPrinter *printer, int pageFrom, int pageTo) { QStringList cupsOptions = cupsOptionsList(printer); - setCupsOption(cupsOptions, QStringLiteral("page-ranges"), QString("%1-%2").arg(pageFrom).arg(pageTo)); + setCupsOption(cupsOptions, QStringLiteral("page-ranges"), QStringLiteral("%1-%2").arg(pageFrom).arg(pageTo)); setCupsOptions(printer, cupsOptions); } @@ -659,8 +661,8 @@ inline bool operator<(const NamedPaperSize &data, const char *name) static inline QPrinter::PaperSize string2PaperSize(const char *name) { - const NamedPaperSize *r = qBinaryFind(named_sizes_map, named_sizes_map + QPrinter::NPageSize, name); - if (r - named_sizes_map != QPrinter::NPageSize) + const NamedPaperSize *r = std::lower_bound(named_sizes_map, named_sizes_map + QPrinter::NPageSize, name); + if ((r != named_sizes_map + QPrinter::NPageSize) && !(name < *r)) return r->size; return QPrinter::Custom; } diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 3e64582b06..9751389d6f 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -127,6 +127,28 @@ Q_PRINTSUPPORT_EXPORT double qt_multiplierForUnit(QPrinter::Unit unit, int resol return 1.0; } +/// return the QSize from the specified in unit as millimeters +Q_PRINTSUPPORT_EXPORT QSizeF qt_SizeFromUnitToMillimeter(const QSizeF &size, QPrinter::Unit unit, double resolution) +{ + switch (unit) { + case QPrinter::Millimeter: + return size; + case QPrinter::Point: + return size * 0.352777778; + case QPrinter::Inch: + return size * 25.4; + case QPrinter::Pica: + return size * 4.23333333334; + case QPrinter::Didot: + return size * 0.377; + case QPrinter::Cicero: + return size * 4.511666667; + case QPrinter::DevicePixel: + return size * (0.352777778 * 72.0 / resolution); + } + return size; +} + // not static: it's needed in qpagesetupdialog_unix.cpp Q_PRINTSUPPORT_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientation, QPrinter::PaperSize paperSize, @@ -983,9 +1005,7 @@ void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit) Q_D(QPrinter); if (d->paintEngine->type() != QPaintEngine::Pdf) ABORT_IF_ACTIVE("QPrinter::setPaperSize"); - const qreal multiplier = qt_multiplierForUnit(unit, resolution()); - QSizeF size(paperSize.width() * multiplier * 25.4/72., paperSize.height() * multiplier * 25.4/72.); - setPageSizeMM(size); + setPageSizeMM(qt_SizeFromUnitToMillimeter(paperSize, unit, resolution())); } /*! diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index a923a0d0fa..57ce5b031d 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -62,6 +62,10 @@ #include #include +#ifdef Q_OS_ANDROID +# include +#endif + QT_BEGIN_NAMESPACE namespace QTest { @@ -206,6 +210,8 @@ void QPlainTestLogger::outputMessage(const char *str) if (stream != stdout) #elif defined(Q_OS_WIN) OutputDebugStringA(str); +#elif defined(Q_OS_ANDROID) + __android_log_print(ANDROID_LOG_INFO, "QTestLib", str); #endif outputString(str); } diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 98472792f8..3ae6445093 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -199,6 +199,7 @@ int runMoc(int argc, char **argv) dummyVariadicFunctionMacro.isVariadic = true; dummyVariadicFunctionMacro.arguments += Symbol(0, PP_IDENTIFIER, "__VA_ARGS__"); pp.macros["__attribute__"] = dummyVariadicFunctionMacro; + pp.macros["__declspec"] = dummyVariadicFunctionMacro; QString filename; QString output; diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp index 0d4e563836..549b3a3918 100644 --- a/src/tools/qdoc/generator.cpp +++ b/src/tools/qdoc/generator.cpp @@ -1120,17 +1120,10 @@ void Generator::generateSince(const Node *node, CodeMarker *marker) QStringList since = node->since().split(QLatin1Char(' ')); if (since.count() == 1) { - // Handle legacy use of \since . - if (project.isEmpty()) - text << "version"; - else - text << Atom(Atom::Link, project) - << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) - << Atom(Atom::String, project) - << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); - text << " " << since[0]; + // If there is only one argument, assume it is the Qt version number. + text << " Qt " << since[0]; } else { - // Reconstruct the string. + // Otherwise, reconstruct the string. text << " " << since.join(' '); } diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 1c28ede976..697955629e 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -1868,18 +1868,11 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker) text.clear(); QStringList since = inner->since().split(QLatin1Char(' ')); if (since.count() == 1) { - // Handle legacy use of \since . - if (project.isEmpty()) - text << "version"; - else - text << Atom(Atom::Link, project) - << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) - << Atom(Atom::String, project) - << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); - text << " " << since[0]; + // If there is only one argument, assume it is the Qt version number. + text << " Qt " << since[0]; } else { - // Reconstruct the string. + //Otherwise, reconstruct the string. text << " " << since.join(' '); } text << Atom::ParaRight; @@ -1998,10 +1991,16 @@ void HtmlGenerator::generateQmlRequisites(QmlClassNode *qcn, CodeMarker *marker) << inheritedBytext; //add the module name and version to the map + QString qmlModuleVersion; + DocNode* dn = qdb_->findQmlModule(qcn->qmlModuleName()); + if (dn) + qmlModuleVersion = dn->qmlModuleVersion(); + else + qmlModuleVersion = qcn->qmlModuleVersion(); text.clear(); text << formattingRightMap()[ATOM_FORMATTING_BOLD] << formattingLeftMap()[ATOM_FORMATTING_TELETYPE] - << "import " + qcn->qmlModuleName() + " " + qcn->qmlModuleVersion() + << "import " + qcn->qmlModuleName() + " " + qmlModuleVersion << formattingRightMap()[ATOM_FORMATTING_TELETYPE]; requisites.insert(importText, text); @@ -2010,19 +2009,11 @@ void HtmlGenerator::generateQmlRequisites(QmlClassNode *qcn, CodeMarker *marker) text.clear(); QStringList since = qcn->since().split(QLatin1Char(' ')); if (since.count() == 1) { - // Handle legacy use of \since . - if (project.isEmpty()) - text << "version"; - else - text << Atom(Atom::Link, project) - << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) - << Atom(Atom::String, project) - << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); - - text << " " << since[0]; + // If there is only one argument, assume it is the Qt version number. + text << " Qt " << since[0]; } else { - // Reconstruct the string. + //Otherwise, reconstruct the string. text << " " << since.join(' '); } text << Atom::ParaRight; @@ -3605,8 +3596,10 @@ QString HtmlGenerator::linkForNode(const Node *node, const Node *relative) back down into the other subdirectory. */ if (node && relative && (node != relative)) { - if (useOutputSubdirs() && node->outputSubdirectory() != relative->outputSubdirectory()) + if (useOutputSubdirs() && !node->isExternalPage() && + node->outputSubdirectory() != relative->outputSubdirectory()) { link.prepend(QString("../" + node->outputSubdirectory() + QLatin1Char('/'))); + } } return link; } diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h index 76e762120e..f1d9931a08 100644 --- a/src/tools/qdoc/node.h +++ b/src/tools/qdoc/node.h @@ -211,6 +211,7 @@ public: virtual bool isWrapper() const; virtual bool isReadOnly() const { return false; } virtual bool isDefault() const { return false; } + virtual bool isExternalPage() const { return false; } virtual void addMember(Node* ) { } virtual bool hasMembers() const { return false; } virtual bool hasNamespaces() const { return false; } @@ -514,6 +515,7 @@ public: virtual bool isGroup() const { return (subType() == Node::Group); } virtual bool isExample() const { return (subType() == Node::Example); } virtual bool isExampleFile() const { return (parent() && parent()->isExample()); } + virtual bool isExternalPage() const { return nodeSubtype_ == ExternalPage; } protected: SubType nodeSubtype_; diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp index d8cb42513e..bef22631f0 100644 --- a/src/tools/qdoc/qdocindexfiles.cpp +++ b/src/tools/qdoc/qdocindexfiles.cpp @@ -499,9 +499,10 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element, QString moduleName = element.attribute("module"); if (!moduleName.isEmpty()) node->setModuleName(moduleName); - if (!indexUrl.isEmpty()) { + if (node->isExternalPage()) + node->setUrl(href); + else if (!indexUrl.isEmpty()) node->setUrl(indexUrl + QLatin1Char('/') + href); - } QString since = element.attribute("since"); if (!since.isEmpty()) { @@ -776,15 +777,20 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, if (!qmlFullBaseName.isEmpty()) writer.writeAttribute("qml-base-type", qmlFullBaseName); } - QString fullName = node->fullDocumentName(); - if (fullName != objName) - writer.writeAttribute("fullname", fullName); + QString href; - if (Generator::useOutputSubdirs()) - href = node->outputSubdirectory(); - if (!href.isEmpty()) - href.append(QLatin1Char('/')); - href.append(gen_->fullDocumentLocation(node)); + if (!node->isExternalPage()) { + QString fullName = node->fullDocumentName(); + if (fullName != objName) + writer.writeAttribute("fullname", fullName); + if (Generator::useOutputSubdirs()) + href = node->outputSubdirectory(); + if (!href.isEmpty()) + href.append(QLatin1Char('/')); + href.append(gen_->fullDocumentLocation(node)); + } + else + href = node->name(); writer.writeAttribute("href", href); writer.writeAttribute("location", node->location().fileName()); diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index cedefb801a..48793e7f09 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -931,6 +931,7 @@ QT_CLASS_LIB(QFocusFrame, QtWidgets, qfocusframe.h) QT_CLASS_LIB(QFontComboBox, QtWidgets, qfontcombobox.h) QT_CLASS_LIB(QFrame, QtWidgets, qframe.h) QT_CLASS_LIB(QGroupBox, QtWidgets, qgroupbox.h) +QT_CLASS_LIB(QKeySequenceEdit, QtWidgets, qkeysequenceedit.h) QT_CLASS_LIB(QLabel, QtWidgets, qlabel.h) QT_CLASS_LIB(QLCDNumber, QtWidgets, qlcdnumber.h) QT_CLASS_LIB(QLineEdit, QtWidgets, qlineedit.h) diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 9c6d972baa..c86c7ff931 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -201,7 +201,9 @@ bool QFileSystemModel::remove(const QModelIndex &aindex) { const QString path = filePath(aindex); QFileSystemModelPrivate * d = const_cast(d_func()); +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.removePath(path); +#endif return QDir(path).removeRecursively(); } @@ -423,7 +425,9 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS return const_cast(&root); QFileSystemModelPrivate *p = const_cast(this); node = p->addNode(parent, element,info); +#ifndef QT_NO_FILESYSTEMWATCHER node->populate(fileInfoGatherer.getInfo(info)); +#endif } else { node = parent->children.value(element); } @@ -610,7 +614,9 @@ void QFileSystemModel::fetchMore(const QModelIndex &parent) if (indexNode->populatedChildren) return; indexNode->populatedChildren = true; +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.list(filePath(parent)); +#endif } /*! @@ -648,8 +654,10 @@ QVariant QFileSystemModel::myComputer(int role) const switch (role) { case Qt::DisplayRole: return d->myComputer(); +#ifndef QT_NO_FILESYSTEMWATCHER case Qt::DecorationRole: return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer); +#endif } return QVariant(); } @@ -683,12 +691,14 @@ QVariant QFileSystemModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: if (index.column() == 0) { QIcon icon = d->icon(index); +#ifndef QT_NO_FILESYSTEMWATCHER if (icon.isNull()) { if (d->node(index)->isDir()) icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder); else icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File); } +#endif // QT_NO_FILESYSTEMWATCHER return icon; } break; @@ -778,7 +788,11 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const if (!index.isValid()) return QString(); QFileSystemNode *dirNode = node(index); - if (fileInfoGatherer.resolveSymlinks() && !resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) { + if ( +#ifndef QT_NO_FILESYSTEMWATCHER + fileInfoGatherer.resolveSymlinks() && +#endif + !resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) { QString fullPath = QDir::fromNativeSeparators(filePath(index)); if (resolvedSymLinks.contains(fullPath)) return resolvedSymLinks[fullPath]; @@ -859,7 +873,9 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in QFileInfo info(d->rootDir, newName); oldValue->fileName = newName; oldValue->parent = parentNode; +#ifndef QT_NO_FILESYSTEMWATCHER oldValue->populate(d->fileInfoGatherer.getInfo(info)); +#endif oldValue->isVisible = true; parentNode->children.remove(oldName); @@ -1278,7 +1294,10 @@ QString QFileSystemModel::filePath(const QModelIndex &index) const Q_D(const QFileSystemModel); QString fullPath = d->filePath(index); QFileSystemModelPrivate::QFileSystemNode *dirNode = d->node(index); - if (dirNode->isSymLink() && d->fileInfoGatherer.resolveSymlinks() + if (dirNode->isSymLink() +#ifndef QT_NO_FILESYSTEMWATCHER + && d->fileInfoGatherer.resolveSymlinks() +#endif && d->resolvedSymLinks.contains(fullPath) && dirNode->isDir()) { QFileInfo resolvedInfo(fullPath); @@ -1333,7 +1352,9 @@ QModelIndex QFileSystemModel::mkdir(const QModelIndex &parent, const QString &na d->addNode(parentNode, name, QFileInfo()); Q_ASSERT(parentNode->children.contains(name)); QFileSystemModelPrivate::QFileSystemNode *node = parentNode->children[name]; +#ifndef QT_NO_FILESYSTEMWATCHER node->populate(d->fileInfoGatherer.getInfo(QFileInfo(dir.absolutePath() + QDir::separator() + name))); +#endif d->addVisibleFiles(parentNode, QStringList(name)); return d->index(node); } @@ -1395,7 +1416,9 @@ QModelIndex QFileSystemModel::setRootPath(const QString &newPath) //We remove the watcher on the previous path if (!rootPath().isEmpty() && rootPath() != QLatin1String(".")) { //This remove the watcher for the old rootPath +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.removePath(rootPath()); +#endif //This line "marks" the node as dirty, so the next fetchMore //call on the path will ask the gatherer to install a watcher again //But it doesn't re-fetch everything @@ -1449,7 +1472,9 @@ QDir QFileSystemModel::rootDirectory() const void QFileSystemModel::setIconProvider(QFileIconProvider *provider) { Q_D(QFileSystemModel); +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.setIconProvider(provider); +#endif d->root.updateIcon(provider, QString()); } @@ -1458,8 +1483,12 @@ void QFileSystemModel::setIconProvider(QFileIconProvider *provider) */ QFileIconProvider *QFileSystemModel::iconProvider() const { +#ifndef QT_NO_FILESYSTEMWATCHER Q_D(const QFileSystemModel); return d->fileInfoGatherer.iconProvider(); +#else + return 0; +#endif } /*! @@ -1506,14 +1535,20 @@ QDir::Filters QFileSystemModel::filter() const */ void QFileSystemModel::setResolveSymlinks(bool enable) { +#ifndef QT_NO_FILESYSTEMWATCHER Q_D(QFileSystemModel); d->fileInfoGatherer.setResolveSymlinks(enable); +#endif } bool QFileSystemModel::resolveSymlinks() const { +#ifndef QT_NO_FILESYSTEMWATCHER Q_D(const QFileSystemModel); return d->fileInfoGatherer.resolveSymlinks(); +#else + return false; +#endif } /*! @@ -1620,7 +1655,9 @@ bool QFileSystemModel::event(QEvent *event) { Q_D(QFileSystemModel); if (event->type() == QEvent::LanguageChange) { +#ifndef QT_NO_FILESYSTEMWATCHER d->root.retranslateStrings(d->fileInfoGatherer.iconProvider(), QString()); +#endif return true; } return QAbstractItemModel::event(event); @@ -1630,7 +1667,9 @@ bool QFileSystemModel::rmdir(const QModelIndex &aindex) { QString path = filePath(aindex); QFileSystemModelPrivate * d = const_cast(d_func()); +#ifndef QT_NO_FILESYSTEMWATCHER d->fileInfoGatherer.removePath(path); +#endif return QDir().rmdir(path); } @@ -1650,12 +1689,10 @@ void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, cons std::sort(newFiles.begin(), newFiles.end()); QHash::const_iterator i = parentNode->children.constBegin(); while (i != parentNode->children.constEnd()) { - QStringList::iterator iterator; - iterator = qBinaryFind(newFiles.begin(), newFiles.end(), - i.value()->fileName); - if (iterator == newFiles.end()) { + QStringList::iterator iterator = std::lower_bound(newFiles.begin(), newFiles.end(), i.value()->fileName); + if ((iterator == newFiles.end()) || (i.value()->fileName < *iterator)) toRemove.append(i.value()->fileName); - } + ++i; } for (int i = 0 ; i < toRemove.count() ; ++i ) @@ -1798,6 +1835,7 @@ void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int */ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QList > &updates) { +#ifndef QT_NO_FILESYSTEMWATCHER Q_Q(QFileSystemModel); QVector rowsToUpdate; QStringList newFiles; @@ -1894,6 +1932,7 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QL forceSort = true; delayedSort(); } +#endif // !QT_NO_FILESYSTEMWATCHER } /*! @@ -1911,6 +1950,7 @@ void QFileSystemModelPrivate::init() { Q_Q(QFileSystemModel); qRegisterMetaType > >(); +#ifndef QT_NO_FILESYSTEMWATCHER q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(QString,QStringList)), q, SLOT(_q_directoryChanged(QString,QStringList))); q->connect(&fileInfoGatherer, SIGNAL(updates(QString,QList >)), @@ -1919,6 +1959,7 @@ void QFileSystemModelPrivate::init() q, SLOT(_q_resolvedName(QString,QString))); q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)), q, SIGNAL(directoryLoaded(QString))); +#endif // !QT_NO_FILESYSTEMWATCHER q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index 55d7ee6d1b..5dc3e1159e 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -176,8 +176,8 @@ void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QL Pair pair(step, value); - QList::iterator result = qBinaryFind(binList->begin(), binList->end(), pair); - if (result != binList->end()) + QList::iterator result = std::lower_bound(binList->begin(), binList->end(), pair); + if ((result != binList->end()) && !(pair < *result)) result->value = value; else { *binList << pair; diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index d273060f7b..a00b72484f 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -242,7 +242,7 @@ void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd) tnd.hIcon = hIcon; const QString tip = q->toolTip(); if (!tip.isNull()) - qStringToLimitedWCharArray(tip, tnd.szTip, 64); + qStringToLimitedWCharArray(tip, tnd.szTip, sizeof(tnd.szTip)/sizeof(wchar_t)); } static int iconFlag( QSystemTrayIcon::MessageIcon icon ) diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp new file mode 100644 index 0000000000..a71c0ada70 --- /dev/null +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -0,0 +1,333 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Ivan Komissarov. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWidgets 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 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 "qkeysequenceedit.h" +#include "qkeysequenceedit_p.h" + +#include "qboxlayout.h" +#include "qlineedit.h" + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_KEYSEQUENCEEDIT + +void QKeySequenceEditPrivate::init() +{ + Q_Q(QKeySequenceEdit); + + lineEdit = new QLineEdit(q); + keyNum = 0; + prevKey = -1; + releaseTimer = 0; + + layout = new QVBoxLayout(q); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(lineEdit); + + key[0] = key[1] = key[2] = key[3] = 0; + + lineEdit->setFocusProxy(q); + lineEdit->installEventFilter(q); + resetState(); + + q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + q->setFocusPolicy(Qt::StrongFocus); + q->setAttribute(Qt::WA_MacShowFocusRect, true); + q->setAttribute(Qt::WA_InputMethodEnabled, false); + + // TODO: add clear button +} + +int QKeySequenceEditPrivate::translateModifiers(Qt::KeyboardModifiers state, const QString &text) +{ + int result = 0; + // The shift modifier only counts when it is not used to type a symbol + // that is only reachable using the shift key anyway + if ((state & Qt::ShiftModifier) && (text.isEmpty() || + !text.at(0).isPrint() || + text.at(0).isLetterOrNumber() || + text.at(0).isSpace())) + result |= Qt::SHIFT; + + if (state & Qt::ControlModifier) + result |= Qt::CTRL; + if (state & Qt::MetaModifier) + result |= Qt::META; + if (state & Qt::AltModifier) + result |= Qt::ALT; + return result; +} + +void QKeySequenceEditPrivate::resetState() +{ + Q_Q(QKeySequenceEdit); + + if (releaseTimer) { + q->killTimer(releaseTimer); + releaseTimer = 0; + } + prevKey = -1; + lineEdit->setText(keySequence.toString(QKeySequence::NativeText)); + lineEdit->setPlaceholderText(QKeySequenceEdit::tr("Press shortcut")); +} + +void QKeySequenceEditPrivate::finishEditing() +{ + Q_Q(QKeySequenceEdit); + + resetState(); + emit q->keySequenceChanged(keySequence); + emit q->editingFinished(); +} + +/*! + \class QKeySequenceEdit + \brief The QKeySequenceEdit widget allows to input a QKeySequence. + + \inmodule QtWidgets + + \since 5.2 + + This widget lets the user choose a QKeySequence, which is usually used as + a shortcut. The recording is initiated when the widget receives the focus + and ends one second after the user releases the last key. + + \sa QKeySequenceEdit::keySequence +*/ + +/*! + Constructs a QKeySequenceEdit widget with the given \a parent. +*/ +QKeySequenceEdit::QKeySequenceEdit(QWidget *parent) : + QWidget(*new QKeySequenceEditPrivate, parent, 0) +{ + Q_D(QKeySequenceEdit); + d->init(); +} + +/*! + Constructs a QKeySequenceEdit widget with the given \a keySequence and \a parent. +*/ +QKeySequenceEdit::QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent) : + QWidget(*new QKeySequenceEditPrivate, parent, 0) +{ + Q_D(QKeySequenceEdit); + d->init(); + setKeySequence(keySequence); +} + +/*! + \internal +*/ +QKeySequenceEdit::QKeySequenceEdit(QKeySequenceEditPrivate &dd, QWidget *parent, Qt::WindowFlags f) : + QWidget(dd, parent, f) +{ + Q_D(QKeySequenceEdit); + d->init(); +} + +/*! + Destroys the QKeySequenceEdit object. +*/ +QKeySequenceEdit::~QKeySequenceEdit() +{ +} + +/*! + \property QKeySequenceEdit::keySequence + + \brief This property contains the currently chosen key sequence. + + The shortcut can be changed by the user or via setter function. +*/ +QKeySequence QKeySequenceEdit::keySequence() const +{ + Q_D(const QKeySequenceEdit); + + return d->keySequence; +} + +void QKeySequenceEdit::setKeySequence(const QKeySequence &keySequence) +{ + Q_D(QKeySequenceEdit); + + d->resetState(); + + if (d->keySequence == keySequence) + return; + + d->keySequence = keySequence; + + d->key[0] = d->key[1] = d->key[2] = d->key[3] = 0; + d->keyNum = keySequence.count(); + for (int i = 0; i < d->keyNum; ++i) + d->key[i] = keySequence[i]; + + d->lineEdit->setText(keySequence.toString(QKeySequence::NativeText)); + + emit keySequenceChanged(keySequence); +} + +/*! + \fn void QKeySequenceEdit::editingFinished() + + This signal is emitted when the user finishes entering the shortcut. + + \note there is a one second delay before releasing the last key and + emitting this signal. +*/ + +/*! + \brief Clears the current key sequence. +*/ +void QKeySequenceEdit::clear() +{ + Q_D(QKeySequenceEdit); + + d->resetState(); + + d->lineEdit->clear(); + d->keySequence = QKeySequence(); + d->keyNum = d->key[0] = d->key[1] = d->key[2] = d->key[3] = 0; + d->prevKey = -1; + emit keySequenceChanged(d->keySequence); +} + +/*! + \reimp +*/ +bool QKeySequenceEdit::event(QEvent *e) +{ + switch (e->type()) { + case QEvent::Shortcut: + return true; + case QEvent::ShortcutOverride: + e->accept(); + return true; + default : + break; + } + + return QWidget::event(e); +} + +/*! + \reimp +*/ +void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) +{ + Q_D(QKeySequenceEdit); + + int nextKey = e->key(); + + if (d->prevKey == -1) { + clear(); + d->prevKey = nextKey; + } + + d->lineEdit->setPlaceholderText(QString()); + if (nextKey == Qt::Key_Control + || nextKey == Qt::Key_Shift + || nextKey == Qt::Key_Meta + || nextKey == Qt::Key_Alt) { + return; + } + + QString selectedText = d->lineEdit->selectedText(); + if (!selectedText.isEmpty() && selectedText == d->lineEdit->text()) { + clear(); + if (nextKey == Qt::Key_Backspace) + return; + } + + if (d->keyNum >= QKeySequenceEditPrivate::MaxKeyCount) + return; + + nextKey |= d->translateModifiers(e->modifiers(), e->text()); + + d->key[d->keyNum] = nextKey; + d->keyNum++; + + QKeySequence key(d->key[0], d->key[1], d->key[2], d->key[3]); + d->keySequence = key; + QString text = key.toString(QKeySequence::NativeText); + if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount) { + //: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..." + text = tr("%1, ...").arg(text); + } + d->lineEdit->setText(text); + e->accept(); +} + +/*! + \reimp +*/ +void QKeySequenceEdit::keyReleaseEvent(QKeyEvent *e) +{ + Q_D(QKeySequenceEdit); + + if (d->prevKey == e->key()) { + if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount) + d->releaseTimer = startTimer(1000); + else + d->finishEditing(); + } + e->accept(); +} + +/*! + \reimp +*/ +void QKeySequenceEdit::timerEvent(QTimerEvent *e) +{ + Q_D(QKeySequenceEdit); + if (e->timerId() == d->releaseTimer) { + d->finishEditing(); + return; + } + + QWidget::timerEvent(e); +} + +#endif // QT_NO_KEYSEQUENCEEDIT + +QT_END_NAMESPACE diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h new file mode 100644 index 0000000000..9312e98d0e --- /dev/null +++ b/src/widgets/widgets/qkeysequenceedit.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Ivan Komissarov. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWidgets 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 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$ +** +****************************************************************************/ + +#ifndef QKEYSEQUENCEEDIT_H +#define QKEYSEQUENCEEDIT_H + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_KEYSEQUENCEEDIT + +class QKeySequenceEditPrivate; +class Q_WIDGETS_EXPORT QKeySequenceEdit : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence RESET clear NOTIFY keySequenceChanged USER true) + +public: + explicit QKeySequenceEdit(QWidget *parent = 0); + explicit QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent = 0); + ~QKeySequenceEdit(); + + QKeySequence keySequence() const; + void setKeySequence(const QKeySequence &keySequence); + +public Q_SLOTS: + void clear(); + +Q_SIGNALS: + void editingFinished(); + void keySequenceChanged(const QKeySequence &keySequence); + +protected: + QKeySequenceEdit(QKeySequenceEditPrivate &d, QWidget *parent, Qt::WindowFlags f); + + bool event(QEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QKeySequenceEdit) + Q_DECLARE_PRIVATE(QKeySequenceEdit) +}; + +#endif // QT_NO_KEYSEQUENCEEDIT + +QT_END_NAMESPACE + +#endif // QKEYSEQUENCEEDIT_H diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h new file mode 100644 index 0000000000..2de86b3a05 --- /dev/null +++ b/src/widgets/widgets/qkeysequenceedit_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Ivan Komissarov. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWidgets 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 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$ +** +****************************************************************************/ + +#ifndef QKEYSEQUENCEEDIT_P_H +#define QKEYSEQUENCEEDIT_P_H + +#include "qkeysequenceedit.h" + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_KEYSEQUENCEEDIT + +class QLineEdit; +class QVBoxLayout; + +class QKeySequenceEditPrivate : public QWidgetPrivate +{ + Q_DECLARE_PUBLIC(QKeySequenceEdit) +public: + enum { MaxKeyCount = 4 }; + + void init(); + int translateModifiers(Qt::KeyboardModifiers state, const QString &text); + void resetState(); + void finishEditing(); + + QLineEdit *lineEdit; + QVBoxLayout *layout; + QKeySequence keySequence; + int keyNum; + int key[MaxKeyCount]; + int prevKey; + int releaseTimer; +}; + +#endif // QT_NO_KEYSEQUENCEEDIT + +QT_END_NAMESPACE + +#endif // QKEYSEQUENCEEDIT_P_H diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index aa7677869c..94c85ff92b 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -2370,8 +2370,20 @@ void CloseButton::paintEvent(QPaintEvent *) style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this); } +void QTabBarPrivate::Tab::TabBarAnimation::updateCurrentValue(const QVariant ¤t) +{ + priv->moveTab(priv->tabList.indexOf(*tab), current.toInt()); +} + +void QTabBarPrivate::Tab::TabBarAnimation::updateState(QAbstractAnimation::State, QAbstractAnimation::State newState) +{ + if (newState == Stopped) priv->moveTabFinished(priv->tabList.indexOf(*tab)); +} + QT_END_NAMESPACE #include "moc_qtabbar.cpp" #endif // QT_NO_TABBAR + + diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 8c6e70b8d7..b7b6998ca3 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -126,11 +126,9 @@ public: TabBarAnimation(Tab *t, QTabBarPrivate *_priv) : tab(t), priv(_priv) { setEasingCurve(QEasingCurve::InOutQuad); } - void updateCurrentValue(const QVariant ¤t) - { priv->moveTab(priv->tabList.indexOf(*tab), current.toInt()); } + void updateCurrentValue(const QVariant ¤t); - void updateState(State, State newState) - { if (newState == Stopped) priv->moveTabFinished(priv->tabList.indexOf(*tab)); } + void updateState(State, State newState); private: //these are needed for the callbacks Tab *tab; diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 27048c1440..6a41144cc1 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1525,6 +1525,7 @@ void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke) || ke == QKeySequence::Undo || ke == QKeySequence::MoveToNextWord || ke == QKeySequence::MoveToPreviousWord + || ke == QKeySequence::MoveToEndOfLine || ke == QKeySequence::MoveToStartOfDocument || ke == QKeySequence::MoveToEndOfDocument || ke == QKeySequence::SelectNextWord @@ -1535,7 +1536,8 @@ void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke) || ke == QKeySequence::SelectEndOfBlock || ke == QKeySequence::SelectStartOfDocument || ke == QKeySequence::SelectAll - || ke == QKeySequence::SelectEndOfDocument) { + || ke == QKeySequence::SelectEndOfDocument + || ke == QKeySequence::DeleteCompleteLine) { ke->accept(); } else if (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier || ke->modifiers() == Qt::KeypadModifier) { diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index a35e6eb3a1..efe1dd3616 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -25,6 +25,8 @@ HEADERS += \ widgets/qframe.h \ widgets/qframe_p.h \ widgets/qgroupbox.h \ + widgets/qkeysequenceedit.h \ + widgets/qkeysequenceedit_p.h \ widgets/qlabel.h \ widgets/qlabel_p.h \ widgets/qlcdnumber.h \ @@ -99,6 +101,7 @@ SOURCES += \ widgets/qfontcombobox.cpp \ widgets/qframe.cpp \ widgets/qgroupbox.cpp \ + widgets/qkeysequenceedit.cpp \ widgets/qlabel.cpp \ widgets/qlcdnumber.cpp \ widgets/qlineedit_p.cpp \ diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index b03aafcf0d..0a705949f3 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -3481,8 +3481,13 @@ void tst_QAccessibility::bridgeTest() BSTR bstrDescription; hr = ia2Table->get_columnDescription(0, &bstrDescription); QVERIFY(SUCCEEDED(hr)); - const QString description((QChar*)bstrDescription); - QCOMPARE(description, QLatin1String("h1")); + QCOMPARE(QString::fromWCharArray(bstrDescription), QLatin1String("h1")); + ::SysFreeString(bstrDescription); + + hr = ia2Table->get_rowDescription(1, &bstrDescription); + QVERIFY(SUCCEEDED(hr)); + QCOMPARE(QString::fromWCharArray(bstrDescription), QLatin1String("v2")); + ::SysFreeString(bstrDescription); IAccessible *accTableCell = 0; hr = ia2Table->get_cellAt(1, 2, (IUnknown**)&accTableCell); diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index 0261224543..7251cca528 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -590,6 +590,7 @@ void tst_QPrinter::setGetPaperSize() QSizeF size(500, 10); p.setPaperSize(size, QPrinter::Millimeter); QCOMPARE(p.paperSize(QPrinter::Millimeter), size); + QCOMPARE(p.pageSizeMM(), size); QSizeF ptSize = p.paperSize(QPrinter::Point); //qDebug() << ptSize; QVERIFY(qAbs(ptSize.width() - size.width() * (72/25.4)) < 1E-4); diff --git a/tests/auto/tools/moc/function-with-attributes.h b/tests/auto/tools/moc/function-with-attributes.h index 21a7405af7..afa02e6f3a 100644 --- a/tests/auto/tools/moc/function-with-attributes.h +++ b/tests/auto/tools/moc/function-with-attributes.h @@ -43,15 +43,22 @@ // test support for gcc attributes with functions #if defined(Q_CC_GNU) || defined(Q_MOC_RUN) -#define DEPRECATED __attribute__ ((__deprecated__)) +#define DEPRECATED1 __attribute__ ((__deprecated__)) #else -#define DEPRECATED +#define DEPRECATED1 +#endif + +#if defined(Q_CC_MSVC) || defined(Q_MOC_RUN) +#define DEPRECATED2 __declspec(deprecated) +#else +#define DEPRECATED2 #endif class FunctionWithAttributes : public QObject { Q_OBJECT public slots: - DEPRECATED void test() {} + DEPRECATED1 void test1() {} + DEPRECATED2 void test2() {} }; diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/.gitignore b/tests/auto/widgets/widgets/qkeysequenceedit/.gitignore new file mode 100644 index 0000000000..04dacefc29 --- /dev/null +++ b/tests/auto/widgets/widgets/qkeysequenceedit/.gitignore @@ -0,0 +1 @@ +tst_qshortcutedit diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/qkeysequenceedit.pro b/tests/auto/widgets/widgets/qkeysequenceedit/qkeysequenceedit.pro new file mode 100644 index 0000000000..097cb00d11 --- /dev/null +++ b/tests/auto/widgets/widgets/qkeysequenceedit/qkeysequenceedit.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +CONFIG += parallel_test +TARGET = tst_qkeysequenceedit +QT += widgets testlib +SOURCES += tst_qkeysequenceedit.cpp diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp new file mode 100644 index 0000000000..8c010abfe6 --- /dev/null +++ b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite 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 + +#include + +Q_DECLARE_METATYPE(Qt::Key) +Q_DECLARE_METATYPE(Qt::KeyboardModifiers) + +class tst_QKeySequenceEdit : public QObject +{ + Q_OBJECT + +private slots: + void testSetters(); + void testKeys_data(); + void testKeys(); +}; + +void tst_QKeySequenceEdit::testSetters() +{ + QKeySequenceEdit edit; + QSignalSpy spy(&edit, SIGNAL(keySequenceChanged(QKeySequence))); + QCOMPARE(edit.keySequence(), QKeySequence()); + + edit.setKeySequence(QKeySequence::New); + QCOMPARE(edit.keySequence(), QKeySequence(QKeySequence::New)); + + edit.clear(); + QCOMPARE(edit.keySequence(), QKeySequence()); + + QCOMPARE(spy.count(), 2); +} + +void tst_QKeySequenceEdit::testKeys_data() +{ + QTest::addColumn("key"); + QTest::addColumn("modifiers"); + QTest::addColumn("keySequence"); + + QTest::newRow("1") << Qt::Key_N << Qt::KeyboardModifiers(Qt::ControlModifier) << QKeySequence("Ctrl+N"); + QTest::newRow("2") << Qt::Key_N << Qt::KeyboardModifiers(Qt::AltModifier) << QKeySequence("Alt+N"); + QTest::newRow("3") << Qt::Key_N << Qt::KeyboardModifiers(Qt::ShiftModifier) << QKeySequence("Shift+N"); + QTest::newRow("4") << Qt::Key_N << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << QKeySequence("Ctrl+Shift+N"); +} + +void tst_QKeySequenceEdit::testKeys() +{ + QFETCH(Qt::Key, key); + QFETCH(Qt::KeyboardModifiers, modifiers); + QFETCH(QKeySequence, keySequence); + QKeySequenceEdit edit; + + QSignalSpy spy(&edit, SIGNAL(editingFinished())); + QTest::keyPress(&edit, key, modifiers); + QTest::keyRelease(&edit, key, modifiers); + + QCOMPARE(spy.count(), 0); + QCOMPARE(edit.keySequence(), keySequence); + QTRY_COMPARE(spy.count(), 1); +} + +QTEST_MAIN(tst_QKeySequenceEdit) +#include "tst_qkeysequenceedit.moc" diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro index 12dfc8f7c8..29d1f7746c 100644 --- a/tests/auto/widgets/widgets/widgets.pro +++ b/tests/auto/widgets/widgets/widgets.pro @@ -17,6 +17,7 @@ SUBDIRS=\ qfocusframe \ qfontcombobox \ qgroupbox \ + qkeysequenceedit \ qlabel \ qlcdnumber \ qlineedit \