KWClassicSerialDataSource.h
1/* This file is part of the KDE project
2 Original file (KWMailMergeDataBase.h): Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2001 Joseph Wenninger <jowenn@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 _SERIALLETTER_CLASSIC_PLUGIN_H_
22#define _SERIALLETTER_CLASSIC_PLUGIN_H_
23
24#include <tqdom.h>
25#include <tqlistview.h>
26#include <kdialogbase.h>
27#include <KoCustomVariablesDia.h>
28#include "KWMailMergeDataSource.h"
29#include <tqspinbox.h>
30
31class TQHBox;
32class TQVBox;
33class TQPushButton;
34class TQListBox;
35class TQLabel;
36class TQLineEdit;
37class TQToolButton;
38
39/******************************************************************
40 *
41 * Class: KWClassicSerialDataSource
42 *
43 ******************************************************************/
44typedef TQValueList< DbRecord > Db;
45
46class KWClassicSerialDataSource: public KWMailMergeDataSource
47{
48 TQ_OBJECT
49
50 public:
51 KWClassicSerialDataSource(TDEInstance *inst,TQObject *parent);
52 ~KWClassicSerialDataSource();
53
54 virtual void save( TQDomDocument &doc,TQDomElement&);
55 virtual void load( TQDomElement& elem );
56 virtual class TQString getValue( const class TQString &name, int record = -1 ) const;
57 virtual int getNumRecords() const {
58 return (int)db.count();
59 }
60 virtual bool showConfigDialog(TQWidget *,int);
61 virtual void refresh(bool){};
62
63 protected:
64 friend class KWClassicMailMergeEditor;
65 friend class KWClassicMailMergeEditorList;
66
67 void setValue( const TQString &name, const TQString &value, int record = -1 );
68 void appendRecord();
69 void addEntry( const TQString &name );
70 void removeEntry( const TQString &name );
71 void removeRecord( int i );
72 Db db;
73};
74
75/******************************************************************
76 *
77 * Class: KWClassicMailMergeEditorListItem
78 *
79 ******************************************************************/
80
81class KWClassicMailMergeEditorListItem : public TQListViewItem
82{
83public:
84 KWClassicMailMergeEditorListItem( TQListView *parent );
85 KWClassicMailMergeEditorListItem( TQListView *parent, TQListViewItem *after );
86 virtual ~KWClassicMailMergeEditorListItem();
87
88 virtual void setText( int i, const TQString &text );
89 virtual TQString text( int i ) const;
90 void setup();
91 void update();
92
93protected:
94 TQLineEdit *editWidget;
95
96};
97
98/******************************************************************
99 *
100 * Class: KWClassicMailMergeEditorList
101 *
102 ******************************************************************/
103
104class KWClassicMailMergeEditorList : public TQListView
105{
106 TQ_OBJECT
107
108
109public:
110 KWClassicMailMergeEditorList( TQWidget *parent, KWClassicSerialDataSource *db_ );
111 virtual ~KWClassicMailMergeEditorList();
112
113 void invalidateCurrentRecord();
114 void updateItems();
115 void displayRecord( int i );
116
117 void setSorting( int, bool increasing = true ) {
118 TQListView::setSorting( -1, increasing );
119 }
120
121protected slots:
122 void columnSizeChange( int c, int os, int ns );
123 void sectionClicked( int c );
124
125protected:
126 KWClassicSerialDataSource *db;
127 int currentRecord;
128
129};
130
131/******************************************************************
132 *
133 * Class: KWClassicMailMergeEditor
134 *
135 ******************************************************************/
136
137class KWClassicMailMergeEditor : public KDialogBase
138{
139 TQ_OBJECT
140
141
142public:
143 KWClassicMailMergeEditor( TQWidget *parent, KWClassicSerialDataSource *db_ );
144
145protected:
146 void resizeEvent( TQResizeEvent *e );
147 void updateButton();
148
149 TQSpinBox *records;
150 KWClassicMailMergeEditorList *dbList;
151 TQWidget *back;
152 KWClassicSerialDataSource *db;
153
154 TQToolButton *first;
155 TQToolButton *back_;
156 TQToolButton *forward;
157 TQToolButton *finish;
158 TQToolButton *newRecord;
159 TQToolButton *newEntry;
160 TQToolButton *deleteRecord;
161 TQToolButton *deleteEntry;
162
163protected slots:
164 void changeRecord( int i );
165 void addEntry();
166 void addRecord();
167 void removeEntry();
168 void removeRecord();
169 void firstRecord();
170 void prevRecord();
171 void nextRecord();
172 void lastRecord();
173};
174
175#endif