home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kabc / addresseedialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.2 KB  |  162 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
  4.  
  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.  
  10.     This library 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 GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef KABC_ADDRESSEEDIALOG_H
  22. #define KABC_ADDRESSEEDIALOG_H
  23.  
  24. #include <qdict.h>
  25.  
  26. #include <kdialogbase.h>
  27. #include <klineedit.h>
  28. #include <klistview.h>
  29.  
  30. #include "addressbook.h"
  31.  
  32. namespace KABC {
  33.  
  34. /**
  35.   @short Special ListViewItem, that is used by the AddresseeDialog.
  36. */
  37. class KABC_EXPORT AddresseeItem : public QListViewItem
  38. {
  39.   public:
  40.  
  41.     /**
  42.       Type of column
  43.       @li @p Name -  Name in Addressee
  44.       @li @p Email - Email in Addressee
  45.     */
  46.     enum columns { Name = 0, Email = 1 };
  47.  
  48.     /**
  49.       Constructor.
  50.  
  51.       @param parent    The parent listview.
  52.       @param addressee The associated addressee.
  53.     */
  54.     AddresseeItem( QListView *parent, const Addressee &addressee );
  55.  
  56.     /**
  57.       Returns the addressee.
  58.     */
  59.     Addressee addressee() const { return mAddressee; }
  60.  
  61.     /**
  62.       Method used by QListView to sort the items.
  63.     */
  64.     virtual QString key( int column, bool ascending ) const;
  65.  
  66.   private:
  67.     Addressee mAddressee;
  68. };
  69.  
  70. /**
  71.   @short Dialog for selecting address book entries.
  72.  
  73.   This class provides a dialog for selecting entries from the standard KDE
  74.   address book. Use the getAddressee() function to open a modal dialog,
  75.   returning an address book entry.
  76.  
  77.   In the dialog you can select an entry from the list with the mouse or type in
  78.   the first letters of the name or email address you are searching for. The
  79.   entry matching best is automatically selected. Use double click, pressing
  80.   return or pressing the ok button to return the selected addressee to the
  81.   application.
  82. */
  83. class KABC_EXPORT AddresseeDialog : public KDialogBase
  84. {
  85.     Q_OBJECT
  86.  
  87.   public:
  88.     /**
  89.       Construct addressbook entry select dialog.
  90.  
  91.       @param parent parent widget
  92.       @param multiple if true, indicates a multiple selection.
  93.     */
  94.     AddresseeDialog( QWidget *parent=0, bool multiple=false );
  95.  
  96.     /**
  97.       Destructor.
  98.     */
  99.     virtual ~AddresseeDialog();
  100.  
  101.     /**
  102.       Return the address chosen.
  103.  
  104.       If it is a multiple select, this will return only the first address chosen
  105.     */
  106.     Addressee addressee();
  107.  
  108.     /**
  109.       Return the list of addresses chosen
  110.     */
  111.     Addressee::List addressees();
  112.  
  113.     /**
  114.       Select a single address book entry.
  115.  
  116.       Open addressee select dialog and return the entry selected by the user.
  117.       If the user doesn't select an entry or presses cancel, the returned
  118.       addressee is empty.
  119.     */
  120.     static Addressee getAddressee( QWidget *parent );
  121.  
  122.     /**
  123.       Select multiple address book entries.
  124.  
  125.       Open addressee select dialog and return the entries selected by the user.
  126.       If the user doesn't select an entry or presses cancel, the returned
  127.       addressee list is empty.
  128.     */
  129.     static Addressee::List getAddressees( QWidget *parent );
  130.  
  131.   private slots:
  132.     void selectItem( const QString & );
  133.     void updateEdit( QListViewItem *item );
  134.     void addSelected( QListViewItem *item );
  135.     void removeSelected();
  136.  
  137.   protected slots:
  138.     void addressBookChanged();
  139.  
  140.   private:
  141.     void loadAddressBook();
  142.     void addCompletionItem( const QString &str, QListViewItem *item );
  143.  
  144.     bool mMultiple;
  145.  
  146.     KListView *mAddresseeList;
  147.     KLineEdit *mAddresseeEdit;
  148.  
  149.     KListView *mSelectedList;
  150.  
  151.     AddressBook *mAddressBook;
  152.  
  153.     QDict<QListViewItem> mItemDict;
  154.     QDict<QListViewItem> mSelectedDict;
  155.  
  156.     class AddresseeDialogPrivate;
  157.     AddresseeDialogPrivate *d;
  158. };
  159.  
  160. }
  161. #endif
  162.