***************************************************************************/
#include "kdirectorycontentscounter.h"
-
-#include "kdirectorycontentscounterworker.h"
-#include <kitemviews/kfileitemmodel.h>
+#include "kitemviews/kfileitemmodel.h"
#include <KDirWatch>
+
+#include <QFileInfo>
#include <QThread>
KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObject* parent) :
QObject(parent),
m_model(model),
m_queue(),
- m_worker(0),
+ m_worker(nullptr),
m_workerIsBusy(false),
- m_dirWatcher(0),
+ m_dirWatcher(nullptr),
m_watchedDirs()
{
connect(m_model, &KFileItemModel::itemsRemoved,
m_workerThread->quit();
m_workerThread->wait();
delete m_workerThread;
- m_workerThread = 0;
+ m_workerThread = nullptr;
// The worker thread has finished running now, so it's safe to delete
// m_worker. deleteLater() would not work at all because the event loop
int KDirectoryContentsCounter::countDirectoryContentsSynchronously(const QString& path)
{
- if (!m_dirWatcher->contains(path)) {
- m_dirWatcher->addDir(path);
- m_watchedDirs.insert(path);
+ const QString resolvedPath = QFileInfo(path).canonicalFilePath();
+
+ if (!m_dirWatcher->contains(resolvedPath)) {
+ m_dirWatcher->addDir(resolvedPath);
+ m_watchedDirs.insert(resolvedPath);
}
KDirectoryContentsCounterWorker::Options options;
{
m_workerIsBusy = false;
- if (!m_dirWatcher->contains(path)) {
- m_dirWatcher->addDir(path);
- m_watchedDirs.insert(path);
+ const QString resolvedPath = QFileInfo(path).canonicalFilePath();
+
+ if (!m_dirWatcher->contains(resolvedPath)) {
+ m_dirWatcher->addDir(resolvedPath);
+ m_watchedDirs.insert(resolvedPath);
}
if (!m_queue.isEmpty()) {
void KDirectoryContentsCounter::slotDirWatchDirty(const QString& path)
{
- const int index = m_model->index(KUrl(path));
+ const int index = m_model->index(QUrl::fromLocalFile(path));
if (index >= 0) {
if (!m_model->fileItem(index).isDir()) {
// If INotify is used, KDirWatch issues the dirty() signal
QMutableSetIterator<QString> it(m_watchedDirs);
while (it.hasNext()) {
const QString& path = it.next();
- if (m_model->index(KUrl(path)) < 0) {
+ if (m_model->index(QUrl::fromLocalFile(path)) < 0) {
m_dirWatcher->removeDir(path);
it.remove();
}
}
}
-QThread* KDirectoryContentsCounter::m_workerThread = 0;
-int KDirectoryContentsCounter::m_workersCount = 0;
\ No newline at end of file
+QThread* KDirectoryContentsCounter::m_workerThread = nullptr;
+int KDirectoryContentsCounter::m_workersCount = 0;