libtdepim
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 <tqintdict.h>
00026 #include <tqstringlist.h>
00027 #include <tqspinbox.h>
00028 #include <tqptrvector.h>
00029 #include <tqvaluevector.h>
00030
00031 #include <kdialogbase.h>
00032
00033 class TQTable;
00034 class TQListView;
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 TQString &header, int count = 0);
00045 virtual ~KImportColumn() {}
00046
00047 TQString header() const { return m_header; }
00048
00049 TQValueList<int> formats();
00050 TQString formatName(int format);
00051 int defaultFormat();
00052
00053 TQString convert();
00054
00055 TQString preview(const TQString &value,int format);
00056
00057 void addColId(int i);
00058 void removeColId(int i);
00059
00060 TQValueList<int> colIdList();
00061
00062 protected:
00063
00064 private:
00065 int m_maxCount, m_refCount;
00066
00067 TQString m_header;
00068 TQValueList<int> mFormats;
00069 int mDefaultFormat;
00070
00071 TQValueList<int> mColIds;
00072
00073 KImportDialog *mDialog;
00074 };
00075
00076 class KImportDialog : public KDialogBase
00077 {
00078 Q_OBJECT
00079
00080 public:
00081 KImportDialog(TQWidget* parent);
00082
00083 public slots:
00084 bool setFile(const TQString& file);
00085
00086 TQString cell(uint row);
00087
00088 void addColumn(KImportColumn *);
00089
00090 protected:
00091 void readFile( int rows = 10 );
00092
00093 void fillTable();
00094 void registerColumns();
00095 int findFormat(int column);
00096
00097 virtual void convertRow() {}
00098
00099 protected slots:
00100 void separatorClicked(int id);
00101 void formatSelected(TQListViewItem* item);
00102 void headerSelected(TQListViewItem* item);
00103 void assignColumn(TQListViewItem *);
00104 void assignColumn();
00105 void assignTemplate();
00106 void removeColumn();
00107 void applyConverter();
00108 void tableSelected();
00109 void slotUrlChanged(const TQString & );
00110 void saveTemplate();
00111
00112 private:
00113 void updateFormatSelection(int column);
00114 void setCellText(int row, int col, const TQString& text);
00115
00116 void setData( uint row, uint col, const TQString &text );
00117 TQString data( uint row, uint col );
00118
00119 TQListView *mHeaderList;
00120 TQSpinBox *mStartRow;
00121 TQSpinBox *mEndRow;
00122 TQTable *mTable;
00123
00124 KComboBox *mFormatCombo;
00125 KComboBox *mSeparatorCombo;
00126
00127 TQString mSeparator;
00128 int mCurrentRow;
00129 TQString mFile;
00130 TQIntDict<KImportColumn> mColumnDict;
00131 TQIntDict<uint> mTemplateDict;
00132 TQMap<int,int> mFormats;
00133 TQPtrList<KImportColumn> mColumns;
00134 TQPtrVector<TQValueVector<TQString> > mData;
00135 };
00136
00137 #endif
|