From: Rafał Długołęcki Date: Wed, 27 Jan 2016 22:56:35 +0000 (+0100) Subject: Restore functionality of loglan helpers X-Git-Tag: 3.4-b1~37 X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=0f44ebb1e0f987ec54afb4036780dd7fc9afb1dc;p=vlp.git Restore functionality of loglan helpers --- diff --git a/src/edit/editor.cpp b/src/edit/editor.cpp index 1daa7e7..5559ac4 100644 --- a/src/edit/editor.cpp +++ b/src/edit/editor.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "editor.h" @@ -44,9 +46,6 @@ Editor::Editor(int argc, char **argv) find_text = ""; sensitive = FALSE; - /* loglan->insertItem( "Program structure", this, SLOT(log_prog()));*/ - /* loglan->insertItem( "Unit structure", this, SLOT(log_unit()));*/ - compiler_path.sprintf("%s/%s", HomeDir, "compile/logcomp"); gen_path.sprintf("%s/%s", HomeDir, "compile/gen"); file_path.sprintf("%s", HomeDir); @@ -252,8 +251,6 @@ void Editor::on_actionClear_all_triggered() void Editor::on_actionFind_triggered() { QDialog dlg(this, Qt::Dialog); - QString *txt; - int res, line, pom; QLineEdit *tmpQLineEdit; tmpQLineEdit = new QLineEdit("", &dlg); @@ -411,14 +408,7 @@ void Editor::on_actionCompile_Gen_triggered() void Editor::on_actionProgram_structure_triggered() { - /* - Code commented during Qt4 migration. - Code is not used, so there is no rush with this... - */ - /* - QString txt; QDialog dlg(this, "unit", TRUE); - int cx, cy; char uname[255]; QLineEdit *files; @@ -430,45 +420,37 @@ void Editor::on_actionProgram_structure_triggered() files->setFrame(TRUE); QLabel *tmpQLabel; - tmpQLabel = new QLabel(&dlg, "Label_1"); + tmpQLabel = new QLabel(&dlg); tmpQLabel->setGeometry(10, 20, 100, 30); tmpQLabel->setText("Program name:"); QPushButton* tmpQPushButton; - tmpQPushButton = new QPushButton(&dlg, "OkBtn"); + tmpQPushButton = new QPushButton(&dlg); tmpQPushButton->setGeometry(40, 70, 70, 30); tmpQPushButton->setText("Ok"); tmpQPushButton->setAutoRepeat(FALSE); - tmpQPushButton->setAutoResize(FALSE); connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(accept())); - tmpQPushButton = new QPushButton(&dlg, "CancelBtn"); + tmpQPushButton = new QPushButton(&dlg); tmpQPushButton->setGeometry(130, 70, 100, 30); tmpQPushButton->setText("Cancel"); tmpQPushButton->setAutoRepeat(FALSE); - tmpQPushButton->setAutoResize(FALSE); connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(reject())); if (dlg.exec()) { strcpy(uname, files->text()); - e->getCursorPosition(&cx, &cy); - txt.sprintf("PROGRAM %s\n\nBEGIN\n\nEND ", uname); - e->insertAt(txt, cx, cy); + QString txt; + txt.sprintf("PROGRAM %s\n\nBEGIN\n\nEND", uname); + + editor->textCursor().insertText(txt); } - */ } void Editor::on_actionUnit_structure_triggered() { - /* - Code commented during Qt4 migration. - Code is not used, so there is no rush with this... - */ - /* - QString txt; QDialog dlg(this, Qt::Dialog); - int cx, cy, i; + int i; char uname[255]; QLineEdit* files; @@ -480,47 +462,49 @@ void Editor::on_actionUnit_structure_triggered() files->setFrame(TRUE); QLabel* tmpQLabel; - tmpQLabel = new QLabel(&dlg, "Label_1"); + 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, "OkBtn"); + tmpQPushButton = new QPushButton(&dlg); tmpQPushButton->setGeometry(40, 170, 70, 30); tmpQPushButton->setText("Ok"); tmpQPushButton->setAutoRepeat(FALSE); - tmpQPushButton->setAutoResize(FALSE); connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(accept())); - tmpQPushButton = new QPushButton(&dlg, "CancelBtn"); + tmpQPushButton = new QPushButton(&dlg); tmpQPushButton->setGeometry(130, 170, 100, 30); tmpQPushButton->setText("Cancel"); tmpQPushButton->setAutoRepeat(FALSE); - tmpQPushButton->setAutoResize(FALSE); connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(reject())); - tmpQLabel = new QLabel(&dlg, "Label_1"); + tmpQLabel = new QLabel(&dlg); tmpQLabel->setGeometry(10, 50, 100, 60); tmpQLabel->setText("Unit type:"); - QListBox lst(&dlg, "type"); + QListWidget *listWidget = new QListWidget(&dlg); for(i = 0; i < TYPENUM; i++) { - lst.insertItem(UnitTypes[i]); + QListWidgetItem *newItem = new QListWidgetItem; + newItem->setText(UnitTypes[i]); + listWidget->insertItem(i, newItem); } - lst.setGeometry(130, 60, 180, 80); - lst.setCurrentItem(0); + listWidget->setCurrentItem(0); if (dlg.exec()) { strcpy(uname, files->text()); - e->getCursorPosition(&cx, &cy); + QString txt; txt.sprintf("UNIT %s : %s( );\nBEGIN\n\nEND %s;", - uname, lst.text(lst.currentItem()).ascii(), uname); - e->insertAt(txt, cx, cy); + uname, + listWidget->currentItem()->text().toStdString().c_str(), + uname + ); + + editor->textCursor().insertText(txt); } - */ } /** diff --git a/src/edit/ui/editor.ui b/src/edit/ui/editor.ui index cfb0376..11c7c23 100644 --- a/src/edit/ui/editor.ui +++ b/src/edit/ui/editor.ui @@ -117,7 +117,7 @@ - false + true Loglan