~ubuntu-branches/debian/stretch/apper/stretch

« back to all changes in this revision

Viewing changes to PkSession/FilesModel.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klumpp
  • Date: 2013-07-30 12:34:46 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130730123446-cgzujaj03pc61drn
Tags: 0.8.1-1
* New upstream release: 0.8.1
* Depend on software-properties-kde instead of suggesting it (Closes: #696583)
* Add patch to make AppStream loading more failsafe

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
{
75
75
    bool ret = false;
76
76
    foreach (const QUrl &url, urls) {
77
 
        if (files().contains(url.path())) {
 
77
        QString path = QUrl::fromPercentEncoding(url.path().toUtf8());
 
78
        if (files().contains(path)) {
78
79
            continue;
79
80
        }
80
81
 
81
 
        QFileInfo fileInfo(url.path());
 
82
        QFileInfo fileInfo(path);
82
83
        QStandardItem *item = 0;
83
84
        if (fileInfo.isFile()) {
84
 
            KMimeType::Ptr mime = KMimeType::findByFileContent(url.path());
 
85
            KMimeType::Ptr mime = KMimeType::findByFileContent(path);
85
86
            kDebug() << url << mime->name();
86
87
            foreach (const QString &mimeType, m_mimes) {
87
88
                if (mime->is(mimeType)) {
88
89
                    ret = true;
89
90
/*                    kDebug() << "Found Supported Mime" << mimeType << mime->iconName();*/
90
91
                    item = new QStandardItem(fileInfo.fileName());
91
 
                    item->setData(url.path());
92
 
                    item->setToolTip(url.path());
 
92
                    item->setData(path);
 
93
                    item->setToolTip(path);
93
94
                    item->setIcon(KIconLoader::global()->loadMimeTypeIcon(mime->iconName(),
94
 
                                                                        KIconLoader::Desktop));
 
95
                                                                          KIconLoader::Desktop));
95
96
                    break;
96
97
                }
97
98
            }
98
99
 
99
100
            if (ret == false && m_mimes.isEmpty()) {
100
101
                if (mime->name() == "application/x-desktop") {
101
 
                    KService *service = new KService(url.path());
 
102
                    KService *service = new KService(path);
102
103
                    item = new QStandardItem(service->name());
103
104
                    item->setData(true, Qt::UserRole);
104
105
                    item->setIcon(KIconLoader::global()->loadMimeTypeIcon(service->icon(),
108
109
                    item->setIcon(KIconLoader::global()->loadMimeTypeIcon(mime->iconName(),
109
110
                                                                        KIconLoader::Desktop));
110
111
                }
111
 
                item->setData(url.path());
112
 
                item->setToolTip(url.path());
 
112
                item->setData(path);
 
113
                item->setToolTip(path);
113
114
            } else if (ret == false && !m_mimes.isEmpty()) {
114
115
                item = new QStandardItem(fileInfo.fileName());
115
 
                item->setData(url.path());
116
 
                item->setToolTip(url.path());
 
116
                item->setData(path);
 
117
                item->setToolTip(path);
117
118
                item->setEnabled(false);
118
119
                item->setIcon(KIconLoader::global()->loadIcon("dialog-cancel", KIconLoader::Desktop));
119
120
            }
120
121
        } else if (m_mimes.isEmpty()) {
121
122
            // It's not a file but we don't have a mime so it's ok
122
123
            item = new QStandardItem(fileInfo.fileName());
123
 
            item->setData(url.path());
124
 
            item->setToolTip(url.path());
 
124
            item->setData(path);
 
125
            item->setToolTip(path);
125
126
            item->setIcon(KIconLoader::global()->loadIcon("unknown", KIconLoader::Desktop));
126
127
        }
127
128