summaryrefslogtreecommitdiffstats
path: root/src/kjtagdialog.cpp
blob: ba05c129d5123f715a354eb351520e2aafa95476 (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
/***************************************************************************
 *   Copyright (C) 2005 by Mark Six                                        *
 *   marksix@xs4all.nl                                                     *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/
#include "kjtagdialog.h"
#include <tqmessagebox.h>
#include <tdefiledialog.h>
#include <kiconloader.h>

KJTAGDialog::KJTAGDialog( TQWidget *parent )
 : TQDialog( parent )
{

	setFixedSize( 330, 300 ) ;
	m_groupConfigure = new TQGroupBox( "Configure", this ) ;
	m_groupConfigure->setFixedSize( 310, 45 ) ;
	m_groupConfigure->move( 10, 10 ) ;

	m_selectFileBtn  = new TQPushButton( m_groupConfigure ) ;
	m_selectFileBtn->setFixedSize( 30, 25 ) ;
	m_selectFileBtn->move( 205, 15 ) ;
	m_selectFileBtn->setPixmap( TDEGlobal::iconLoader()->loadIcon( "document-open", TDEIcon::Small ) ) ;
	connect( m_selectFileBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( selectFileName() ) ) ;

	m_configureBtn = new TQPushButton( "Configure", m_groupConfigure ) ;
	m_configureBtn->setFixedSize( 60, 25 ) ;
	m_configureBtn->move( 240, 15 ) ;

	connect( m_configureBtn, TQ_SIGNAL( clicked() ), this, TQ_SLOT( configure() ) ) ;
	
	m_bitFileLabel = new TQLabel( "Bit file", m_groupConfigure ) ;
	m_bitFileLabel->setFixedSize( 50, 25 ) ;
	m_bitFileLabel->move( 10, 15 ) ;
	
	m_bitFileEdit = new KLineEdit( m_groupConfigure ) ;
	m_bitFileEdit->setFixedSize( 150, 25 ) ;
	m_bitFileEdit->move( 50, 15 ) ;

	m_progress = new KProgress( this ) ;
	m_progress->setFixedSize( width(), 20 ) ;	
	m_progress->move( 0, 280 ) ;
	m_progress->setTotalSteps( 100 ) ;

	m_debug = new KTextEdit( this ) ;
	m_debug->setFixedSize( 310, 200 ) ;
	m_debug->move( 10, 60 ) ;
	
	m_programmer = new JTAGProgrammer( this ) ;
	connect( m_programmer, TQ_SIGNAL( progress(int) ), this, TQ_SLOT( progress(int) ) ) ;
	connect( m_programmer, TQ_SIGNAL( message(const char*) ), this, TQ_SLOT( addMessage(const char*) ) ) ;

	m_debug->insert( "This option is still very experimental!!\n"
                     "The code is tested with the Spartan-3 Development Board.\n"
					 "Assuming the following setup:\n"
                     " TDI--->[XC3SXXX]--->[XCF]--->TDO\n"
                     "========================================================\n" ) ;
}

KJTAGDialog::~KJTAGDialog()
{
	delete m_programmer ;
}

void KJTAGDialog::configure()
{
	m_debug->clear() ;
	m_programmer->setBitFile( m_bitFileEdit->text().ascii() ) ;
	m_programmer->program() ;
	m_progress->setProgress( 0 ) ;
}

void KJTAGDialog::progress( int percent )
{
	m_progress->setProgress( percent ) ;
}

void KJTAGDialog::setFilename( TQString filename )
{
	m_bitFileEdit->setText( filename ) ;
}

TQString KJTAGDialog::getFilename()
{
	return m_bitFileEdit->text() ;
}

void KJTAGDialog::selectFileName()
{
	TQString filename = KFileDialog::getOpenFileName( TQString(), 
                                                    "*.bit|bit files\n*|All files", 
		   										     this,
  												     "Select configuration file" ) ;
	if ( filename != "" )	
		m_bitFileEdit->setText( filename ) ;
}

void KJTAGDialog::addMessage( const char *msg )
{
	m_debug->insert( msg ) ;
}

#include "kjtagdialog.moc"