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.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #ifndef KHISTORYPROVIDER_H
  17. #define KHISTORYPROVIDER_H
  18. #include <tqdict.h>
  19. #include <tqobject.h>
  20. #include <tdelibs_export.h>
  21. namespace KParts {
  22. /**
  23. * Basic class to manage a history of "items". This class is only meant
  24. * for fast lookup, if an item is in the history or not.
  25. *
  26. * May be subclassed to implement a persistent history for example.
  27. * For usage with tdehtml, just create your provider and call the
  28. * HistoryProvider constructor _before_ you do any tdehtml stuff. That way,
  29. * tdehtml, using the self()-method, will use your subclassed provider.
  30. *
  31. * @author Carsten Pfeiffer <pfeiffer@kde.org>
  32. */
  33. class TDEPARTS_EXPORT HistoryProvider : public TQObject
  34. {
  35. Q_OBJECT
  36. public:
  37. static HistoryProvider * self();
  38. /**
  39. * Creates a KHistoryProvider with an optional parent and name
  40. */
  41. HistoryProvider( TQObject *parent = 0L, const char *name = 0 );
  42. /**
  43. * Destroys the provider.
  44. */
  45. virtual ~HistoryProvider();
  46. /**
  47. * @returns true if @p item is present in the history.
  48. */
  49. virtual bool contains( const TQString& item ) const;
  50. /**
  51. * Inserts @p item into the history.
  52. */
  53. virtual void insert( const TQString& item );
  54. /**
  55. * Removes @p item from the history.
  56. */
  57. virtual void remove( const TQString& item );
  58. /**
  59. * Clears the history. The cleared() signal is emitted after clearing.
  60. */
  61. virtual void clear();
  62. signals:
  63. /**
  64. * Emitted after the history has been cleared.
  65. */
  66. void cleared();
  67. /**
  68. * This signal is never emitted from this class, it is only meant as an
  69. * interface for subclasses. Emit this signal to notify others that the
  70. * history has changed. Put those items that were added or removed from the
  71. * history into @p items.
  72. */
  73. void updated( const TQStringList& items );
  74. /**
  75. * Emitted after the item has been inserted
  76. */
  77. void inserted( const TQString& item );
  78. private:
  79. static HistoryProvider *s_self;
  80. protected:
  81. virtual void virtual_hook( int id, void* data );
  82. private:
  83. class HistoryProviderPrivate;
  84. HistoryProviderPrivate *d;
  85. };
  86. }
  87. #endif // KHISTORYPROVIDER_H