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/itemviews/qdirmodel.cpp

    r376 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545#include <qstack.h>
    4646#include <qfile.h>
     47#include <qfilesystemmodel.h>
    4748#include <qurl.h>
    4849#include <qmime.h>
     
    190191    \ingroup model-view
    191192
     193    \note The usage of QDirModel is not recommended anymore. The
     194    QFileSystemModel class is a more performant alternative.
     195
    192196    This class provides access to the local filesystem, providing functions
    193197    for renaming and removing files and directories, and for creating new
     
    228232    \note QDirModel requires an instance of a GUI application.
    229233
    230     \sa nameFilters(), setFilter(), filter(), QListView, QTreeView,
     234    \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel,
    231235    {Dir View Example}, {Model Classes}
    232236*/
     
    869873
    870874    QString absolutePath = QDir(path).absolutePath();
     875#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2)
     876    absolutePath = absolutePath.toLower();
     877#endif
    871878#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2)
    872     absolutePath = absolutePath.toLower();
    873879    // On Windows, "filename......." and "filename" are equivalent
    874880    if (absolutePath.endsWith(QLatin1Char('.'))) {
     
    910916        if (childAppended)
    911917            emit const_cast<QDirModel*>(this)->layoutChanged();
    912     } else if (pathElements.at(0).endsWith(QLatin1Char(':'))) {
     918    } else
     919#endif
     920#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2)
     921    if (pathElements.at(0).endsWith(QLatin1Char(':'))) {
    913922        pathElements[0] += QLatin1Char('/');
    914923    }
     
    932941            const QFileInfo& fi = parent->children.at(j).info;
    933942            QString childFileName;
    934 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2)
    935943            childFileName = idx.isValid() ? fi.fileName() : fi.absoluteFilePath();
     944#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2)
    936945            childFileName = childFileName.toLower();
    937 #else
    938             childFileName = idx.isValid() ? fi.fileName() : fi.absoluteFilePath();
    939946#endif
    940947            if (childFileName == element) {
     
    953960                newPath = parent->info.absoluteFilePath() + element;
    954961            else
    955                 newPath= parent->info.absoluteFilePath() + QLatin1Char('/') + element;
     962                newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element;
    956963#else
    957964            QString newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element;
     
    13051312        if (name.startsWith(QLatin1Char('/'))) // UNC host
    13061313            return info.fileName();
     1314#endif       
     1315#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2)
    13071316        if (name.endsWith(QLatin1Char('/')))
    13081317            name.chop(1);
     
    13361345    quint64 bytes = n->info.size();
    13371346    if (bytes >= tb)
    1338         return QLocale().toString(bytes / tb) + QString::fromLatin1(" TB");
     1347        return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));
    13391348    if (bytes >= gb)
    1340         return QLocale().toString(bytes / gb) + QString::fromLatin1(" GB");
     1349        return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2));
    13411350    if (bytes >= mb)
    1342         return QLocale().toString(bytes / mb) + QString::fromLatin1(" MB");
     1351        return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
    13431352    if (bytes >= kb)
    1344         return QLocale().toString(bytes / kb) + QString::fromLatin1(" KB");
    1345     return QLocale().toString(bytes) + QString::fromLatin1(" bytes");
     1353        return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
     1354    return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes));
    13461355}
    13471356
Note: See TracChangeset for help on using the changeset viewer.