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

KIO

kdirwatch_win.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2008 Jarosław Staniek <staniek@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "kdirwatch_p.h"
00020 
00021 #include <windows.h>
00022 
00023 KFileSystemWatcher::KFileSystemWatcher()
00024  : QObject(), m_recentWatcher(0)
00025 {
00026 }
00027 
00028 KFileSystemWatcher::~KFileSystemWatcher()
00029 {
00030   qDeleteAll(m_watchers);
00031 }
00032 
00033 QFileSystemWatcher* KFileSystemWatcher::availableWatcher()
00034 {
00035   QFileSystemWatcher* watcher = m_recentWatcher;
00036   if (!watcher || m_usedObjects.value(watcher) >= MAXIMUM_WAIT_OBJECTS) {
00037     uint i = 0;
00038     watcher = 0;
00039     for (QList<QFileSystemWatcher*>::ConstIterator watchersIt(m_watchers.constBegin());
00040       watchersIt!=m_watchers.constEnd(); ++watchersIt, i++)
00041     {
00042       if (m_usedObjects.value(*watchersIt) < MAXIMUM_WAIT_OBJECTS) {
00043         watcher = *watchersIt;
00044         m_recentWatcher = watcher;
00045         return watcher;
00046       }
00047     }
00048   }
00049   if (!watcher) { //new one needed
00050     watcher = new QFileSystemWatcher();
00051     connect(watcher, SIGNAL(directoryChanged(QString)), this, SIGNAL(directoryChanged(QString)));
00052     connect(watcher, SIGNAL(fileChanged(QString)), this, SIGNAL(fileChanged(QString)));
00053     m_watchers.append( watcher );
00054     m_usedObjects.insert(watcher, 0);
00055     m_recentWatcher = watcher;
00056   }
00057   return watcher;
00058 }
00059 
00060 void KFileSystemWatcher::addPath(const QString &file)
00061 {
00062   QFileSystemWatcher* watcher = availableWatcher();
00063   watcher->addPath(file);
00064   m_usedObjects[watcher]++;
00065   m_paths.insert(file, watcher);
00066 }
00067 
00068 void KFileSystemWatcher::removePath(const QString &file)
00069 {
00070   QFileSystemWatcher* watcher = m_paths.value(file);
00071   if (!watcher)
00072     return;
00073   watcher->removePath(file);
00074   m_usedObjects[watcher]--;
00075   if (m_recentWatcher != watcher)
00076     m_recentWatcher = 0;
00077 }

KIO

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal