~ubuntu-branches/ubuntu/precise/kde-baseapps/precise

« back to all changes in this revision

Viewing changes to dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-01-04 14:55:21 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120104145521-mot8933asc3ua3z6
Tags: 4:4.7.97-0ubuntu1
New upstream release candidate

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
 
170
170
void KFileItemModelRolesUpdater::setEnabledPlugins(const QStringList& list)
171
171
{
 
172
    if (m_enabledPlugins == list) {
 
173
        return;
 
174
    }
 
175
 
172
176
    m_enabledPlugins = list;
 
177
    if (m_previewShown) {
 
178
        if (m_paused) {
 
179
            m_previewChangedDuringPausing = true;
 
180
        } else {
 
181
            sortAndResolveAllRoles();
 
182
        }
 
183
    }
173
184
}
174
185
 
175
186
void KFileItemModelRolesUpdater::setPaused(bool paused)
345
356
 
346
357
    const bool hasSlowRoles = m_previewShown
347
358
                              || m_roles.contains("size")
348
 
                              || m_roles.contains("type");
 
359
                              || m_roles.contains("type")
 
360
                              || m_roles.contains("isExpandable");
349
361
    const ResolveHint resolveHint = hasSlowRoles ? ResolveFast : ResolveAll;
350
362
 
351
363
    // Resolving the MIME type can be expensive. Assure that not more than MaxBlockTimeout ms are
704
716
{
705
717
    QHash<QByteArray, QVariant> data;
706
718
 
707
 
    if (m_roles.contains("size")) {
708
 
        if (item.isDir() && item.isLocalFile()) {
709
 
            const QString path = item.localPath();
710
 
            const int count = subDirectoriesCount(path);
711
 
            if (count >= 0) {
 
719
    const bool getSizeRole = m_roles.contains("size");
 
720
    const bool getIsExpandableRole = m_roles.contains("isExpandable");
 
721
 
 
722
    if ((getSizeRole || getIsExpandableRole) && item.isDir() && item.isLocalFile()) {
 
723
        const QString path = item.localPath();
 
724
        const int count = subDirectoriesCount(path);
 
725
        if (count >= 0) {
 
726
            if (getSizeRole) {
712
727
                data.insert("size", KIO::filesize_t(count));
713
728
            }
 
729
            if (getIsExpandableRole) {
 
730
                data.insert("isExpandable", count > 0);
 
731
            }
714
732
        }
715
733
    }
716
734
 
759
777
    return itemList;
760
778
}
761
779
 
762
 
int KFileItemModelRolesUpdater::subDirectoriesCount(const QString& path)
 
780
int KFileItemModelRolesUpdater::subDirectoriesCount(const QString& path) const
763
781
{
 
782
    const bool countHiddenFiles = m_model->showHiddenFiles();
 
783
 
764
784
#ifdef Q_WS_WIN
765
785
    QDir dir(path);
766
 
    return dir.entryList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::System).count();
 
786
    QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::System;
 
787
    if (countHiddenFiles) {
 
788
        filters |= QDir::Hidden;
 
789
    }
 
790
    return dir.entryList(filters).count();
767
791
#else
768
792
    // Taken from kdelibs/kio/kio/kdirmodel.cpp
769
793
    // Copyright (C) 2006 David Faure <faure@kde.org>
775
799
        struct dirent *dirEntry = 0;
776
800
        while ((dirEntry = ::readdir(dir))) { // krazy:exclude=syscalls
777
801
            if (dirEntry->d_name[0] == '.') {
778
 
                if (dirEntry->d_name[1] == '\0') {
779
 
                    // Skip "."
 
802
                if (dirEntry->d_name[1] == '\0' || !countHiddenFiles) {
 
803
                    // Skip "." or hidden files
780
804
                    continue;
781
805
                }
782
806
                if (dirEntry->d_name[1] == '.' && dirEntry->d_name[2] == '\0') {