summaryrefslogtreecommitdiffstats
path: root/kbarcode/batchwizard.h
blob: e736a6f87694f9dcb8725ce1923cd6ec3a487d3e (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/***************************************************************************
                          batchwizard.h  -  description
                             -------------------
    begin                : Sun Mar 20 2005
    copyright            : (C) 2005 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 BATCHWIZARD_H
#define BATCHWIZARD_H

#include <kwizard.h>
#include "batchiface.h"

class BatchPrinter;
class EncodingCombo;
class KComboBox;
class KCompletion;
class KIntNumInput;
class KLineEdit;
class KListBox;
class KListView;
class KPushButton;
class KURLRequester;
class QCheckBox;
class QHBox;
class QLabel;
class QListView;
class QListViewItem;
class QRadioButton;
class QTable;
class QVBox;
class QWidgetStack;

class BatchWizard : public KWizard, public BatchIface {
    Q_OBJECT
    public:
        BatchWizard( QWidget* parent = NULL, const char* name = NULL );
        ~BatchWizard();

    	/** reimplemented DCOP method from BatchIface 
	 *  Allow the user to add an article to print to KBarcode
	 *  @p article article number to add
	 *  @p group   use group as group name for this article
	 *  @p count   number of labels to print for this article
	 *  @p msgbox  show a messagebox if adding the item fails
	 */
        bool addItem( const QString & article, const QString & group, int count, bool msgbox = true );

    	/** reimplemented DCOP method from BatchIface 
	 *  tests wether the arctile is existing in KBarcodes database
	 *  @p article article number to test for
	 */
	virtual bool existsArticle( const QString & article );

	/** reimplemented DCOP method from BatchIface 
	 *  import articles from a file. The user is asked for the filename
	 */
	virtual void loadFromFile( const QString & url );

	/** reimplemented DCOP method from BatchIface 
	 *  print immediately with current settings
	 *  @p printer  print to this printer (must be known to the system)
         *  @p bUserInteraction if false no dialog will pop up besides the printer dialog
	 */
	virtual void printNow( const QString & printer, bool bUserInteraction = true );

    	/** reimplemented DCOP method from BatchIface 
	 *  to allow the user to set the label to be used
	 *  @p url  path of the label which shall get printed
	 */
	virtual void setFilename( const QString & url );

	/** reimplemented DCOP method from BatchIface 
	 *  Set the batchwizards mode to print from imported data
	 *  and import the data from the csv file @p filname
	 *  @p filename csv file to import
	 */
	virtual void setImportCsvFile( const QString & filename );

	/** reimplemented DCOP method from BatchIface 
	 *  Set the batchwizards mode to print from imported data
	 *  and import the data from the sql query @p query
	 *  @p query sql query to execute to get on user defined variables
	 */
	virtual void setImportSqlQuery( const QString & query );

	/** reimplemented DCOP method from BatchIface 
	 *  set the numbers of labels to print.
	 *  the option to print without data import is activated too using
	 *  this option
	 *  @p n number of labels to print
	 */
	virtual void setNumLabels( const int n );

	/** reimplemented DCOP method from BatchIface 
	 *  sets wether the user wants to print to a postscript printer,
	 *  a barcode printer or to image files.
	 *  @p e is of datatype BatchPrinter::EOutputFormat
	 */
	virtual void setOutputFormat( const int e );

	/** reimplemented DCOP method from BatchIface 
	 *  allow the user to set the value and start value for
	 *  the serial number that can be used on labels using the [serial] token
	 *  @p val  value of the serial number (e.g. TEST0002)
	 *  @p inc  the serial number is increased that much for every label
	 */
	virtual void setSerialNumber( const QString & val, int inc );

	public slots:
	/** reimplemented DCOP method from BatchIface 
	 *  import articles from the clipboard
	 */
	virtual void loadFromClipboard();


    private slots:
	void addAllItems();
	void enableControls();
        void customerIdChanged( int index );
	void customerNameChanged( int index );
	void addItem();
        bool slotAddItem( const QString & article, const QString & group, int count );
	void changeItem( QListViewItem* item, const QPoint &, int );
	void editItem();
	void removeItem();

	void slotTableInsert();
	void slotTableRemove();
        void loadFromFile();

        void slotAddAddress();
        void slotAddAllAddress();
        void slotRemoveAddress();
        void slotRemoveAllAddress();

    private:
        void moveAddress( QListView* src, QListView* dst, bool bAll = false );

	void fillByteArray();
	void fillVarList();
	bool fillVarTable();
        void fillAddressList();

        void setupPage1();
        void setupPage2();
	void setupPage3();
	void setupPage4();
	void setupPage5();
	void setupPage10();

	void setupStackPage1();
	void setupStackPage2();
	void setupStackPage3();
	void setupStackPage4();

	void setupSql();
	void setupBatchPrinter( BatchPrinter* batch, int m );

	void addGroupCompletion( const QString & group );
	void loadData( const QString & data );

    protected:
	void accept();
	void showPage( QWidget* w );

    private:
	/** m_bytearray_filename is set whenever
	 *  the kbarcide label file has been read into 
	 *  the buffer m_bytearray. Therefore we have only
	 *  to re-read the bytearray when the filename was 
	 *  changed by the user.
	 */
	QString m_bytearray_filename;
	QByteArray m_bytearray;

	QWidget* page1;
	QWidget* page2;
	QWidgetStack* page3;
	QVBox* page4;
	QVBox* page5;
	QWidget* page10;

	QVBox* stack1;
	QHBox* stack2;
	QVBox* stack3;
        QWidget* stack4;

	QVBox* imageBox;

	QLabel* labelInfo;
	QLabel* labelSqlQuery;
	QLabel* labelCsvFile;
        QLabel* labelEncoding;

	QRadioButton* radioSqlArticles;
	QRadioButton* radioVarImport;
	QRadioButton* radioSimple;
	QRadioButton* radioAddressBook;

	QRadioButton* radioPrinter;
	QRadioButton* radioImage;
	QRadioButton* radioBarcode;

	QRadioButton* radioImportSql;
	QRadioButton* radioImportCSV;
	QRadioButton* radioImportManual;

	QRadioButton* radioImageFilenameArticle;
	QRadioButton* radioImageFilenameBarcode;
	QRadioButton* radioImageFilenameCustom;
	KLineEdit* editImageFilename;
	KURLRequester* imageDirPath;

	KLineEdit* importSqlQuery;
	KURLRequester* importCsvFile;

	KComboBox* customerName;
	KComboBox* customerId;
	KComboBox* comboFormat;
        EncodingCombo* comboEncoding;

	KCompletion* compGroup;

	KIntNumInput* serialInc;
	KIntNumInput* numLabels;

	QTable* m_varTable;
	KListBox* m_varList;

        KListView* listAddress;
        KListView* listSelectedAddress;

	KListView* sqlList;
	KLineEdit* serialStart;

        QCheckBox* checkKeepOpen;

        KPushButton* buttonAddAddress;
        KPushButton* buttonRemoveAddress;
        KPushButton* buttonAddAllAddress;
        KPushButton* buttonRemoveAllAddress;

        KPushButton* buttonAdd;
	KPushButton* buttonImport;
        KPushButton* buttonEdit;
        KPushButton* buttonRemove;
        KPushButton* buttonRemoveAll;

	KPushButton* buttonTableInsert;
	KPushButton* buttonTableRemove;

	KURLRequester* m_url;
};

#endif // BATCHWIZARD_H