00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CSV_IMPORT_DLG_H
00023 #define CSV_IMPORT_DLG_H
00024
00025 #include <kabc/addressbook.h>
00026 #include <kabc/addresseelist.h>
00027 #include <kdialogbase.h>
00028
00029 #include <qvaluelist.h>
00030
00031 class KURLRequester;
00032
00033 class QButtonGroup;
00034 class QComboBox;
00035 class QCheckBox;
00036 class QLineEdit;
00037 class QPushButton;
00038 class QRadioButton;
00039 class QTable;
00040
00041 class CSVImportDialog : public KDialogBase
00042 {
00043 Q_OBJECT
00044
00045 public:
00046 CSVImportDialog( KABC::AddressBook *ab, QWidget *parent,
00047 const char *name = 0 );
00048 ~CSVImportDialog();
00049
00050 KABC::AddresseeList contacts() const;
00051
00052 protected slots:
00053 virtual void slotOk();
00054
00055 private slots:
00056 void returnPressed();
00057 void delimiterClicked( int id );
00058 void lineSelected( const QString& line );
00059 void textquoteSelected( const QString& mark );
00060 void textChanged ( const QString & );
00061 void ignoreDuplicatesChanged( int );
00062 void setFile( const QString& );
00063 void urlChanged( const QString& );
00064 void codecChanged();
00065
00066 void applyTemplate();
00067 void saveTemplate();
00068
00069 private:
00070 enum { Undefined, FormattedName, FamilyName, GivenName, AdditionalName,
00071 Prefix, Suffix, NickName, Birthday,
00072 HomeAddressStreet, HomeAddressLocality, HomeAddressRegion,
00073 HomeAddressPostalCode, HomeAddressCountry, HomeAddressLabel,
00074 BusinessAddressStreet, BusinessAddressLocality, BusinessAddressRegion,
00075 BusinessAddressPostalCode, BusinessAddressCountry,
00076 BusinessAddressLabel,
00077 HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, CarPhone,
00078 Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL
00079 };
00080
00081 QTable* mTable;
00082 QButtonGroup* mDelimiterBox;
00083 QRadioButton* mRadioComma;
00084 QRadioButton* mRadioSemicolon;
00085 QRadioButton* mRadioTab;
00086 QRadioButton* mRadioSpace;
00087 QRadioButton* mRadioOther;
00088 QLineEdit* mDelimiterEdit;
00089 QLineEdit* mDatePatternEdit;
00090 QComboBox* mComboLine;
00091 QComboBox* mComboQuote;
00092 QCheckBox* mIgnoreDuplicates;
00093 QComboBox* mCodecCombo;
00094 QWidget* mPage;
00095 KURLRequester* mUrlRequester;
00096
00097 void initGUI();
00098 void fillTable();
00099 void clearTable();
00100 void fillComboBox();
00101 void setText( int row, int col, const QString& text );
00102 void adjustRows( int rows );
00103 void resizeColumns();
00104 QString getText( int row, int col );
00105 uint posToType( int pos ) const;
00106 int typeToPos( uint type ) const;
00107
00108 void reloadCodecs();
00109 QTextCodec *currentCodec();
00110 QPtrList<QTextCodec> mCodecs;
00111
00112 bool mAdjustRows;
00113 int mStartLine;
00114 QChar mTextQuote;
00115 QString mDelimiter;
00116 QByteArray mFileArray;
00117 QMap<QString, uint> mTypeMap;
00118 KABC::AddressBook *mAddressBook;
00119 int mCustomCounter;
00120 bool mClearTypeStore;
00121 QValueList<int> mTypeStore;
00122 };
00123
00124 #endif