# kparts Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# historyprovider.cpp

    00001 /* This file is part of the KDE project
    00002    Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@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 as published by the Free Software Foundation; either
    00007    version 2 of the License, or (at your option) any later version.
    00008
    00009    This library is distributed in the hope that it will be useful,
    00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012    Library General Public License for more details.
    00013
    00014    You should have received a copy of the GNU Library General Public License
    00015    along with this library; see the file COPYING.LIB.  If not, write to
    00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017    Boston, MA 02111-1307, USA.
    00018 */
    00019
    00020 #include <qdict.h>
    00021
    00022 #include <kapplication.h>
    00023
    00024 #include "historyprovider.h"
    00025
    00026 using namespace KParts;
    00027 template class QDict<void>;
    00028
    00029 HistoryProvider * HistoryProvider::s_self = 0L;
    00030
    00031 class HistoryProvider::HistoryProviderPrivate
    00032 {
    00033 public:
    00034     HistoryProviderPrivate()
    00035         : dict( 1009 ) {}
    00036
    00037     QDict<void> dict;
    00038 };
    00039
    00040 HistoryProvider * HistoryProvider::self()
    00041 {
    00042     if ( !s_self )
    00043         s_self = new HistoryProvider( kapp, "history provider" );
    00044     return s_self;
    00045 }
    00046
    00047 HistoryProvider::HistoryProvider( QObject *parent, const char *name )
    00048     : QObject( parent, name )
    00049 {
    00050     if ( !s_self )
    00051         s_self = this;
    00052
    00053     d = new HistoryProviderPrivate;
    00054 }
    00055
    00056 HistoryProvider::~HistoryProvider()
    00057 {
    00058     delete d;
    00059
    00060     if ( s_self == this )
    00061         s_self = 0;
    00062 }
    00063
    00064 bool HistoryProvider::contains( const QString& item ) const
    00065 {
    00066     return (bool) d->dict.find( item );
    00067 }
    00068
    00069 void HistoryProvider::insert( const QString& item )
    00070 {
    00071     // no need to allocate memory, we only want to have fast lookup, no mapping
    00072     d->dict.replace( item, (void*) 1 );
    00073 }
    00074
    00075 void HistoryProvider::remove( const QString& item )
    00076 {
    00077     (void) d->dict.remove( item );
    00078 }
    00079
    00080 void HistoryProvider::clear()
    00081 {
    00082     d->dict.clear();
    00083     emit cleared();
    00084 }
    00085
    00086 void HistoryProvider::virtual_hook( int, void* )
    00087 { /*BASE::virtual_hook( id, data );*/ }
    00088
    00089 #include "historyprovider.moc"

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:26:50 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001