Changeset View
Changeset View
Standalone View
Standalone View
krusader/FileSystem/sizecalculator.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 82 | { | |||
---|---|---|---|---|---|
92 | if (m_nextUrls.isEmpty()) { | 92 | if (m_nextUrls.isEmpty()) { | ||
93 | done(); | 93 | done(); | ||
94 | return; | 94 | return; | ||
95 | } | 95 | } | ||
96 | m_currentUrl = m_nextUrls.takeFirst(); | 96 | m_currentUrl = m_nextUrls.takeFirst(); | ||
97 | 97 | | |||
98 | if (m_currentUrl.scheme() == "virt") { | 98 | if (m_currentUrl.scheme() == "virt") { | ||
99 | // calculate size of all files/directories in this virtual directory | 99 | // calculate size of all files/directories in this virtual directory | ||
100 | VirtualFileSystem *fs = new VirtualFileSystem(); | 100 | auto *fs = new VirtualFileSystem(); | ||
101 | if (!fs->scanDir(m_currentUrl)) { | 101 | if (!fs->scanDir(m_currentUrl)) { | ||
102 | qWarning() << "cannot scan virtual FS, URL=" << m_currentUrl.toDisplayString(); | 102 | qWarning() << "cannot scan virtual FS, URL=" << m_currentUrl.toDisplayString(); | ||
103 | nextUrl(); | 103 | nextUrl(); | ||
104 | return; | 104 | return; | ||
105 | } | 105 | } | ||
106 | for (FileItem *file : fs->fileItems()) | 106 | for (FileItem *file : fs->fileItems()) | ||
107 | m_nextSubUrls << file->getUrl(); | 107 | m_nextSubUrls << file->getUrl(); | ||
108 | delete fs; | 108 | delete fs; | ||
Show All 25 Lines | 133 | if (m_canceled) | |||
134 | return; | 134 | return; | ||
135 | 135 | | |||
136 | if (job->error()) { | 136 | if (job->error()) { | ||
137 | qWarning() << "stat job failed, error=" << job->error() << "; error string=" << job->errorString(); | 137 | qWarning() << "stat job failed, error=" << job->error() << "; error string=" << job->errorString(); | ||
138 | nextSubUrl(); | 138 | nextSubUrl(); | ||
139 | return; | 139 | return; | ||
140 | } | 140 | } | ||
141 | 141 | | |||
142 | const KIO::StatJob *statJob = static_cast<KIO::StatJob *>(job); | 142 | const KIO::StatJob *statJob = dynamic_cast<KIO::StatJob *>(job); | ||
143 | const QUrl url = statJob->url(); | 143 | const QUrl& url = statJob->url(); | ||
144 | 144 | | |||
145 | const KFileItem kfi(statJob->statResult(), url, true); | 145 | const KFileItem kfi(statJob->statResult(), url, true); | ||
146 | if (kfi.isFile() || kfi.isLink()) { | 146 | if (kfi.isFile() || kfi.isLink()) { | ||
147 | m_totalFiles++; | 147 | m_totalFiles++; | ||
148 | m_totalSize += kfi.size(); | 148 | m_totalSize += kfi.size(); | ||
149 | m_currentUrlSize += kfi.size(); | 149 | m_currentUrlSize += kfi.size(); | ||
150 | nextSubUrl(); | 150 | nextSubUrl(); | ||
151 | return; | 151 | return; | ||
Show All 11 Lines | 162 | { | |||
163 | if (!m_directorySizeJob->error()) { | 163 | if (!m_directorySizeJob->error()) { | ||
164 | m_totalSize += m_directorySizeJob->totalSize(); | 164 | m_totalSize += m_directorySizeJob->totalSize(); | ||
165 | // do not count filesystem size of empty directories for this current directory | 165 | // do not count filesystem size of empty directories for this current directory | ||
166 | m_currentUrlSize += | 166 | m_currentUrlSize += | ||
167 | m_directorySizeJob->totalFiles() == 0 ? 0 : m_directorySizeJob->totalSize(); | 167 | m_directorySizeJob->totalFiles() == 0 ? 0 : m_directorySizeJob->totalSize(); | ||
168 | m_totalFiles += m_directorySizeJob->totalFiles(); | 168 | m_totalFiles += m_directorySizeJob->totalFiles(); | ||
169 | m_totalDirs += m_directorySizeJob->totalSubdirs(); | 169 | m_totalDirs += m_directorySizeJob->totalSubdirs(); | ||
170 | } | 170 | } | ||
171 | m_directorySizeJob = 0; | 171 | m_directorySizeJob = nullptr; | ||
172 | nextSubUrl(); | 172 | nextSubUrl(); | ||
173 | } | 173 | } | ||
174 | 174 | | |||
175 | void SizeCalculator::done() | 175 | void SizeCalculator::done() | ||
176 | { | 176 | { | ||
177 | emit finished(m_canceled); | 177 | emit finished(m_canceled); | ||
178 | deleteLater(); | 178 | deleteLater(); | ||
179 | } | 179 | } | ||
180 | 180 | | |||
181 | void SizeCalculator::emitProgress() | 181 | void SizeCalculator::emitProgress() | ||
182 | { | 182 | { | ||
183 | emit progressChanged((m_urls.length() - (float)m_nextUrls.length()) / m_urls.length() * 100); | 183 | emit progressChanged((m_urls.length() - (float)m_nextUrls.length()) / m_urls.length() * 100); | ||
184 | } | 184 | } |