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.

addresslineedit.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. This file is part of libtdeabc.
  3. Copyright (c) 2002 Helge Deller <deller@gmx.de>
  4. 2002 Lubos Lunak <llunak@suse.cz>
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public License
  14. along with this library; see the file COPYING.LIB. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef KABC_ADDRESSLINEEDIT_H
  19. #define KABC_ADDRESSLINEEDIT_H
  20. // $Id$
  21. #include <tqobject.h>
  22. #include <tqptrlist.h>
  23. #include <tqtimer.h>
  24. #include "klineedit.h"
  25. #include "kcompletion.h"
  26. class TDEConfig;
  27. namespace TDEABC {
  28. class LdapSearch;
  29. /**
  30. * A lineedit with LDAP and tdeabc completion
  31. *
  32. * This lineedit is supposed to be used wherever the user types email addresses
  33. * and might want a completion. You can simply use it as a replacement for
  34. * KLineEdit or TQLineEdit.
  35. *
  36. * You can enable or disable the lineedit at any time.
  37. *
  38. * @see AddressLineEdit::enableCompletion()
  39. */
  40. class KABC_EXPORT AddressLineEdit : public KLineEdit
  41. {
  42. Q_OBJECT
  43. public:
  44. AddressLineEdit(TQWidget* parent, bool useCompletion = true,
  45. const char *name = 0L);
  46. virtual ~AddressLineEdit();
  47. /**
  48. * Reimplented for internal reasons.
  49. * @ see KLineEdit::setFont()
  50. */
  51. virtual void setFont( const TQFont& );
  52. static TDEConfig *config();
  53. public slots:
  54. /**
  55. * Set cursor to end of line.
  56. */
  57. void cursorAtEnd();
  58. /**
  59. * Toggle completion.
  60. */
  61. void enableCompletion( bool enable );
  62. protected:
  63. /**
  64. * Always call AddressLineEdit::loadAddresses() as the first thing.
  65. * Use addAddress() to add addresses.
  66. */
  67. virtual void loadAddresses();
  68. void addAddress( const TQString& );
  69. virtual void keyPressEvent(TQKeyEvent*);
  70. virtual void dropEvent(TQDropEvent *e);
  71. virtual void paste();
  72. virtual void insert(const TQString &t);
  73. virtual void mouseReleaseEvent( TQMouseEvent * e );
  74. void doCompletion(bool ctrlT);
  75. private slots:
  76. void slotCompletion() { doCompletion(false); }
  77. void slotPopupCompletion( const TQString& );
  78. void slotStartLDAPLookup();
  79. void slotLDAPSearchData( const TQStringList& );
  80. private:
  81. void init();
  82. void startLoadingLDAPEntries();
  83. void stopLDAPLookup();
  84. TQStringList addresses();
  85. TQStringList removeMailDupes( const TQStringList& adrs );
  86. TQString m_previousAddresses;
  87. bool m_useCompletion;
  88. bool m_completionInitialized;
  89. bool m_smartPaste;
  90. TQString m_typedText; // unused
  91. static bool s_addressesDirty;
  92. static TDECompletion *s_completion;
  93. static TQTimer *s_LDAPTimer;
  94. static LdapSearch *s_LDAPSearch;
  95. static TQString *s_LDAPText;
  96. static AddressLineEdit *s_LDAPLineEdit;
  97. static TDEConfig *s_config;
  98. private:
  99. class AddressLineEditPrivate* d;
  100. };
  101. }
  102. #endif /* KABC_ADDRESSLINEEDIT_H */