1 /* 2 * Copyright (C) 2010, 2014 Nicolas Bonnefon and other contributors 3 * 4 * This file is part of glogg. 5 * 6 * glogg is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * glogg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with glogg. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef FILEWATCHER_H 21 #define FILEWATCHER_H 22 23 #include <QObject> 24 25 // This class encapsulate Qt's QFileSystemWatcher and additionally support 26 // watching a file that doesn't exist yet (the class will watch the owning 27 // directory) 28 // Only supports one file at the moment. 29 class FileWatcher : public QObject { 30 Q_OBJECT 31 32 public: 33 // Create an empty object 34 FileWatcher() {} 35 // Destroy the object 36 virtual ~FileWatcher() {} 37 38 // Adds the file to the list of file to watch 39 // (do nothing if a file is already monitored) 40 virtual void addFile( const QString& fileName ) = 0; 41 // Removes the file to the list of file to watch 42 // (do nothing if said file is not monitored) 43 virtual void removeFile( const QString& fileName ) = 0; 44 45 signals: 46 // Sent when the file on disk has changed in any way. 47 void fileChanged( const QString& ); 48 }; 49 50 #endif 51