kimportdialog.h
00001 #ifndef KIMPORTDIALOG_H
00002 #define KIMPORTDIALOG_H
00003
00004
00005 #include <qintdict.h>
00006 #include <qstringlist.h>
00007 #include <qspinbox.h>
00008 #include <qptrvector.h>
00009 #include <qvaluevector.h>
00010
00011 #include <kdialogbase.h>
00012
00013 class QTable;
00014 class QListView;
00015
00016 class KImportDialog;
00017 class KComboBox;
00018
00019 class KImportColumn
00020 {
00021 public:
00022 enum { FormatUndefined = 0, FormatPlain, FormatUnquoted, FormatBracketed, FormatLast };
00023
00024 KImportColumn(KImportDialog *dlg, const QString &header, int count = 0);
00025 virtual ~KImportColumn() {}
00026
00027 QString header() const { return m_header; }
00028
00029 QValueList<int> formats();
00030 QString formatName(int format);
00031 int defaultFormat();
00032
00033 QString convert();
00034
00035 QString preview(const QString &value,int format);
00036
00037 void addColId(int i);
00038 void removeColId(int i);
00039
00040 QValueList<int> colIdList();
00041
00042 protected:
00043
00044 private:
00045 int m_maxCount, m_refCount;
00046
00047 QString m_header;
00048 QValueList<int> mFormats;
00049 int mDefaultFormat;
00050
00051 QValueList<int> mColIds;
00052
00053 KImportDialog *mDialog;
00054 };
00055
00056 class KImportDialog : public KDialogBase
00057 {
00058 Q_OBJECT
00059 public:
00060 KImportDialog(QWidget* parent);
00061
00062 public slots:
00063 bool setFile(const QString& file);
00064
00065 QString cell(uint row);
00066
00067 void addColumn(KImportColumn *);
00068
00069 protected:
00070 void readFile( int rows = 10 );
00071
00072 void fillTable();
00073 void registerColumns();
00074 int findFormat(int column);
00075
00076 virtual void convertRow() {};
00077
00078 protected slots:
00079 void separatorClicked(int id);
00080 void formatSelected(QListViewItem* item);
00081 void headerSelected(QListViewItem* item);
00082 void assignColumn(QListViewItem *);
00083 void assignColumn();
00084 void assignTemplate();
00085 void removeColumn();
00086 void applyConverter();
00087 void tableSelected();
00088 void slotUrlChanged(const QString & );
00089 void saveTemplate();
00090
00091 private:
00092 void updateFormatSelection(int column);
00093 void setCellText(int row, int col, const QString& text);
00094
00095 void setData( uint row, uint col, const QString &text );
00096 QString data( uint row, uint col );
00097
00098 QListView *mHeaderList;
00099 QSpinBox *mStartRow;
00100 QSpinBox *mEndRow;
00101 QTable *mTable;
00102
00103 KComboBox *mFormatCombo;
00104 KComboBox *mSeparatorCombo;
00105
00106 QString mSeparator;
00107 int mCurrentRow;
00108 QString mFile;
00109 QIntDict<KImportColumn> mColumnDict;
00110 QIntDict<uint> mTemplateDict;
00111 QMap<int,int> mFormats;
00112 QPtrList<KImportColumn> mColumns;
00113 QPtrVector<QValueVector<QString> > mData;
00114 };
00115
00116 #endif
This file is part of the documentation for kdelibs Version 3.1.5.