X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fedit%2Feditor.cpp;fp=src%2Fedit%2Feditor.cpp;h=59e7f9e53d0eae1885a5bcbb8343e959d60b7907;hb=51482069fdcb6419521f9f5cfcff5980a185428b;hp=c832f3e88b37c10d9a82c2e4db6194a8e002c804;hpb=a65ea8a9671bc17933d43714eb108ce950606209;p=vlp.git diff --git a/src/edit/editor.cpp b/src/edit/editor.cpp index c832f3e..59e7f9e 100644 --- a/src/edit/editor.cpp +++ b/src/edit/editor.cpp @@ -14,20 +14,10 @@ #include #include -#include "editor.h" - -#define TYPENUM 5 +#include "ProgramStructureDialog.h" +#include "UnitStructureDialog.h" -/** - * @attention Currently not in use - */ -const char *UnitTypes[TYPENUM] = { - "CLASS", - "PROCEDURE", - "FUNCTION", - "PROCESS", - "COROUTINE" -}; +#include "editor.h" /** * Editor constructor. Initializes and sets variables of Loglan Editor. @@ -412,102 +402,19 @@ void Editor::on_actionCompile_Gen_triggered() void Editor::on_actionProgram_structure_triggered() { - QDialog dlg(this, "unit", TRUE); - char uname[255]; - - QLineEdit *files; - files = new QLineEdit(&dlg, "f_path"); - files->setGeometry(130, 20, 250, 30); - files->setText(""); - files->setMaxLength(32767); - files->setEchoMode(QLineEdit::Normal); - files->setFrame(TRUE); - - QLabel *tmpQLabel; - tmpQLabel = new QLabel(&dlg); - tmpQLabel->setGeometry(10, 20, 100, 30); - tmpQLabel->setText("Program name:"); - - QPushButton* tmpQPushButton; - tmpQPushButton = new QPushButton(&dlg); - tmpQPushButton->setGeometry(40, 70, 70, 30); - tmpQPushButton->setText("Ok"); - tmpQPushButton->setAutoRepeat(FALSE); - connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(accept())); - - tmpQPushButton = new QPushButton(&dlg); - tmpQPushButton->setGeometry(130, 70, 100, 30); - tmpQPushButton->setText("Cancel"); - tmpQPushButton->setAutoRepeat(FALSE); - connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(reject())); - - if (dlg.exec()) { - strcpy(uname, files->text()); - - QString txt; - txt.sprintf("PROGRAM %s\n\nBEGIN\n\nEND", uname); + ProgramStructureDialog dialog(this); - editor->textCursor().insertText(txt); + if (dialog.exec()) { + editor->textCursor().insertText(dialog.getCode()); } } void Editor::on_actionUnit_structure_triggered() { - QDialog dlg(this, Qt::Dialog); - int i; - char uname[255]; - - QLineEdit* files; - files = new QLineEdit(&dlg, "f_path"); - files->setGeometry(130, 20, 250, 30); - files->setText(""); - files->setMaxLength(32767); - files->setEchoMode(QLineEdit::Normal); - files->setFrame(TRUE); - - QLabel* tmpQLabel; - tmpQLabel = new QLabel(&dlg); - tmpQLabel->setGeometry(10, 20, 100, 30); - tmpQLabel->setText("Unit name:"); - tmpQLabel->setAlignment(289); - tmpQLabel->setMargin(-1); - - QPushButton* tmpQPushButton; - tmpQPushButton = new QPushButton(&dlg); - tmpQPushButton->setGeometry(40, 170, 70, 30); - tmpQPushButton->setText("Ok"); - tmpQPushButton->setAutoRepeat(FALSE); - connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(accept())); - - tmpQPushButton = new QPushButton(&dlg); - tmpQPushButton->setGeometry(130, 170, 100, 30); - tmpQPushButton->setText("Cancel"); - tmpQPushButton->setAutoRepeat(FALSE); - connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(reject())); - - tmpQLabel = new QLabel(&dlg); - tmpQLabel->setGeometry(10, 50, 100, 60); - tmpQLabel->setText("Unit type:"); - - QListWidget *listWidget = new QListWidget(&dlg); - for(i = 0; i < TYPENUM; i++) { - QListWidgetItem *newItem = new QListWidgetItem; - newItem->setText(UnitTypes[i]); - listWidget->insertItem(i, newItem); - } - listWidget->setCurrentItem(0); - - if (dlg.exec()) { - strcpy(uname, files->text()); - - QString txt; - txt.sprintf("UNIT %s : %s( );\nBEGIN\n\nEND %s;", - uname, - listWidget->currentItem()->text().toStdString().c_str(), - uname - ); + UnitStructureDialog dialog(this); - editor->textCursor().insertText(txt); + if (dialog.exec()) { + editor->textCursor().insertText(dialog.getCode()); } }