OpenCores
URL https://opencores.org/ocsvn/ezidebug/ezidebug/trunk

Subversion Repositories ezidebug

[/] [ezidebug/] [trunk/] [EziDebug_src/] [projectsetwizard.cpp] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 EziDebug
#include "projectsetwizard.h"
2
#include "toolwindow.h"
3
#include "ezidebugscanchain.h"
4
#include <QDebug>
5
#include <QtGui>
6
 
7
ProjectSetWizard::ProjectSetWizard(QWidget *parent):QWizard(parent)
8
{
9
    QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
10
 
11
    createPage1();
12
    createPage2();
13
    createConclusionPage();
14
 
15
    addPage(m_iprjSetPage);
16
    addPage(m_iregSetPage);
17
    addPage(m_itoolSetPage);
18
 
19
    setWindowTitle(tr("工程设置向导"));
20
 
21
    connect(this,SIGNAL(currentIdChanged(int)),this,SLOT(saveModifiedPage(int)));
22
}
23
 
24
ProjectSetWizard::~ProjectSetWizard()
25
{
26
 
27
}
28
 
29
void ProjectSetWizard::done (int result)
30
{
31
   // ToolWindow* pparent = 0 ;
32
 
33
    /*保存使用工具*/
34
    if(!(alteraCheckBox->isChecked()||xilinxCheckBox->isChecked()))
35
    {
36
        qDebug() << "No Tool Selected!";
37
        m_ecurrentTool = EziDebugPrj::ToolQuartus ;
38
    }
39
    else if(alteraCheckBox->isChecked()&&xilinxCheckBox->isChecked())
40
    {
41
        qDebug() << "Wrong Tool selected!";
42
        m_ecurrentTool = EziDebugPrj::ToolQuartus ;
43
    }
44
    else if(alteraCheckBox->isChecked())
45
    {
46
        m_ecurrentTool = EziDebugPrj::ToolQuartus ;
47
    }
48
    else if(xilinxCheckBox->isChecked())
49
    {
50
        m_ecurrentTool = EziDebugPrj::ToolIse ;
51
    }
52
 
53
    if(m_ixilinxComplieOption->checkState() == Qt::Checked)
54
    {
55
        m_isXilinxErrChecked = true ;
56
    }
57
    else
58
    {
59
        m_isXilinxErrChecked = false ;
60
    }
61
    QWizard::done(result);
62
 
63
}
64
 
65
 
66
void ProjectSetWizard::saveModifiedPage(int m)
67
{
68
    m = m ;
69
    if(m_iprjSetPage == m_currentPage)
70
    {
71
        /*保存路径信息*/
72
        m_icurrentDir = QDir::fromNativeSeparators(proPathComboBox->itemText(proPathComboBox->currentIndex()));
73
        qDebug() << m_icurrentDir << __LINE__;
74
 
75
    }
76
    else if(m_iregSetPage == m_currentPage)
77
    {
78
        /*保存寄存器最大个数信息*/
79
        m_uncurrentRegNum = m_nregNumComBox->currentText().toInt() ;
80
    }
81
    else if(m_itoolSetPage == m_currentPage)
82
    {
83
        /*保存使用工具*/
84
        /*不会进入这个条件*/
85
    }
86
    else
87
    {
88
        /*空指针*/
89
    }
90
 
91
    m_currentPage = this->currentPage() ;
92
}
93
 
94
void ProjectSetWizard::changeXilinxCompileOption(bool checked)
95
{
96
    if(checked)
97
    {
98
        m_ixilinxComplieOption->setCheckable(true);
99
    }
100
    else
101
    {
102
        m_ixilinxComplieOption->setCheckable(false);
103
    }
104
}
105
 
106
void ProjectSetWizard::browse()
107
{
108
//    QString directory = QFileDialog::getExistingDirectory(this,
109
//                               tr("Chose a File"), QDir::currentPath());
110
 
111
//    if (!directory.isEmpty()) {
112
//        if (proPathComboBox->findText(directory) == -1)
113
//            proPathComboBox->addItem(directory);
114
//        proPathComboBox->setCurrentIndex(proPathComboBox->findText(directory));
115
//    }
116
 
117
 
118
//    QFileDialog::Options options;
119
//    //options |= QFileDialog::DontUseNativeDialog;
120
//    QString selectedFilter;
121
//    QString fileName = QFileDialog::getOpenFileName(this,
122
//                                tr("QFileDialog::getOpenFileName()"),
123
//                                proPathComboBox->currentText(),
124
//                                tr("所有文件 (*.*);;文本文件 (*.txt)"),
125
//                                &selectedFilter,
126
//                                options);
127
//    if (!fileName.isEmpty()){
128
//        if (proPathComboBox->findText(fileName) == -1)
129
//                proPathComboBox->addItem(fileName);
130
//        proPathComboBox->setCurrentIndex(proPathComboBox->findText(fileName));
131
//    }
132
 
133
 
134
    QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly;
135
    //options |= QFileDialog::DontUseNativeDialog;
136
    QString directory = QFileDialog::getExistingDirectory(this,
137
                                tr("设置工程目录"),
138
                                proPathComboBox->currentText(),
139
                                options);
140
    if (!directory.isEmpty()){
141
        if (proPathComboBox->findText(directory) == -1)
142
                proPathComboBox->addItem(directory);
143
        proPathComboBox->setCurrentIndex(proPathComboBox->findText(directory));
144
    }
145
}
146
 
147
void ProjectSetWizard::createPage1()
148
{
149
    m_iprjSetPage = new QWizardPage(this);
150
    m_iprjSetPage->setTitle(tr("设置工程目录"));
151
 
152
    QLabel *label = new QLabel(tr("工程目录:"));
153
    proPathComboBox = createComboBox(QDir::currentPath());
154
    label->setBuddy(proPathComboBox);
155
    proPathComboBox->clear();
156
    proPathComboBox->clearEditText();
157
    ToolWindow *pparent = dynamic_cast<ToolWindow*>(this->parentWidget());
158
    if(pparent->getCurrentProject())
159
    {
160
        proPathComboBox->addItem(pparent->getCurrentProject()->getCurrentDir().absolutePath());
161
        m_icurrentDir = QDir::toNativeSeparators(pparent->getCurrentProject()->getCurrentDir().absolutePath()) ;
162
        qDebug() << m_icurrentDir << __LINE__;
163
    }
164
 
165
 
166
    browseButton = createButton(tr("浏览"), SLOT(browse()));
167
 
168
    QGridLayout *layout = new QGridLayout;
169
    layout->addWidget(label, 0, 0);
170
    layout->addWidget(proPathComboBox, 3, 0, 1, 4);
171
    layout->addWidget(browseButton, 3, 4, 1, 1);
172
    m_iprjSetPage->setLayout(layout);
173
 
174
    return ;
175
}
176
 
177
void ProjectSetWizard::createPage2()
178
{
179
    m_iregSetPage = new QWizardPage(this);
180
    m_iregSetPage->setTitle(QObject::tr("设置最大扫描链的寄存器个数"));
181
 
182
 
183
    ///////////test/////////////////
184
    // chainNum = 1;
185
    QStringList chainNameList;
186
    chainNameList << "Chain 1"
187
                  << "Chain 2"
188
                  << "Chain 3"
189
                  << "Chain 4"
190
                  << "Chain 5";
191
    ///////////end of test/////////////////
192
 
193
 
194
    //QVector<int> regNumVector;
195
    QStringList regNumList;
196
 
197
    QGridLayout *layout = new QGridLayout;
198
 
199
#if 0
200
    for(int i = 0; i < chainNum; i++){
201
        QLabel *label = new QLabel(chainNameList[i] + tr(":"));
202
        spinBox = new QSpinBox;
203
        spinBox->setMaximum(2048);
204
        //regNumVector.append(0);
205
        //connect(spinBox, SIGNAL(valueChanged(int)), regNumVector, SLOT(replace(i, int)));
206
        regNumList << tr("0");
207
        //connect(spinBox, SIGNAL(valueChanged(int)), regNumList[i], SLOT(setNum()));
208
 
209
        label->setBuddy(spinBox);
210
        layout->addWidget(label, i, 0, 1, 1);
211
        layout->addWidget(spinBox, i, 1, 1, 2);
212
    }
213
#endif
214
    m_nregNumComBox = new QComboBox(this) ;
215
    m_imaxregNumLabel = new QLabel("The Max Regnum Per Chain :",this);
216
 
217
    m_imaxregNumLabel->setBuddy(m_imaxregNumLabel);
218
    layout->addWidget(m_imaxregNumLabel, 0, 0, 1, 1,Qt::AlignLeft);
219
    layout->addWidget(m_nregNumComBox, 0 , 1, 1, 1);
220
    //m_nregNumComBox->addItem("256");
221
    m_nregNumComBox->addItem("512");
222
    m_nregNumComBox->addItem("1024");
223
    m_nregNumComBox->addItem("2048");
224
    layout->setMargin(50);
225
    m_iregSetPage->setLayout(layout);
226
 
227
    ToolWindow *pparent = dynamic_cast<ToolWindow*>(this->parentWidget());
228
    if(pparent->getCurrentProject())
229
    {
230
        int nNum = pparent->getCurrentProject()->getMaxRegNumPerChain() ;
231
        if((nNum != 512)&&(nNum != 1024)&&(nNum != 2048))
232
        {
233
            qDebug() << "EziDebug Error: The project 's max reg num is not right!";
234
            nNum = 512 ;
235
        }
236
 
237
        m_nregNumComBox->setCurrentIndex(m_nregNumComBox->findText(QString::number(nNum)));
238
        m_uncurrentRegNum = nNum ;
239
    }
240
}
241
 
242
void ProjectSetWizard::createConclusionPage()
243
{
244
    m_itoolSetPage = new QWizardPage(this);
245
    m_itoolSetPage->setTitle(QObject::tr("设置所用FPGA类型"));
246
 
247
    #if 0
248
    QLabel *languageLabel = new QLabel(tr("所使用编程语言:"));
249
    QCheckBox *verilogCheckBox = new QCheckBox(tr("Verilog"));
250
    QCheckBox *vhdlCheckBox = new QCheckBox(tr("VHDL"));
251
 
252
    QLabel *slotLabel = new QLabel(tr("所使用计数器时钟:"));
253
    slotComboBox = createComboBox(tr(""));
254
    #endif
255
 
256
    //添加各个时钟。。。。
257
    QLabel *fpgaLabel = new QLabel(tr("所使用FPGA:"));
258
    alteraCheckBox = new QRadioButton(tr("Altera"),this);
259
    xilinxCheckBox = new QRadioButton(tr("Xilinx"),this);
260
 
261
    alteraCheckBox->setCheckable(true);
262
    xilinxCheckBox->setCheckable(true);
263
 
264
    m_ixilinxComplieOption = new QCheckBox(tr("Disable Equivalent Register Removal"),this);
265
    m_ixilinxComplieOption->setCheckable(false);
266
    m_ixilinxComplieOption->setVisible(false);
267
    connect(xilinxCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeXilinxCompileOption(bool)));
268
    QGridLayout *layout = new QGridLayout;
269
    //layout->addWidget(languageLabel, 0, 0);
270
    //layout->addWidget(verilogCheckBox, 1, 0, 1, 2);
271
    //layout->addWidget(vhdlCheckBox, 1, 2, 1, 2);
272
    //layout->addWidget(slotLabel, 3, 0);
273
    //layout->addWidget(slotComboBox, 3, 1, 1, 4);
274
    ToolWindow *pparent = dynamic_cast<ToolWindow*>(this->parentWidget());
275
    if(pparent->getCurrentProject())
276
    {
277
        if(pparent->getCurrentProject()->getToolType() == EziDebugPrj::ToolQuartus)
278
        {
279
            alteraCheckBox->setChecked(true);
280
            m_ecurrentTool = EziDebugPrj::ToolQuartus ;
281
        }
282
        else if(pparent->getCurrentProject()->getToolType() == EziDebugPrj::ToolIse)
283
        {
284
            xilinxCheckBox->setChecked(true);
285
            m_ecurrentTool = EziDebugPrj::ToolIse ;
286
        }
287
        else
288
        {
289
            qDebug() << "EziDebug Error: The project 's fpag type is not right!" ;
290
        }
291
    }
292
 
293
    layout->addWidget(fpgaLabel, 4, 0);
294
    layout->addWidget(alteraCheckBox, 5, 0, 1, 2);
295
    layout->addWidget(xilinxCheckBox, 5, 2, 1, 2);
296
    layout->addWidget(m_ixilinxComplieOption,6,2,1,2);
297
 
298
    m_itoolSetPage->setLayout(layout);
299
}
300
 
301
QPushButton *ProjectSetWizard::createButton(const QString &text, const char *member)
302
{
303
    QPushButton *button = new QPushButton(text);
304
    connect(button, SIGNAL(clicked()), this, member);
305
    return button;
306
}
307
 
308
QComboBox *ProjectSetWizard::createComboBox(const QString &text, const QStringList &items)
309
{
310
    QComboBox *comboBox = new QComboBox;
311
    comboBox->setEditable(true);
312
    if(text != tr(""))
313
        comboBox->addItem(text);
314
    if(!items.isEmpty())
315
        comboBox->insertItems(comboBox->count(), items);
316
    comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
317
 
318
    return comboBox;
319
}
320
 
321
QString ProjectSetWizard::getProPath()
322
{
323
    return proPathComboBox->currentText();
324
}
325
 
326
void ProjectSetWizard::cc()
327
{
328
    qDebug("flag is cc");
329
 
330
    proPathComboBox->addItem(tr("aa"));
331
}
332
 
333
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.