MauiKit File Browsing

fmstatic.h
1#pragma once
2
3#include <QtGlobal>
4
5#include <MauiKit4/Core/fmh.h>
6
7#ifdef Q_OS_ANDROID
8#include <MauiKit4/Core/mauiandroid.h>
9#endif
10
11#include <QObject>
12#include <QString>
13#include <QMimeData>
14#include <QMimeDatabase>
15#include <QMimeType>
16#include <QStandardPaths>
17#include <QUrl>
18#include <QQmlEngine>
19
20#ifdef KIO_AVAILABLE
21class KFileItem;
22#endif
23
24#include "filebrowsing_export.h"
25
26/**
27 * @brief The FMStatic class is a group of static file management methods, this class has a constructor only as a way to register it to QML, however all methods in here are static.
28 */
29class FILEBROWSING_EXPORT FMStatic : public QObject
30{
32 // QML_NAMED_ELEMENT(FM)
33 // QML_SINGLETON
34
35 Q_DISABLE_COPY_MOVE(FMStatic)
36
37public:
38 /**
39 * @private
40 */
41 explicit FMStatic(QObject *parent = nullptr);
42
43 /**
44 * @brief The common file types for filtering
45 */
46 enum FILTER_TYPE : int { AUDIO, VIDEO, TEXT, IMAGE, DOCUMENT, COMPRESSED, FONT, NONE };
47
48 /**
49 * @brief The list of supported audio formats, associated to `FILTER_TYPE::AUDIO`
50 */
51 inline static const QStringList AUDIO_MIMETYPES = {
52 QStringLiteral("audio/mpeg"),
53 QStringLiteral("audio/mp4"),
54 QStringLiteral("audio/flac"),
55 QStringLiteral("audio/ogg"),
56 QStringLiteral("audio/wav")};
57
58 /**
59 * @brief The list of supported video formats, associated to `FILTER_TYPE::VIDEO`
60 */
61 inline static const QStringList VIDEO_MIMETYPES = {
62 QStringLiteral("video/mp4"),
63 QStringLiteral("video/x-matroska"),
64 QStringLiteral("video/webm"),
65 QStringLiteral("video/avi"),
66 QStringLiteral("video/flv"),
67 QStringLiteral("video/mpg"),
68 QStringLiteral("video/wmv"),
69 QStringLiteral("video/mov"),
70 QStringLiteral("video/quicktime"),
71 QStringLiteral("video/ogg"),
72 QStringLiteral("video/x-flv"),
73 QStringLiteral("video/mpeg"),
74 QStringLiteral("video/jpeg")};
75
76 /**
77 * @brief The list of supported text formats, associated to `FILTER_TYPE::TEXT`
78 */
79 inline static const QStringList TEXT_MIMETYPES = {
80 QStringLiteral("text/markdown"),
81 QStringLiteral("text/x-chdr"),
82 QStringLiteral("text/x-c++src"),
83 QStringLiteral("text/x-c++hdr"),
84 QStringLiteral("text/css"),
85 QStringLiteral("text/html"),
86 QStringLiteral("text/plain"),
87 QStringLiteral("text/richtext"),
88 QStringLiteral("text/scriptlet"),
89 QStringLiteral("text/x-vcard"),
90 QStringLiteral("text/x-go"),
91 QStringLiteral("text/x-cmake"),
92 QStringLiteral("text/x-makefile"),
93 QStringLiteral("text/x-qml"),
94 QStringLiteral("text/x-java"),
95 QStringLiteral("text/x-log"),
96 QStringLiteral("text/x-python"),
97 QStringLiteral("text/*"),
98 QStringLiteral("text/x-copying"),
99 QStringLiteral("text/x-dbus-service"),
100 QStringLiteral("text/x-gettext-translation"),
101 QStringLiteral("application/xml"),
102 QStringLiteral("application/yaml"),
103 QStringLiteral("application/vnd.kde.knotificationrc"),
104 QStringLiteral("application/x-gitignore"),
105 QStringLiteral("application/javascript"),
106 QStringLiteral("application/json"),
107 QStringLiteral("application/pgp-keys"),
108 QStringLiteral("application/x-shellscript"),
109 QStringLiteral("application/x-cmakecache"),
110 QStringLiteral("application/x-yaml"),
111 QStringLiteral("application/x-perl"),
112 QStringLiteral("application/x-kdevelop"),
113 QStringLiteral("application/x-kicad-project")};
114
115 /**
116 * @brief The list of supported image formats, associated to `FILTER_TYPE::IMAGE`
117 */
118 inline static const QStringList IMAGE_MIMETYPES = {
119 QStringLiteral("image/bmp"),
120 QStringLiteral("image/webp"),
121 QStringLiteral("image/png"),
122 QStringLiteral("image/gif"),
123 QStringLiteral("image/jpeg"),
124 QStringLiteral("image/web"),
125 QStringLiteral("image/svg"),
126 QStringLiteral("image/svg+xml"),
127 QStringLiteral("application/x-krita"),
128 QStringLiteral("image/x-xcf"),
129 QStringLiteral("image/vnd.adobe.photoshop"),
130 QStringLiteral("image/x-eps"),
131 QStringLiteral("image/jxl"),
132 QStringLiteral("image/avif"),
133 QStringLiteral("image/qoi"),
134 QStringLiteral("image/heif"),
135 QStringLiteral("image/x-jp2-codestream"),
136 QStringLiteral("image/jp2"),
137 QStringLiteral("image/jpx"),
138 QStringLiteral("image/x-dds")};
139
140 /**
141 * @brief The list of supported document formats, associated to `FILTER_TYPE::DOCUMENT`
142 */
143 inline static const QStringList DOCUMENT_MIMETYPES = {
144 QStringLiteral("application/pdf"),
145 QStringLiteral("application/rtf"),
146 QStringLiteral("application/doc"),
147 QStringLiteral("application/odf"),
148 QStringLiteral("application/vnd.comicbook+zip"),
149 QStringLiteral("application/vnd.comicbook+rar")};
150
151 /**
152 * @brief The list of supported archive formats, associated to `FILTER_TYPE::COMPRESSED`
153 */
154 inline static const QStringList COMPRESSED_MIMETYPES = {
155 QStringLiteral("application/x-compress"),
156 QStringLiteral("application/x-compressed"),
157 QStringLiteral("application/x-xz-compressed-tar"),
158 QStringLiteral("application/x-compressed-tar"),
159 // "application/vnd.android.package-archive",
160 QStringLiteral("application/x-xz"),
161 QStringLiteral("application/x-bzip"),
162 QStringLiteral("application/x-gtar"),
163 QStringLiteral("application/x-gzip"),
164 QStringLiteral("application/zip")};
165
166 /**
167 * @brief The list of supported font formats, associated to `FILTER_TYPE::FONT`
168 */
169 inline static const QStringList FONT_MIMETYPES = {
170 QStringLiteral("font/ttf"),
171 QStringLiteral("font/otf")};
172
173 /**
174 * @brief The map set of the supported mime types for the FM classes. This structure maps the `FILTER_TYPE` to the associated list of mime types.
175 * * For example `SUPPORTED_MIMETYPES[FILTER_TYPE::AUDIO]` would return a list of mimetypes associated to the FILTER_TYPE::AUDIO, such as `"audio/mpeg", "audio/mp4", "audio/flac", "audio/ogg", "audio/wav"`.
176 */
177 inline static const QMap<FILTER_TYPE, QStringList> SUPPORTED_MIMETYPES {{FILTER_TYPE::AUDIO, AUDIO_MIMETYPES},
178 {FILTER_TYPE::VIDEO, VIDEO_MIMETYPES},
179 {FILTER_TYPE::TEXT, TEXT_MIMETYPES},
180 {FILTER_TYPE::IMAGE, IMAGE_MIMETYPES},
181 {FILTER_TYPE::DOCUMENT, DOCUMENT_MIMETYPES},
182 {FILTER_TYPE::FONT, FONT_MIMETYPES},
183 {FILTER_TYPE::COMPRESSED, COMPRESSED_MIMETYPES}};
184
185 /**
186 * @brief Given a FILTER_TYPE and its associated mime-types, return a list of all the supported file extension suffixes.
187 * @param type the FILTER_TYPE
188 * @param cb a callback function to modify the gathered suffix extension. This function will receive the supported suffix and it can return a new string of a modified suffix or the same one. This is optional.
189 * @return the list of associated file extensions
190 */
191 inline static QStringList getMimeTypeSuffixes(const FILTER_TYPE &type, QString (*cb)(QString) = nullptr)
192 {
193 QStringList res;
194 QMimeDatabase mimedb;
195 for (const auto &mime : SUPPORTED_MIMETYPES[type]) {
196 if (cb) {
197 const auto suffixes = mimedb.mimeTypeForName(mime).suffixes();
198 for (const QString &_suffix : suffixes) {
199 res << cb(_suffix);
200 }
201 } else {
202 res << mimedb.mimeTypeForName(mime).suffixes();
203 }
204 }
205 return res;
206 }
207
208 /**
209 * @private
210 */
211 inline static auto func = [](QString suffix) -> QString {
212 return QStringLiteral("*.") + suffix;
213 };
214
215 /**
216 * @brief Convenient map set of file type extensions.
217 * The values make use of the regex wildcard operator [*] meant for filtering a directory contents, for example.
218 * `FILTER_LIST[FILTER_TYPE::AUDIO]` could possible return something alike `["*.mp3", "*.mp4", "*.mpeg", "*.wav"]` etc.
219 */
220 inline static QHash<FILTER_TYPE, QStringList> FILTER_LIST = {{FILTER_TYPE::AUDIO,
221 getMimeTypeSuffixes(FILTER_TYPE::AUDIO,
222 func)},
223 {FILTER_TYPE::VIDEO,
224 getMimeTypeSuffixes(FILTER_TYPE::VIDEO,
225 func)},
226 {FILTER_TYPE::TEXT,
227 getMimeTypeSuffixes(FILTER_TYPE::TEXT,
228 func)},
229 {FILTER_TYPE::DOCUMENT,
230 getMimeTypeSuffixes(FILTER_TYPE::DOCUMENT,
231 func)},
232 {FILTER_TYPE::COMPRESSED,
233 getMimeTypeSuffixes(FILTER_TYPE::COMPRESSED,
234 func)},
235 {FILTER_TYPE::FONT,
236 getMimeTypeSuffixes(FILTER_TYPE::FONT,
237 func)},
238 {FILTER_TYPE::IMAGE,
239 getMimeTypeSuffixes(FILTER_TYPE::IMAGE,
240 func)},
241 {FILTER_TYPE::NONE, QStringList()}};
242
243 /** * @brief A location contents structured for convenience. */
245
246 /**
247 * @brief The location URL holding all of the contents.
248 */
250
251 /**
252 * @brief The contents of the location.
253 */
255 };
256
257 /** * @brief The different location types supported. Most of them need of KDE KIO framework to be fully operational. */
258 enum PATHTYPE_KEY : int {
259 /**
260 * Local paths, such as the Downloads, Pictures, etc. `file:/`
261 */
263
264 /**
265 * Remote locations, such as servers accessed via SSH or FTP
266 */
268
269 /**
270 * Hard drives locations
271 */
273
274 /**
275 * Removable places, such as optic CDs, USB pen drives, etc.
276 */
278
279 /**
280 * A tag location.
281 */
283
284 /**
285 * Unknown location type.
286 */
288
289 /**
290 * The applications location. Accessed with KIO via the `applications://` scheme.
291 */
293
294 /**
295 * The trash location. `trash:/`
296 */
298
299 /**
300 * A search results.
301 */
303
304 /**
305 * A remote cloud server path.
306 */
308
309 /**
310 * A remote SHH or FTP. `fish:/` `ftp:/`
311 */
313
314 /**
315 * MTP path
316 */
318
319 /**
320 * The common standard paths
321 */
323
324 /**
325 * A bookmarked location. `file:/`
326 */
328
329 /**
330 * Any other path
331 */
333 };
334
335 /**
336 * @brief The map of the PATH_TYPE to its associated protocol scheme.
337 * For example `PATHTYPE_SCHEME[PATHTYPE_KEY::TRASH_PATH] = "trash"`, `PATHTYPE_SCHEME[PATHTYPE_KEY::PLACES_PATH] = "file"`
338 */
339 inline static const QHash<PATHTYPE_KEY, QString> PATHTYPE_SCHEME = {{PATHTYPE_KEY::PLACES_PATH, QStringLiteral("file")},
340 {PATHTYPE_KEY::BOOKMARKS_PATH, QStringLiteral("file")},
341 {PATHTYPE_KEY::DRIVES_PATH, QStringLiteral("drives")},
342 {PATHTYPE_KEY::APPS_PATH, QStringLiteral("applications")},
343 {PATHTYPE_KEY::REMOTE_PATH, QStringLiteral("remote")},
344 {PATHTYPE_KEY::REMOVABLE_PATH, QStringLiteral("removable")},
345 {PATHTYPE_KEY::UNKNOWN_TYPE, QStringLiteral("unknown")},
346 {PATHTYPE_KEY::TRASH_PATH, QStringLiteral("trash")},
347 {PATHTYPE_KEY::TAGS_PATH, QStringLiteral("tags")},
348 {PATHTYPE_KEY::SEARCH_PATH, QStringLiteral("search")},
349 {PATHTYPE_KEY::CLOUD_PATH, QStringLiteral("cloud")},
350 {PATHTYPE_KEY::FISH_PATH, QStringLiteral("fish")},
351 {PATHTYPE_KEY::MTP_PATH, QStringLiteral("mtp")}};
352
353 /**
354 * @brief The protocol scheme mapped to its PATHTYPE_KEY.
355 * Where `PATHTYPE_SCHEME_NAME["file"] = FMH::PATHTYPE_KEY::PLACES_PATH`
356 */
370
371 /**
372 * @brief Similar to PATHTYPE_SCHEME, but mapped with the complete scheme.
373 * For example `PATHTYPE_URIE[PATHTYPE_KEY::TRASH_PATH] = "trash://"`, `PATHTYPE_URI[PLACES_PATH] = "file://"`
374 */
388
389
390 /**
391 * @brief Given a PATHTYPE_KEY return a user friendly string.
392 * @warning This is a user visible and translatable string, so it should not be used as a key anywhere
393 * @param key the PATHTYPE_KEY key
394 **/
395 static QString PathTypeLabel(const FMStatic::PATHTYPE_KEY &key);
396
397 /** * @brief Standard Data location path */
399
400 /** * @brief Standard Configuration location path */
402
403 /** * @brief Standard Cloud Cache location path */
404 inline static const QString CloudCachePath = DataPath + QStringLiteral("/Cloud/");
405
406 /** * @brief Standard desktop location path */
408
409 /** * @brief Standard applications location path */
411
412 /** * @brief Standard root location path */
413 inline static const QString RootPath = QUrl::fromLocalFile(QStringLiteral("/")).toString();
414
415
416#if defined(Q_OS_ANDROID)
417 /** * @brief Standard home location path */
419 inline static const QString MusicPath = QUrl::fromLocalFile(MAUIAndroid::getStandardPath(QStandardPaths::MusicLocation)).toString();
420 inline static const QString PicturesPath = QUrl::fromLocalFile(MAUIAndroid::getStandardPath(QStandardPaths::PicturesLocation)).toString();
421 inline static const QString DownloadsPath = QUrl::fromLocalFile(MAUIAndroid::getStandardPath(QStandardPaths::DownloadLocation)).toString();
422 inline static const QString DocumentsPath = QUrl::fromLocalFile(MAUIAndroid::getStandardPath(QStandardPaths::DocumentsLocation)).toString();
423 inline static const QString VideosPath = QUrl::fromLocalFile(MAUIAndroid::getStandardPath(QStandardPaths::MoviesLocation)).toString();
424
425 /** * @brief The internally defined quick standard locations. */
426 inline static const QStringList defaultPaths = {
427 HomePath,
428 DocumentsPath,
429 PicturesPath,
430 MusicPath,
431 VideosPath,
432 DownloadsPath};
433#else
434
435 /** * @brief Standard home location path */
442
443 /** * @brief Standard trash location path */
444 inline static const QString TrashPath = QStringLiteral("trash:/");
445
446 /** * @brief The internally defined quick standard locations. */
447 inline static const QStringList defaultPaths = {
448 HomePath,
450 DocumentsPath,
451 DownloadsPath,
452 MusicPath,
453 PicturesPath,
454 VideosPath,
456 };
457
458#endif
459
460 /**
461 * @brief A mapping of the standard location to a icon name.
462 */
463 inline static const QMap<QString, QString> folderIcon {{PicturesPath, QStringLiteral("folder-pictures")},
464 {DownloadsPath, QStringLiteral("folder-download")},
465 {DocumentsPath, QStringLiteral("folder-documents")},
466 {HomePath, QStringLiteral("user-home")},
467 {MusicPath, QStringLiteral("folder-music")},
468 {VideosPath, QStringLiteral("folder-videos")},
469 {DesktopPath, QStringLiteral("user-desktop")},
470 {AppsPath, QStringLiteral("system-run")},
471 {RootPath, QStringLiteral("folder-root")}};
472
473public Q_SLOTS:
474 /**
475 * @brief Search for files in a path using name filters
476 * @param query the term query to be searched, such as `".qml"` or `"music"`
477 * @param path the path where to perform or start the search
478 * @param hidden whether to search for hidden files
479 * @param onlyDirs whether to only search for directories and not files
480 * @param filters list of filter patterns such as `{"*.qml"}`, it can use regular expressions.
481 * @return the search results are returned as a FMH::MODEL_LIST
482 */
483 static FMH::MODEL_LIST search(const QString &query, const QUrl &path, const bool &hidden = false, const bool &onlyDirs = false, const QStringList &filters = QStringList());
484
485 /**
486 * @brief Devices mounted in the file system
487 * @return list of devices represented as a FMH::MODEL_LIST with information
488 */
489 static FMH::MODEL_LIST getDevices();
490
491 /**
492 * @brief A model list of the default paths in most systems, such as Home, Pictures, Video, Downloads, Music and Documents folders
493 * @return the packaged model with information for each directory
494 */
495 static FMH::MODEL_LIST getDefaultPaths();
496
497 /**
498 * @brief Given a list of path URLs pack all the info of such files as a FMH::MODEL_LIST
499 * @param items list of local URLs
500 * @param type the type of the list of URLs, such as local, remote etc. This value is inserted with the key `FMH::MODEL_KEY::TYPE`
501 * @return
502 */
503 static FMH::MODEL_LIST packItems(const QStringList &items, const QString &type);
504
505 /**
506 * @brief Perform a move operation of the given files to a new destination
507 * @param urls list of URLs to be copied
508 * @param destinationDir destination
509 * @param name the name of the new directory where all the entries will be grouped/moved into
510 * @return whether the operation has been successful
511 */
512 static bool group(const QList<QUrl> &urls, const QUrl &destinationDir, const QString &name);
513
514 /**
515 * @brief Perform a copy of the files to the given destination
516 * @param urls list of URLs to be copy
517 * @param destinationDir destination
518 * @return whether the operation has been successful
519 */
520 static bool copy(const QList<QUrl> &urls, const QUrl &destinationDir);
521
522 /**
523 * @brief Perform a move/cut of a list of files to a destination. This function also moves the associated tags.
524 * @param urls list of URLs to be moved
525 * @param where destination path
526 * @return whether the operation has been successful
527 */
528 static bool cut(const QList<QUrl> &urls, const QUrl &where);
529
530 /**
531 * @see cut
532 * @param name new name of the directory where the files will be pasted
533 */
534 static bool cut(const QList<QUrl> &urls, const QUrl &where, const QString &name);
535
536 /**
537 * @brief List of files to be removed completely. This function also removes the associated tags to the files.
538 * @param urls file URLs to be removed
539 * @return Whether the operation has been sucessfull
540 */
541 static bool removeFiles(const QList<QUrl> &urls);
542
543 /**
544 * @brief Remove a directory recursively.
545 * @param path directory URL to be removed
546 * @return whether the operation has been sucessfull
547 */
548 static bool removeDir(const QUrl &path);
549
550 /**
551 * @brief The default home path.
552 * @return URL of the home location
553 */
554 static QString homePath();
555
556 /**
557 * @brief Given a file URL return its parent directory
558 * @param path the file URL
559 * @return the parent directory URL if it exists otherwise returns the passed URL
560 */
561 static QUrl parentDir(const QUrl &path);
562
563 /**
564 * @brief Checks if a given path URL is a default path as found in the `defaultPaths` method
565 * @param path the directory location path
566 * @return whether is a default path
567 */
568 static bool isDefaultPath(const QString &path);
569
570 /**
571 * @brief Whether a local file URL is a directory
572 * @param path file URL
573 * @return is a directory
574 */
575 static bool isDir(const QUrl &path);
576
577 /**
578 * @brief Whether a path is a URL server instead of a local file
579 * @param path
580 * @return
581 */
582 static bool isCloud(const QUrl &path);
583
584 /**
585 * @brief Checks if a local file exists in the file system
586 * @param path file URL
587 * @return whether the file path exists locally
588 */
589 static bool fileExists(const QUrl &path);
590
591 /**
592 * @brief Given a file URL, return its parent directory
593 * @note If the given path is a directory then returns the same path.
594 * @param path file path URL
595 * @return the directory URL
596 */
597 static QUrl fileDir(const QUrl &path);
598
599 /**
600 * @brief Write a configuration key-value entry to the directory conf file
601 * @param path directory path
602 * @param group the entry group name
603 * @param key the key name of the entry
604 * @param value the value of the entry
605 */
606 static void setDirConf(const QUrl &path, const QString &group, const QString &key, const QVariant &value);
607
608 /**
609 * @brief Checks if a mime-type belongs to a file type, for example, whether `image/jpg` belongs to the type `FMH::FILTER_TYPE`
610 * @param type FMH::FILTER_TYPE value
611 * @param mimeTypeName the mime type name
612 * @return whether the type contains the given name
613 */
614 static bool checkFileType(const int &type, const QString &mimeTypeName);
615 static bool checkFileType(const FMStatic::FILTER_TYPE &type, const QString &mimeTypeName);
616
617 /**
618 * @brief Moves to the trashcan the provided file URLs. The associated tags are kept in case the files are restored.
619 * @param urls the file URLs
620 */
621 static void moveToTrash(const QList<QUrl> &urls);
622
623 /**
624 * @brief Empty the trashcan
625 */
626 static void emptyTrash();
627
628 /**
629 * @brief Rename a file. The associated tags will be updated.
630 * @param url the file URL to be renamed
631 * @param name the new name of the file, not the new URL, for setting a new URl use cut instead.
632 * @return whether the operation was successful.
633 */
634 static bool rename(const QUrl &url, const QString &name);
635
636 /**
637 * @brief Creates a new directory given a base path and a name
638 * @param path base path where to create the new directory
639 * @param name the new directory name
640 * @return whether the operation was successful
641 */
642 static bool createDir(const QUrl &path, const QString &name);
643
644 /**
645 * @brief Creates a file given the base directory path and a file name
646 * @param path the base location path
647 * @param name the name of the new file to be created with the extension
648 * @return whether the operation was successful
649 */
650 static bool createFile(const QUrl &path, const QString &name);
651
652 /**
653 * @brief Creates a symbolic link to a given file URL
654 * @param path file to be linked
655 * @param where destination of the symbolic link
656 * @return whether the operation was successful
657 */
658 static bool createSymlink(const QUrl &path, const QUrl &where);
659
660 /**
661 * @brief Given a URL it tries to open it using the default application associated to it
662 * @param url the file URL to be opened
663 */
664 static void openUrl(const QUrl &url);
665
666 /**
667 * @brief Open the file URLs with the default file manager
668 * @param urls file or location URLs to be opened
669 */
670 static void openLocation(const QStringList &urls);
671
672 /**
673 * @brief Add a directory URL to the places bookmarks
674 * @param url the directory URL to be bookmarked
675 */
676 static void bookmark(const QUrl &url);
677
678 /**
679 * @brief Given a filter type return a list of associated name filters, as their suffixes.
680 * @param type the filter type to be mapped to a FMH::FILTER_TYPE
681 * @see FMH::FILTER_LIST
682 */
683 static QStringList nameFilters(const int &type);
684
685#ifdef KIO_AVAILABLE
686 /**
687 * @brief Get the file information packaged in a key-value model.
688 * @param path the file path
689 * @return the file info packed into a model
690 */
691 static const FMH::MODEL getFileInfo(const KFileItem &kfile);
692#endif
693
694 /**
695 * @brief getFileInfoModel
696 * @param path
697 * @return
698 */
699 static const FMH::MODEL getFileInfoModel(const QUrl &path);
700
701 /**
702 * @brief getFileInfo
703 * @param path
704 * @return
705 */
706 static const QVariantMap getFileInfo(const QUrl &path);
707
708 /**
709 * @brief Returns the icon name for certain file.
710 * The file path must be represented as a local file URL.
711 * It also looks into the directory conf file to get the directory custom icon.
712 *
713 * @note To get an abstract icon, use a template name, such as `test.jpg`, to get an icon for the JPG image type. The file does not need to exists.
714 * @param path file path
715 * @return
716 */
717 static const QString getIconName(const QUrl &path);
718
719 /**
720 * @brief Return the icon name set in the directory `.directory` conf file.
721 * The passed path must be a local file URL.
722 * @param path the directory location
723 * @return the icon name
724 */
725 static const QString dirConfIcon(const QUrl &path);
726
727 /**
728 * @brief Get the mime type of the given file path
729 * @param path the file path
730 * @return the mime-type string
731 */
732 static const QString getMime(const QUrl &path);
733
734 /**
735 * @brief Given a file URL with a well defined scheme, get the PATHTYPE_KEY.
736 * @see PATHTYPE_KEY
737 * @param url the file URL
738 * @return the file PATHTYPE_KEY
739 */
740 static FMStatic::PATHTYPE_KEY getPathType(const QUrl &url);
741};
static const QStringList VIDEO_MIMETYPES
The list of supported video formats, associated to FILTER_TYPE::VIDEO
Definition fmstatic.h:61
static const QHash< QString, PATHTYPE_KEY > PATHTYPE_SCHEME_NAME
The protocol scheme mapped to its PATHTYPE_KEY.
Definition fmstatic.h:357
static const QStringList AUDIO_MIMETYPES
The list of supported audio formats, associated to FILTER_TYPE::AUDIO
Definition fmstatic.h:51
static const QStringList defaultPaths
The internally defined quick standard locations.
Definition fmstatic.h:447
static const QString RootPath
Standard root location path.
Definition fmstatic.h:413
static const QStringList IMAGE_MIMETYPES
The list of supported image formats, associated to FILTER_TYPE::IMAGE
Definition fmstatic.h:118
static const QString AppsPath
Standard applications location path.
Definition fmstatic.h:410
static const QMap< QString, QString > folderIcon
A mapping of the standard location to a icon name.
Definition fmstatic.h:463
static const QHash< PATHTYPE_KEY, QString > PATHTYPE_SCHEME
The map of the PATH_TYPE to its associated protocol scheme.
Definition fmstatic.h:339
static const QStringList FONT_MIMETYPES
The list of supported font formats, associated to FILTER_TYPE::FONT
Definition fmstatic.h:169
static QHash< FILTER_TYPE, QStringList > FILTER_LIST
Convenient map set of file type extensions.
Definition fmstatic.h:220
static const QHash< PATHTYPE_KEY, QString > PATHTYPE_URI
Similar to PATHTYPE_SCHEME, but mapped with the complete scheme.
Definition fmstatic.h:375
static QStringList getMimeTypeSuffixes(const FILTER_TYPE &type, QString(*cb)(QString)=nullptr)
Given a FILTER_TYPE and its associated mime-types, return a list of all the supported file extension ...
Definition fmstatic.h:191
static const QStringList DOCUMENT_MIMETYPES
The list of supported document formats, associated to FILTER_TYPE::DOCUMENT
Definition fmstatic.h:143
static const QStringList TEXT_MIMETYPES
The list of supported text formats, associated to FILTER_TYPE::TEXT
Definition fmstatic.h:79
static const QString TrashPath
Standard trash location path.
Definition fmstatic.h:444
static const QMap< FILTER_TYPE, QStringList > SUPPORTED_MIMETYPES
The map set of the supported mime types for the FM classes.
Definition fmstatic.h:177
static const QString ConfigPath
Standard Configuration location path.
Definition fmstatic.h:401
static const QString DataPath
Standard Data location path.
Definition fmstatic.h:398
static const QString CloudCachePath
Standard Cloud Cache location path.
Definition fmstatic.h:404
static const QString HomePath
Standard home location path.
Definition fmstatic.h:436
static const QStringList COMPRESSED_MIMETYPES
The list of supported archive formats, associated to FILTER_TYPE::COMPRESSED
Definition fmstatic.h:154
FILTER_TYPE
The common file types for filtering.
Definition fmstatic.h:46
PATHTYPE_KEY
The different location types supported. Most of them need of KDE KIO framework to be fully operationa...
Definition fmstatic.h:258
@ REMOTE_PATH
Remote locations, such as servers accessed via SSH or FTP.
Definition fmstatic.h:267
@ OTHER_PATH
Any other path.
Definition fmstatic.h:332
@ UNKNOWN_TYPE
Unknown location type.
Definition fmstatic.h:287
@ FISH_PATH
A remote SHH or FTP.
Definition fmstatic.h:312
@ APPS_PATH
The applications location.
Definition fmstatic.h:292
@ TAGS_PATH
A tag location.
Definition fmstatic.h:282
@ SEARCH_PATH
A search results.
Definition fmstatic.h:302
@ DRIVES_PATH
Hard drives locations.
Definition fmstatic.h:272
@ MTP_PATH
MTP path.
Definition fmstatic.h:317
@ CLOUD_PATH
A remote cloud server path.
Definition fmstatic.h:307
@ TRASH_PATH
The trash location.
Definition fmstatic.h:297
@ BOOKMARKS_PATH
A bookmarked location.
Definition fmstatic.h:327
@ REMOVABLE_PATH
Removable places, such as optic CDs, USB pen drives, etc.
Definition fmstatic.h:277
@ QUICK_PATH
The common standard paths.
Definition fmstatic.h:322
@ PLACES_PATH
Local paths, such as the Downloads, Pictures, etc.
Definition fmstatic.h:262
static const QString DesktopPath
Standard desktop location path.
Definition fmstatic.h:407
static QString homePath()
QVector< MODEL > MODEL_LIST
QHash< MODEL_KEY, QString > MODEL
QMimeType mimeTypeForName(const QString &nameOrAlias) const const
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
QString writableLocation(StandardLocation type)
QUrl fromLocalFile(const QString &localFile)
QString toString(FormattingOptions options) const const
A location contents structured for convenience.
Definition fmstatic.h:244
FMH::MODEL_LIST content
The contents of the location.
Definition fmstatic.h:254
QUrl path
The location URL holding all of the contents.
Definition fmstatic.h:249
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:55:53 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.