| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | class QFileIconProviderPrivate | - |
| 5 | { | - |
| 6 | inline QFileIconProvider* q_func() { return static_cast<QFileIconProvider *>(q_ptr); } inline const QFileIconProvider* q_func() const { return static_cast<const QFileIconProvider *>(q_ptr); } friend class QFileIconProvider; | - |
| 7 | | - |
| 8 | public: | - |
| 9 | QFileIconProviderPrivate(); | - |
| 10 | QIcon getIcon(QStyle::StandardPixmap name) const; | - |
| 11 | QIcon getIcon(const QFileInfo &fi) const; | - |
| 12 | | - |
| 13 | QFileIconProvider *q_ptr; | - |
| 14 | const QString homePath; | - |
| 15 | | - |
| 16 | private: | - |
| 17 | mutable QIcon file; | - |
| 18 | mutable QIcon fileLink; | - |
| 19 | mutable QIcon directory; | - |
| 20 | mutable QIcon directoryLink; | - |
| 21 | mutable QIcon harddisk; | - |
| 22 | mutable QIcon floppy; | - |
| 23 | mutable QIcon cdrom; | - |
| 24 | mutable QIcon ram; | - |
| 25 | mutable QIcon network; | - |
| 26 | mutable QIcon computer; | - |
| 27 | mutable QIcon desktop; | - |
| 28 | mutable QIcon trashcan; | - |
| 29 | mutable QIcon generic; | - |
| 30 | mutable QIcon home; | - |
| 31 | }; | - |
| 32 | | - |
| 33 | QFileIconProviderPrivate::QFileIconProviderPrivate() : | - |
| 34 | homePath(QDir::home().absolutePath()) | - |
| 35 | { | - |
| 36 | } executed: }Execution Count:376 | 376 |
| 37 | | - |
| 38 | QIcon QFileIconProviderPrivate::getIcon(QStyle::StandardPixmap name) const | - |
| 39 | { | - |
| 40 | switch (name) { | - |
| 41 | case QStyle::SP_FileIcon: | - |
| 42 | if (file.isNull()) evaluated: file.isNull()| yes Evaluation Count:89 | yes Evaluation Count:24339 |
| 89-24339 |
| 43 | file = QApplication::style()->standardIcon(name); executed: file = QApplication::style()->standardIcon(name);Execution Count:89 | 89 |
| 44 | return file; executed: return file;Execution Count:24428 | 24428 |
| 45 | case QStyle::SP_FileLinkIcon: | - |
| 46 | if (fileLink.isNull()) evaluated: fileLink.isNull()| yes Evaluation Count:13 | yes Evaluation Count:55 |
| 13-55 |
| 47 | fileLink = QApplication::style()->standardIcon(name); executed: fileLink = QApplication::style()->standardIcon(name);Execution Count:13 | 13 |
| 48 | return fileLink; executed: return fileLink;Execution Count:68 | 68 |
| 49 | case QStyle::SP_DirIcon: | - |
| 50 | if (directory.isNull()) evaluated: directory.isNull()| yes Evaluation Count:251 | yes Evaluation Count:3054 |
| 251-3054 |
| 51 | directory = QApplication::style()->standardIcon(name); executed: directory = QApplication::style()->standardIcon(name);Execution Count:251 | 251 |
| 52 | return directory; executed: return directory;Execution Count:3305 | 3305 |
| 53 | case QStyle::SP_DirLinkIcon: | - |
| 54 | if (directoryLink.isNull()) partially evaluated: directoryLink.isNull()| yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
| 55 | directoryLink = QApplication::style()->standardIcon(name); executed: directoryLink = QApplication::style()->standardIcon(name);Execution Count:12 | 12 |
| 56 | return directoryLink; executed: return directoryLink;Execution Count:12 | 12 |
| 57 | case QStyle::SP_DriveHDIcon: | - |
| 58 | if (harddisk.isNull()) evaluated: harddisk.isNull()| yes Evaluation Count:29 | yes Evaluation Count:2 |
| 2-29 |
| 59 | harddisk = QApplication::style()->standardIcon(name); executed: harddisk = QApplication::style()->standardIcon(name);Execution Count:29 | 29 |
| 60 | return harddisk; executed: return harddisk;Execution Count:31 | 31 |
| 61 | case QStyle::SP_DriveFDIcon: | - |
| 62 | if (floppy.isNull()) never evaluated: floppy.isNull() | 0 |
| 63 | floppy = QApplication::style()->standardIcon(name); never executed: floppy = QApplication::style()->standardIcon(name); | 0 |
| 64 | return floppy; never executed: return floppy; | 0 |
| 65 | case QStyle::SP_DriveCDIcon: | - |
| 66 | if (cdrom.isNull()) never evaluated: cdrom.isNull() | 0 |
| 67 | cdrom = QApplication::style()->standardIcon(name); never executed: cdrom = QApplication::style()->standardIcon(name); | 0 |
| 68 | return cdrom; never executed: return cdrom; | 0 |
| 69 | case QStyle::SP_DriveNetIcon: | - |
| 70 | if (network.isNull()) partially evaluated: network.isNull()| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 71 | network = QApplication::style()->standardIcon(name); executed: network = QApplication::style()->standardIcon(name);Execution Count:1 | 1 |
| 72 | return network; executed: return network;Execution Count:1 | 1 |
| 73 | case QStyle::SP_ComputerIcon: | - |
| 74 | if (computer.isNull()) evaluated: computer.isNull()| yes Evaluation Count:191 | yes Evaluation Count:108 |
| 108-191 |
| 75 | computer = QApplication::style()->standardIcon(name); executed: computer = QApplication::style()->standardIcon(name);Execution Count:191 | 191 |
| 76 | return computer; executed: return computer;Execution Count:299 | 299 |
| 77 | case QStyle::SP_DesktopIcon: | - |
| 78 | if (desktop.isNull()) partially evaluated: desktop.isNull()| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 79 | desktop = QApplication::style()->standardIcon(name); executed: desktop = QApplication::style()->standardIcon(name);Execution Count:1 | 1 |
| 80 | return desktop; executed: return desktop;Execution Count:1 | 1 |
| 81 | case QStyle::SP_TrashIcon: | - |
| 82 | if (trashcan.isNull()) partially evaluated: trashcan.isNull()| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 83 | trashcan = QApplication::style()->standardIcon(name); executed: trashcan = QApplication::style()->standardIcon(name);Execution Count:1 | 1 |
| 84 | return trashcan; executed: return trashcan;Execution Count:1 | 1 |
| 85 | case QStyle::SP_DirHomeIcon: | - |
| 86 | if (home.isNull()) evaluated: home.isNull()| yes Evaluation Count:197 | yes Evaluation Count:399 |
| 197-399 |
| 87 | home = QApplication::style()->standardIcon(name); executed: home = QApplication::style()->standardIcon(name);Execution Count:197 | 197 |
| 88 | return home; executed: return home;Execution Count:596 | 596 |
| 89 | default: | - |
| 90 | return QIcon(); never executed: return QIcon(); | 0 |
| 91 | } | - |
| 92 | return QIcon(); never executed: return QIcon(); | 0 |
| 93 | } | - |
| 94 | | - |
| 95 | | - |
| 96 | | - |
| 97 | | - |
| 98 | | - |
| 99 | QFileIconProvider::QFileIconProvider() | - |
| 100 | : d_ptr(new QFileIconProviderPrivate) | - |
| 101 | { | - |
| 102 | } executed: }Execution Count:376 | 376 |
| 103 | | - |
| 104 | | - |
| 105 | | - |
| 106 | | - |
| 107 | | - |
| 108 | | - |
| 109 | QFileIconProvider::~QFileIconProvider() | - |
| 110 | { | - |
| 111 | } | - |
| 112 | | - |
| 113 | | - |
| 114 | | - |
| 115 | | - |
| 116 | | - |
| 117 | QIcon QFileIconProvider::icon(IconType type) const | - |
| 118 | { | - |
| 119 | const QFileIconProviderPrivate * const d = d_func(); | - |
| 120 | switch (type) { | - |
| 121 | case Computer: | - |
| 122 | return d->getIcon(QStyle::SP_ComputerIcon); executed: return d->getIcon(QStyle::SP_ComputerIcon);Execution Count:299 | 299 |
| 123 | case Desktop: | - |
| 124 | return d->getIcon(QStyle::SP_DesktopIcon); executed: return d->getIcon(QStyle::SP_DesktopIcon);Execution Count:1 | 1 |
| 125 | case Trashcan: | - |
| 126 | return d->getIcon(QStyle::SP_TrashIcon); executed: return d->getIcon(QStyle::SP_TrashIcon);Execution Count:1 | 1 |
| 127 | case Network: | - |
| 128 | return d->getIcon(QStyle::SP_DriveNetIcon); executed: return d->getIcon(QStyle::SP_DriveNetIcon);Execution Count:1 | 1 |
| 129 | case Drive: | - |
| 130 | return d->getIcon(QStyle::SP_DriveHDIcon); executed: return d->getIcon(QStyle::SP_DriveHDIcon);Execution Count:1 | 1 |
| 131 | case Folder: | - |
| 132 | return d->getIcon(QStyle::SP_DirIcon); executed: return d->getIcon(QStyle::SP_DirIcon);Execution Count:1 | 1 |
| 133 | case File: | - |
| 134 | return d->getIcon(QStyle::SP_FileIcon); executed: return d->getIcon(QStyle::SP_FileIcon);Execution Count:1 | 1 |
| 135 | default: | - |
| 136 | break; | 0 |
| 137 | }; | - |
| 138 | return QIcon(); never executed: return QIcon(); | 0 |
| 139 | } | - |
| 140 | | - |
| 141 | QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const | - |
| 142 | { | - |
| 143 | QIcon retIcon; | - |
| 144 | const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); | - |
| 145 | if (!theme) partially evaluated: !theme| no Evaluation Count:0 | yes Evaluation Count:28437 |
| 0-28437 |
| 146 | return retIcon; never executed: return retIcon; | 0 |
| 147 | | - |
| 148 | QList<int> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<int> >(); | - |
| 149 | if (sizes.isEmpty()) partially evaluated: sizes.isEmpty()| yes Evaluation Count:28437 | no Evaluation Count:0 |
| 0-28437 |
| 150 | return retIcon; executed: return retIcon;Execution Count:28437 | 28437 |
| 151 | | - |
| 152 | const QString fileExtension = fi.suffix().toUpper(); | - |
| 153 | const QString keyBase = QLatin1String("qt_.") + fi.suffix().toUpper(); | - |
| 154 | | - |
| 155 | bool cacheable = fi.isFile() && !fi.isExecutable() && !fi.isSymLink() && fileExtension != QLatin1String("ICO"); never evaluated: !fi.isExecutable() never evaluated: !fi.isSymLink() never evaluated: fileExtension != QLatin1String("ICO") never evaluated: fi.isFile() | 0 |
| 156 | if (cacheable) { never evaluated: cacheable | 0 |
| 157 | QPixmap pixmap; | - |
| 158 | QPixmapCache::find(keyBase + QString::number(sizes.at(0)), pixmap); | - |
| 159 | if (!pixmap.isNull()) { never evaluated: !pixmap.isNull() | 0 |
| 160 | bool iconIsComplete = true; | - |
| 161 | retIcon.addPixmap(pixmap); | - |
| 162 | for (int i = 1; i < sizes.count(); i++) never evaluated: i < sizes.count() | 0 |
| 163 | if (QPixmapCache::find(keyBase + QString::number(sizes.at(i)), pixmap)) { never evaluated: QPixmapCache::find(keyBase + QString::number(sizes.at(i)), pixmap) | 0 |
| 164 | retIcon.addPixmap(pixmap); | - |
| 165 | } else { | 0 |
| 166 | iconIsComplete = false; | - |
| 167 | break; | 0 |
| 168 | } | - |
| 169 | if (iconIsComplete) never evaluated: iconIsComplete | 0 |
| 170 | return retIcon; never executed: return retIcon; | 0 |
| 171 | } | 0 |
| 172 | } | 0 |
| 173 | | - |
| 174 | for (QForeachContainer<__typeof__(sizes)> _container_(sizes); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (int size = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 175 | QPixmap pixmap = theme->fileIconPixmap(fi, QSizeF(size, size)); | - |
| 176 | if (!pixmap.isNull()) { never evaluated: !pixmap.isNull() | 0 |
| 177 | retIcon.addPixmap(pixmap); | - |
| 178 | if (cacheable) never evaluated: cacheable | 0 |
| 179 | QPixmapCache::insert(keyBase + QString::number(size), pixmap); never executed: QPixmapCache::insert(keyBase + QString::number(size), pixmap); | 0 |
| 180 | } | 0 |
| 181 | } | 0 |
| 182 | | - |
| 183 | return retIcon; never executed: return retIcon; | 0 |
| 184 | } | - |
| 185 | | - |
| 186 | | - |
| 187 | | - |
| 188 | | - |
| 189 | | - |
| 190 | | - |
| 191 | QIcon QFileIconProvider::icon(const QFileInfo &info) const | - |
| 192 | { | - |
| 193 | const QFileIconProviderPrivate * const d = d_func(); | - |
| 194 | QIcon retIcon = d->getIcon(info); | - |
| 195 | if (!retIcon.isNull()) partially evaluated: !retIcon.isNull()| no Evaluation Count:0 | yes Evaluation Count:28437 |
| 0-28437 |
| 196 | return retIcon; never executed: return retIcon; | 0 |
| 197 | | - |
| 198 | if (info.isRoot()) evaluated: info.isRoot()| yes Evaluation Count:30 | yes Evaluation Count:28407 |
| 30-28407 |
| 199 | return d->getIcon(QStyle::SP_DriveHDIcon); executed: return d->getIcon(QStyle::SP_DriveHDIcon);Execution Count:30 | 30 |
| 200 | | - |
| 201 | | - |
| 202 | if (info.isFile()) { evaluated: info.isFile()| yes Evaluation Count:24495 | yes Evaluation Count:3912 |
| 3912-24495 |
| 203 | if (info.isSymLink()) evaluated: info.isSymLink()| yes Evaluation Count:68 | yes Evaluation Count:24427 |
| 68-24427 |
| 204 | return d->getIcon(QStyle::SP_FileLinkIcon); executed: return d->getIcon(QStyle::SP_FileLinkIcon);Execution Count:68 | 68 |
| 205 | else | - |
| 206 | return d->getIcon(QStyle::SP_FileIcon); executed: return d->getIcon(QStyle::SP_FileIcon);Execution Count:24427 | 24427 |
| 207 | } | - |
| 208 | if (info.isDir()) { partially evaluated: info.isDir()| yes Evaluation Count:3912 | no Evaluation Count:0 |
| 0-3912 |
| 209 | if (info.isSymLink()) { evaluated: info.isSymLink()| yes Evaluation Count:12 | yes Evaluation Count:3900 |
| 12-3900 |
| 210 | return d->getIcon(QStyle::SP_DirLinkIcon); executed: return d->getIcon(QStyle::SP_DirLinkIcon);Execution Count:12 | 12 |
| 211 | } else { | - |
| 212 | if (info.absoluteFilePath() == d->homePath) { evaluated: info.absoluteFilePath() == d->homePath| yes Evaluation Count:596 | yes Evaluation Count:3304 |
| 596-3304 |
| 213 | return d->getIcon(QStyle::SP_DirHomeIcon); executed: return d->getIcon(QStyle::SP_DirHomeIcon);Execution Count:596 | 596 |
| 214 | } else { | - |
| 215 | return d->getIcon(QStyle::SP_DirIcon); executed: return d->getIcon(QStyle::SP_DirIcon);Execution Count:3304 | 3304 |
| 216 | } | - |
| 217 | } | - |
| 218 | } | - |
| 219 | return QIcon(); never executed: return QIcon(); | 0 |
| 220 | } | - |
| 221 | | - |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | | - |
| 226 | QString QFileIconProvider::type(const QFileInfo &info) const | - |
| 227 | { | - |
| 228 | if (info.isRoot()) evaluated: info.isRoot()| yes Evaluation Count:29 | yes Evaluation Count:28973 |
| 29-28973 |
| 229 | return QApplication::translate("QFileDialog", "Drive"); executed: return QApplication::translate("QFileDialog", "Drive");Execution Count:29 | 29 |
| 230 | if (info.isFile()) { evaluated: info.isFile()| yes Evaluation Count:24904 | yes Evaluation Count:4069 |
| 4069-24904 |
| 231 | if (!info.suffix().isEmpty()) evaluated: !info.suffix().isEmpty()| yes Evaluation Count:13326 | yes Evaluation Count:11578 |
| 11578-13326 |
| 232 | return info.suffix() + QLatin1Char(' ') + QApplication::translate("QFileDialog", "File"); executed: return info.suffix() + QLatin1Char(' ') + QApplication::translate("QFileDialog", "File");Execution Count:13326 | 13326 |
| 233 | return QApplication::translate("QFileDialog", "File"); executed: return QApplication::translate("QFileDialog", "File");Execution Count:11578 | 11578 |
| 234 | } | - |
| 235 | | - |
| 236 | if (info.isDir()) evaluated: info.isDir()| yes Evaluation Count:4045 | yes Evaluation Count:24 |
| 24-4045 |
| 237 | | - |
| 238 | | - |
| 239 | | - |
| 240 | return QApplication::translate("QFileDialog", "Folder", "All other platforms"); executed: return QApplication::translate("QFileDialog", "Folder", "All other platforms");Execution Count:4045 | 4045 |
| 241 | | - |
| 242 | | - |
| 243 | | - |
| 244 | | - |
| 245 | | - |
| 246 | | - |
| 247 | if (info.isSymLink()) partially evaluated: info.isSymLink()| yes Evaluation Count:24 | no Evaluation Count:0 |
| 0-24 |
| 248 | | - |
| 249 | | - |
| 250 | | - |
| 251 | return QApplication::translate("QFileDialog", "Shortcut", "All other platforms"); executed: return QApplication::translate("QFileDialog", "Shortcut", "All other platforms");Execution Count:24 | 24 |
| 252 | | - |
| 253 | | - |
| 254 | | - |
| 255 | | - |
| 256 | | - |
| 257 | | - |
| 258 | return QApplication::translate("QFileDialog", "Unknown"); never executed: return QApplication::translate("QFileDialog", "Unknown"); | 0 |
| 259 | } | - |
| 260 | | - |
| 261 | | - |
| 262 | | - |
| | |