summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2009-09-17 08:48:44 (GMT)
committerSarah Smith <sarah.j.smith@nokia.com>2009-09-17 08:48:44 (GMT)
commit2ec5d3977e454815a11ad0a9b6e95f77b7e17d0f (patch)
treee66b6cfc3f477966c713f68e5156dd914a516a53 /src
parent11566a349f8b9d5b6bcaf1dff64e30266a55411f (diff)
parente7c36fc2e420f1cee4370020b9f50bb5a6dfe92a (diff)
downloadQt-2ec5d3977e454815a11ad0a9b6e95f77b7e17d0f.zip
Qt-2ec5d3977e454815a11ad0a9b6e95f77b7e17d0f.tar.gz
Qt-2ec5d3977e454815a11ad0a9b6e95f77b7e17d0f.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/phonon/gstreamer/mediaobject.cpp14
-rw-r--r--src/corelib/tools/qregexp.cpp95
-rw-r--r--src/corelib/tools/qregexp.h8
-rw-r--r--src/gui/painting/qpainter.cpp6
-rw-r--r--src/gui/text/qfontdatabase_mac.cpp31
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp10
6 files changed, 140 insertions, 24 deletions
diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
index 74fc1b4..13f9734 100644
--- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp
+++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
@@ -965,11 +965,15 @@ void MediaObject::getStreamInfo()
gint64 titleCount;
GstFormat format = gst_format_get_by_nick("track");
if (gst_element_query_duration (m_pipeline, &format, &titleCount)) {
- int oldAvailableTitles = m_availableTitles;
- m_availableTitles = (int)titleCount;
- if (m_availableTitles != oldAvailableTitles) {
- emit availableTitlesChanged(m_availableTitles);
- m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
+ //check if returned format is still "track",
+ //gstreamer sometimes returns the total time, if tracks information is not available.
+ if (qstrcmp(gst_format_get_name(format), "track") == 0) {
+ int oldAvailableTitles = m_availableTitles;
+ m_availableTitles = (int)titleCount;
+ if (m_availableTitles != oldAvailableTitles) {
+ emit availableTitlesChanged(m_availableTitles);
+ m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
+ }
}
}
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 8d7a75d..1f23211 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -522,6 +522,10 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
outside, backslash has no special meaning.
\endtable
+ In the mode Wildcard, the wildcard characters cannot be
+ escaped. In the mode WildcardUnix, the character '\' escapes the
+ wildcard.
+
For example if we are in wildcard mode and have strings which
contain filenames we could identify HTML files with \bold{*.html}.
This will match zero or more characters followed by a dot followed
@@ -751,50 +755,100 @@ static void mergeInto(QVector<int> *a, const QVector<int> &b)
/*
Translates a wildcard pattern to an equivalent regular expression
pattern (e.g., *.cpp to .*\.cpp).
+
+ If enableEscaping is true, it is possible to escape the wildcard
+ characters with \
*/
-static QString wc2rx(const QString &wc_str)
+static QString wc2rx(const QString &wc_str, const bool enableEscaping)
{
- int wclen = wc_str.length();
+ const int wclen = wc_str.length();
QString rx;
int i = 0;
+ bool isEscaping = false; // the previous character is '\'
const QChar *wc = wc_str.unicode();
+
while (i < wclen) {
- QChar c = wc[i++];
+ const QChar c = wc[i++];
switch (c.unicode()) {
+ case '\\':
+ if (enableEscaping) {
+ if (isEscaping) {
+ rx += QLatin1String("\\\\");
+ } // we insert the \\ later if necessary
+ if (i+1 == wclen) { // the end
+ rx += QLatin1String("\\\\");
+ }
+ } else {
+ rx += QLatin1String("\\\\");
+ }
+ isEscaping = true;
+ break;
case '*':
- rx += QLatin1String(".*");
+ if (isEscaping) {
+ rx += QLatin1String("\\*");
+ isEscaping = false;
+ } else {
+ rx += QLatin1String(".*");
+ }
break;
case '?':
- rx += QLatin1Char('.');
+ if (isEscaping) {
+ rx += QLatin1String("\\?");
+ isEscaping = false;
+ } else {
+ rx += QLatin1Char('.');
+ }
+
break;
case '$':
case '(':
case ')':
case '+':
case '.':
- case '\\':
case '^':
case '{':
case '|':
case '}':
+ if (isEscaping) {
+ isEscaping = false;
+ rx += QLatin1String("\\\\");
+ }
rx += QLatin1Char('\\');
rx += c;
break;
- case '[':
- rx += c;
- if (wc[i] == QLatin1Char('^'))
- rx += wc[i++];
- if (i < wclen) {
- if (rx[i] == QLatin1Char(']'))
- rx += wc[i++];
- while (i < wclen && wc[i] != QLatin1Char(']')) {
- if (wc[i] == QLatin1Char('\\'))
- rx += QLatin1Char('\\');
+ case '[':
+ if (isEscaping) {
+ isEscaping = false;
+ rx += QLatin1String("\\[");
+ } else {
+ rx += c;
+ if (wc[i] == QLatin1Char('^'))
rx += wc[i++];
+ if (i < wclen) {
+ if (rx[i] == QLatin1Char(']'))
+ rx += wc[i++];
+ while (i < wclen && wc[i] != QLatin1Char(']')) {
+ if (wc[i] == QLatin1Char('\\'))
+ rx += QLatin1Char('\\');
+ rx += wc[i++];
+ }
}
}
+ break;
+
+ case ']':
+ if(isEscaping){
+ isEscaping = false;
+ rx += QLatin1String("\\");
+ }
+ rx += c;
break;
+
default:
+ if(isEscaping){
+ isEscaping = false;
+ rx += QLatin1String("\\\\");
+ }
rx += c;
}
}
@@ -1272,7 +1326,10 @@ Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &pattern, QRegExp::Pat
switch (patternSyntax) {
#ifndef QT_NO_REGEXP_WILDCARD
case QRegExp::Wildcard:
- return wc2rx(pattern);
+ return wc2rx(pattern, false);
+ break;
+ case QRegExp::WildcardUnix:
+ return wc2rx(pattern, true);
break;
#endif
case QRegExp::FixedString:
@@ -3715,6 +3772,10 @@ static void invalidateEngine(QRegExpPrivate *priv)
similar to that used by shells (command interpreters) for "file
globbing". See \l{Wildcard Matching}.
+ \value WildcardUnix This is similar to Wildcard but with the
+ behavior of a Unix shell. The wildcard characters can be escaped
+ with the character "\".
+
\value FixedString The pattern is a fixed string. This is
equivalent to using the RegExp pattern on a string in
which all metacharacters are escaped using escape().
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index c03e9e4..1a7cf53 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -61,7 +61,13 @@ class QStringList;
class Q_CORE_EXPORT QRegExp
{
public:
- enum PatternSyntax { RegExp, Wildcard, FixedString, RegExp2, W3CXmlSchema11 };
+ enum PatternSyntax {
+ RegExp,
+ Wildcard,
+ FixedString,
+ RegExp2,
+ WildcardUnix,
+ W3CXmlSchema11 };
enum CaretMode { CaretAtZero, CaretAtOffset, CaretWontMatch };
QRegExp();
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index b3aef71..53d2102 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7535,7 +7535,11 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
bool hidemnmemonic = (tf & Qt::TextHideMnemonic);
Qt::LayoutDirection layout_direction;
- if(option)
+ if (tf & Qt::TextForceLeftToRight)
+ layout_direction = Qt::LeftToRight;
+ else if (tf & Qt::TextForceRightToLeft)
+ layout_direction = Qt::RightToLeft;
+ else if (option)
layout_direction = option->textDirection();
else if (painter)
layout_direction = painter->layoutDirection();
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp
index d65910c..2584003 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/gui/text/qfontdatabase_mac.cpp
@@ -308,6 +308,21 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (familyRef) {
fontRef = ATSFontFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
goto FamilyFound;
+ } else {
+#if defined(QT_MAC_USE_COCOA)
+ // ATS and CT disagrees on what the family name should be,
+ // use CT to look up the font if ATS fails.
+ QCFString familyName = QString::fromAscii(family_name);
+ QCFType<CTFontRef> CTfontRef = CTFontCreateWithName(familyName, 12, NULL);
+ QCFType<CTFontDescriptorRef> fontDescriptor = CTFontCopyFontDescriptor(CTfontRef);
+ QCFString displayName = (CFStringRef)CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontDisplayNameAttribute);
+
+ familyRef = ATSFontFamilyFindFromName(displayName, kATSOptionFlagsDefault);
+ if (familyRef) {
+ fontRef = ATSFontFindFromName(displayName, kATSOptionFlagsDefault);
+ goto FamilyFound;
+ }
+#endif
}
}
}
@@ -456,11 +471,27 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
return;
fnt->families.clear();
+#if defined(QT_MAC_USE_COCOA)
+ // Make sure that the family name set on the font matches what
+ // kCTFontFamilyNameAttribute returns in initializeDb().
+ // So far the best solution seems find the installed font
+ // using CoreText and get the family name from it.
+ // (ATSFontFamilyGetName appears to be the correct API, but also
+ // returns the font display name.)
+ for(int i = 0; i < containedFonts.size(); ++i) {
+ QCFString fontPostScriptName;
+ ATSFontGetPostScriptName(containedFonts[i], kATSOptionFlagsDefault, &fontPostScriptName);
+ QCFType<CTFontDescriptorRef> font = CTFontDescriptorCreateWithNameAndSize(fontPostScriptName, 14);
+ QCFString familyName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
+ fnt->families.append(familyName);
+ }
+#else
for(int i = 0; i < containedFonts.size(); ++i) {
QCFString family;
ATSFontGetName(containedFonts[i], kATSOptionFlagsDefault, &family);
fnt->families.append(family);
}
+#endif
fnt->handle = handle;
}
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 22f446d..7cf5e8b 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -882,6 +882,11 @@ bool QODBCResult::reset (const QString& query)
return false;
}
+ SQLINTEGER isScrollable, bufferLength;
+ r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
+ if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
+ setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
+
SQLSMALLINT count;
SQLNumResultCols(d->hStmt, &count);
if (count) {
@@ -1500,6 +1505,11 @@ bool QODBCResult::exec()
return false;
}
+ SQLINTEGER isScrollable, bufferLength;
+ r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
+ if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
+ setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
+
SQLSMALLINT count;
SQLNumResultCols(d->hStmt, &count);
if (count) {