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

Subversion Repositories ezidebug

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

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

powered by: WebSVN 2.1.0

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