1 /*******************************************************************
2 
3 Part of the Fritzing project - http://fritzing.org
4 Copyright (c) 2007-2014 Fachhochschule Potsdam - http://fh-potsdam.de
5 
6 Fritzing is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 Fritzing is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with Fritzing.  If not, see <http://www.gnu.org/licenses/>.
18 
19 ********************************************************************
20 
21 $Revision: 6112 $:
22 $Author: cohen@irascible.com $:
23 $Date: 2012-06-28 00:18:10 +0200 (Do, 28. Jun 2012) $
24 
25 ********************************************************************/
26 
27 
28 #ifndef PINLABELDIALOG_H
29 #define PINLABELDIALOG_H
30 
31 #include <QDialog>
32 #include <QList>
33 #include <QFrame>
34 #include <QStringList>
35 #include <QGridLayout>
36 #include <QUndoStack>
37 #include <QUndoCommand>
38 #include <QLineEdit>
39 #include <QPushButton>
40 
41 class PinLabelDialog : public QDialog
42 {
43 	Q_OBJECT
44 
45 public:
46 	PinLabelDialog(const QStringList & labels, bool singleRow, const QString & chipLabel, bool isCore, QWidget *parent = 0);
47 	~PinLabelDialog();
48 
49 	const QStringList & labels();
50 	void setLabelText(int index, QLineEdit *, const QString & text);
51 	bool doSaveAs();
52 
53 protected slots:
54 	void labelChanged();
55 	void buttonClicked(QAbstractButton *);
56 	void undoChanged(bool);
57 	void labelEdited(const QString &) ;
58 
59 protected:
60 	QFrame * initLabels(const QStringList & labels, bool singleRow, const QString & chipLabel);
61 	void makeOnePinEntry(int index, const QString & label, Qt::Alignment alignment, int row, QGridLayout *);
62 	void keyPressEvent(QKeyEvent *e);
63 
64 protected:
65 	bool m_isCore;
66 	QStringList m_labels;
67 	QUndoStack m_undoStack;
68 	QPushButton * m_saveAsButton;
69 	QPushButton * m_undoButton;
70 	QPushButton * m_redoButton;
71 	bool m_doSaveAs;
72 
73 };
74 
75 class PinLabelUndoCommand : public QUndoCommand {
76 
77 public:
78 	PinLabelUndoCommand(PinLabelDialog *, int index, QLineEdit *, const QString & previous, const QString & next);
79 
80 	void undo();
81 	void redo();
82 
83 protected:
84 	QString m_previous;
85 	QString m_next;
86 	PinLabelDialog * m_pinLabelDialog;
87 	int m_index;
88 	QLineEdit * m_lineEdit;
89 
90 };
91 
92 #endif
93