#include <QtGui/QListWidget>
#include <QtGui/QListWidgetItem>
-#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.
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( <params> );\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());
}
}