ktimetracker
focusdetectornotifier.cpp
Go to the documentation of this file.00001 /* 00002 * Copyright (C) 2007 by Mathias Soeken <msoeken@tzi.de> 00003 * 2007 the ktimetracker developers 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the 00017 * Free Software Foundation, Inc. 00018 * 51 Franklin Street, Fifth Floor 00019 * Boston, MA 02110-1301 USA. 00020 * 00021 */ 00022 #include "focusdetectornotifier.h" 00023 00024 #include "focusdetector.h" 00025 #include "taskview.h" 00026 00027 //@cond PRIVATE 00028 class FocusDetectorNotifier::Private { 00029 public: 00030 Private() 00031 { 00032 mDetector = new FocusDetector(); 00033 } 00034 ~Private() 00035 { 00036 delete mDetector; 00037 } 00038 FocusDetector *mDetector; 00039 QList< TaskView * > mViews; 00040 }; 00041 //@endcond 00042 00043 FocusDetectorNotifier* FocusDetectorNotifier::mInstance = 0; 00044 00045 FocusDetectorNotifier::FocusDetectorNotifier( QObject *parent ) 00046 : QObject( parent ), d( new Private() ) 00047 { 00048 } 00049 00050 FocusDetectorNotifier* FocusDetectorNotifier::instance() 00051 { 00052 if ( !mInstance ) 00053 { 00054 mInstance = new FocusDetectorNotifier; 00055 } 00056 00057 return mInstance; 00058 } 00059 00060 FocusDetectorNotifier::~FocusDetectorNotifier() 00061 { 00062 delete d; 00063 } 00064 00065 void FocusDetectorNotifier::attach( TaskView *view ) 00066 { 00067 d->mViews.append( view ); 00068 if ( d->mViews.count() == 1 ) 00069 { 00070 //d->mDetector->startFocusDetection(); 00071 } 00072 } 00073 00074 void FocusDetectorNotifier::detach( TaskView *view ) 00075 { 00076 d->mViews.removeAll( view ); 00077 if ( d->mViews.count() == 0) 00078 { 00079 //d->mDetector->stopFocusDetection(); 00080 } 00081 } 00082 00083 FocusDetector *FocusDetectorNotifier::focusDetector() const 00084 { 00085 return d->mDetector; 00086 } 00087 00088 #include "focusdetectornotifier.moc"
KDE 4.2 API Reference