• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.12
  • kdelibs
  • kdecore
  • io
kdirwatch_win.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2008 JarosÅ‚aw Staniek <staniek@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "kdirwatch_p.h"
20 
21 #include <windows.h>
22 
23 KFileSystemWatcher::KFileSystemWatcher()
24  : QObject(), m_recentWatcher(0)
25 {
26 }
27 
28 KFileSystemWatcher::~KFileSystemWatcher()
29 {
30  qDeleteAll(m_watchers);
31 }
32 
33 QFileSystemWatcher* KFileSystemWatcher::availableWatcher()
34 {
35  QFileSystemWatcher* watcher = m_recentWatcher;
36  if (!watcher || m_usedObjects.value(watcher) >= MAXIMUM_WAIT_OBJECTS) {
37  uint i = 0;
38  watcher = 0;
39  for (QList<QFileSystemWatcher*>::ConstIterator watchersIt(m_watchers.constBegin());
40  watchersIt!=m_watchers.constEnd(); ++watchersIt, i++)
41  {
42  if (m_usedObjects.value(*watchersIt) < MAXIMUM_WAIT_OBJECTS) {
43  watcher = *watchersIt;
44  m_recentWatcher = watcher;
45  return watcher;
46  }
47  }
48  }
49  if (!watcher) { //new one needed
50  watcher = new QFileSystemWatcher();
51  connect(watcher, SIGNAL(directoryChanged(QString)), this, SIGNAL(directoryChanged(QString)));
52  connect(watcher, SIGNAL(fileChanged(QString)), this, SIGNAL(fileChanged(QString)));
53  m_watchers.append( watcher );
54  m_usedObjects.insert(watcher, 0);
55  m_recentWatcher = watcher;
56  }
57  return watcher;
58 }
59 
60 void KFileSystemWatcher::addPath(const QString &file)
61 {
62  QFileSystemWatcher* watcher = availableWatcher();
63  watcher->addPath(file);
64  m_usedObjects[watcher]++;
65  m_paths.insert(file, watcher);
66 }
67 
68 void KFileSystemWatcher::removePath(const QString &file)
69 {
70  QFileSystemWatcher* watcher = m_paths.value(file);
71  if (!watcher)
72  return;
73  watcher->removePath(file);
74  m_usedObjects[watcher]--;
75  if (m_recentWatcher != watcher)
76  m_recentWatcher = 0;
77 }
KFileSystemWatcher::KFileSystemWatcher
KFileSystemWatcher()
Definition: kdirwatch_win.cpp:23
QString
QObject
KFileSystemWatcher::removePath
void removePath(const QString &file)
Definition: kdirwatch_win.cpp:68
KFileSystemWatcher::fileChanged
void fileChanged(const QString &path)
kdirwatch_p.h
KFileSystemWatcher::addPath
void addPath(const QString &file)
Definition: kdirwatch_win.cpp:60
KFileSystemWatcher::~KFileSystemWatcher
~KFileSystemWatcher()
Definition: kdirwatch_win.cpp:28
KFileSystemWatcher::directoryChanged
void directoryChanged(const QString &path)
QList
Definition: kaboutdata.h:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal