kword

KWMailMergeDataBase.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3
4 Modified by Joseph wenninger, 2001
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#ifndef mailmerge_h
23#define mailmerge_h
24
25#include <kdialogbase.h>
26#include <ktrader.h>
27
28
29#include <tqmap.h>
30#include <tqstring.h>
31#include <tqstringlist.h>
32#include <tqdom.h>
33#include <tqtextstream.h>
34
35#include "KWMailMergeDataSource.h"
36#include "KWordMailMergeDatabaseIface.h"
37#include <koffice_export.h>
38
39class TQListBox;
40class TQPushButton;
41class TQLineEdit;
42class TQSpinBox;
43class KWDocument;
44class TQVBox;
45
46//class KWMailMergeDataBase;
47
48
49
50
51/******************************************************************
52 *
53 * Class: KWMailMergeDataBase
54 *
55 ******************************************************************/
56
57class KWORD_EXPORT KWMailMergeDataBase: public TQObject,KWordMailMergeDatabaseIface
58{
59TQ_OBJECT
60
61
62public:
63 KWMailMergeDataBase( KWDocument *doc_ );
64 void showConfigDialog(TQWidget *); // Select datasource type and / or configure datasource
65
66 TQString getValue( const TQString &name, int record = -1 ) const; //accesses the plugin
67 bool isSampleRecord();
68
69 const TQMap< TQString, TQString > &getRecordEntries() const; //accesses the plugin
70 int getNumRecords() const; //accesses the plugin
71
72 TQDomElement save(TQDomDocument &doc) const; // save some global config + plugin config
73 void load( const TQDomElement& elem ); // save some global config + plugin config
74
75 KWMailMergeDataSource *loadPlugin(const TQString& name);
76 KWMailMergeDataSource *openPluginFor(int type,int &version);
77
78 virtual void refresh(bool force);
79 virtual TQStringList availablePlugins();
80 virtual bool loadPlugin(const TQString &name,const TQString &command);
81 virtual bool isConfigDialogShown();
82
83 int version();
84private:
85 int m_version;
86protected:
87 friend class KWMailMergeConfigDialog;
88 KWDocument *doc;
89 int action;
90 class KWMailMergeDataSource *plugin;
91 TQMap<TQString, TQString> emptyMap;
92 bool askUserForConfirmationAndConfig(KWMailMergeDataSource *tmpPlugin,bool config,TQWidget *par,int version);
93 bool rejectdcopcall;
94};
95
96
97class KWMailMergeChoosePluginDialog : public KDialogBase
98{
99 TQ_OBJECT
100
101
102 public:
103 KWMailMergeChoosePluginDialog( TDETrader::OfferList );
104 ~KWMailMergeChoosePluginDialog();
105
106 int currentPlugin() const;
107
108 private slots:
109 void pluginChanged( int pos );
110
111 private:
112 class TQComboBox *chooser;
113 class TQLabel *descriptionLabel;
114 TDETrader::OfferList pluginOffers;
115};
116
117class KWMailMergeConfigDialog : public KDialogBase
118{
119 TQ_OBJECT
120
121
122public:
123 KWMailMergeConfigDialog ( TQWidget *parent, KWMailMergeDataBase *db );
124 ~KWMailMergeConfigDialog();
125protected:
126 TQPushButton *edit;
127 TQPushButton *create;
128 TQPushButton *open;
129 TQPushButton *preview;
130 TQPushButton *document;
131 KWMailMergeDataBase *db_;
132 void enableDisableEdit();
133 void doNewActions();
134
135protected slots:
136 void slotEditClicked();
137 void slotCreateClicked();
138 void slotOpenClicked();
139 void slotPreviewClicked();
140 void slotDocumentClicked();
141};
142
143/******************************************************************
144 *
145 * Class: KWMailMergeVariableInsertDia
146 *
147 ******************************************************************/
148
149class KWMailMergeVariableInsertDia : public KDialogBase
150{
151 TQ_OBJECT
152
153
154 public:
155 KWMailMergeVariableInsertDia( TQWidget *parent, KWMailMergeDataBase *db );
156 TQString getName() const; // ### unused, can we remove this?
157
158 protected slots:
159 void slotSelectionChanged();
160
161 private:
162 KWMailMergeDataBase *m_db;
163
164 protected:
165 TQListBox *names;
166};
167
168#endif
DCOP interface for the MailMergeDataBase class.