kaddressbook

csvimportdialog.h

00001 /*
00002    This file is part of KAddressBook.
00003    Copyright (C) 2003 Tobias Koenig <tokoe@kde.org>
00004                  based on the code of KSpread's CSV Import Dialog
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
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
KDE Home | KDE Accessibility Home | Description of Access Keys