TDE personal information management applications
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.

112 lines
2.9KB

  1. /*
  2. This file is part of KAddressBook.
  3. Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. As a special exception, permission is given to link this program
  16. with any edition of TQt, and distribute the resulting executable,
  17. without including the source code for TQt in the source distribution.
  18. */
  19. #ifndef SEARCHMANAGER_H
  20. #define SEARCHMANAGER_H
  21. #include <config.h> // for KDEPIM_NEW_DISTRLISTS
  22. #include <tqobject.h>
  23. #include <kabc/stdaddressbook.h>
  24. #ifdef KDEPIM_NEW_DISTRLISTS
  25. #include <libtdepim/distributionlist.h>
  26. #endif
  27. namespace KAB {
  28. class SearchManager : public TQObject
  29. {
  30. Q_OBJECT
  31. TQ_OBJECT
  32. public:
  33. enum Type {
  34. StartsWith,
  35. EndsWith,
  36. Contains,
  37. Equals
  38. };
  39. SearchManager( KABC::AddressBook *ab,
  40. TQObject *parent, const char *name = 0 );
  41. /**
  42. This method takes a pattern and searches for a match of the specified
  43. field of all available contacts. The result is propagated via
  44. contactsUpdated().
  45. @param pattern The search string.
  46. @param field The field which shall be compared with the search string.
  47. @param type The type for the matching.
  48. */
  49. void search( const TQString &pattern, const KABC::Field::List &fields, Type type = Contains );
  50. /**
  51. Returns the contacts which matched the last search query.
  52. */
  53. KABC::Addressee::List contacts() const;
  54. #ifdef KDEPIM_NEW_DISTRLISTS
  55. /**
  56. sets the distribution list to be shown
  57. */
  58. void setSelectedDistributionList( const TQString &name );
  59. /**
  60. Returns all the distribution lists.
  61. */
  62. KPIM::DistributionList::List distributionLists() const;
  63. /**
  64. Returns the name of all the distribution lists.
  65. */
  66. TQStringList distributionListNames() const;
  67. #endif
  68. signals:
  69. /**
  70. Emitted whenever the contacts have changed.
  71. */
  72. void contactsUpdated();
  73. public slots:
  74. void reload();
  75. private:
  76. KABC::Addressee::List mContacts;
  77. #ifdef KDEPIM_NEW_DISTRLISTS
  78. TQString mSelectedDistributionList;
  79. KPIM::DistributionList::List mDistributionLists;
  80. #endif
  81. KABC::AddressBook *mAddressBook;
  82. TQString mPattern;
  83. KABC::Field::List mFields;
  84. Type mType;
  85. };
  86. }
  87. #endif