TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.7KB

  1. /*
  2. This file is part of KAddressBook.
  3. Copyright (C) 2003 Tobias Koenig <tokoe@kde.org>
  4. based on the code of KSpread's CSV Import Dialog
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public License
  14. along with this library; see the file COPYING.LIB. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef CSV_IMPORT_DLG_H
  19. #define CSV_IMPORT_DLG_H
  20. #include <kabc/addressbook.h>
  21. #include <kabc/addresseelist.h>
  22. #include <kdialogbase.h>
  23. #include <tqvaluelist.h>
  24. class KURLRequester;
  25. class TQButtonGroup;
  26. class TQComboBox;
  27. class TQCheckBox;
  28. class TQLineEdit;
  29. class TQPushButton;
  30. class TQRadioButton;
  31. class TQTable;
  32. class CSVImportDialog : public KDialogBase
  33. {
  34. Q_OBJECT
  35. TQ_OBJECT
  36. public:
  37. CSVImportDialog( KABC::AddressBook *ab, TQWidget *parent,
  38. const char *name = 0 );
  39. ~CSVImportDialog();
  40. KABC::AddresseeList contacts() const;
  41. protected slots:
  42. virtual void slotOk();
  43. private slots:
  44. void returnPressed();
  45. void delimiterClicked( int id );
  46. void lineSelected( const TQString& line );
  47. void textquoteSelected( const TQString& mark );
  48. void textChanged ( const TQString & );
  49. void ignoreDuplicatesChanged( int );
  50. void setFile( const TQString& );
  51. void urlChanged( const TQString& );
  52. void codecChanged();
  53. void applyTemplate();
  54. void saveTemplate();
  55. private:
  56. enum { Undefined, FormattedName, FamilyName, GivenName, AdditionalName,
  57. Prefix, Suffix, NickName, Birthday,
  58. HomeAddressStreet, HomeAddressLocality, HomeAddressRegion,
  59. HomeAddressPostalCode, HomeAddressCountry, HomeAddressLabel,
  60. BusinessAddressStreet, BusinessAddressLocality, BusinessAddressRegion,
  61. BusinessAddressPostalCode, BusinessAddressCountry,
  62. BusinessAddressLabel,
  63. HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, CarPhone,
  64. Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL
  65. };
  66. TQTable* mTable;
  67. TQButtonGroup* mDelimiterBox;
  68. TQRadioButton* mRadioComma;
  69. TQRadioButton* mRadioSemicolon;
  70. TQRadioButton* mRadioTab;
  71. TQRadioButton* mRadioSpace;
  72. TQRadioButton* mRadioOther;
  73. TQLineEdit* mDelimiterEdit;
  74. TQLineEdit* mDatePatternEdit;
  75. TQComboBox* mComboLine;
  76. TQComboBox* mComboQuote;
  77. TQCheckBox* mIgnoreDuplicates;
  78. TQComboBox* mCodecCombo;
  79. TQWidget* mPage;
  80. KURLRequester* mUrlRequester;
  81. void initGUI();
  82. void fillTable();
  83. void clearTable();
  84. void fillComboBox();
  85. void setText( int row, int col, const TQString& text );
  86. void adjustRows( int rows );
  87. void resizeColumns();
  88. TQString getText( int row, int col );
  89. uint posToType( int pos ) const;
  90. int typeToPos( uint type ) const;
  91. void reloadCodecs();
  92. TQTextCodec *currentCodec();
  93. TQPtrList<TQTextCodec> mCodecs;
  94. bool mAdjustRows;
  95. int mStartLine;
  96. TQChar mTextQuote;
  97. TQString mDelimiter;
  98. TQByteArray mFileArray;
  99. TQMap<TQString, uint> mTypeMap;
  100. KABC::AddressBook *mAddressBook;
  101. int mCustomCounter;
  102. bool mClearTypeStore;
  103. TQValueList<int> mTypeStore;
  104. };
  105. #endif