kaddressbook

distributionlistwidget.h
1 /*
2  This file is part of KAddressBook.
3  Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 
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.
9 
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.
14 
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.
18 
19  As a special exception, permission is given to link this program
20  with any edition of TQt, and distribute the resulting executable,
21  without including the source code for TQt in the source distribution.
22 */
23 
24 #ifndef DISTRIBUTIONLISTWIDGET_H
25 #define DISTRIBUTIONLISTWIDGET_H
26 
27 #include <config.h> // for TDEPIM_NEW_DISTRLISTS
28 #include <kdialogbase.h>
29 #include <tdelistview.h>
30 
31 #include "extensionwidget.h"
32 
33 class TQButtonGroup;
34 class TQComboBox;
35 class TQListView;
36 
38 
39 namespace KAB {
40 class Core;
41 }
42 
43 namespace TDEABC {
44 class AddressBook;
45 class DistributionListManager;
46 }
47 
48 class DistributionListWidget : public KAB::ExtensionWidget
49 {
50  TQ_OBJECT
51 
52 
53  public:
54  DistributionListWidget( KAB::Core*, TQWidget *parent, const char *name = 0 );
55  virtual ~DistributionListWidget();
56 
57  void contactsSelectionChanged();
58 
59  TQString title() const;
60  TQString identifier() const;
61 
62  public slots:
63  void save();
64  void dropped( TQDropEvent*, TQListViewItem* );
65 
66  void removeContact();
67 
68  private slots:
69  void createList();
70  void editList();
71  void removeList();
72  void addContact();
73  void changeEmail();
74  void updateNameCombo();
75  void updateContactView();
76  void selectionContactViewChanged();
77 
78  private:
79 #ifdef TDEPIM_NEW_DISTRLISTS
80  void changed( const TDEABC::Addressee& dist );
81 #else
82  void changed();
83 #endif
84  bool alreadyExists( const TQString& distrListName ) const;
85 
86  protected:
87  void dropEvent( TQDropEvent* );
88 
89  private:
90  TQComboBox *mNameCombo;
91  TQLabel *mEntryCountLabel;
92  DistributionListView *mContactView;
93 
94 #ifndef TDEPIM_NEW_DISTRLISTS
95  TDEABC::DistributionListManager *mManager;
96 #endif
97  TQPushButton *mCreateListButton;
98  TQPushButton *mEditListButton;
99  TQPushButton *mRemoveListButton;
100  TQPushButton *mChangeEmailButton;
101  TQPushButton *mAddContactButton;
102  TQPushButton *mRemoveContactButton;
103 };
104 
108 class DistributionListView : public TDEListView
109 {
110  TQ_OBJECT
111 
112 
113  public:
114  DistributionListView( TQWidget *parent, const char* name = 0 );
115 
116  protected:
117  void dragEnterEvent( TQDragEnterEvent *e );
118  void dropEvent( TQDropEvent *e );
119  void viewportDragMoveEvent( TQDragMoveEvent *e );
120  void viewportDropEvent( TQDropEvent *e );
121 };
122 
126 class EmailSelector : public KDialogBase
127 {
128  public:
129  EmailSelector( const TQStringList &emails, const TQString &current,
130  TQWidget *parent );
131 
132  TQString selected() const;
133 
134  static TQString getEmail( const TQStringList &emails, const TQString &current,
135  TQWidget *parent, bool &canceled );
136 
137  private:
138  TQButtonGroup *mButtonGroup;
139  TQMap<int, TQString> mEmailMap;
140 };
141 
142 #endif