MauiKit File Browsing

fmstatic.cpp
1#include "fmstatic.h"
2#include "placeslist.h"
3#include "tagging.h"
4
5#include <QDesktopServices>
6#include <QDirIterator>
7#include <QFileInfo>
8#include <QDateTime>
9#include <QDebug>
10#include <QSettings>
11
12#include <KLocalizedString>
13
14#if (defined Q_OS_LINUX || defined Q_OS_FREEBSD) && !defined Q_OS_ANDROID
15#include <KConfig>
16#include <KConfigGroup>
17#endif
18
19#ifdef KIO_AVAILABLE
20#include <KIO/CopyJob>
21#include <KIO/DeleteJob>
22#include <KIO/EmptyTrashJob>
23#include <KIO/MkdirJob>
24#include <KIO/SimpleJob>
25#include <KIO/OpenUrlJob>
26#include <KApplicationTrader>
27#include <KIO/PreviewJob>
28#include <KFileItem>
29#endif
30
32{
33 static const QHash<FMStatic::PATHTYPE_KEY, QString> PATHTYPE_LABEL = {{PATHTYPE_KEY::PLACES_PATH, i18n("Places")},
34 {PATHTYPE_KEY::BOOKMARKS_PATH, i18n("Bookmarks")},
38 {PATHTYPE_KEY::REMOVABLE_PATH, i18n("Removable")},
39 {PATHTYPE_KEY::UNKNOWN_TYPE, i18n("Unknown")},
44 {PATHTYPE_KEY::FISH_PATH, i18n("Remote")},
45 {PATHTYPE_KEY::MTP_PATH, i18n("Drives")},
46 {PATHTYPE_KEY::OTHER_PATH, i18n("Others")},
47 {PATHTYPE_KEY::QUICK_PATH, i18n("Quick")}};
48
49 return PATHTYPE_LABEL[key];
50}
51
52
53FMStatic::FMStatic(QObject *parent)
54 : QObject(parent)
55{}
56
58{
59 FMH::MODEL_LIST data;
60
61 for (const auto &path : items)
62 {
63 if (QUrl(path).isLocalFile() && !FMH::fileExists(QUrl(path)))
64 continue;
65
66 auto model = FMStatic::getFileInfoModel(QUrl(path));
67 model.insert(FMH::MODEL_KEY::TYPE, type);
68 data << model;
69 }
70
71 return data;
72}
73
78
79FMH::MODEL_LIST FMStatic::search(const QString &query, const QUrl &path, const bool &hidden, const bool &onlyDirs, const QStringList &filters)
80{
81 FMH::MODEL_LIST content;
82
83 if (!path.isLocalFile()) {
84 qWarning() << "URL recived is not a local file. FM::search" << path;
85 return content;
86 }
87
88 if (FMStatic::isDir(path)) {
89 QDir::Filters dirFilter;
90
92
93 if (hidden)
94 dirFilter = dirFilter | QDir::Hidden | QDir::System;
95
96 QDirIterator it(path.toLocalFile(), filters, dirFilter, QDirIterator::Subdirectories);
97 while (it.hasNext()) {
98 auto url = it.next();
99 if (it.fileName().contains(query, Qt::CaseInsensitive)) {
101 }
102 }
103 } else
104 qWarning() << "Search path does not exists" << path;
105
106 qDebug() << content;
107 return content;
108}
109
111{
112 FMH::MODEL_LIST drives;
113
114#ifdef Q_OS_ANDROID
116 return drives;
117#endif
118
119 return drives;
120}
121
123{
124 return FMStatic::defaultPaths.contains(path);
125}
126
128{
129 if (!path.isLocalFile()) {
130 qWarning() << "URL recived is not a local file, FM::parentDir" << path;
131 return path;
132 }
133
134 QDir dir(path.toLocalFile());
135 dir.cdUp();
136 return QUrl::fromLocalFile(dir.absolutePath());
137}
138
139bool FMStatic::isDir(const QUrl &path)
140{
141 if (!path.isLocalFile()) {
142 // qWarning() << "URL recived is not a local file. FM::isDir" << path;
143 return false;
144 }
145
146 const QFileInfo file(path.toLocalFile());
147 return file.isDir();
148}
149
150bool FMStatic::isCloud(const QUrl &path)
151{
153}
154
155bool FMStatic::fileExists(const QUrl &path)
156{
157 return FMH::fileExists(path);
158}
159
160QUrl FMStatic::fileDir(const QUrl &path) // the directory path of the file
161{
162 QUrl res = path;
163 if (path.isLocalFile()) {
164 const QFileInfo file(path.toLocalFile());
165 if (file.isDir())
166 res = path;
167 else
168 res = QUrl::fromLocalFile(file.dir().absolutePath());
169 } else
170 qWarning() << "The path is not a local one. FM::fileDir";
171
172 return res;
173}
174
179#if !defined KIO_AVAILABLE
180
181static bool copyRecursively(QString sourceFolder, QString destFolder)
182{
183 bool success = false;
184 QDir sourceDir(sourceFolder);
185
186 if (!sourceDir.exists())
187 return false;
188
189 QDir destDir(destFolder);
190 if (!destDir.exists())
191 destDir.mkdir(destFolder);
192
193 QStringList files = sourceDir.entryList(QDir::Files);
194 for (int i = 0; i < files.count(); i++) {
195 QString srcName = sourceFolder + QDir::separator() + files[i];
196 QString destName = destFolder + QDir::separator() + files[i];
197 success = QFile::copy(srcName, destName);
198 if (!success)
199 return false;
200 }
201
202 files.clear();
203 files = sourceDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
204 for (int i = 0; i < files.count(); i++) {
205 QString srcName = sourceFolder + QDir::separator() + files[i];
206 QString destName = destFolder + QDir::separator() + files[i];
207 success = copyRecursively(srcName, destName);
208 if (!success)
209 return false;
210 }
211
212 return true;
213}
214#endif
215
216bool FMStatic::copy(const QList<QUrl> &urls, const QUrl &destinationDir)
217{
218#ifdef KIO_AVAILABLE
219 auto job = KIO::copy(urls, destinationDir);
220 job->start();
221 return true;
222#else
223 for (const auto &url : std::as_const(urls)) {
224 QFileInfo srcFileInfo(url.toLocalFile());
225 if (!srcFileInfo.isDir() && srcFileInfo.isFile()) {
226 const auto _destination = QUrl(destinationDir.toString() + QStringLiteral("/") + FMStatic::getFileInfoModel(url)[FMH::MODEL_KEY::LABEL]);
227 if (!QFile::copy(url.toLocalFile(), _destination.toLocalFile())) {
228 continue;
229 }
230 } else {
231 const auto _destination = QUrl(destinationDir.toString() + QStringLiteral("/") + FMStatic::getFileInfoModel(url)[FMH::MODEL_KEY::LABEL]);
232 QDir destDir(_destination.toLocalFile());
233 if (!destDir.exists())
234 destDir.mkdir(_destination.toLocalFile());
235
236 if (!copyRecursively(url.toLocalFile(), _destination.toLocalFile()))
237 continue;
238 }
239 }
240 return true;
241#endif
242}
243
244bool FMStatic::group(const QList<QUrl>& urls, const QUrl& destinationDir, const QString &name)
245{
246
247 if(!FMStatic::fileExists(QUrl(destinationDir.toString() + QStringLiteral("/") + name)))
248 {
249 QDir(destinationDir.toLocalFile()).mkdir(name);
250 }
251
252 return FMStatic::cut(urls, destinationDir, name);
253}
254
255
256bool FMStatic::cut(const QList<QUrl> &urls, const QUrl &where)
257{
258 return FMStatic::cut(urls, where, QString());
259}
260
261bool FMStatic::cut(const QList<QUrl> &urls, const QUrl &where, const QString &name)
262{
263#ifdef KIO_AVAILABLE
264 QUrl _where = where;
265 if (!name.isEmpty())
266 _where = QUrl(where.toString() + QStringLiteral("/") + name);
267
268 auto job = KIO::move(urls, _where, KIO::HideProgressInfo);
269 job->start();
270
271 for (const auto &url : urls) {
272 QUrl where_ = QUrl(where.toString() + QStringLiteral("/") + FMStatic::getFileInfoModel(url)[FMH::MODEL_KEY::LABEL]);
273 if (!name.isEmpty())
274 where_ = QUrl(where.toString() + QStringLiteral("/") + name);
275
276 Tagging::getInstance()->updateUrl(url.toString(), where_.toString());
277 }
278#else
279 for (const auto &url : std::as_const(urls)) {
280 QUrl _where;
281 if (name.isEmpty())
282 _where = QUrl(where.toString() + QStringLiteral("/") + FMStatic::getFileInfoModel(url)[FMH::MODEL_KEY::LABEL]);
283 else
284 _where = QUrl(where.toString() + QStringLiteral("/") + name);
285
286 QFile file(url.toLocalFile());
287 file.rename(_where.toLocalFile());
288
289 Tagging::getInstance()->updateUrl(url.toString(), _where.toString());
290 }
291#endif
292
293 return true;
294}
295
297{
298 for (const auto &url : std::as_const(urls)) {
299 Tagging::getInstance()->removeUrl(url.toString());
300 }
301
302#ifdef KIO_AVAILABLE
303 auto job = KIO::del(urls);
304 job->start();
305 return true;
306#else
307 qDebug() << "ASKED GTO DELETE FILES" << urls;
308 for (const auto &url : std::as_const(urls)) {
309 qDebug() << "@ Want to remove files << " << url.toLocalFile();
310
311 if (isDir(url)) {
312 qDebug() << "Want to remove dir << " << url.toLocalFile();
314 } else {
315 qDebug() << "Want to remove files << " << url.toLocalFile();
316 QFile::remove(url.toLocalFile());
317 }
318 }
319 return true;
320#endif
321}
322
324{
325#ifdef KIO_AVAILABLE
326 auto job = KIO::trash(urls);
327 job->start();
328#else
329 Q_UNUSED(urls)
330#endif
331}
332
334{
335#ifdef KIO_AVAILABLE
336 auto job = KIO::emptyTrash();
337 job->start();
338#endif
339}
340
341bool FMStatic::removeDir(const QUrl &path)
342{
343 bool result = true;
344 QDir dir(path.toLocalFile());
345 qDebug() << "TRYING TO REMOVE DIR" << path << path.toLocalFile();
346 if (dir.exists())
347 {
349 {
350 if (info.isDir()) {
351 result = removeDir(QUrl::fromLocalFile(info.absoluteFilePath()));
352 } else {
353 result = QFile::remove(info.absoluteFilePath());
354 }
355
356 if (!result) {
357 return result;
358 }
359 }
360 result = dir.rmdir(path.toLocalFile());
361 }
362
363 return result;
364}
365
366bool FMStatic::rename(const QUrl &url, const QString &name)
367{
368 return FMStatic::cut({url}, QUrl(url.toString().left(url.toString().lastIndexOf(QStringLiteral("/")))), name);
369}
370
371bool FMStatic::createDir(const QUrl &path, const QString &name)
372{
373#ifdef KIO_AVAILABLE
374 auto job = KIO::mkdir(name.isEmpty() ? path : QUrl(path.toString() + QStringLiteral("/") + name));
375 job->start();
376 return true;
377#else
378 return QDir(path.toLocalFile()).mkdir(name);
379#endif
380}
381
382bool FMStatic::createFile(const QUrl &path, const QString &name)
383{
384 QFile file(path.toLocalFile() + QStringLiteral("/") + name);
385
386 if (file.open(QIODevice::ReadWrite)) {
387 file.close();
388 return true;
389 }
390
391 return false;
392}
393
394bool FMStatic::createSymlink(const QUrl &path, const QUrl &where)
395{
396#ifdef KIO_AVAILABLE
397 qDebug() << "trying to create symlink" << path << where;
398 const auto job = KIO::link({path}, where);
399 job->start();
400 return true;
401#else
402 return QFile::link(path.toLocalFile(), where.toLocalFile() + QStringLiteral("/") + QFileInfo(path.toLocalFile()).fileName());
403#endif
404}
405
406void FMStatic::openUrl(const QUrl &url)
407{
408#ifdef KIO_AVAILABLE
409 KIO::OpenUrlJob *job = new KIO::OpenUrlJob(url);
410 job->setRunExecutables(true);
411 job->start();
412#else
413
414#if defined Q_OS_ANDROID
416#else
418#endif
419
420#endif
421}
422
424{
425 for (const auto &url : std::as_const(urls))
426 {
427 if(isDir(QUrl(url)))
428 {
430 }else
431 {
433 }
434 }
435}
436
438{
439 QString icon = QStringLiteral("folder");
440
441 if (!path.isLocalFile()) {
442 qWarning() << "URL recived is not a local file" << path;
443 return icon;
444 }
445
446 if (!fileExists(path))
447 return icon;
448
449
450#if defined Q_OS_ANDROID || defined Q_OS_WIN || defined Q_OS_MACOS || defined Q_OS_IOS
451 QSettings file(path.toLocalFile(), QSettings::Format::NativeFormat);
452 file.beginGroup(QStringLiteral("Desktop Entry"));
453 icon = file.value(QStringLiteral("Icon"), icon).toString();
454 file.endGroup();
455#else
456 KConfig file(path.toLocalFile());
457 const auto map = file.entryMap(QStringLiteral("Desktop Entry"));
458 icon = map.isEmpty() ? QStringLiteral("folder") : map.value(QStringLiteral("Icon"));
459#endif
460
461 return icon;
462}
463
464void FMStatic::setDirConf(const QUrl &path, const QString &group, const QString &key, const QVariant &value)
465{
466 if (!path.isLocalFile()) {
467 qWarning() << "URL recived is not a local file" << path;
468 return;
469 }
470
471#if defined Q_OS_ANDROID || defined Q_OS_WIN || defined Q_OS_MACOS || defined Q_OS_IOS
472 QSettings file(path.toLocalFile(), QSettings::Format::IniFormat);
473 file.beginGroup(group);
474 file.setValue(key, value);
475 file.endGroup();
476 file.sync();
477#else
478 KConfig file(path.toLocalFile(), KConfig::SimpleConfig);
479 auto kgroup = file.group(group);
480 kgroup.writeEntry(key, value);
481 // file.reparseConfiguration();
482 file.sync();
483#endif
484}
485
486bool FMStatic::checkFileType(const int &type, const QString &mimeTypeName)
487{
488 return FMStatic::checkFileType(static_cast<FMStatic::FILTER_TYPE>(type), mimeTypeName);
489}
490
491bool FMStatic::checkFileType(const FMStatic::FILTER_TYPE &type, const QString &mimeTypeName)
492{
493 return SUPPORTED_MIMETYPES[type].contains(mimeTypeName);
494}
495
496void FMStatic::bookmark(const QUrl &url)
497{
499}
500
502{
503 return FMStatic::FILTER_LIST[static_cast<FMStatic::FILTER_TYPE>(type)];
504}
505
507{
508 if (!path.isLocalFile()) {
509 qWarning() << "URL recived is not a local file, getMime" << path;
510 return QString();
511 }
512
513 const QMimeDatabase mimedb;
514 return mimedb.mimeTypeForFile(path.toLocalFile()).name();
515}
516
517static const QUrl thumbnailUrl(const QUrl &url, const QString &mimetype)
518{
519#ifdef KIO_AVAILABLE
520 if (FMStatic::checkFileType(FMStatic::FILTER_TYPE::FONT, mimetype) || FMStatic::checkFileType(FMStatic::FILTER_TYPE::TEXT, mimetype) || FMStatic::checkFileType(FMStatic::FILTER_TYPE::AUDIO, mimetype) || FMStatic::checkFileType(FMStatic::FILTER_TYPE::DOCUMENT, mimetype) || FMStatic::checkFileType(FMStatic::FILTER_TYPE::VIDEO, mimetype) || url.toString().endsWith(QStringLiteral(".appimage"), Qt::CaseInsensitive)) {
521 return QUrl(QStringLiteral("image://thumbnailer/") + url.toString());
522 }
523
524 // if (KIO::PreviewJob::supportedMimeTypes().contains(mimetype)) {
525 // return QUrl("image://thumbnailer/" + url.toString());
526 // }
527#endif
528
529 if (FMStatic::checkFileType(FMStatic::FILTER_TYPE::IMAGE, mimetype)) {
530 return url;
531 }
532
533 return QUrl();
534}
535
536#ifdef KIO_AVAILABLE
538{
539 return FMH::MODEL {
540 {FMH::MODEL_KEY::LABEL, kfile.name()},
541 {FMH::MODEL_KEY::NAME, kfile.name()},
542 {FMH::MODEL_KEY::DATE, kfile.time(KFileItem::FileTimes::CreationTime).toString(Qt::TextDate)},
543 {FMH::MODEL_KEY::MODIFIED, kfile.time(KFileItem::FileTimes::ModificationTime).toString(Qt::TextDate)},
544 {FMH::MODEL_KEY::LAST_READ, kfile.time(KFileItem::FileTimes::AccessTime).toString(Qt::TextDate)},
545 {FMH::MODEL_KEY::PATH, kfile.mostLocalUrl().toString()},
546 {FMH::MODEL_KEY::URL, kfile.mostLocalUrl().toString()},
547 {FMH::MODEL_KEY::THUMBNAIL, thumbnailUrl(kfile.mostLocalUrl(), kfile.mimetype()).toString()},
548 {FMH::MODEL_KEY::SYMLINK, kfile.linkDest()},
549 {FMH::MODEL_KEY::IS_SYMLINK, QVariant(kfile.isLink()).toString()},
550 {FMH::MODEL_KEY::HIDDEN, QVariant(kfile.isHidden()).toString()},
551 {FMH::MODEL_KEY::IS_DIR, QVariant(kfile.isDir()).toString()},
552 {FMH::MODEL_KEY::IS_FILE, QVariant(kfile.isFile()).toString()},
553 {FMH::MODEL_KEY::MIME, kfile.mimetype()},
554 {FMH::MODEL_KEY::ICON, kfile.iconName()},
555 {FMH::MODEL_KEY::SIZE, QString::number(kfile.size())},
556 {FMH::MODEL_KEY::COUNT, kfile.isLocalFile() && kfile.isDir() ? QString::number(QDir(kfile.localPath()).count()-2) : QStringLiteral("0")}};
557 }
558#endif
559
561 {
562 FMH::MODEL res;
563#ifdef KIO_AVAILABLE
564 res = FMStatic::getFileInfo(KFileItem(path, KFileItem::MimeTypeDetermination::NormalMimeTypeDetermination));
565#else
567 {
568 res = FMH::MODEL {
569 {FMH::MODEL_KEY::LABEL, path.fileName()},
570 {FMH::MODEL_KEY::NAME, path.fileName()},
571 {FMH::MODEL_KEY::IS_SYMLINK, QStringLiteral("false")},
572 {FMH::MODEL_KEY::IS_FILE, QStringLiteral("false")},
573 {FMH::MODEL_KEY::HIDDEN, QStringLiteral("false")},
574 {FMH::MODEL_KEY::IS_DIR, QStringLiteral("false")},
575 {FMH::MODEL_KEY::SIZE, QStringLiteral("0")}, /*locale.formattedDataSize(file.size())*/
576 {FMH::MODEL_KEY::PATH, path.toString()},
577 {FMH::MODEL_KEY::URL, path.toString()}};
578
579 }else
580 {
581 const QFileInfo file(path.toLocalFile());
582 if (!file.exists())
583 return FMH::MODEL();
584
585 const auto mime = FMStatic::getMime(path);
586 res = FMH::MODEL {
587 {FMH::MODEL_KEY::SUFFIX, file.completeSuffix()},
588 {FMH::MODEL_KEY::LABEL, path.toString() == HomePath ? QStringLiteral("Home") : file.fileName()},
589 {FMH::MODEL_KEY::NAME, file.fileName()},
590 {FMH::MODEL_KEY::DATE, file.birthTime(QTimeZone::UTC).toString(Qt::TextDate)},
591 {FMH::MODEL_KEY::MODIFIED, file.lastModified(QTimeZone::UTC).toString(Qt::TextDate)},
592 {FMH::MODEL_KEY::LAST_READ, file.lastRead(QTimeZone::UTC).toString(Qt::TextDate)},
593 {FMH::MODEL_KEY::MIME, mime},
594 {FMH::MODEL_KEY::SYMLINK, file.symLinkTarget()},
595 {FMH::MODEL_KEY::IS_SYMLINK, QVariant(file.isSymLink()).toString()},
596 {FMH::MODEL_KEY::IS_FILE, QVariant(file.isFile()).toString()},
597 {FMH::MODEL_KEY::HIDDEN, QVariant(file.isHidden()).toString()},
598 {FMH::MODEL_KEY::IS_DIR, QVariant(file.isDir()).toString()},
599 {FMH::MODEL_KEY::SIZE, QString::number(file.size()) /*locale.formattedDataSize(file.size())*/},
600 {FMH::MODEL_KEY::PATH, path.toString()},
601 {FMH::MODEL_KEY::URL, path.toString()},
602 {FMH::MODEL_KEY::THUMBNAIL, thumbnailUrl(path, mime).toString()},
603 {FMH::MODEL_KEY::COUNT, file.isDir() ? QString::number(QDir(path.toLocalFile()).count()) : QStringLiteral("0")}};
604 }
605 #endif
606
607
608 res[FMH::MODEL_KEY::ICON] = getIconName(path); //to control what icon is shown
609 return res;
610 }
611
612
613 const QVariantMap FMStatic::getFileInfo(const QUrl &path)
614 {
615 return FMH::toMap(getFileInfoModel(path));
616 }
617
619 {
621 {
622 return QStringLiteral("tag");
623 }
624
625 if (path.isLocalFile() && QFileInfo(path.toLocalFile()).isDir())
626 {
627 if (folderIcon.contains(path.toString()))
628 return folderIcon[path.toString()];
629 else
630 {
631 return dirConfIcon(QUrl(QString(path.toString() + QStringLiteral("/%1")).arg(QStringLiteral(".directory"))));
632 }
633
634 } else {
635 #ifdef KIO_AVAILABLE
636 KFileItem mime(path);
637 return mime.iconName();
638 #else
639 QMimeDatabase mime;
640 const auto type = mime.mimeTypeForFile(path.toString());
641 return type.iconName();
642 #endif
643 }
644 }
645
static const QString getIconName(const QUrl &path)
Returns the icon name for certain file.
Definition fmstatic.cpp:618
static QStringList nameFilters(const int &type)
Given a filter type return a list of associated name filters, as their suffixes.
Definition fmstatic.cpp:501
static const QHash< QString, PATHTYPE_KEY > PATHTYPE_SCHEME_NAME
The protocol scheme mapped to its PATHTYPE_KEY.
Definition fmstatic.h:351
static bool fileExists(const QUrl &path)
Checks if a local file exists in the file system.
Definition fmstatic.cpp:155
static const QStringList defaultPaths
The internally defined quick standard locations.
Definition fmstatic.h:441
static bool group(const QList< QUrl > &urls, const QUrl &destinationDir, const QString &name)
Perform a move operation of the given files to a new destination.
Definition fmstatic.cpp:244
static FMH::MODEL_LIST packItems(const QStringList &items, const QString &type)
Given a list of path URLs pack all the info of such files as a FMH::MODEL_LIST.
Definition fmstatic.cpp:57
static const QMap< QString, QString > folderIcon
A mapping of the standard location to a icon name.
Definition fmstatic.h:457
static FMH::MODEL_LIST search(const QString &query, const QUrl &path, const bool &hidden=false, const bool &onlyDirs=false, const QStringList &filters=QStringList())
Search for files in a path using name filters.
Definition fmstatic.cpp:79
static const QHash< PATHTYPE_KEY, QString > PATHTYPE_SCHEME
The map of the PATH_TYPE to its associated protocol scheme.
Definition fmstatic.h:333
static bool cut(const QList< QUrl > &urls, const QUrl &where)
Perform a move/cut of a list of files to a destination.
Definition fmstatic.cpp:256
static FMH::MODEL_LIST getDevices()
Devices mounted in the file system.
Definition fmstatic.cpp:110
static QHash< FILTER_TYPE, QStringList > FILTER_LIST
Convenient map set of file type extensions.
Definition fmstatic.h:214
static bool isCloud(const QUrl &path)
Whether a path is a URL server instead of a local file.
Definition fmstatic.cpp:150
static bool removeDir(const QUrl &path)
Remove a directory recursively.
Definition fmstatic.cpp:341
static void openLocation(const QStringList &urls)
Open the file URLs with the default file manager.
Definition fmstatic.cpp:423
static void openUrl(const QUrl &url)
Given a URL it tries to open it using the default application associated to it.
Definition fmstatic.cpp:406
static QUrl fileDir(const QUrl &path)
Given a file URL, return its parent directory.
Definition fmstatic.cpp:160
static FMStatic::PATHTYPE_KEY getPathType(const QUrl &url)
Given a file URL with a well defined scheme, get the PATHTYPE_KEY.
Definition fmstatic.cpp:646
static bool createSymlink(const QUrl &path, const QUrl &where)
Creates a symbolic link to a given file URL.
Definition fmstatic.cpp:394
static QUrl parentDir(const QUrl &path)
Given a file URL return its parent directory.
Definition fmstatic.cpp:127
static const QString dirConfIcon(const QUrl &path)
Return the icon name set in the directory .directory conf file.
Definition fmstatic.cpp:437
static void bookmark(const QUrl &url)
Add a directory URL to the places bookmarks.
Definition fmstatic.cpp:496
static QString PathTypeLabel(const FMStatic::PATHTYPE_KEY &key)
Given a PATHTYPE_KEY return a user friendly string.
Definition fmstatic.cpp:31
static bool removeFiles(const QList< QUrl > &urls)
List of files to be removed completely.
Definition fmstatic.cpp:296
static const FMH::MODEL getFileInfoModel(const QUrl &path)
getFileInfoModel
Definition fmstatic.cpp:560
static bool copy(const QList< QUrl > &urls, const QUrl &destinationDir)
Perform a copy of the files to the given destination.
Definition fmstatic.cpp:216
static FMH::MODEL_LIST getDefaultPaths()
A model list of the default paths in most systems, such as Home, Pictures, Video, Downloads,...
Definition fmstatic.cpp:74
static const QMap< FILTER_TYPE, QStringList > SUPPORTED_MIMETYPES
The map set of the supported mime types for the FM classes.
Definition fmstatic.h:171
static bool isDefaultPath(const QString &path)
Checks if a given path URL is a default path as found in the defaultPaths method.
Definition fmstatic.cpp:122
static bool isDir(const QUrl &path)
Whether a local file URL is a directory.
Definition fmstatic.cpp:139
static QString homePath()
The default home path.
Definition fmstatic.cpp:175
static const QString HomePath
Standard home location path
Definition fmstatic.h:430
static bool createDir(const QUrl &path, const QString &name)
Creates a new directory given a base path and a name.
Definition fmstatic.cpp:371
static const QString getMime(const QUrl &path)
Get the mime type of the given file path.
Definition fmstatic.cpp:506
static bool checkFileType(const int &type, const QString &mimeTypeName)
Checks if a mime-type belongs to a file type, for example, whether image/jpg belongs to the type FMH:...
Definition fmstatic.cpp:486
static void emptyTrash()
Empty the trashcan.
Definition fmstatic.cpp:333
static bool rename(const QUrl &url, const QString &name)
Rename a file.
Definition fmstatic.cpp:366
static void setDirConf(const QUrl &path, const QString &group, const QString &key, const QVariant &value)
Write a configuration key-value entry to the directory conf file.
Definition fmstatic.cpp:464
static void moveToTrash(const QList< QUrl > &urls)
Moves to the trashcan the provided file URLs.
Definition fmstatic.cpp:323
FILTER_TYPE
The common file types for filtering.
Definition fmstatic.h:46
static bool createFile(const QUrl &path, const QString &name)
Creates a file given the base directory path and a file name.
Definition fmstatic.cpp:382
PATHTYPE_KEY
The different location types supported. Most of them need of KDE KIO framework to be fully operationa...
Definition fmstatic.h:252
@ REMOTE_PATH
Remote locations, such as servers accessed via SSH or FTP.
Definition fmstatic.h:261
@ OTHER_PATH
Any other path.
Definition fmstatic.h:326
@ UNKNOWN_TYPE
Unknown location type.
Definition fmstatic.h:281
@ FISH_PATH
A remote SHH or FTP.
Definition fmstatic.h:306
@ APPS_PATH
The applications location.
Definition fmstatic.h:286
@ TAGS_PATH
A tag location.
Definition fmstatic.h:276
@ SEARCH_PATH
A search results.
Definition fmstatic.h:296
@ DRIVES_PATH
Hard drives locations.
Definition fmstatic.h:266
@ MTP_PATH
MTP path.
Definition fmstatic.h:311
@ CLOUD_PATH
A remote cloud server path.
Definition fmstatic.h:301
@ TRASH_PATH
The trash location.
Definition fmstatic.h:291
@ BOOKMARKS_PATH
A bookmarked location.
Definition fmstatic.h:321
@ REMOVABLE_PATH
Removable places, such as optic CDs, USB pen drives, etc.
Definition fmstatic.h:271
@ QUICK_PATH
The common standard paths.
Definition fmstatic.h:316
@ PLACES_PATH
Local paths, such as the Downloads, Pictures, etc.
Definition fmstatic.h:256
static const QVariantMap getFileInfo(const QUrl &path)
getFileInfo
Definition fmstatic.cpp:613
QString iconName() const
QUrl mostLocalUrl(bool *local=nullptr) const
bool isLocalFile() const
KIO::filesize_t size() const
bool isLink() const
Q_INVOKABLE QDateTime time(KFileItem::FileTimes which) const
QString mimetype() const
bool isFile() const
QString linkDest() const
QString localPath() const
bool isDir() const
bool isHidden() const
QString name(bool lowerCase=false) const
void start() override
void setRunExecutables(bool allow)
static void openUrl(const QUrl &url)
static QStringList sdDirs()
static void addBookmark(const QUrl &url)
Add a location to the bookmarks sections.
bool removeUrl(const QString &url)
Removes a URL with its associated tags.
Definition tagging.cpp:270
static Tagging * getInstance()
Returns an instance to the tagging object.
Definition tagging.cpp:70
bool updateUrl(const QString &url, const QString &newUrl)
Updates a file URL to a new URL, preserving all associated tags.
Definition tagging.cpp:205
QString i18n(const char *text, const TYPE &arg...)
bool fileExists(const QUrl &path)
QHash< MODEL_KEY, QString > MODEL
const QVariantMap toMap(const MODEL &model)
KIOCORE_EXPORT DeleteJob * del(const QList< QUrl > &src, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT CopyJob * move(const QList< QUrl > &src, const QUrl &dest, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT MkdirJob * mkdir(const QUrl &url, int permissions=-1)
KIOCORE_EXPORT CopyJob * copy(const QList< QUrl > &src, const QUrl &dest, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT CopyJob * trash(const QList< QUrl > &src, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT EmptyTrashJob * emptyTrash()
HideProgressInfo
QString toString(QStringView format, QCalendar cal) const const
bool openUrl(const QUrl &url)
QString absolutePath() const const
qsizetype count() const const
bool exists() const const
bool mkdir(const QString &dirName) const const
QChar separator()
QString fileName() const const
bool hasNext() const const
QString next()
bool copy(const QString &fileName, const QString &newName)
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
bool remove()
bool rename(const QString &newName)
virtual void close() override
QDateTime birthTime() const const
QString completeSuffix() const const
QDir dir() const const
bool exists(const QString &path)
QString fileName() const const
bool isDir() const const
bool isFile() const const
bool isHidden() const const
QDateTime lastModified() const const
QDateTime lastRead() const const
qint64 size() const const
QString symLinkTarget() const const
void clear()
qsizetype count() const const
bool contains(const Key &key) const const
QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const const
void beginGroup(QAnyStringView prefix)
void endGroup()
QString group() const const
void setValue(QAnyStringView key, const QVariant &value)
void sync()
QVariant value(QAnyStringView key) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
QString number(double n, char format, int precision)
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
CaseInsensitive
TextDate
QUrl fromLocalFile(const QString &localFile)
QString scheme() const const
QString toLocalFile() const const
QString toString(FormattingOptions options) const const
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.