Changeset 561 for trunk/src/gui/dialogs/qfilesystemmodel.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/dialogs/qfilesystemmodel.cpp
r173 r561 2 2 ** 3 3 ** 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]) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 50 50 51 51 #ifdef Q_OS_WIN 52 #include < windows.h>52 #include <windows.h> 53 53 #endif 54 54 … … 297 297 QString longSection = QDir::toNativeSeparators(section); 298 298 #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 { 311 305 longPath.append(section); 312 306 break; 313 } else {314 ::FindClose(h);315 307 } 316 308 } … … 338 330 Q_Q(const QFileSystemModel); 339 331 Q_UNUSED(q); 340 if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1 String(":")))332 if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1))) 341 333 return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root); 342 334 … … 355 347 QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts); 356 348 if ((pathElements.isEmpty()) 357 #if !defined(Q_OS_OS2) && (!defined(Q_OS_WIN) || defined(Q_OS_WINCE))349 #if ) 358 350 && QDir::fromNativeSeparators(longPath) != QLatin1String("/") 359 351 #endif … … 384 376 index = q->index(r, 0, QModelIndex()); 385 377 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 } 389 389 if (pathElements.at(0).endsWith(QLatin1Char('/'))) 390 390 pathElements[0].chop(1); … … 880 880 return pixmap; 881 881 } 882 882 883 case Qt::TextAlignmentRole: 883 884 return Qt::AlignLeft; … … 1083 1084 void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent) 1084 1085 { 1086 1085 1087 QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent); 1086 1088 if (indexNode->children.count() == 0) … … 1102 1104 // First update the new visible list 1103 1105 indexNode->visibleChildren.clear(); 1106 1107 1104 1108 for (int i = 0; i < values.count(); ++i) { 1105 1109 indexNode->visibleChildren.append(values.at(i).first->fileName); 1106 1110 values.at(i).first->isVisible = true; 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1107 1121 } 1108 1122 } … … 1396 1410 Q_D(QFileSystemModel); 1397 1411 d->fileInfoGatherer.setIconProvider(provider); 1398 qApp->processEvents();1412 processEvents(); 1399 1413 d->root.updateIcon(provider, QString()); 1400 1414 } … … 1585 1599 return; 1586 1600 QStringList toRemove; 1601 1602 1603 1604 1605 1606 1607 1587 1608 QStringList newFiles = files; 1609 1588 1610 qSort(newFiles.begin(), newFiles.end()); 1589 1611 QHash<FileNameKey, QFileSystemNode*>::const_iterator i = parentNode->children.constBegin(); 1590 1612 while (i != parentNode->children.constEnd()) { 1591 1613 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 1593 1620 if (iterator == newFiles.end()) { 1594 1621 toRemove.append(i.value()->fileName); … … 1681 1708 q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1); 1682 1709 } 1710 1711 1712 1713 1683 1714 for (int i = 0; i < newFiles.count(); ++i) { 1684 1715 parentNode->visibleChildren.append(newFiles.at(i)); … … 1833 1864 Q_Q(QFileSystemModel); 1834 1865 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(