TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

historyprovider.cpp 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* This file is part of the KDE project
  2. Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. Boston, MA 02110-1301, USA.
  15. */
  16. #include <tqdict.h>
  17. #include <tdeapplication.h>
  18. #include "historyprovider.h"
  19. using namespace KParts;
  20. template class TQDict<void>;
  21. HistoryProvider * HistoryProvider::s_self = 0L;
  22. class HistoryProvider::HistoryProviderPrivate
  23. {
  24. public:
  25. HistoryProviderPrivate()
  26. : dict( 1009 ) {}
  27. TQDict<void> dict;
  28. };
  29. HistoryProvider * HistoryProvider::self()
  30. {
  31. if ( !s_self )
  32. s_self = new HistoryProvider( TQT_TQOBJECT(kapp), "history provider" );
  33. return s_self;
  34. }
  35. HistoryProvider::HistoryProvider( TQObject *parent, const char *name )
  36. : TQObject( parent, name )
  37. {
  38. if ( !s_self )
  39. s_self = this;
  40. d = new HistoryProviderPrivate;
  41. }
  42. HistoryProvider::~HistoryProvider()
  43. {
  44. delete d;
  45. if ( s_self == this )
  46. s_self = 0;
  47. }
  48. bool HistoryProvider::contains( const TQString& item ) const
  49. {
  50. return (bool) d->dict.find( item );
  51. }
  52. void HistoryProvider::insert( const TQString& item )
  53. {
  54. // no need to allocate memory, we only want to have fast lookup, no mapping
  55. d->dict.replace( item, (void*) 1 );
  56. emit inserted( item );
  57. }
  58. void HistoryProvider::remove( const TQString& item )
  59. {
  60. (void) d->dict.remove( item );
  61. }
  62. void HistoryProvider::clear()
  63. {
  64. d->dict.clear();
  65. emit cleared();
  66. }
  67. void HistoryProvider::virtual_hook( int, void* )
  68. { /*BASE::virtual_hook( id, data );*/ }
  69. #include "historyprovider.moc"