summaryrefslogtreecommitdiffstats
path: root/kbarcode/labeleditor.h
blob: 9bd9b309509e09413132550647547ed4cb0cd8e5 (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
/***************************************************************************
                          labeleditor.h  -  description
                             -------------------
    begin                : Die Apr 23 2002
    copyright            : (C) 2002 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 LABELEDITOR_H
#define LABELEDITOR_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "sqltables.h"
#include "labelutils.h"
#include "definition.h"
#include "dsmainwindow.h"
#include "xmlutils.h"
#include "editoriface.h"

#include <kdialogbase.h>
#include <qdialog.h>
#include <qmap.h>

class BatchPrinter;
class KURL;
class KAction;
class KActionMenu;
class KActionSeparator;
class KToggleAction;
class KRecentFilesAction;
class KToolBarPopupAction;
class KListBox;
class KMenuBar;
class KPopupMenu;
class KRuler;
class KToolBar;
class KCommandHistory;
class MyCanvasText;
class MyCanvasRectangle;
class MyCanvasView;
class BarcodeItem;
class MyCanvas;
class QCanvasItemList;
class QCheckBox;
class KComboBox;
class QDockArea;
class QDockWindow;
class QGroupBox;
class QLabel;
class QImage;
class QHBoxLayout;
class QVBoxLayout;
class QPoint;
class QRect;
class QPaintDevice;
class QString;
class KPushButton;
class KPrinter;
class QCanvasItem;
class TCanvasItem;
class RectItem;
class LineItem;

class TokenProvider;
/** The LabelEditor is a graphical, easy to use label designer.
  * It provides all the function necessary to create colorful labels
  * and save them. Labels can also be printed directly, but without database
  * support. Use Batchprinting (LabelPrinter) for this.
  */
class LabelEditor : public DSMainWindow, public EditorIface, private LabelUtils, private XMLUtils {
    Q_OBJECT
    public:
        enum ELabelEditorMode {
            eCreateNewLabel,
            eLoadLabel
        };

        LabelEditor( QWidget *parent=0, QString _filename = QString::null,
            const char *name="labeleditor", WFlags f = WType_TopLevel | WDestructiveClose );
        ~LabelEditor();
        bool startupDlg( ELabelEditorMode mode, QString f = QString::null );

        /**
          * returns the filename of the currently loaded label.
          */
        const QString fileName() const;
        
    public slots:
        void print();
        void printBCP();
        void printImage();
        
    private:

	/** Creates a KCommandHistory object which will be 
	 *  pointed to by history.
	 *  Make sure to delete history by yourself when needed.
	 */
	void createCommandHistory();
	/** Create undo and redo actions and plug them into
	 *  menus and toolbars. They have to be regenerated
	 *  when ever createCommandHistory was called.
	 */
	void createCommandHistoryActions();

        QString getCustomerName( int mode = 0, QString text = "" );
        void clearLabel();
        //void setupBarcode( BarcodeItem* bcode );
        void insertText( QString caption );
        //NY35
        void insertTextLine( QString caption );
        //NY35
        void setupActions();
        void enableActions();
        bool isChanged();   // if the current document has been changed
        void batchPrint( BatchPrinter* batch, int copies, int mode );
        void setupContextMenu();
        
    private slots:
        void startEditor();
        bool open();
        bool openUrl( const QString & url );
        bool save();
        bool saveas();
        bool save( QString url );
        void save( QIODevice* device );
        bool newLabel();
        void insertBarcode();
        void insertPicture();
        void insertText();
        void insertDataText();
        //NY36
        void insertTextLine();
        //NY36
        void insertRect();
        void insertCircle();
        void insertLine();

        void changeDes();
        void changeSize();
        void updateInfo();
        void doubleClickedItem( TCanvasItem* item );
        void showContextMenu( QPoint pos );
        void doubleClickedCurrent();
        void spellCheck();
        void centerVertical();
        void centerHorizontal();
        void raiseCurrent();
        void lowerCurrent();
        void onTopCurrent();
        void backCurrent();
        void preview();
        void toggleGrid();
        void cut();
        void copy();
        void paste();
        void startBarcodeGen();
        void saveConfig();
        void loadConfig();
        void startLoadRecentEditor( const KURL& url );
        void startLoadEditor();
        void batchPrint();
        void closeLabel();
        void setEdited();
        void launchAddressBook();
        void lockItem();
        
    protected:
        void closeEvent( QCloseEvent* e );

        KCommandHistory* history;

        KAction* saveAct;
        KAction* saveAsAct;
        KAction* exportAct;
        KAction* descriptionAct;
        KAction* printAct;
        KAction* bcpAct;
        KAction* imgAct;
        KAction* changeSizeAct;
        KAction* deleteAct;
        KAction* editPropAct;
        KAction* barcodeAct;
        KAction* rectAct;
        KAction* circleAct;
        KAction* lineAct;
        KAction* pictureAct;
        KAction* previewAct;
        KAction* textAct;
        KAction* textDataAct;
        KAction* textLineAct;
        KAction* spellAct;
        KAction* cutAct;
        KAction* copyAct;
        KAction* pasteAct;
        KAction* undoAct;
        KAction* redoAct;
        KAction* closeLabelAct;
        KAction* addressBookAct;
        KAction* selectAllAct;
        KAction* deSelectAllAct;

	/**
	 * Undo/Redo actins get pluged into this menu
	 */
	KPopupMenu* editMenu;        
        KPopupMenu* exportMenu;        
        KPopupMenu* m_mnuContext;
        
        KToolBar* tools;
        
        KToggleAction* gridAct;
        
        KComboBox* comboScale;

        KRecentFilesAction* recentAct;
        KActionSeparator* sep;
        KToolBarPopupAction* listAct;
        MyCanvas* c;
        MyCanvasView* cv;

        Definition* d;
	TokenProvider* m_token;

        // Label info's:
        QString description;    // description
        QString filename;       // current file

        KListBox* listFields;
        KPushButton* buttonText;

        QVBoxLayout* pageLayout;

        QMap<QString,QString> fields;

        bool m_edited;
};

#endif