QString KFileItem::mimeComment() const { const QString displayType = d->m_entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_TYPE ); if (!displayType.isEmpty()) return displayType; KMimeType::Ptr mType = determineMimeType(); bool isLocalUrl; KUrl url = mostLocalUrl(isLocalUrl); KMimeType::Ptr mime = mimeTypePtr(); // This cannot move to kio_file (with UDS_DISPLAY_TYPE) because it needs // the mimetype to be determined, which is done here, and possibly delayed... if (isLocalUrl && mime->is("application/x-desktop")) { KDesktopFile cfg( url.toLocalFile() ); QString comment = cfg.desktopGroup().readEntry( "Comment" ); if (!comment.isEmpty()) return comment; } QString comment = mType->comment( url ); //kDebug() << "finding comment for " << url.url() << " : " << d->m_pMimeType->name(); if (!comment.isEmpty()) return comment; else return mType->name(); }
QString KFileItem::iconName() { if (d && (!d->iconName.isEmpty())) return d->iconName; bool isLocalURL; KURL url = mostLocalURL(isLocalURL); //kdDebug() << "finding icon for " << url.url() << " : " << m_pMimeType->name() << endl; return determineMimeType()->icon(url, isLocalURL); }
QString KFileItem::mimeComment() { KMimeType::Ptr mType = determineMimeType(); bool isLocalURL; KURL url = mostLocalURL(isLocalURL); QString comment = mType->comment( url, isLocalURL ); //kdDebug() << "finding comment for " << url.url() << " : " << m_pMimeType->name() << endl; if (!comment.isEmpty()) return comment; else return mType->name(); }
void ResourceHandler::handle(Client &client) { Common::String filename = client.path(); filename.deleteChar(0); // if archive hidden file is requested, ignore if (filename.size() && filename[0] == '.') return; // if file not found, don't set handler either Common::SeekableReadStream *file = HandlerUtils::getArchiveFile(filename); if (file == nullptr) return; LocalWebserver::setClientGetHandler(client, file, 200, determineMimeType(filename)); }
void KFileItem::assign( const KFileItem & item ) { if ( this == &item ) return; m_entry = item.m_entry; m_url = item.m_url; m_bIsLocalURL = item.m_bIsLocalURL; m_strName = item.m_strName; m_strText = item.m_strText; m_fileMode = item.m_fileMode; m_permissions = item.m_permissions; m_user = item.m_user; m_group = item.m_group; m_bLink = item.m_bLink; m_pMimeType = item.m_pMimeType; m_strLowerCaseName = item.m_strLowerCaseName; m_bMimeTypeKnown = item.m_bMimeTypeKnown; m_hidden = item.m_hidden; m_guessedMimeType = item.m_guessedMimeType; m_access = item.m_access; m_metaInfo = item.m_metaInfo; for ( int i = 0; i < NumFlags; i++ ) m_time[i] = item.m_time[i]; m_size = item.m_size; // note: m_extra is NOT copied, as we'd have no control over who is // deleting the data or not. // We had a mimetype previously (probably), so we need to re-determine it determineMimeType(); if ( item.d ) { if ( !d ) d = new KFileItemPrivate; d->iconName = item.d->iconName; } else { delete d; d = 0; } }
QString KFileItem::getStatusBarInfo() { QString text = m_strText; if ( m_bLink ) { QString comment = determineMimeType()->comment( m_url, m_bIsLocalURL ); QString tmp; if ( comment.isEmpty() ) tmp = i18n ( "Symbolic Link" ); else tmp = i18n("%1 (Link)").arg(comment); text += "->"; text += linkDest(); text += " "; text += tmp; } else if ( S_ISREG( m_fileMode ) ) { bool hasSize; KIO::filesize_t sizeValue = size(hasSize); if(hasSize) text += QString(" (%1) ").arg( KIO::convertSize( sizeValue ) ); text += mimeComment(); } else if ( S_ISDIR ( m_fileMode ) ) { text += "/ "; text += mimeComment(); } else { text += " "; text += mimeComment(); } text.replace('\n', " "); // replace any newlines with a space, so the statusbar doesn't get a two-line string which messes the display up, Alex return text; }
Archive *Archive::create(const QString &fileName, const QString &fixedMimeType, QObject *parent) { qCDebug(ARK) << "Going to create archive" << fileName; qRegisterMetaType<ArchiveEntry>("ArchiveEntry"); PluginManager pluginManager; const QMimeType mimeType = fixedMimeType.isEmpty() ? determineMimeType(fileName) : QMimeDatabase().mimeTypeForName(fixedMimeType); const QVector<Plugin*> offers = pluginManager.preferredPluginsFor(mimeType); if (offers.isEmpty()) { qCCritical(ARK) << "Could not find a plugin to handle" << fileName; return new Archive(NoPlugin, parent); } Archive *archive; foreach (Plugin *plugin, offers) { archive = create(fileName, plugin, parent); // Use the first valid plugin, according to the priority sorting. if (archive->isValid()) { return archive; } }