kword

KWClassicSerialDataSource.h

00001 /* This file is part of the KDE project
00002    Original file (KWMailMergeDataBase.h): Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef _SERIALLETTER_CLASSIC_PLUGIN_H_
00022 #define _SERIALLETTER_CLASSIC_PLUGIN_H_
00023 
00024 #include <qdom.h>
00025 #include <qlistview.h>
00026 #include <kdialogbase.h>
00027 #include <KoCustomVariablesDia.h>
00028 #include "KWMailMergeDataSource.h"
00029 #include <qspinbox.h>
00030 
00031 class QHBox;
00032 class QVBox;
00033 class QPushButton;
00034 class QListBox;
00035 class QLabel;
00036 class QLineEdit;
00037 class QToolButton;
00038 
00039 /******************************************************************
00040  *
00041  * Class: KWClassicSerialDataSource
00042  *
00043  ******************************************************************/
00044 typedef QValueList< DbRecord > Db;
00045 
00046 class KWClassicSerialDataSource: public KWMailMergeDataSource
00047 {
00048     Q_OBJECT
00049     public:
00050     KWClassicSerialDataSource(KInstance *inst,QObject *parent);
00051     ~KWClassicSerialDataSource();
00052 
00053     virtual void save( QDomDocument &doc,QDomElement&);
00054     virtual void load( QDomElement& elem );
00055     virtual class QString getValue( const class QString &name, int record = -1 ) const;
00056     virtual int getNumRecords() const {
00057         return (int)db.count();
00058     }
00059     virtual  bool showConfigDialog(QWidget *,int);
00060     virtual void refresh(bool){};
00061 
00062     protected:
00063     friend class KWClassicMailMergeEditor;
00064     friend class KWClassicMailMergeEditorList;
00065 
00066     void setValue( const QString &name, const QString &value, int record = -1 );
00067     void appendRecord();
00068     void addEntry( const QString &name );
00069     void removeEntry( const QString &name );
00070     void removeRecord( int i );
00071     Db db;
00072 };
00073 
00074 /******************************************************************
00075  *
00076  * Class: KWClassicMailMergeEditorListItem
00077  *
00078  ******************************************************************/
00079 
00080 class KWClassicMailMergeEditorListItem : public QListViewItem
00081 {
00082 public:
00083     KWClassicMailMergeEditorListItem( QListView *parent );
00084     KWClassicMailMergeEditorListItem( QListView *parent, QListViewItem *after );
00085     virtual ~KWClassicMailMergeEditorListItem();
00086 
00087     virtual void setText( int i, const QString &text );
00088     virtual QString text( int i ) const;
00089     void setup();
00090     void update();
00091 
00092 protected:
00093     QLineEdit *editWidget;
00094 
00095 };
00096 
00097 /******************************************************************
00098  *
00099  * Class: KWClassicMailMergeEditorList
00100  *
00101  ******************************************************************/
00102 
00103 class KWClassicMailMergeEditorList : public QListView
00104 {
00105     Q_OBJECT
00106 
00107 public:
00108     KWClassicMailMergeEditorList( QWidget *parent, KWClassicSerialDataSource *db_ );
00109     virtual ~KWClassicMailMergeEditorList();
00110 
00111     void invalidateCurrentRecord();
00112     void updateItems();
00113     void displayRecord( int i );
00114 
00115     void setSorting( int, bool increasing = TRUE ) {
00116         QListView::setSorting( -1, increasing );
00117     }
00118 
00119 protected slots:
00120     void columnSizeChange( int c, int os, int ns );
00121     void sectionClicked( int c );
00122 
00123 protected:
00124     KWClassicSerialDataSource *db;
00125     int currentRecord;
00126 
00127 };
00128 
00129 /******************************************************************
00130  *
00131  * Class: KWClassicMailMergeEditor
00132  *
00133  ******************************************************************/
00134 
00135 class KWClassicMailMergeEditor : public KDialogBase
00136 {
00137     Q_OBJECT
00138 
00139 public:
00140     KWClassicMailMergeEditor( QWidget *parent, KWClassicSerialDataSource *db_ );
00141 
00142 protected:
00143     void resizeEvent( QResizeEvent *e );
00144     void updateButton();
00145 
00146     QSpinBox *records;
00147     KWClassicMailMergeEditorList *dbList;
00148     QWidget *back;
00149     KWClassicSerialDataSource *db;
00150 
00151     QToolButton *first;
00152     QToolButton *back_;
00153     QToolButton *forward;
00154     QToolButton *finish;
00155     QToolButton *newRecord;
00156     QToolButton *newEntry;
00157     QToolButton *deleteRecord;
00158     QToolButton *deleteEntry;
00159 
00160 protected slots:
00161     void changeRecord( int i );
00162     void addEntry();
00163     void addRecord();
00164     void removeEntry();
00165     void removeRecord();
00166     void firstRecord();
00167     void prevRecord();
00168     void nextRecord();
00169     void lastRecord();
00170 };
00171 
00172 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys