libkdepim

kimportdialog.h

00001 /*
00002     This file is part of libkdepim.
00003 
00004     Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 #ifndef KIMPORTDIALOG_H
00023 #define KIMPORTDIALOG_H
00024 
00025 #include <qintdict.h>
00026 #include <qstringlist.h>
00027 #include <qspinbox.h>
00028 #include <qptrvector.h>
00029 #include <qvaluevector.h>
00030 
00031 #include <kdialogbase.h>
00032 
00033 class QTable;
00034 class QListView;
00035 
00036 class KImportDialog;
00037 class KComboBox;
00038 
00039 class KImportColumn
00040 {
00041   public:
00042     enum { FormatUndefined = 0, FormatPlain, FormatUnquoted, FormatBracketed, FormatLast };
00043 
00044     KImportColumn(KImportDialog *dlg, const QString &header, int count = 0);
00045     virtual ~KImportColumn() {}
00046 
00047     QString header() const { return m_header; }
00048 
00049     QValueList<int> formats();
00050     QString formatName(int format);
00051     int defaultFormat();
00052 
00053     QString convert();
00054 //    virtual void convert(const QString &value,int format) = 0;
00055     QString preview(const QString &value,int format);
00056 
00057     void addColId(int i);
00058     void removeColId(int i);
00059 
00060     QValueList<int> colIdList();
00061 
00062   protected:
00063 
00064   private:
00065     int m_maxCount, m_refCount;
00066 
00067     QString m_header;
00068     QValueList<int> mFormats;
00069     int mDefaultFormat;
00070     
00071     QValueList<int> mColIds;
00072     
00073     KImportDialog *mDialog;
00074 };
00075 
00076 class KImportDialog : public KDialogBase
00077 {
00078     Q_OBJECT
00079   public:
00080     KImportDialog(QWidget* parent);
00081 
00082   public slots:
00083     bool setFile(const QString& file);
00084 
00085     QString cell(uint row);
00086 
00087     void addColumn(KImportColumn *);
00088 
00089   protected:
00090     void readFile( int rows = 10 );
00091   
00092     void fillTable();
00093     void registerColumns();
00094     int findFormat(int column);
00095 
00096     virtual void convertRow() {};
00097 
00098   protected slots:
00099     void separatorClicked(int id);
00100     void formatSelected(QListViewItem* item);
00101     void headerSelected(QListViewItem* item);
00102     void assignColumn(QListViewItem *);
00103     void assignColumn();
00104     void assignTemplate();
00105     void removeColumn();
00106     void applyConverter();
00107     void tableSelected();
00108     void slotUrlChanged(const QString & );
00109     void saveTemplate();
00110 
00111   private:
00112     void updateFormatSelection(int column);
00113     void setCellText(int row, int col, const QString& text);
00114 
00115     void setData( uint row, uint col, const QString &text );
00116     QString data( uint row, uint col );
00117 
00118     QListView *mHeaderList;
00119     QSpinBox *mStartRow;
00120     QSpinBox *mEndRow;
00121     QTable *mTable;
00122 
00123     KComboBox *mFormatCombo;
00124     KComboBox *mSeparatorCombo;
00125 
00126     QString mSeparator;
00127     int mCurrentRow;
00128     QString mFile;
00129     QIntDict<KImportColumn> mColumnDict;
00130     QIntDict<uint> mTemplateDict;
00131     QMap<int,int> mFormats;
00132     QPtrList<KImportColumn> mColumns;
00133     QPtrVector<QValueVector<QString> > mData;
00134 };
00135 
00136 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys