libtdepim

kimportdialog.h
1 /*
2  This file is part of libtdepim.
3 
4  Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #ifndef KIMPORTDIALOG_H
23 #define KIMPORTDIALOG_H
24 
25 #include <tqintdict.h>
26 #include <tqstringlist.h>
27 #include <tqspinbox.h>
28 #include <tqptrvector.h>
29 #include <tqvaluevector.h>
30 
31 #include <kdialogbase.h>
32 
33 class TQTable;
34 class TQListView;
35 
36 class KImportDialog;
37 class KComboBox;
38 
39 class KImportColumn
40 {
41  public:
42  enum { FormatUndefined = 0, FormatPlain, FormatUnquoted, FormatBracketed, FormatLast };
43 
44  KImportColumn(KImportDialog *dlg, const TQString &header, int count = 0);
45  virtual ~KImportColumn() {}
46 
47  TQString header() const { return m_header; }
48 
49  TQValueList<int> formats();
50  TQString formatName(int format);
51  int defaultFormat();
52 
53  TQString convert();
54 // virtual void convert(const TQString &value,int format) = 0;
55  TQString preview(const TQString &value,int format);
56 
57  void addColId(int i);
58  void removeColId(int i);
59 
60  TQValueList<int> colIdList();
61 
62  protected:
63 
64  private:
65  int m_maxCount, m_refCount;
66 
67  TQString m_header;
68  TQValueList<int> mFormats;
69  int mDefaultFormat;
70 
71  TQValueList<int> mColIds;
72 
73  KImportDialog *mDialog;
74 };
75 
76 class KImportDialog : public KDialogBase
77 {
78  TQ_OBJECT
79 
80  public:
81  KImportDialog(TQWidget* parent);
82 
83  public slots:
84  bool setFile(const TQString& file);
85 
86  TQString cell(uint row);
87 
88  void addColumn(KImportColumn *);
89 
90  protected:
91  void readFile( int rows = 10 );
92 
93  void fillTable();
94  void registerColumns();
95  int findFormat(int column);
96 
97  virtual void convertRow() {}
98 
99  protected slots:
100  void separatorClicked(int id);
101  void formatSelected(TQListViewItem* item);
102  void headerSelected(TQListViewItem* item);
103  void assignColumn(TQListViewItem *);
104  void assignColumn();
105  void assignTemplate();
106  void removeColumn();
107  void applyConverter();
108  void tableSelected();
109  void slotUrlChanged(const TQString & );
110  void saveTemplate();
111 
112  private:
113  void updateFormatSelection(int column);
114  void setCellText(int row, int col, const TQString& text);
115 
116  void setData( uint row, uint col, const TQString &text );
117  TQString data( uint row, uint col );
118 
119  TQListView *mHeaderList;
120  TQSpinBox *mStartRow;
121  TQSpinBox *mEndRow;
122  TQTable *mTable;
123 
124  KComboBox *mFormatCombo;
125  KComboBox *mSeparatorCombo;
126 
127  TQString mSeparator;
128  int mCurrentRow;
129  TQString mFile;
130  TQIntDict<KImportColumn> mColumnDict;
131  TQIntDict<uint> mTemplateDict;
132  TQMap<int,int> mFormats;
133  TQPtrList<KImportColumn> mColumns;
134  TQPtrVector<TQValueVector<TQString> > mData;
135 };
136 
137 #endif