You need a space here
[kdepim.git] / kaddressbook / searchmanager.h
blob741034ab94a43826e6887fc45b924f89d0f524dd
1 /*
2 This file is part of KAddressBook.
3 Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
24 #ifndef SEARCHMANAGER_H
25 #define SEARCHMANAGER_H
27 #include <QtCore/QObject>
29 #include <kabc/stdaddressbook.h>
31 #include <libkdepim/distributionlist.h>
33 namespace KAB {
35 class SearchManager : public QObject
37 Q_OBJECT
39 public:
40 enum Type {
41 StartsWith,
42 EndsWith,
43 Contains,
44 Equals
47 SearchManager( KABC::AddressBook *ab,
48 QObject *parent, const char *name = 0 );
50 /**
51 This method takes a pattern and searches for a match of the specified
52 field of all available contacts. The result is propagated via
53 contactsUpdated().
55 @param pattern The search string.
56 @param field The field which shall be compared with the search string.
57 @param type The type for the matching.
59 void search( const QString &pattern, const KABC::Field::List &fields, Type type = Contains );
61 /**
62 Returns the contacts which matched the last search query.
64 KABC::Addressee::List contacts() const;
66 /**
67 sets the distribution list to be shown
69 void setSelectedDistributionList( const QString &name );
71 /**
72 Returns all the distribution lists.
74 KPIM::DistributionList::List distributionLists() const;
76 /**
77 Returns the name of all the distribution lists.
79 QStringList distributionListNames() const;
81 Q_SIGNALS:
82 /**
83 Emitted whenever the contacts have changed.
85 void contactsUpdated();
87 public Q_SLOTS:
88 void reload();
90 private:
91 KABC::Addressee::List mContacts;
92 QString mSelectedDistributionList;
93 KPIM::DistributionList::List mDistributionLists;
94 KABC::AddressBook *mAddressBook;
96 QString mPattern;
97 KABC::Field::List mFields;
98 Type mType;
103 #endif