summaryrefslogtreecommitdiffstats
path: root/kbarcode/csvimportdlg.h
blob: 1ad78578a73eea3f60c8bf0ad38384ce9a8f17c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/***************************************************************************
                          csvimportdlg.h  -  description
                             -------------------
    begin                : Don Aug 21 2003
    copyright            : (C) 2003 by Dominik Seichter
    email                : domseichter@web.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CSVIMPORTDLG_H
#define CSVIMPORTDLG_H

#include <tqwidget.h>
#include <kdialogbase.h>

class CSVFile;
class EncodingCombo;
class KComboBox;
class KIntNumInput;
class KLineEdit;
class KPushButton;
class KURLRequester;
class TQCheckBox;
class TQFrame;
class TQGroupBox;
class TQTable;
class TQRadioButton;

/** Import a CSV (comma separated value) file into
  * a SQL table. CSV files can be generated by almost
  * any spreadsheet application.
  * This dialog is also available as a separate application
  * KESI ( http://kesi.sf.net ).
  * This class makes importing data in KBarcode very easy
  * for the user.
  *
  * @author Dominik Seichter
  */
class CSVImportDlg : public KDialogBase  {
    TQ_OBJECT
  
    public: 
        CSVImportDlg(TQWidget *parent=0, const char *name=0);
        ~CSVImportDlg();

    private slots:
        void settingsChanged();
        void setCol();
        void updateFields();
        void updateCol( int c );
        void addWidth();
        void removeWidth();

        void enableControls();

    private:
        /**
         * Returns the current database name which can be 
         * user specified or internal to KBarcode.
         * It also enables the correct GUI items for 
         * a user specified or internal database.
         *
         * \returns the name of the current database table.
         */
        TQString getDatabaseName();

        /** Get the field with from listWidth
         *  as an integer list.
         */
        TQValueList<int> getFieldWidth();

        /** Create the first tab of the dialog 
         *  to set the import data.
         */
        void createPage1();

        /** Create the first tab of the dialog 
         *  to set the import settings.
         */
        void createPage2();

        /** Initialize a CSVFile with the settings
         *  from the GUI.
         */
        void initCsvFile( CSVFile* file );

    private:
        KComboBox* comboSQL;
        KComboBox* comboField;
        EncodingCombo* comboEncoding;
        KIntNumInput* spinCol;
        KPushButton* buttonSet;
        KURLRequester* requester;
        TQFrame* frame;
        TQTable* table;
        KLineEdit* databaseName;

        TQRadioButton* radioCSVFile;
        TQRadioButton* radioFixedFile;

        KLineEdit* comment;
        KLineEdit* quote;
        KLineEdit* separator;

        TQGroupBox* groupCSV;
        TQGroupBox* groupFixed;

        TDEListBox* listWidth;
        KPushButton* buttonAdd;
        KPushButton* buttonRemove;
        KIntNumInput* spinNumber;

        TQCheckBox* checkLoadAll;
        KIntNumInput* spinLoadOnly;

    protected slots:
        void accept();
};

#endif