Struct qt_core::QMimeType

source ·
#[repr(C)]
pub struct QMimeType { /* private fields */ }
Expand description

The QMimeType class describes types of file or data, represented by a MIME type string.

C++ class: QMimeType.

C++ documentation:

The QMimeType class describes types of file or data, represented by a MIME type string.

For instance a file named "readme.txt" has the MIME type "text/plain". The MIME type can be determined from the file name, or from the file contents, or from both. MIME type determination can also be done on buffers of data not coming from files.

Determining the MIME type of a file can be useful to make sure your application supports it. It is also useful in file-manager-like applications or widgets, in order to display an appropriate icon for the file, or even the descriptive comment in detailed views.

To check if a file has the expected MIME type, you should use inherits() rather than a simple string comparison based on the name(). This is because MIME types can inherit from each other: for instance a C source file is a specific type of plain text file, so text/x-csrc inherits text/plain.

Implementations§

source§

impl QMimeType

source

pub unsafe fn aliases(&self) -> CppBox<QStringList>

Return the list of aliases of this mimetype.

Calls C++ function: QStringList QMimeType::aliases() const.

C++ documentation:

Return the list of aliases of this mimetype.

For instance, for text/csv, the returned list would be: text/x-csv, text/x-comma-separated-values.

Note that all QMimeType instances refer to proper mimetypes, never to aliases directly.

The order of the aliases in the list is undefined.

source

pub unsafe fn all_ancestors(&self) -> CppBox<QStringList>

Return all the parent mimetypes of this mimetype, direct and indirect. This includes the parent(s) of its parent(s), etc.

Calls C++ function: QStringList QMimeType::allAncestors() const.

C++ documentation:

Return all the parent mimetypes of this mimetype, direct and indirect. This includes the parent(s) of its parent(s), etc.

For instance, for image/svg+xml the list would be: application/xml, text/plain, application/octet-stream.

Note that application/octet-stream is the ultimate parent for all types of files (but not directories).

source

pub unsafe fn comment(&self) -> CppBox<QString>

Returns the description of the MIME type to be displayed on user interfaces.

Calls C++ function: QString QMimeType::comment() const.

C++ documentation:

Returns the description of the MIME type to be displayed on user interfaces.

The default language (QLocale().name()) is used to select the appropriate translation.

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QMimeType>> ) -> Ref<QMimeType>

Assigns the data of other to this QMimeType object, and returns a reference to this object.

Calls C++ function: QMimeType& QMimeType::operator=(const QMimeType& other).

C++ documentation:

Assigns the data of other to this QMimeType object, and returns a reference to this object.

source

pub unsafe fn filter_string(&self) -> CppBox<QString>

Returns a filter string usable for a file dialog.

Calls C++ function: QString QMimeType::filterString() const.

C++ documentation:

Returns a filter string usable for a file dialog.

source

pub unsafe fn generic_icon_name(&self) -> CppBox<QString>

Returns the file name of a generic icon that represents the MIME type.

Calls C++ function: QString QMimeType::genericIconName() const.

C++ documentation:

Returns the file name of a generic icon that represents the MIME type.

This should be used if the icon returned by iconName() cannot be found on the system. It is used for categories of similar types (like spreadsheets or archives) that can use a common icon. The freedesktop.org Icon Naming Specification lists a set of such icon names.

The icon name can be given to QIcon::fromTheme() in order to load the icon.

source

pub unsafe fn glob_patterns(&self) -> CppBox<QStringList>

Returns the list of glob matching patterns.

Calls C++ function: QStringList QMimeType::globPatterns() const.

C++ documentation:

Returns the list of glob matching patterns.

source

pub unsafe fn icon_name(&self) -> CppBox<QString>

Returns the file name of an icon image that represents the MIME type.

Calls C++ function: QString QMimeType::iconName() const.

C++ documentation:

Returns the file name of an icon image that represents the MIME type.

The icon name can be given to QIcon::fromTheme() in order to load the icon.

source

pub unsafe fn inherits( &self, mime_type_name: impl CastInto<Ref<QString>> ) -> bool

Returns true if this mimetype is mimeTypeName, or inherits mimeTypeName (see parentMimeTypes()), or mimeTypeName is an alias for this mimetype.

Calls C++ function: bool QMimeType::inherits(const QString& mimeTypeName) const.

C++ documentation:

Returns true if this mimetype is mimeTypeName, or inherits mimeTypeName (see parentMimeTypes()), or mimeTypeName is an alias for this mimetype.

source

pub unsafe fn is_default(&self) -> bool

Returns true if this MIME type is the default MIME type which applies to all files: application/octet-stream.

Calls C++ function: bool QMimeType::isDefault() const.

C++ documentation:

Returns true if this MIME type is the default MIME type which applies to all files: application/octet-stream.

source

pub unsafe fn is_valid(&self) -> bool

Returns true if the QMimeType object contains valid data, otherwise returns false. A valid MIME type has a non-empty name(). The invalid MIME type is the default-constructed QMimeType.

Calls C++ function: bool QMimeType::isValid() const.

C++ documentation:

Returns true if the QMimeType object contains valid data, otherwise returns false. A valid MIME type has a non-empty name(). The invalid MIME type is the default-constructed QMimeType.

source

pub unsafe fn name(&self) -> CppBox<QString>

Returns the name of the MIME type.

Calls C++ function: QString QMimeType::name() const.

C++ documentation:

Returns the name of the MIME type.

source

pub unsafe fn new() -> CppBox<QMimeType>

Constructs this QMimeType object initialized with default property values that indicate an invalid MIME type.

Calls C++ function: [constructor] void QMimeType::QMimeType().

C++ documentation:

Constructs this QMimeType object initialized with default property values that indicate an invalid MIME type.

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QMimeType>> ) -> CppBox<QMimeType>

Constructs this QMimeType object as a copy of other.

Calls C++ function: [constructor] void QMimeType::QMimeType(const QMimeType& other).

C++ documentation:

Constructs this QMimeType object as a copy of other.

source

pub unsafe fn parent_mime_types(&self) -> CppBox<QStringList>

A type is a subclass of another type if any instance of the first type is also an instance of the second. For example, all image/svg+xml files are also text/xml, text/plain and application/octet-stream files. Subclassing is about the format, rather than the category of the data (for example, there is no 'generic spreadsheet' class that all spreadsheets inherit from). Conversely, the parent mimetype of image/svg+xml is text/xml.

Calls C++ function: QStringList QMimeType::parentMimeTypes() const.

C++ documentation:

A type is a subclass of another type if any instance of the first type is also an instance of the second. For example, all image/svg+xml files are also text/xml, text/plain and application/octet-stream files. Subclassing is about the format, rather than the category of the data (for example, there is no ‘generic spreadsheet’ class that all spreadsheets inherit from). Conversely, the parent mimetype of image/svg+xml is text/xml.

A mimetype can have multiple parents. For instance application/x-perl has two parents: application/x-executable and text/plain. This makes it possible to both execute perl scripts, and to open them in text editors.

source

pub unsafe fn preferred_suffix(&self) -> CppBox<QString>

Returns the preferred suffix for the MIME type. No leading dot is included, so for instance this would return "pdf" for application/pdf. The return value can be empty, for mime types which do not have any suffixes associated.

Calls C++ function: QString QMimeType::preferredSuffix() const.

C++ documentation:

Returns the preferred suffix for the MIME type. No leading dot is included, so for instance this would return “pdf” for application/pdf. The return value can be empty, for mime types which do not have any suffixes associated.

source

pub unsafe fn static_meta_object() -> Ref<QMetaObject>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a reference to the staticMetaObject field.

source

pub unsafe fn suffixes(&self) -> CppBox<QStringList>

Returns the known suffixes for the MIME type. No leading dot is included, so for instance this would return "jpg", "jpeg" for image/jpeg.

Calls C++ function: QStringList QMimeType::suffixes() const.

C++ documentation:

Returns the known suffixes for the MIME type. No leading dot is included, so for instance this would return “jpg”, “jpeg” for image/jpeg.

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QMimeType>>)

Swaps QMimeType other with this QMimeType object.

Calls C++ function: void QMimeType::swap(QMimeType& other).

C++ documentation:

Swaps QMimeType other with this QMimeType object.

This operation is very fast and never fails.

The swap() method helps with the implementation of assignment operators in an exception-safe way. For more information consult More C++ Idioms - Copy-and-swap.

Trait Implementations§

source§

impl CppDeletable for QMimeType

source§

unsafe fn delete(&self)

Destroys the QMimeType object, and releases the d pointer.

Calls C++ function: [destructor] void QMimeType::~QMimeType().

C++ documentation:

Destroys the QMimeType object, and releases the d pointer.

source§

impl PartialEq<Ref<QMimeType>> for QMimeType

source§

fn eq(&self, other: &Ref<QMimeType>) -> bool

Returns true if other equals this QMimeType object, otherwise returns false. The name is the unique identifier for a mimetype, so two mimetypes with the same name, are equal.

Calls C++ function: bool QMimeType::operator==(const QMimeType& other) const.

C++ documentation:

Returns true if other equals this QMimeType object, otherwise returns false. The name is the unique identifier for a mimetype, so two mimetypes with the same name, are equal.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.