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: 6385 $:
22 $Author: cohen@irascible.com $:
23 $Date: 2012-09-08 21:21:20 +0200 (Sa, 08. Sep 2012) $
24 
25 ********************************************************************/
26 
27 #include "kicadmoduledialog.h"
28 #include "../debugdialog.h"
29 #include "../connectors/connectoritem.h"
30 #include "../sketch/pcbsketchwidget.h"
31 
32 #include <QDialogButtonBox>
33 #include <QVBoxLayout>
34 #include <QLabel>
35 #include <QPushButton>
36 #include <QFormLayout>
37 
38 /////////////////////////////////////////////////////////
39 
KicadModuleDialog(const QString & partType,const QString & filename,const QStringList & modules,QWidget * parent)40 KicadModuleDialog::KicadModuleDialog(const QString & partType, const QString & filename, const QStringList & modules, QWidget *parent) : QDialog(parent)
41 {
42 	this->setWindowTitle(QObject::tr("Select %1").arg(partType));
43 
44 	QVBoxLayout * vLayout = new QVBoxLayout(this);
45 
46 	QFrame * frame = new QFrame(this);
47 
48 	QFormLayout * formLayout = new QFormLayout();
49 
50 	m_comboBox = new QComboBox(this);
51 	m_comboBox->addItems(modules);
52 	formLayout->addRow(QString("%1:").arg(partType), m_comboBox );
53 
54 	frame->setLayout(formLayout);
55 
56 	QLabel * label = new QLabel(QString("There are %1 %3 descriptions in '%2'.  Please select one.").arg(modules.count()).arg(filename).arg(partType));
57 	vLayout->addWidget(label);
58 
59 	vLayout->addWidget(frame);
60 
61     QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
62 	buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
63 	buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK"));
64 
65     connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
66     connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
67 
68 	vLayout->addWidget(buttonBox);
69 
70 	this->setLayout(vLayout);
71 }
72 
~KicadModuleDialog()73 KicadModuleDialog::~KicadModuleDialog() {
74 }
75 
selectedModule()76 const QString KicadModuleDialog::selectedModule() {
77 	return m_comboBox->currentText();
78 }
79 
80