libkdepim
kimportdialog.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
|