1
0
mirror of git://projects.qi-hardware.com/nn-usb-fpga.git synced 2025-04-21 12:27:27 +03:00

Adding bases to the code generator. Code text edit, fixing input/output ID control, etc.

This commit is contained in:
Juan64Bits
2010-11-20 16:19:34 -05:00
parent 9d578912b7
commit 2efe106cf3
29 changed files with 531 additions and 157 deletions

View File

@@ -51,18 +51,43 @@ MainWindow::MainWindow()
createActions();
createToolBox();
createMenus();
statusBar = new QStatusBar(this);
scene = new DiagramScene(itemMenu);
scene = new DiagramScene(itemMenu,this);
scene->setSceneRect(QRectF(0, 0, 1000, 1000));
connect(scene, SIGNAL(textInserted(QGraphicsTextItem*)),
this, SLOT(textInserted(QGraphicsTextItem*)));
createToolbars();
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(toolBox);
view = new QGraphicsView(scene);
layout->addWidget(view);
/* Create widgets for code editor */
headerTextEdit = new QTextEdit;
headerTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
headerTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
blockTextEdit = new QTextEdit;
blockTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
blockTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
extraTextEdit = new QTextEdit;
extraTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
extraTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
prototypeLabel = new QLabel;
prototypeLabel->setText("\nvoid BLOCK_NAME () {");
headerLabel = new QLabel;
headerLabel->setText("Code for Header Section Here");
extraLabel = new QLabel;
extraLabel->setText("}\n\nCode for Extra Section Here");
/* Create central widget */
QGridLayout *layout = new QGridLayout;
layout->addWidget(toolBox,0,0,7,1);
view = new QGraphicsView(scene);
layout->addWidget(view,0,1,1,1);
layout->addWidget(headerLabel,1,1,1,1);
layout->addWidget(headerTextEdit,2,1,1,1);
layout->addWidget(prototypeLabel,3,1,1,1);
layout->addWidget(blockTextEdit,4,1,1,1);
layout->addWidget(extraLabel,5,1,1,1);
layout->addWidget(extraTextEdit,6,1,1,1);
QWidget *widget = new QWidget;
widget->setLayout(layout);
@@ -74,6 +99,8 @@ MainWindow::MainWindow()
if(QApplication::argc()>1)
{newDiagram(QString(QApplication::argv()[1]));}
statusBar->showMessage("Ready...");
this->setStatusBar(statusBar);
}
void MainWindow::deleteItem()
@@ -103,6 +130,7 @@ void MainWindow::deleteItem()
scene->removeItem(item);
delete(item);
}
updateProt();
}
}
}
@@ -111,8 +139,13 @@ void MainWindow::textInserted(QGraphicsTextItem*)
{
buttonGroup->button(selectedButton)->setChecked(false);
scene->setMode(DiagramScene::MoveItem);
updateProt();
}
void MainWindow::updateProt()
{
prototypeLabel->setText(scene->createPrototype());
}
void MainWindow::sceneScaleChanged(const QString &scale)
{
@@ -158,27 +191,27 @@ void MainWindow::createToolBox()
QGridLayout *layout = new QGridLayout;
//INPUTS
int i=0;
layout->addWidget(createToolButton(129+i,tr("Bool"),
layout->addWidget(createToolButton(128+i,tr("Bool"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("Char"),
layout->addWidget(createToolButton(128+i,tr("Char"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("Integer"),
layout->addWidget(createToolButton(128+i,tr("Integer"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("Double"),
layout->addWidget(createToolButton(128+i,tr("Double"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("Float"),
layout->addWidget(createToolButton(128+i,tr("Float"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("Short"),
layout->addWidget(createToolButton(128+i,tr("Short"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("Long"),
layout->addWidget(createToolButton(128+i,tr("Long"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("UChar"),
layout->addWidget(createToolButton(128+i,tr("UChar"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("UInt"),
layout->addWidget(createToolButton(128+i,tr("UInt"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("UShort"),
layout->addWidget(createToolButton(128+i,tr("UShort"),
QIcon(":/images/background1.png")),++i,0);
layout->addWidget(createToolButton(129+i,tr("ULong"),
layout->addWidget(createToolButton(128+i,tr("ULong"),
QIcon(":/images/background1.png")),++i,0);
@@ -343,6 +376,7 @@ bool MainWindow::newDiagram(QString filePath)
{
saveIfNeeded();
scene->cleanScene();
prototypeLabel->setText("\nvoid BLOCK_NAME () {");
myFilePath="";
if(filePath=="")
@@ -357,8 +391,8 @@ bool MainWindow::newDiagram(QString filePath)
file.close();
if(!parsing)
{
QMessageBox::warning(this,"Aborting","Failed to parse file, "
"wrong format or encoding.");
QMessageBox::warning(this,"Parsing warning","Invalid or void "
" element found in file.");
return 0;
}
scene->fromXmlFormat(document);