~ubuntu-branches/ubuntu/utopic/kde4libs/utopic

« back to all changes in this revision

Viewing changes to kio/kio/kfileitem.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-16 13:53:22 UTC
  • mfrom: (1.14.11)
  • Revision ID: package-import@ubuntu.com-20111216135322-joct6gdco90t3koc
Tags: 4:4.7.90-0ubuntu1
* New upstream beta release
* Remove kubuntu_mobile patches, kactivities is split out now and they 
  will be out of date, keep 
  kubuntu-mobile-07-serviceAvailabilityChanged-bool-signal.diff
  for binary compatibility reasons

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
#include <knfsshare.h>
56
56
#include <ksambashare.h>
57
57
#endif
 
58
#include <kfilesystemtype_p.h>
58
59
 
59
60
class KFileItemPrivate : public QSharedData
60
61
{
79
80
          m_bMimeTypeKnown( false ),
80
81
          m_delayedMimeTypes( delayedMimeTypes ),
81
82
          m_useIconNameCache(false),
82
 
          m_hidden( Auto )
 
83
          m_hidden(Auto),
 
84
          m_slow(SlowUnknown)
83
85
    {
84
86
        if (entry.count() != 0) {
85
87
            readUDSEntry( urlIsDirectory );
103
105
     */
104
106
    void init();
105
107
 
 
108
    QString localPath() const;
106
109
    KIO::filesize_t size() const;
107
110
    KDateTime time( KFileItem::FileTimes which ) const;
108
111
    void setTime(KFileItem::FileTimes which, long long time_t_val) const;
109
112
    bool cmp( const KFileItemPrivate & item ) const;
110
113
    QString user() const;
111
114
    QString group() const;
 
115
    bool isSlow() const;
112
116
 
113
117
    /**
114
118
     * Extracts the data from the UDSEntry member and updates the KFileItem
187
191
    // Auto: check leading dot.
188
192
    enum { Auto, Hidden, Shown } m_hidden:3;
189
193
 
 
194
    // Slow? (nfs/smb/ssh)
 
195
    mutable enum { SlowUnknown, Fast, Slow } m_slow:3;
 
196
 
190
197
    // For special case like link to dirs over FTP
191
198
    QString m_guessedMimeType;
192
199
    mutable QString m_access;
561
568
    return QString();
562
569
}
563
570
 
564
 
QString KFileItem::localPath() const
 
571
QString KFileItemPrivate::localPath() const
565
572
{
566
 
  if ( d->m_bIsLocalUrl ) {
567
 
    return d->m_url.toLocalFile();
 
573
  if (m_bIsLocalUrl) {
 
574
    return m_url.toLocalFile();
568
575
  }
569
576
 
570
577
  // Extract the local path from the KIO::UDSEntry
571
 
  return d->m_entry.stringValue( KIO::UDSEntry::UDS_LOCAL_PATH );
 
578
  return m_entry.stringValue( KIO::UDSEntry::UDS_LOCAL_PATH );
 
579
}
 
580
 
 
581
QString KFileItem::localPath() const
 
582
{
 
583
    return d->localPath();
572
584
}
573
585
 
574
586
KIO::filesize_t KFileItem::size() const
685
697
    return groupName;
686
698
}
687
699
 
 
700
bool KFileItemPrivate::isSlow() const
 
701
{
 
702
    if (m_slow == SlowUnknown) {
 
703
        const QString path = localPath();
 
704
        if (!path.isEmpty()) {
 
705
            const KFileSystemType::Type fsType = KFileSystemType::fileSystemType(path);
 
706
            m_slow = (fsType == KFileSystemType::Nfs || fsType == KFileSystemType::Smb) ? Slow : Fast;
 
707
        } else {
 
708
            m_slow = Slow;
 
709
        }
 
710
    }
 
711
    return m_slow == Slow;
 
712
}
 
713
 
 
714
bool KFileItem::isSlow() const
 
715
{
 
716
    return d->isSlow();
 
717
}
 
718
 
688
719
QString KFileItem::mimetype() const
689
720
{
690
721
    KFileItem * that = const_cast<KFileItem *>(this);
729
760
    KMimeType::Ptr mime = mimeTypePtr();
730
761
    // This cannot move to kio_file (with UDS_DISPLAY_TYPE) because it needs
731
762
    // the mimetype to be determined, which is done here, and possibly delayed...
732
 
    if (isLocalUrl && mime->is("application/x-desktop")) {
 
763
    if (isLocalUrl && !d->isSlow() && mime->is("application/x-desktop")) {
733
764
        KDesktopFile cfg( url.toLocalFile() );
734
765
        QString comment = cfg.desktopGroup().readEntry( "Comment" );
735
766
        if (!comment.isEmpty())
736
767
            return comment;
737
768
    }
738
769
 
739
 
    QString comment = mType->comment( url );
 
770
    QString comment = d->isSlow() ? mType->comment() : mType->comment(url);
740
771
    //kDebug() << "finding comment for " << url.url() << " : " << d->m_pMimeType->name();
741
772
    if (!comment.isEmpty())
742
773
        return comment;
783
814
    bool isLocalUrl;
784
815
    KUrl url = mostLocalUrl(isLocalUrl);
785
816
 
786
 
    KMimeType::Ptr mime = mimeTypePtr();
787
 
    if (isLocalUrl && mime->is("application/x-desktop")) {
 
817
    KMimeType::Ptr mime;
 
818
    // Use guessed mimetype for the icon
 
819
    if (!d->m_guessedMimeType.isEmpty()) {
 
820
        mime = KMimeType::mimeType( d->m_guessedMimeType );
 
821
    } else {
 
822
        mime = mimeTypePtr();
 
823
    }
 
824
 
 
825
    if (isLocalUrl && !isSlow() && mime->is("application/x-desktop")) {
788
826
        d->m_iconName = iconFromDesktopFile(url.toLocalFile());
789
827
        if (!d->m_iconName.isEmpty()) {
790
828
            d->m_useIconNameCache = d->m_bMimeTypeKnown;
795
833
    // KDE5: handle .directory files here too, and get rid of
796
834
    // KFolderMimeType and the url argument in KMimeType::iconName().
797
835
 
798
 
    d->m_iconName = mime->iconName(url);
 
836
    if (isSlow())
 
837
        d->m_iconName = mime->iconName();
 
838
    else
 
839
        d->m_iconName = mime->iconName(url);
799
840
    d->m_useIconNameCache = d->m_bMimeTypeKnown;
800
841
    //kDebug() << "finding icon for" << url << ":" << d->m_iconName;
801
842
    return d->m_iconName;
913
954
    }
914
955
 
915
956
    KMimeType::Ptr mime;
916
 
    // Use guessed mimetype if the main one hasn't been determined for sure
917
 
    if ( !d->m_bMimeTypeKnown && !d->m_guessedMimeType.isEmpty() )
 
957
    // Use guessed mimetype for the icon
 
958
    if (!d->m_guessedMimeType.isEmpty())
918
959
        mime = KMimeType::mimeType( d->m_guessedMimeType );
919
960
    else
920
961
        mime = d->m_pMimeType;