summaryrefslogtreecommitdiffstats
path: root/kword/mailmerge/tdeabc/KWMailMergeTDEABC.h
blob: 3db02d9189fa0d665e903798b989cec8a291b360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
   This file is part of the KDE project
   Copyright (C) 2003 Tobias Koenig <tokoe@kde.org>
   Copyright (C) 2004 Tobias Koenig <tokoe@kde.org>
                      Dirk Schmidt <fs@dirk.schmidt.net>
 
   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 _KWMAILMERGE_KABC_H_
#define _KWMAILMERGE_KABC_H_

#include <tqdom.h>
#include <tqguardedptr.h>

#include <tdeabc/addressbook.h>

#include "KWMailMergeDataSource.h"

class KWMailMergeTDEABC: public KWMailMergeDataSource
{
    Q_OBJECT
  

public:
    KWMailMergeTDEABC( TDEInstance *inst, TQObject *parent );
    ~KWMailMergeTDEABC();

    /**
       Saves the mail merge list to the kword document.
     */
    virtual void save( TQDomDocument&, TQDomElement& );

    /**
       Loads the mail merge list stored in the kword document.
     */
    virtual void load( TQDomElement& );

    /**
       @param name	The name of the value e.g. "Family name".
       @param record	The position of the the entry in mail merge list.
       @return		The value of the mail merge variable.
       
       If @p record equals -1, @p name is returned.
     */
    virtual class TQString getValue( const class TQString &name, int record = -1 ) const;

    /**
       @return	The number of available contacts in mail merge list.
     */
    virtual int getNumRecords() const;

    /**
       Only for compatability reasons.
       
       @param force	Hasn't any effect.
     */
    virtual void refresh( bool force );

    /**
       Shows a KWMailMergeTDEABCConfig dialog for selecting entries from KAddressbook.
     */
    virtual bool showConfigDialog( TQWidget*, int action);

protected:
    friend class KWMailMergeTDEABCConfig;

    /**
       Adds an entry from TDEABC::StdAddressBook::self()
       to the mail merge list.
      
       To be called by KWMailMergeTDEABC::load() and 
       KWMailMergeTDEABCConfig::acceptSelection() only.
       
       @param uid	The entry's TDEABC::Addressee::uid().
     */
    void addEntry( const TQString &uid );

    /**
       Adds a distribution list to the mail merge list.
       
       To be called by KWMailMergeTDEABC::load() and 
       KWMailMergeTDEABCConfig::acceptSelection() only.
       
       @param id	The DistributionList::name().
     */
    void addList( const TQString &id );

    /**
       Removes all entries and distribution lists from the mail merge list.
     */
    void clear();

    /**
       @return	All selected DistributionList::name().
       
       To be called by KWMailMergeTDEABCConfig::initSelectedLists()
     */
    virtual TQStringList lists() const;

    /**
       @return	The TDEABC::Addressee::uid() of all individually selected 
       entries in mail merge list.
       
       To be called by KWMailMergeTDEABCConfig::initSelectedAddressees()
    */
    virtual TQStringList singleRecords() const;

private:
    /**
       The TDEABC::StdAddressBook::self().
     */
    TDEABC::AddressBook* _addressBook;

    /**
       Just an Iterator.
     */
    mutable TDEABC::AddressBook::ConstIterator _iterator;

    /**
       Just an Iterator.
     */
    mutable TQStringList::ConstIterator _UIDIterator;

    /**
       The "real" mail merge list. A list of TQStrings. Each represents 
       the TDEABC::Addressee::uid() of a KAdressbook entry.
       There is no UID twice in this list.
      
       Needed because selected contacts may appear in a selected 
       distribution list, too. And we don't want to print it multiple.
     */
    TQStringList _exclusiveUIDs;

    /**
       This list contains all the TDEABC::Addressee::uid() selected 
       individually with the KWMailMergeTDEABCConfig dialog.
     */
    TQStringList _individualUIDs;

    /**
       This list contains all the TDEABC::Addressee::uid() from the distribution 
       lists selected with the KWMailMergeTDEABCConfig dialog.
     */
    TQStringList _listUIDs;

    /**
       This list contains all the DistributionList::name() selected with the
       KWMailMergeTDEABCConfig dialog.
     */
    TQStringList _lists;


    /**
       Appends all TDEABC::Addressee::uid() of a distribution list to _listUIDs
       and updates the mail merge list.
       
       To be used by KWMailMergeTDEABCConfig::addList( const TQString &id )
       only.
       
       @param listName	The DistributionList::name() of the distribution list.
     */
    void parseList( const TQString& listName );

    /**
       Removes duplicate entries in the mail merge list. 
     */
    void makeUIDsExclusive();

};

#endif