krop's commit fixes my problem in a better way, reverting
[kdepim.git] / libkdepim / kmailcompletion.h
blobe8574cceae00441a5ff3f9f4ad10a7482f133d06
1 /*
2 This file is part of libkdepim.
4 Copyright (c) 2006 Christian Schaarschmidt <schaarsc@gmx.de>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef KDEPIM_KMAILCOMPLETION_H
23 #define KDEPIM_KMAILCOMPLETION_H
25 #include <KCompletion>
27 #include <QMap>
28 #include <QString>
29 #include <QStringList>
31 namespace KPIM {
33 /**
34 * KMailCompletion allows lookup of email addresses by keyword.
35 * Typically a keywods would be firstname, lastname, nickname or domain.
37 class KMailCompletion : public KCompletion
39 Q_OBJECT
41 public:
42 KMailCompletion();
44 /**
45 * clears internal keyword map and calls KCompletion::clear.
47 virtual void clear();
49 /**
50 * uses KCompletion::makeCompletion to find email addresses which starts
51 * with string. ignores keywords.
53 * @returns email address
55 QString makeCompletion( const QString &string );
57 /**
58 * specify keywords for email.
60 * Items may be added with KCompletion::addItem, those will only be
61 * returned as match if they are in one of these formats:
62 * \li contains localpart@domain
63 * \li contains <email>
64 * or if they have also been added with this function.
66 void addItemWithKeys( const QString &email, int weight, const QStringList *keyWords );
68 /**
69 * use internal map to replace all keywords in pMatches with corresponding
70 * email addresses.
72 virtual void postProcessMatches( QStringList *pMatches ) const;
74 // We are not using allWeightedMatches() anywhere, therefore we don't need
75 // to override the other postProcessMatches() function
76 using KCompletion::postProcessMatches;
78 private:
79 QMap< QString, QStringList > m_keyMap;
84 #endif