Changeset View
Changeset View
Standalone View
Standalone View
krusader/FileSystem/filesystem.cpp
Show All 35 Lines | |||||
36 | 36 | | |||
37 | #include "fileitem.h" | 37 | #include "fileitem.h" | ||
38 | #include "krpermhandler.h" | 38 | #include "krpermhandler.h" | ||
39 | #include "../defaults.h" | 39 | #include "../defaults.h" | ||
40 | #include "../krglobal.h" | 40 | #include "../krglobal.h" | ||
41 | #include "../JobMan/jobman.h" | 41 | #include "../JobMan/jobman.h" | ||
42 | #include "../JobMan/krjob.h" | 42 | #include "../JobMan/krjob.h" | ||
43 | 43 | | |||
44 | FileSystem::FileSystem() : DirListerInterface(0), _isRefreshing(false) {} | 44 | FileSystem::FileSystem() : DirListerInterface(nullptr), _isRefreshing(false) {} | ||
45 | 45 | | |||
46 | FileSystem::~FileSystem() | 46 | FileSystem::~FileSystem() | ||
47 | { | 47 | { | ||
48 | clear(_fileItems); | 48 | clear(_fileItems); | ||
49 | // please don't remove this line. This informs the view about deleting the file items. | 49 | // please don't remove this line. This informs the view about deleting the file items. | ||
50 | emit cleared(); | 50 | emit cleared(); | ||
51 | } | 51 | } | ||
52 | 52 | | |||
53 | QList<QUrl> FileSystem::getUrls(const QStringList &names) const | 53 | QList<QUrl> FileSystem::getUrls(const QStringList &names) const | ||
54 | { | 54 | { | ||
55 | QList<QUrl> urls; | 55 | QList<QUrl> urls; | ||
56 | for (const QString name : names) { | 56 | for (const QString& name : names) { | ||
57 | urls.append(getUrl(name)); | 57 | urls.append(getUrl(name)); | ||
58 | } | 58 | } | ||
59 | return urls; | 59 | return urls; | ||
60 | } | 60 | } | ||
61 | 61 | | |||
62 | FileItem *FileSystem::getFileItem(const QString &name) const | 62 | FileItem *FileSystem::getFileItem(const QString &name) const | ||
63 | { | 63 | { | ||
64 | return _fileItems.contains(name) ? _fileItems.value(name) : 0; | 64 | return _fileItems.contains(name) ? _fileItems.value(name) : 0; | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 161 | connect(krJob, &KrJob::started, this, [=](KIO::Job *job) { | |||
162 | // Note: the "trash" protocol should always have only one "/" after the "scheme:" part | 162 | // Note: the "trash" protocol should always have only one "/" after the "scheme:" part | ||
163 | connect(job, &KIO::Job::result, this, [=]() { emit fileSystemChanged(QUrl("trash:/"), false); }); | 163 | connect(job, &KIO::Job::result, this, [=]() { emit fileSystemChanged(QUrl("trash:/"), false); }); | ||
164 | }); | 164 | }); | ||
165 | } | 165 | } | ||
166 | 166 | | |||
167 | krJobMan->manageJob(krJob); | 167 | krJobMan->manageJob(krJob); | ||
168 | } | 168 | } | ||
169 | 169 | | |||
170 | void FileSystem::connectJobToSources(KJob *job, const QList<QUrl> urls) | 170 | void FileSystem::connectJobToSources(KJob *job, const QList<QUrl>& urls) | ||
171 | { | 171 | { | ||
172 | if (!urls.isEmpty()) { | 172 | if (!urls.isEmpty()) { | ||
173 | // TODO we assume that all files were in the same directory and only emit one signal for | 173 | // TODO we assume that all files were in the same directory and only emit one signal for | ||
174 | // the directory of the first file URL (all subdirectories of parent are notified) | 174 | // the directory of the first file URL (all subdirectories of parent are notified) | ||
175 | const QUrl url = urls.first().adjusted(QUrl::RemoveFilename); | 175 | const QUrl url = urls.first().adjusted(QUrl::RemoveFilename); | ||
176 | connect(job, &KIO::Job::result, this, [=]() { emit fileSystemChanged(url, true); }); | 176 | connect(job, &KIO::Job::result, this, [=]() { emit fileSystemChanged(url, true); }); | ||
177 | } | 177 | } | ||
178 | } | 178 | } | ||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | |||||
282 | 282 | | |||
283 | FileItem *FileSystem::createFileItemFromKIO(const KIO::UDSEntry &entry, const QUrl &directory, bool virt) | 283 | FileItem *FileSystem::createFileItemFromKIO(const KIO::UDSEntry &entry, const QUrl &directory, bool virt) | ||
284 | { | 284 | { | ||
285 | const KFileItem kfi(entry, directory, true, true); | 285 | const KFileItem kfi(entry, directory, true, true); | ||
286 | 286 | | |||
287 | const QString name = kfi.text(); | 287 | const QString name = kfi.text(); | ||
288 | // ignore un-needed entries | 288 | // ignore un-needed entries | ||
289 | if (name.isEmpty() || name == "." || name == "..") { | 289 | if (name.isEmpty() || name == "." || name == "..") { | ||
290 | return 0; | 290 | return nullptr; | ||
291 | } | 291 | } | ||
292 | 292 | | |||
293 | const QString localPath = kfi.localPath(); | 293 | const QString localPath = kfi.localPath(); | ||
294 | const QUrl url = !localPath.isEmpty() ? QUrl::fromLocalFile(localPath) : kfi.url(); | 294 | const QUrl url = !localPath.isEmpty() ? QUrl::fromLocalFile(localPath) : kfi.url(); | ||
295 | const QString fname = virt ? url.toDisplayString() : name; | 295 | const QString fname = virt ? url.toDisplayString() : name; | ||
296 | 296 | | |||
297 | // get file statistics... | 297 | // get file statistics... | ||
298 | const time_t mtime = kfi.time(KFileItem::ModificationTime).toTime_t(); | 298 | const time_t mtime = kfi.time(KFileItem::ModificationTime).toTime_t(); | ||
Show All 36 Lines |