summaryrefslogtreecommitdiffstats
path: root/kword/mailmerge/kabc/KWMailMergeTDEABCConfig.h
blob: 1a23b44cae31c34e3ab980525ceb160c2b803d04 (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
/*
   This file is part of the KDE project
   Copyright (C) 2004 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_CONFIG_H_
#define _KWMAILMERGE_KABC_CONFIG_H_

#include <kdialogbase.h>
#include <tdelistview.h>
#include <tdeabc/stdaddressbook.h>

#include "KWMailMergeTDEABC.h"


class AddressPickerUI;
class KWMailMergeTDEABC;

class KWMailMergeTDEABCConfig: public KDialogBase
{
    Q_OBJECT
  
public:
    KWMailMergeTDEABCConfig( TQWidget *parent, KWMailMergeTDEABC *db_ );
    virtual ~KWMailMergeTDEABCConfig();


private slots:

    /**
       Moves selected items from the left Listview to the right one.
     */
    void addSelectedContacts();

    /**
       Moves selected items from the right Listview to the left one.
     */
    void removeSelectedContacts();

    /**
       Executes KAddressbook as external application.
     */
    void launchAddressbook() const;

    /**
       Updates the parent's mail merge list from items in the right Listview.
     */
    void acceptSelection();

    /**
       Hides items in the left listview, which are not matching  @p txt.
     */
    void filterChanged( const TQString& txt );

    /**
       Saves the selected single entries to a new TDEABC::DistributionList in KAddressbook.
     */
    void saveDistributionList();
private:
    /**
       The addresspicker widget.
     */
    AddressPickerUI *_ui;

    /**
       Store all categories used in the addressbook, to avoid some iterator cycles.
     */
    TQStringList _usedCategories;

    /**
       The mail merge list.
    */
    KWMailMergeTDEABC *_db;

    /**
       Removes duplicates in the left TQListView, when moving an item to the right.
     */
    void destroyAvailableClones( const TQString& uid );

    /**
       Appends the previously selected entries to the right TQListView.
     */
    void initSelectedAddressees();

    /**
      Appends the previously selected distribution lists to the right TQListView.
    */
    void initSelectedLists();

    /**
       Just connects signals and slots.
     */
    void initSlotSignalConnections();

    /**
       Moves @p item from the right Listview to the left one.
       
       Called by KWMailMergeTDEABCConfig::removeSelectedContacts().
     */
    void removeContact( TQListViewItem* item );

    /**
       Appends all KAddressbook entries in TDEABC::StdAddressBook::self() and all
       TDEABC::DistributionLists to the left TQListView.
    */
    void updateAvailable();
};


class KWMailMergeTDEABCConfigListItem : public TQListViewItem
{

public:
    KWMailMergeTDEABCConfigListItem( TQListView *parent, const TDEABC::Addressee& addressEntry );
    KWMailMergeTDEABCConfigListItem( TQListViewItem *parent, const TDEABC::Addressee& addressEntry );
    virtual ~KWMailMergeTDEABCConfigListItem();

    /**
       Returns the TDEABC::Addressee of a KWMailMergeTDEABCConfigListItem.
     */
    TDEABC::Addressee addressee() const;

    /**
       This is an overloaded member function of TQListViewItem::text( int column ).
       It Returns the TDEABC::Addressee::uid(), if column is set to -1.
       Otherwise TQListViewItem::text( int column ) is returned.
     */
    TQString text( int column ) const;


private:
    TDEABC::Addressee _addressEntry;

};
#endif