From: Jocelyn Turcotte Date: Tue, 28 Mar 2017 18:55:29 +0000 (+0200) Subject: Remove the unused folderwatcher_qt implementation X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~737 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e10a08f64de5a07216b5c6881274dbd8e410ea2f;p=nextcloud-desktop.git Remove the unused folderwatcher_qt implementation --- diff --git a/src/gui/folderwatcher_qt.cpp b/src/gui/folderwatcher_qt.cpp deleted file mode 100644 index 313ce229a..000000000 --- a/src/gui/folderwatcher_qt.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) by Klaas Freitag - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include "folderwatcher.h" -#include "folderwatcher_qt.h" - -#include -#include -#include - -namespace OCC { - -FolderWatcherPrivate::FolderWatcherPrivate() - :QObject(), _parent(0) -{ - -} - -FolderWatcherPrivate::FolderWatcherPrivate(FolderWatcher *p, const QString &path) - : QObject(), _parent(p) - -{ - _watcher.reset(new QFileSystemWatcher); - - QObject::connect(_watcher.data(), SIGNAL(directoryChanged(QString)), - _parent, SLOT(changeDetected(QString)) ); - - QMetaObject::invokeMethod(this, "slotAddFolderRecursive", Q_ARG(QString, path)); -} - -// attention: result list passed by reference! -bool FolderWatcherPrivate::findFoldersBelow( const QDir& dir, QStringList& fullList ) -{ - bool ok = true; - if( !(dir.exists() && dir.isReadable()) ) { - qDebug() << "Non existing path coming in: " << dir.absolutePath(); - ok = false; - } else { - QStringList nameFilter; - nameFilter << QLatin1String("*"); - QDir::Filters filter = QDir::Dirs | QDir::NoDotAndDotDot|QDir::NoSymLinks; - const QStringList pathes = dir.entryList(nameFilter, filter); - - QStringList::const_iterator constIterator; - for (constIterator = pathes.constBegin(); constIterator != pathes.constEnd(); - ++constIterator) { - const QString fullPath(dir.path()+QLatin1String("/")+(*constIterator)); - fullList.append(fullPath); - ok = findFoldersBelow(QDir(fullPath), fullList); - } - } - - return ok; -} - -void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path) -{ - int subdirs = 0; - qDebug() << "(+) Watcher:" << path; - - _watcher->addPath(path); - const QStringList watchedFolders(_watcher->directories()); - - QStringList allSubfolders; - if( !findFoldersBelow(QDir(path), allSubfolders)) { - qDebug() << "Could not traverse all sub folders"; - } - // qDebug() << "currently watching " << watchedFolders; - QStringListIterator subfoldersIt(allSubfolders); - while (subfoldersIt.hasNext()) { - QString subfolder = subfoldersIt.next(); - // qDebug() << " (**) subfolder: " << subfolder; - QDir folder (subfolder); - if (folder.exists() && !watchedFolders.contains(folder.path())) { - subdirs++; - if( _parent->pathIsIgnored(subfolder) ) { - qDebug() << "* Not adding" << folder.path(); - continue; - } - _watcher->addPath(folder.path()); - } else { - qDebug() << " `-> discarded:" << folder.path(); - } - } - - if (subdirs >0) { - qDebug() << " `-> and" << subdirs << "subdirectories"; - } -} - -void FolderWatcherPrivate::removePath(const QString &path ) -{ - _watcher->removePath(path); -} - - -} // namespace OCC diff --git a/src/gui/folderwatcher_qt.h b/src/gui/folderwatcher_qt.h deleted file mode 100644 index ec898ee9c..000000000 --- a/src/gui/folderwatcher_qt.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) by Klaas Freitag - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef MIRALL_FOLDERWATCHER_QT_H -#define MIRALL_FOLDERWATCHER_QT_H - -#include -#include -#include - -namespace OCC { - -class FolderWatcher; - -/** - * @brief Qt API implementation of FolderWatcher - * @ingroup gui - */ -class FolderWatcherPrivate : public QObject { - Q_OBJECT -public: - FolderWatcherPrivate(); - FolderWatcherPrivate(FolderWatcher *p, const QString& path); - void addPath(const QString &path) { slotAddFolderRecursive(path); } - void removePath(const QString &); - -signals: - void error(const QString& error); - -private slots: - void slotAddFolderRecursive(const QString &path); - -protected: - bool findFoldersBelow( const QDir& dir, QStringList& fullList ); - -private: - QScopedPointer _watcher; - - FolderWatcher *_parent; - -}; - -} - -#endif // MIRALL_FOLDERWATCHER_QT_H