clean-logint-extra:
rm -f bin/logint
-bin_logedit_SOURCES = src/edit/editor.cpp src/edit/editor.moc.cpp
-bin_logedit_CPPFLAGS = $(bin_logedit_CFLAGS)
+bin_logedit_SOURCES = \
+ src/edit/editor.cpp \
+ src/edit/editor.moc.cpp \
+ src/edit/ProgramStructureDialog.cpp \
+ src/edit/UnitStructureDialog.cpp
+bin_logedit_CPPFLAGS = $(bin_logedit_CFLAGS)
bin_logedit_LDADD = $(bin_logedit_LIBS)
bin_logeditdir = src/edit
bin_logedit_HEADERS =\
src/edit/editor.h \
- src/edit/ui/editor.h
+ src/edit/ui/editor.h \
+ src/edit/ProgramStructureDialog.h \
+ src/edit/ui/dialogs/ProgramStructureDialog.h \
+ src/edit/UnitStructureDialog.h \
+ src/edit/ui/dialogs/UnitStructureDialog.h
src/edit/editor.moc.cpp: \
src/edit/editor.h \
- src/edit/ui/editor.h
+ src/edit/ui/editor.h \
+ src/edit/ui/dialogs/ProgramStructureDialog.h \
+ src/edit/ui/dialogs/UnitStructureDialog.h
moc-qt4 src/edit/editor.h -o src/edit/editor.moc.cpp
# $(MOC) src/edit/editor.h -o src/edit/editor.moc.cpp
src/edit/ui/editor.h:
uic src/edit/ui/editor.ui -o src/edit/ui/editor.h
+src/edit/ui/dialogs/ProgramStructureDialog.h:
+ uic src/edit/ui/dialogs/ProgramStructureDialog.ui -o src/edit/ui/dialogs/ProgramStructureDialog.h
+
+src/edit/ui/dialogs/UnitStructureDialog.h:
+ uic src/edit/ui/dialogs/UnitStructureDialog.ui -o src/edit/ui/dialogs/UnitStructureDialog.h
+
clean-logedit-extra:
+ rm -f src/edit/ui/dialogs/*.h
rm -f src/edit/ui/editor.h
rm -f src/edit/*.moc.cpp
rm -f bin/modules/logedit
--- /dev/null
+#include "ProgramStructureDialog.h"
+
+
+ProgramStructureDialog::ProgramStructureDialog(QWidget * parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+ProgramStructureDialog::~ProgramStructureDialog()
+{
+}
+
+QString ProgramStructureDialog::getProgramName()
+{
+ return lineEdit->text();
+}
+
+QString ProgramStructureDialog::getCode()
+{
+ QString code;
+ code.sprintf("PROGRAM %s\n\nBEGIN\n\nEND", getProgramName().toStdString().c_str());
+ return code;
+}
--- /dev/null
+#ifndef _VLP_EDITOR_PROGRAMSTRUCTUREDIALOG_H
+#define _VLP_EDITOR_PROGRAMSTRUCTUREDIALOG_H
+
+#include <QtGui/QDialog>
+#include <QtCore/QString>
+
+
+#include "ui/dialogs/ProgramStructureDialog.h"
+
+/**
+ * Program Structure Dialog class
+ * Displays dialog for generating code template for program structure
+ */
+class ProgramStructureDialog : public QDialog, private Ui::ProgramStructureDialog {
+public:
+ /**
+ * Class constructor
+ */
+ ProgramStructureDialog(QWidget * parent = 0);
+
+ /**
+ * Class destuctor
+ */
+ ~ProgramStructureDialog();
+
+ /**
+ * Gets user-passed program name
+ *
+ * @return program name entered in dialog
+ */
+ QString getProgramName();
+
+ /**
+ * Gets program code template
+ *
+ * @return program code template with program name
+ */
+ QString getCode();
+};
+
+#endif /* _VLP_EDITOR_PROGRAMSTRUCTUREDIALOG_H */
--- /dev/null
+#include "UnitStructureDialog.h"
+
+#define TYPENUM 5
+
+const char *UnitTypes[TYPENUM] = {
+ "CLASS",
+ "PROCEDURE",
+ "FUNCTION",
+ "PROCESS",
+ "COROUTINE"
+};
+
+UnitStructureDialog::UnitStructureDialog(QWidget * parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+
+ for (int i = 0; i < TYPENUM; i++) {
+ QListWidgetItem *newItem = new QListWidgetItem;
+ newItem->setText(UnitTypes[i]);
+ listWidget->insertItem(i, newItem);
+ }
+ listWidget->setCurrentItem(0);
+
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+UnitStructureDialog::~UnitStructureDialog()
+{
+}
+
+QString UnitStructureDialog::getUnitName()
+{
+ return lineEdit->text();
+}
+
+QString UnitStructureDialog::getCode()
+{
+ QString code;
+ code.sprintf("UNIT %s : %s( <params> );\nBEGIN\n\nEND %s;",
+ getUnitName().toStdString().c_str(),
+ listWidget->currentItem()->text().toStdString().c_str(),
+ getUnitName().toStdString().c_str()
+ );
+ return code;
+}
--- /dev/null
+#ifndef _VLP_EDITOR_UNITSTRUCTUREDIALOG_H
+#define _VLP_EDITOR_UNITSTRUCTUREDIALOG_H
+
+#include <QtGui/QDialog>
+#include <QtCore/QString>
+
+#include "ui/dialogs/UnitStructureDialog.h"
+
+/**
+ * Program Unit Dialog class
+ * Displays dialog for generating code template for unit structure
+ */
+class UnitStructureDialog : public QDialog, private Ui::UnitStructureDialog {
+public:
+ /**
+ * Class constructor
+ */
+ UnitStructureDialog(QWidget * parent = 0);
+
+ /**
+ * Class destuctor
+ */
+ ~UnitStructureDialog();
+
+ /**
+ * Gets user-passed unit name
+ *
+ * @return unit name entered in dialog
+ */
+ QString getUnitName();
+
+ /**
+ * Gets unit code template
+ *
+ * @return unit code template with unit name
+ */
+ QString getCode();
+};
+
+#endif /* _VLP_EDITOR_PROGRAMSTRUCTUREDIALOG_H */
#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());
}
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProgramStructureDialog</class>
+ <widget class="QDialog" name="ProgramStructureDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>318</width>
+ <height>108</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Program Structure</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>20</number>
+ </property>
+ <property name="bottomMargin">
+ <number>20</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Program name</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ProgramStructureDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ProgramStructureDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UnitStructureDialog</class>
+ <widget class="QDialog" name="UnitStructureDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>486</width>
+ <height>262</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Unit type</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="listWidget">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Unit name</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>UnitStructureDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>UnitStructureDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>