diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-04-20 07:23:43 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-04-20 07:23:43 (GMT) |
commit | 67926b8e4d9e7463597ef113944d78ca326fd9ae (patch) | |
tree | e24fa54e245a8c3b27cd1f740aaf5d296e05621b /src | |
parent | 2c762f3b8b284a7c6dc0c499b7052013bad5b707 (diff) | |
parent | 10194aafd10824fe1919aa44083224e8bea442ca (diff) | |
download | Qt-67926b8e4d9e7463597ef113944d78ca326fd9ae.zip Qt-67926b8e4d9e7463597ef113944d78ca326fd9ae.tar.gz Qt-67926b8e4d9e7463597ef113944d78ca326fd9ae.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
src/gui/itemviews/qheaderview_p.h
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qtemporaryfile.cpp | 264 | ||||
-rw-r--r-- | src/gui/dialogs/qfontdialog_mac.mm | 8 | ||||
-rw-r--r-- | src/gui/dialogs/qmessagebox.cpp | 53 | ||||
-rw-r--r-- | src/gui/image/qpixmap_x11.cpp | 2 | ||||
-rw-r--r-- | src/gui/itemviews/qheaderview.cpp | 31 | ||||
-rw-r--r-- | src/gui/itemviews/qheaderview_p.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/qtabbar.cpp | 6 | ||||
-rw-r--r-- | src/sql/drivers/oci/qsql_oci.cpp | 4 |
8 files changed, 203 insertions, 168 deletions
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 6a7b067..4856353 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -105,100 +105,100 @@ QT_BEGIN_NAMESPACE */ static int _gettemp(char *path, int *doopen, int domkdir, int slen) { - char *start, *trv, *suffp; - QT_STATBUF sbuf; - int rval; + char *start, *trv, *suffp; + QT_STATBUF sbuf; + int rval; #if defined(Q_OS_WIN) int pid; #else - pid_t pid; + pid_t pid; #endif - if (doopen && domkdir) { - errno = EINVAL; - return(0); - } - - for (trv = path; *trv; ++trv) - ; - trv -= slen; - suffp = trv; - --trv; - if (trv < path) { - errno = EINVAL; - return (0); - } + if (doopen && domkdir) { + errno = EINVAL; + return 0; + } + + for (trv = path; *trv; ++trv) + ; + trv -= slen; + suffp = trv; + --trv; + if (trv < path) { + errno = EINVAL; + return 0; + } #if defined(Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400 - pid = _getpid(); + pid = _getpid(); #else - pid = getpid(); + pid = getpid(); #endif - while (trv >= path && *trv == 'X' && pid != 0) { - *trv-- = (pid % 10) + '0'; - pid /= 10; - } + while (trv >= path && *trv == 'X' && pid != 0) { + *trv-- = (pid % 10) + '0'; + pid /= 10; + } #ifndef S_ISDIR -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif - while (trv >= path && *trv == 'X') { - char c; - - // CHANGE arc4random() -> random() - pid = (qrand() & 0xffff) % (26+26); - if (pid < 26) - c = pid + 'A'; - else - c = (pid - 26) + 'a'; - *trv-- = c; - } - start = trv + 1; - - /* - * check the target directory; if you have six X's and it - * doesn't exist this runs for a *very* long time. - */ - if (doopen || domkdir) { - for (;; --trv) { - if (trv <= path) - break; - if (*trv == '/') { - *trv = '\0'; + while (trv >= path && *trv == 'X') { + char c; + + // CHANGE arc4random() -> random() + pid = (qrand() & 0xffff) % (26+26); + if (pid < 26) + c = pid + 'A'; + else + c = (pid - 26) + 'a'; + *trv-- = c; + } + start = trv + 1; + + /* + * check the target directory; if you have six X's and it + * doesn't exist this runs for a *very* long time. + */ + if (doopen || domkdir) { + for (;; --trv) { + if (trv <= path) + break; + if (*trv == '/') { + *trv = '\0'; #if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) - if (trv - path == 2 && path[1] == ':') { - // Special case for Windows drives - // (e.g., "C:" => "C:\"). - // ### Better to use a Windows - // call for this. - char drive[] = "c:\\"; - drive[0] = path[0]; - rval = QT_STAT(drive, &sbuf); - } else + if (trv - path == 2 && path[1] == ':') { + // Special case for Windows drives + // (e.g., "C:" => "C:\"). + // ### Better to use a Windows + // call for this. + char drive[] = "c:\\"; + drive[0] = path[0]; + rval = QT_STAT(drive, &sbuf); + } else #endif - rval = QT_STAT(path, &sbuf); - *trv = '/'; - if (rval != 0) - return(0); - if (!S_ISDIR(sbuf.st_mode)) { - errno = ENOTDIR; - return(0); - } - break; - } - } - } - - for (;;) { - if (doopen) { + rval = QT_STAT(path, &sbuf); + *trv = '/'; + if (rval != 0) + return 0; + if (!S_ISDIR(sbuf.st_mode)) { + errno = ENOTDIR; + return 0; + } + break; + } + } + } + + for (;;) { + if (doopen) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400 - if (_sopen_s(doopen, path, QT_OPEN_CREAT|O_EXCL|QT_OPEN_RDWR|QT_OPEN_BINARY -#ifdef QT_LARGEFILE_SUPPORT - |QT_OPEN_LARGEFILE -#endif - , _SH_DENYNO, _S_IREAD | _S_IWRITE)== 0) -#else -#if defined(Q_OS_WINCE) + if (_sopen_s(doopen, path, QT_OPEN_CREAT|O_EXCL|QT_OPEN_RDWR|QT_OPEN_BINARY +# ifdef QT_LARGEFILE_SUPPORT + |QT_OPEN_LARGEFILE +# endif + , _SH_DENYNO, _S_IREAD | _S_IWRITE)== 0) +#else // WIN && !CE +# if defined(Q_OS_WINCE) QString targetPath; if (QDir::isAbsolutePath(QString::fromLatin1(path))) targetPath = QLatin1String(path); @@ -207,72 +207,82 @@ static int _gettemp(char *path, int *doopen, int domkdir, int slen) if ((*doopen = QT_OPEN(targetPath.toLocal8Bit(), O_CREAT|O_EXCL|O_RDWR -#else - if ((*doopen = - open(path, QT_OPEN_CREAT|O_EXCL|QT_OPEN_RDWR -#endif -#ifdef QT_LARGEFILE_SUPPORT - |QT_OPEN_LARGEFILE -#endif +# else // CE + if ((*doopen = + open(path, QT_OPEN_CREAT|O_EXCL|QT_OPEN_RDWR +# endif +# ifdef QT_LARGEFILE_SUPPORT + |QT_OPEN_LARGEFILE +# endif # if defined(Q_OS_WINCE) - |_O_BINARY + |_O_BINARY # elif defined(Q_OS_WIN) - |O_BINARY + |O_BINARY # endif - , 0600)) >= 0) +# ifdef O_CLOEXEC + // supported on Linux >= 2.6.23; avoids one extra system call + // and avoids a race condition: if another thread forks, we could + // end up leaking a file descriptor... + |O_CLOEXEC +# endif + , 0600)) >= 0) +#endif // WIN && !CE + { +#if defined(Q_OS_UNIX) && !defined(O_CLOEXEC) + fcntl(*doopen, F_SETFD, FD_CLOEXEC); #endif - - return(1); - if (errno != EEXIST) - return(0); - } else if (domkdir) { + return 1; + } + if (errno != EEXIST) + return 0; + } else if (domkdir) { #ifdef Q_OS_WIN - if (QT_MKDIR(path) == 0) + if (QT_MKDIR(path) == 0) #else - if (mkdir(path, 0700) == 0) + if (mkdir(path, 0700) == 0) #endif - return(1); - if (errno != EEXIST) - return(0); - } + return 1; + if (errno != EEXIST) + return 0; + } #ifndef Q_OS_WIN - else if (QT_LSTAT(path, &sbuf)) - return(errno == ENOENT ? 1 : 0); + else if (QT_LSTAT(path, &sbuf)) + return (errno == ENOENT) ? 1 : 0; #else - if (!QFileInfo(QLatin1String(path)).exists()) - return 1; + if (!QFileInfo(QLatin1String(path)).exists()) + return 1; #endif - /* tricky little algorwwithm for backward compatibility */ - for (trv = start;;) { - if (!*trv) - return (0); - if (*trv == 'Z') { - if (trv == suffp) - return (0); - *trv++ = 'a'; - } else { - if (isdigit(*trv)) - *trv = 'a'; - else if (*trv == 'z') /* inc from z to A */ - *trv = 'A'; - else { - if (trv == suffp) - return (0); - ++*trv; - } - break; - } + /* tricky little algorwwithm for backward compatibility */ + for (trv = start;;) { + if (!*trv) + return 0; + if (*trv == 'Z') { + if (trv == suffp) + return 0; + *trv++ = 'a'; + } else { + if (isdigit(*trv)) + *trv = 'a'; + else if (*trv == 'z') /* inc from z to A */ + *trv = 'A'; + else { + if (trv == suffp) + return 0; + ++*trv; } + break; + } } - /*NOTREACHED*/ + } + /*NOTREACHED*/ } #ifndef Q_WS_WIN static int qt_mkstemps(char *path, int slen) { - int fd = 0; - return (_gettemp(path, &fd, 0, slen) ? fd : -1); + int fd = 0; + return (_gettemp(path, &fd, 0, slen) ? fd : -1); } #endif diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm index d6ddfa3..42be3be 100644 --- a/src/gui/dialogs/qfontdialog_mac.mm +++ b/src/gui/dialogs/qfontdialog_mac.mm @@ -190,7 +190,7 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin newFont.setStrikeOut(mQtFont->strikeOut()); } - [self setQtFont:newFont]; + [self setQtFont:newFont]; if (mPriv) mPriv->updateSampleFont(*mQtFont); } @@ -357,8 +357,8 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin - (void)setQtFont:(const QFont &)newFont { - delete mQtFont; - mQtFont = new QFont(newFont); + delete mQtFont; + mQtFont = new QFont(newFont); } - (QFont)qtFont @@ -404,6 +404,7 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin } [mFontPanel setDelegate:nil]; [[NSFontManager sharedFontManager] setDelegate:nil]; + [[NSFontManager sharedFontManager] setTarget:nil]; } @end @@ -527,6 +528,7 @@ void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial, extraHeight:dialogExtraHeight]; [ourPanel setDelegate:delegate]; [[NSFontManager sharedFontManager] setDelegate:delegate]; + [[NSFontManager sharedFontManager] setTarget:delegate]; setFont(delegate, initial); // hack to get correct initial layout diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 1967837..1ddb8f4 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -1680,7 +1680,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) { #ifdef Q_WS_MAC static QPointer<QMessageBox> oldMsgBox; - + if (oldMsgBox) { oldMsgBox->show(); oldMsgBox->raise(); @@ -1692,29 +1692,34 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) QString translatedTextAboutQt; translatedTextAboutQt = QMessageBox::tr( "<h3>About Qt</h3>" - "%1<p>Qt is a C++ toolkit for cross-platform " - "application development.</p>" - "<p>Qt provides single-source " - "portability across MS Windows, Mac OS X, " - "Linux, and all major commercial Unix variants. Qt is also" - " available for embedded devices as Qt for Embedded Linux" - " and Qt for Windows CE.</p>" - "<p>Qt is a Nokia product. See " - "<a href=\"http://qtsoftware.com/qt/\">qtsoftware.com/qt/</a> for more information.</p>" - ) -#if QT_EDITION != QT_EDITION_OPENSOURCE - .arg(QMessageBox::tr("<p>This program uses Qt version %1.</p>")) -#else - .arg(QMessageBox::tr("<p>This program uses Qt Open Source Edition version %1.</p>" - "<p>Qt Open Source Edition is intended for the development " - "of Open Source applications. You need a commercial Qt " - "license for development of proprietary (closed source) " - "applications.</p>" - "<p>Please see <a href=\"http://qtsoftware.com/company/model/\">qtsoftware.com/company/model/</a> " - "for an overview of Qt licensing.</p>")) -#endif - - .arg(QLatin1String(QT_VERSION_STR)); + "<p>This program uses Qt version %1.</p>" + "<p>Qt is a C++ toolkit for cross-platform application " + "development.</p>" + "<p>Qt provides single-source portability across MS Windows, " + "Mac OS X, Linux, and all major commercial Unix variants. " + "Qt is also available for embedded devices as Qt for Embedded Linux " + "and Qt for Windows CE.</p>" + "<p>Qt is available under three different licensing options designed " + "to accommodate the needs of our various users.</p>" + "Qt licensed under our commercial license agreement is appropriate " + "for development of proprietary/commercial software where you do not " + "want to share any source code with third parties or otherwise cannot " + "comply with the terms of the GNU LGPL version 2.1 or GNU GPL version " + "3.0.</p>" + "<p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the " + "development of Qt applications (proprietary or open source) provided " + "you can comply with the terms and conditions of the GNU LGPL version " + "2.1.</p>" + "<p>Qt licensed under the GNU General Public License version 3.0 is " + "appropriate for the development of Qt applications where you wish to " + "use such applications in combination with software subject to the " + "terms of the GNU GPL version 3.0 or where you are otherwise willing " + "to comply with the terms of the GNU GPL version 3.0.</p>" + "<p>Please see <a href=\"http://www.qtsoftware.com/products/licensing\">www.qtsoftware.com/products/licensing</a> " + "for an overview of Qt licensing.</p>" + "<p>Qt is a Nokia product. See <a href=\"http://www.qtsoftware.com/qt/\">www.qtsoftware.com/qt</a> " + "for more information.</p>" + ).arg(QLatin1String(QT_VERSION_STR)); QMessageBox *msgBox = new QMessageBox(parent); msgBox->setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 725caeb..d9c10db 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -1437,7 +1437,7 @@ QImage QX11PixmapData::toImage() const // we may have to swap the byte order if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) - || (QSysInfo::ByteOrder == QSysInfo::BigEndian)) + || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) { for (int i=0; i < image.height(); i++) { uint *p = (uint*)image.scanLine(i); diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index eb36178..6238df5 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1388,8 +1388,7 @@ int QHeaderView::defaultSectionSize() const void QHeaderView::setDefaultSectionSize(int size) { Q_D(QHeaderView); - d->defaultSectionSize = size; - d->forceInitializing = true; + d->setDefaultSectionSize(size); } /*! @@ -1894,9 +1893,6 @@ void QHeaderView::initializeSections() //make sure we update the hidden sections if (newCount < oldCount) d->updateHiddenSections(0, newCount-1); - } else if (d->forceInitializing) { - initializeSections(0, newCount - 1); - d->forceInitializing = false; } } @@ -1952,7 +1948,7 @@ void QHeaderView::initializeSections(int start, int end) if (!d->sectionHidden.isEmpty()) d->sectionHidden.resize(d->sectionCount); - if (d->sectionCount > oldCount || d->forceInitializing) + if (d->sectionCount > oldCount) d->createSectionSpan(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode); //Q_ASSERT(d->headerLength() == d->length); @@ -3365,6 +3361,29 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) viewport->update(); } +void QHeaderViewPrivate::setDefaultSectionSize(int size) +{ + Q_Q(QHeaderView); + defaultSectionSize = size; + int currentVisualIndex = 0; + for (int i = 0; i < sectionSpans.count(); ++i) { + QHeaderViewPrivate::SectionSpan &span = sectionSpans[i]; + if (span.size > 0) { + //we resize it if it is not hidden (ie size > 0) + const int newSize = span.count * size; + if (newSize != span.size) { + length += newSize - span.size; //the whole length is changed + const int oldSectionSize = span.sectionSize(); + span.size = span.count * size; + for (int i = currentVisualIndex; i < currentVisualIndex + span.count; ++i) { + emit q->sectionResized(logicalIndex(i), oldSectionSize, size); + } + } + } + currentVisualIndex += span.count; + } +} + void QHeaderViewPrivate::resizeSectionSpan(int visualIndex, int oldSize, int newSize) { Q_Q(QHeaderView); diff --git a/src/gui/itemviews/qheaderview_p.h b/src/gui/itemviews/qheaderview_p.h index 95bd84c..cfb1c3e 100644 --- a/src/gui/itemviews/qheaderview_p.h +++ b/src/gui/itemviews/qheaderview_p.h @@ -90,7 +90,6 @@ public: highlightSelected(false), stretchLastSection(false), cascadingResizing(false), - forceInitializing(false), resizeRecursionBlock(false), stretchSections(0), contentsSections(0), @@ -271,7 +270,6 @@ public: bool highlightSelected; bool stretchLastSection; bool cascadingResizing; - bool forceInitializing; bool resizeRecursionBlock; int stretchSections; int contentsSections; @@ -307,6 +305,7 @@ public: void createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode); void removeSectionsFromSpans(int start, int end); void resizeSectionSpan(int visualIndex, int oldSize, int newSize); + void setDefaultSectionSize(int size); inline int headerSectionCount() const { // for debugging int count = 0; diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index b6e6b6d..b562b1f 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1167,13 +1167,13 @@ void QTabBar::setCurrentIndex(int index) d->currentIndex = index; update(); d->makeVisible(index); + d->tabList[index].lastTab = oldIndex; + d->layoutWidgets(oldIndex); + d->layoutWidgets(index); #ifdef QT3_SUPPORT emit selected(index); #endif emit currentChanged(index); - d->tabList[index].lastTab = oldIndex; - d->layoutWidgets(oldIndex); - d->layoutWidgets(index); } } diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index fa9b5f0..d63c482 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -2208,7 +2208,7 @@ QStringList QOCIDriver::tables(QSql::TableType type) const user = user.toUpper(); while (t.next()) { - if (t.value(0).toString() != user) + if (t.value(0).toString().toUpper() != user.toUpper()) tl.append(t.value(0).toString() + QLatin1String(".") + t.value(1).toString()); else tl.append(t.value(1).toString()); @@ -2224,7 +2224,7 @@ QStringList QOCIDriver::tables(QSql::TableType type) const "and owner != 'CTXSYS'" "and owner != 'WMSYS'")); while (t.next()) { - if (t.value(0).toString() != d->user) + if (t.value(0).toString().toUpper() != d->user.toUpper()) tl.append(t.value(0).toString() + QLatin1String(".") + t.value(1).toString()); else tl.append(t.value(1).toString()); |