"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2bFileSystemWatcher.cpp" (12 Feb 2021, 887 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "c2bFileSystemWatcher.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0.0_vs_2.0.1.

    1 /***************************************************************************
    2  *   Copyright (C) 2004-2021 by Pere Constans
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *   See the LICENSE file that comes with this distribution.
    6  ***************************************************************************/
    7 #include "c2bFileSystemWatcher.h"
    8 
    9 #include <QTimer>
   10 
   11 
   12 /**
   13     Workaround to avoid reading a file when external writing has not yet finished
   14 */
   15 c2bFileSystemWatcher::c2bFileSystemWatcher(QObject* parento) : QObject(parento)
   16 {
   17     connect(&_filewatcher, SIGNAL(fileChanged(QString)), this, SLOT(waitForSaved(QString)));
   18 }
   19 
   20 void c2bFileSystemWatcher::waitForSaved(const QString& path)
   21 {
   22     _path = path;
   23     QTimer::singleShot(500, this, SLOT(fileSaved()));
   24 }
   25 
   26 void c2bFileSystemWatcher::fileSaved()
   27 {
   28     emit fileChanged(_path);
   29 }