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.
184 lines
6.0 KiB
184 lines
6.0 KiB
15 years ago
|
/*
|
||
13 years ago
|
This file is part of libtdepim.
|
||
15 years ago
|
Copyright (c) 2002 Helge Deller <deller@gmx.de>
|
||
|
2002 Lubos Lunak <llunak@suse.cz>
|
||
|
2001,2003 Carsten Pfeiffer <pfeiffer@kde.org>
|
||
|
2001 Waldo Bastian <bastian@kde.org>
|
||
|
2004 Daniel Molkentin <danimo@klaralvdalens-datakonsult.se>
|
||
|
2004 Karl-Heinz Zimmer <khz@klaralvdalens-datakonsult.se>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef ADDRESSEELINEEDIT_H
|
||
|
#define ADDRESSEELINEEDIT_H
|
||
|
|
||
15 years ago
|
#include <tqobject.h>
|
||
|
#include <tqptrlist.h>
|
||
|
#include <tqtimer.h>
|
||
|
#include <tqpair.h>
|
||
|
#include <tqvaluelist.h>
|
||
15 years ago
|
|
||
|
#include <kabc/addressee.h>
|
||
|
|
||
|
#include "clicklineedit.h"
|
||
|
#include "kmailcompletion.h"
|
||
|
#include <dcopobject.h>
|
||
13 years ago
|
#include <tdepimmacros.h>
|
||
15 years ago
|
|
||
|
class KConfig;
|
||
|
|
||
|
namespace KPIM {
|
||
|
class LdapSearch;
|
||
|
class LdapResult;
|
||
15 years ago
|
typedef TQValueList<LdapResult> LdapResultList;
|
||
14 years ago
|
typedef TQMap< TQString, TQPair<int,int> > CompletionItemsMap;
|
||
15 years ago
|
}
|
||
|
|
||
|
namespace KPIM {
|
||
|
|
||
|
class KDE_EXPORT AddresseeLineEdit : public ClickLineEdit, public DCOPObject
|
||
|
{
|
||
|
K_DCOP
|
||
|
Q_OBJECT
|
||
14 years ago
|
TQ_OBJECT
|
||
15 years ago
|
|
||
|
public:
|
||
14 years ago
|
AddresseeLineEdit( TQWidget* parent, bool useCompletion = true,
|
||
15 years ago
|
const char *name = 0L);
|
||
|
virtual ~AddresseeLineEdit();
|
||
|
|
||
15 years ago
|
virtual void setFont( const TQFont& );
|
||
15 years ago
|
void allowSemiColonAsSeparator( bool );
|
||
|
|
||
14 years ago
|
/// Sets if distribution lists will be used for completion.
|
||
|
/// This is true by default.
|
||
|
/// Call this right after the constructor, before anything calls loadContacts(),
|
||
|
/// otherwise this has no effect.
|
||
|
void allowDistributionLists( bool allowDistLists );
|
||
|
|
||
15 years ago
|
public slots:
|
||
|
void cursorAtEnd();
|
||
|
void enableCompletion( bool enable );
|
||
|
/** Reimplemented for stripping whitespace after completion */
|
||
15 years ago
|
virtual void setText( const TQString& txt );
|
||
15 years ago
|
|
||
|
protected slots:
|
||
|
virtual void loadContacts();
|
||
|
protected:
|
||
|
void addContact( const KABC::Addressee&, int weight, int source = -1 );
|
||
15 years ago
|
virtual void keyPressEvent( TQKeyEvent* );
|
||
15 years ago
|
/**
|
||
|
* Reimplemented for smart insertion of email addresses.
|
||
|
* Features:
|
||
|
* - Automatically adds ',' if necessary to separate email addresses
|
||
|
* - Correctly decodes mailto URLs
|
||
|
* - Recognizes email addresses which are protected against address
|
||
|
* harvesters, i.e. "name at kde dot org" and "name(at)kde.org"
|
||
|
*/
|
||
15 years ago
|
virtual void insert( const TQString &text );
|
||
15 years ago
|
/** Reimplemented for smart insertion of pasted email addresses. */
|
||
|
virtual void paste();
|
||
|
/** Reimplemented for smart insertion with middle mouse button. */
|
||
15 years ago
|
virtual void mouseReleaseEvent( TQMouseEvent *e );
|
||
15 years ago
|
/** Reimplemented for smart insertion of dragged email addresses. */
|
||
15 years ago
|
virtual void dropEvent( TQDropEvent *e );
|
||
15 years ago
|
void doCompletion( bool ctrlT );
|
||
15 years ago
|
virtual TQPopupMenu *createPopupMenu();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Adds the name of a completion source to the internal list of
|
||
|
* such sources and returns its index, such that that can be used
|
||
|
* for insertion of items associated with that source.
|
||
14 years ago
|
*
|
||
|
* If the source already exists, the weight will be updated.
|
||
15 years ago
|
*/
|
||
14 years ago
|
int addCompletionSource( const TQString&, int weight );
|
||
15 years ago
|
|
||
|
/** return whether we are using sorted or weighted display */
|
||
|
static KCompletion::CompOrder completionOrder();
|
||
|
|
||
|
k_dcop:
|
||
|
// Connected to the DCOP signal
|
||
|
void slotIMAPCompletionOrderChanged();
|
||
|
|
||
|
private slots:
|
||
|
void slotCompletion();
|
||
15 years ago
|
void slotPopupCompletion( const TQString& );
|
||
|
void slotReturnPressed( const TQString& );
|
||
15 years ago
|
void slotStartLDAPLookup();
|
||
|
void slotLDAPSearchData( const KPIM::LdapResultList& );
|
||
|
void slotEditCompletionOrder();
|
||
15 years ago
|
void slotUserCancelled( const TQString& );
|
||
15 years ago
|
|
||
|
private:
|
||
15 years ago
|
virtual bool eventFilter(TQObject *o, TQEvent *e);
|
||
15 years ago
|
void init();
|
||
|
void startLoadingLDAPEntries();
|
||
|
void stopLDAPLookup();
|
||
14 years ago
|
void updateLDAPWeights();
|
||
15 years ago
|
|
||
15 years ago
|
void setCompletedItems( const TQStringList& items, bool autoSuggest );
|
||
|
void addCompletionItem( const TQString& string, int weight, int source, const TQStringList * keyWords=0 );
|
||
|
TQString completionSearchText( TQString& );
|
||
|
const TQStringList getAdjustedCompletionItems( bool fullSearch );
|
||
15 years ago
|
void updateSearchString();
|
||
|
|
||
15 years ago
|
TQString m_previousAddresses;
|
||
|
TQString m_searchString;
|
||
15 years ago
|
bool m_useCompletion;
|
||
|
bool m_completionInitialized;
|
||
|
bool m_smartPaste;
|
||
|
bool m_addressBookConnected;
|
||
|
bool m_lastSearchMode;
|
||
|
bool m_searchExtended; //has \" been added?
|
||
|
bool m_useSemiColonAsSeparator;
|
||
14 years ago
|
bool m_allowDistLists;
|
||
15 years ago
|
|
||
15 years ago
|
//TQMap<TQString, KABC::Addressee> m_contactMap;
|
||
15 years ago
|
|
||
|
static bool s_addressesDirty;
|
||
|
static KMailCompletion *s_completion;
|
||
|
static CompletionItemsMap* s_completionItemMap;
|
||
15 years ago
|
static TQTimer *s_LDAPTimer;
|
||
15 years ago
|
static KPIM::LdapSearch *s_LDAPSearch;
|
||
15 years ago
|
static TQString *s_LDAPText;
|
||
15 years ago
|
static AddresseeLineEdit *s_LDAPLineEdit;
|
||
15 years ago
|
static TQStringList *s_completionSources;
|
||
14 years ago
|
static TQMap<int,int> *s_ldapClientToCompletionSourceMap;
|
||
15 years ago
|
|
||
|
class AddresseeLineEditPrivate;
|
||
|
AddresseeLineEditPrivate *d;
|
||
|
|
||
|
//until MenuID moves into protected in KLineEdit, we keep a copy here
|
||
|
//Constants that represent the ID's of the popup menu.
|
||
|
enum MenuID
|
||
|
{
|
||
|
Default = 42,
|
||
|
NoCompletion,
|
||
|
AutoCompletion,
|
||
|
ShellCompletion,
|
||
|
PopupCompletion,
|
||
|
ShortAutoCompletion,
|
||
|
PopupAutoCompletion
|
||
|
};
|
||
|
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|