Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/dialogs/qfilesystemmodel.cpp

    r173 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5050
    5151#ifdef Q_OS_WIN
    52 #include <windows.h>
     52#include <windows.h>
    5353#endif
    5454
     
    297297                QString longSection = QDir::toNativeSeparators(section);
    298298#endif
    299                 QT_WA({
    300                     WIN32_FIND_DATAW findData;
    301                     h = ::FindFirstFileW((wchar_t *)longSection.utf16(), &findData);
    302                     if (h != INVALID_HANDLE_VALUE)
    303                         longPath.append(QString::fromUtf16((ushort*)findData.cFileName));
    304                     } , {
    305                     WIN32_FIND_DATAA findData;
    306                     h = ::FindFirstFileA(section.toLocal8Bit(), &findData);
    307                     if (h != INVALID_HANDLE_VALUE)
    308                         longPath.append(QString::fromLocal8Bit(findData.cFileName));
    309                 });
    310                 if (h == INVALID_HANDLE_VALUE) {
     299                WIN32_FIND_DATA findData;
     300                h = ::FindFirstFile((wchar_t*)longSection.utf16(), &findData);
     301                if (h != INVALID_HANDLE_VALUE) {
     302                    longPath.append(QString::fromWCharArray(findData.cFileName));
     303                    ::FindClose(h);
     304                } else {
    311305                    longPath.append(section);
    312306                    break;
    313                 } else {
    314                     ::FindClose(h);
    315307                }
    316308            }
     
    338330    Q_Q(const QFileSystemModel);
    339331    Q_UNUSED(q);
    340     if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1String(":")))
     332    if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1)))
    341333        return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
    342334
     
    355347    QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);
    356348    if ((pathElements.isEmpty())
    357 #if !defined(Q_OS_OS2) && (!defined(Q_OS_WIN) || defined(Q_OS_WINCE))
     349#if )
    358350        && QDir::fromNativeSeparators(longPath) != QLatin1String("/")
    359351#endif
     
    384376        index = q->index(r, 0, QModelIndex());
    385377        pathElements.pop_front();
    386     } else {
    387         if (!pathElements.at(0).contains(QLatin1String(":")))
    388             pathElements.prepend(QDir(longPath).rootPath());
     378    } else
     379#endif
     380
     381#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
     382    {
     383        if (!pathElements.at(0).contains(QLatin1String(":"))) {
     384            // The reason we express it like this instead of with anonymous, temporary
     385            // variables, is to workaround a compiler crash with Q_CC_NOKIAX86.
     386            QString rootPath = QDir(longPath).rootPath();
     387            pathElements.prepend(rootPath);
     388        }
    389389        if (pathElements.at(0).endsWith(QLatin1Char('/')))
    390390            pathElements[0].chop(1);
     
    880880            return pixmap;
    881881        }
     882
    882883    case Qt::TextAlignmentRole:
    883884        return Qt::AlignLeft;
     
    10831084void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent)
    10841085{
     1086
    10851087    QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent);
    10861088    if (indexNode->children.count() == 0)
     
    11021104    // First update the new visible list
    11031105    indexNode->visibleChildren.clear();
     1106
     1107
    11041108    for (int i = 0; i < values.count(); ++i) {
    11051109        indexNode->visibleChildren.append(values.at(i).first->fileName);
    11061110        values.at(i).first->isVisible = true;
     1111
     1112
     1113
     1114
     1115
     1116
     1117
     1118
     1119
     1120
    11071121    }
    11081122}
     
    13961410    Q_D(QFileSystemModel);
    13971411    d->fileInfoGatherer.setIconProvider(provider);
    1398     qApp->processEvents();
     1412    processEvents();
    13991413    d->root.updateIcon(provider, QString());
    14001414}
     
    15851599        return;
    15861600    QStringList toRemove;
     1601
     1602
     1603
     1604
     1605
     1606
     1607
    15871608    QStringList newFiles = files;
     1609
    15881610    qSort(newFiles.begin(), newFiles.end());
    15891611    QHash<FileNameKey, QFileSystemNode*>::const_iterator i = parentNode->children.constBegin();
    15901612    while (i != parentNode->children.constEnd()) {
    15911613        QStringList::iterator iterator;
    1592         iterator = qBinaryFind(newFiles.begin(), newFiles.end(), i.value()->fileName);
     1614        iterator = qBinaryFind(newFiles.begin(), newFiles.end(),
     1615#if defined(Q_OS_SYMBIAN)
     1616                    i.value()->fileName.toLower());
     1617#else
     1618                    i.value()->fileName);
     1619#endif
    15931620        if (iterator == newFiles.end()) {
    15941621            toRemove.append(i.value()->fileName);
     
    16811708        q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1);
    16821709    }
     1710
     1711
     1712
     1713
    16831714    for (int i = 0; i < newFiles.count(); ++i) {
    16841715            parentNode->visibleChildren.append(newFiles.at(i));
     
    18331864    Q_Q(QFileSystemModel);
    18341865    qRegisterMetaType<QList<QPair<QString,QFileInfo> > >("QList<QPair<QString,QFileInfo> >");
    1835     q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(const QString &, const QStringList &)),
    1836                q, SLOT(_q_directoryChanged(const QString &, const QStringList &)));
    1837     q->connect(&fileInfoGatherer, SIGNAL(updates(const QString &, const QList<QPair<QString, QFileInfo> > &)),
    1838             q, SLOT(_q_fileSystemChanged(const QString &, const QList<QPair<QString, QFileInfo> > &)));
    1839     q->connect(&fileInfoGatherer, SIGNAL(nameResolved(const QString &, const QString &)),
    1840             q, SLOT(_q_resolvedName(const QString &, const QString &)));
     1866    q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles()),
     1867               q, SLOT(_q_directoryChanged()));
     1868    q->connect(&fileInfoGatherer, SIGNAL(updates()),
     1869            q, SLOT(_q_fileSystemChanged()));
     1870    q->connect(&fileInfoGatherer, SIGNAL(nameResolved()),
     1871            q, SLOT(_q_resolvedName(