From deab1cfe393edb3d04caf94340cb5c58aa2626ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Wed, 27 Jan 2016 23:27:43 +0100 Subject: [PATCH] Replace and remove old methods with newly named ones integrated with layout generated code --- Makefile.am | 1 + src/edit/editor.cpp | 630 +++++++++++++--------------------- src/edit/editor.h | 44 +-- src/edit/ui/editor.ui | 74 +++- src/kernel/ui/kernelwindow.ui | 31 ++ 5 files changed, 346 insertions(+), 434 deletions(-) diff --git a/Makefile.am b/Makefile.am index 33527d6..0ffe5b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -180,6 +180,7 @@ src/edit/ui/editor.h: clean-logedit-extra: + rm -f src/edit/ui/editor.h rm -f src/edit/*.moc.cpp rm -f bin/modules/logedit rm -f bin/logedit diff --git a/src/edit/editor.cpp b/src/edit/editor.cpp index b8514b0..a35baf8 100644 --- a/src/edit/editor.cpp +++ b/src/edit/editor.cpp @@ -16,8 +16,6 @@ #define TYPENUM 5 -Editor *editor; - /** * @attention Currently not in use */ @@ -29,117 +27,32 @@ char *UnitTypes[TYPENUM] = { "COROUTINE" }; -/** - * My_Edit constructor. Initializes and sets variables of Multiline editor - * widget. - * @param parent Parent widget of this widget. If set, this widget becomes a - * child window inside parent. If not set this widget becomes a - * top level window. Default: NULL - * @param name @deprecated If set, name is sent to the Qobject constructor, so widget is - * identifiable (e.g. in Qt Designer) - */ -My_Edit::My_Edit(QWidget *parent, const char *name) - : QTextEdit(parent) -{ - parent = NULL; - name = NULL; -} - -/** - * @copydoc QWidget::keyPressEvent(QKeyEvent*) - */ -void My_Edit::keyPressEvent(QKeyEvent *ev) -{ - QTextEdit::keyPressEvent(ev); - emit cursorMove(); -} - -/** - * Event invoked on program close. - * @copydoc QWidget::closeEvent(QCloseEvent*) - */ -void Editor::closeEvent(QCloseEvent * e) { - e->accept(); -} - /** * Editor constructor. Initializes and sets variables of Loglan Editor. - * @param hdir Home directory of program (specified in configuration file) - * @param parent Parent widget of this widget. If set, this widget becomes a - * child window inside parent. If not set this widget becomes a - * top level window. Default: NULL - * @param name If set, name is sent to the Qobject constructor, so widget is - * identifiable (e.g. in Qt Designer) + * + * @param argc command line argc parameter + * @param argv command line argv parameter */ -Editor::Editor(char *hdir, QWidget * parent) - : QMainWindow(parent) +Editor::Editor(int argc, char **argv) { setupUi(this); - strcpy(HomeDir, hdir); + if (argc > 1) { + strcpy(HomeDir, argv[1]); + } + find_text = ""; sensitive = FALSE; -// QMenu * file = NULL; -// /* QMenu * comp = new QMenu();*/ -// /* QMenu * loglan = new QMenu();*/ -// QMenu * medit = NULL; -// QAction* action = NULL; -// -// file = menuBar()->addMenu("&File"); -// medit = menuBar()->addMenu("&Edit"); -// -// action = menuBar()->addAction("&Compile", this, SLOT(cmp())); -// -// /* m->insertItem( "&LOGLAN ", loglan );*/ -// -// action = menuBar()->addAction("&Properties", this, SLOT(props())); -// -// file->addAction("New", this, SLOT(create()), QKeySequence(Qt::CTRL + Qt::Key_N)); -// file->addAction("Open", this, SLOT(load()), QKeySequence(Qt::CTRL + Qt::Key_O)); -// file->addAction("Save", this, SLOT(save()), QKeySequence(Qt::CTRL + Qt::Key_S)); -// file->addAction("Save as", this, SLOT(save_as()), QKeySequence(Qt::CTRL + Qt::Key_A)); -// file->addSeparator(); -// file->addAction("Quit ", this, SLOT(close())); - - /* comp->insertItem("Compile ", this, SLOT(cmp()), CTRL + Key_C);*/ - /* comp->insertItem("Gen ", this, SLOT(gen()), CTRL + Key_G);*/ - /* comp->insertItem("Compile & Gen ", this, SLOT(comp_all()));*/ /* loglan->insertItem( "Program structure", this, SLOT(log_prog()));*/ /* loglan->insertItem( "Unit structure", this, SLOT(log_unit()));*/ -// e = new My_Edit(this, "editor"); -// connect(e, SIGNAL(cursorMove()), this, SLOT(updateline())); -// medit->addAction("Copy", e, SLOT(copy()), QKeySequence(Qt::CTRL + Qt::Key_Insert)); -// medit->addAction("Paste", e, SLOT(paste()), QKeySequence(Qt::SHIFT + Qt::Key_Insert)); -// medit->addAction("Cut", e, SLOT(cut()), QKeySequence(Qt::CTRL + Qt::Key_Delete)); -// medit->addAction("Clear All", e, SLOT(clear())); -// medit->addSeparator(); -// medit->addAction("Find", this, SLOT(findText()), QKeySequence(Qt::CTRL + Qt::Key_F)); -// medit->addAction("Find Next", this, SLOT(find_next()), QKeySequence(Qt::CTRL + Qt::Key_L)); - -// msg = new QTextEdit(this); -// msg->setReadOnly(TRUE); -// -// QVBoxLayout * layout = new QVBoxLayout(); -// layout->setContentsMargins (3, 0, 3, 0); -// layout->addWidget(e); -// layout->addWidget(msg); -// QWidget *window = new QWidget(); -// window->setLayout(layout); -// setCentralWidget(window); - compiler_path.sprintf("%s/%s", HomeDir, "compile/logcomp"); gen_path.sprintf("%s/%s", HomeDir, "compile/gen"); file_path.sprintf("%s", HomeDir); - -// QColor col(200, 200, 200); -// QPalette grp(Qt::black, col, col.lighter(), col.darker(), col.darker(), Qt::black, col); -// -// msg->setPalette(grp); -// -// position = new QLabel(); -// statusBar()->addPermanentWidget(position); + + + connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(on_editor_cursorPositionChanged())); } /** @@ -152,81 +65,131 @@ Editor::~Editor() /** * Displays line:column position of cursor */ -void Editor::updateline() +void Editor::on_editor_cursorPositionChanged() { - char pom[255]; + QString position; int cx; int cy; - cx = e->textCursor().blockNumber(); - cy = e->textCursor().columnNumber(); - sprintf(pom,"%d:%d ", cx, cy); - position->setText(pom); + cx = editor->textCursor().blockNumber(); + cy = editor->textCursor().columnNumber(); + position.sprintf("%d:%d", cx, cy); + + statusBar()->showMessage(position); } /** - * Event invoked on resizing editor application window. - * @copydoc QWidget::resizeEvent(QResizeEvent*) - * @param event Currently does nothing + * Loads given file content to the editor. + * + * @param fileName Filename of file which will be read. */ -void Editor::resizeEvent(QResizeEvent *event) +void Editor::load(const char *fileName) { -/* -TODO: Remove entire method? - if (e && m) { - e->setGeometry(0, m->height(), width(), - 3 * (int)((height() - m->height()) / 4)); - - msg->setGeometry(0, m->height() + e->height(), width(), - (int)((height() - m->height()) / 4)); - - position->setGeometry(width() - 80, - m->height() + e->height() - 10, - position->width(), - position->height()); + fname.sprintf("%s", fileName); + + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return; + + editor->clear(); + + QTextStream textStream(&file); + while (!file.atEnd()) { + editor->append(textStream.readLine()); } -*/ + + file.close(); + + editor->repaint(); + setWindowTitle(fileName); } /** - * Displays additional window + * Saves editor content to the given filename. + * @param fileName File name of the file where content should be saved. */ -void Editor::load() +void Editor::save(const char *fileName) { - QString fn = QFileDialog::getOpenFileName(this, "Load file", file_path, "*.log"); - if (!fn.isEmpty()) - load(fn.toAscii().data()); + QFile file(fileName); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return; + + file.reset(); + file.write(editor->toPlainText().toAscii().data(), editor->toPlainText().length()); + file.close(); } /** - * Loads given file content to the editor. - * @param fileName Filename of file which will be read. + * Invokes compiler in the giving mode. + * @param mode Mode of compilation. Possible values: + * - COMP_MODE - compilation mode + * - GEN_MODE - program generation mode + * - ALL_MODE - compilation & generation mode. */ -void Editor::load(const char *fileName) +void Editor::compile(int mode) { - fname.sprintf("%s", fileName); + char cmd[255]; + messages->setReadOnly(FALSE); + messages->clear(); + messages->repaint(); + + /*i = fname.find('.');*/ + /* if (i>=0) {*/ + + /* fn.truncate(i);*/ + switch(mode) { + case COMP_MODE: + sprintf(cmd, "%s %s > comp_data!", compiler_path.toAscii().data(), + fname.toAscii().data()); + break; + case GEN_MODE: + sprintf(cmd, "%s %s > comp_data!", gen_path.toAscii().data(), + fname.toAscii().data()); + break; + case ALL_MODE: + sprintf(cmd, "%s %s > comp_data!", compiler_path.toAscii().data(), + fname.toAscii().data()); + system(cmd); + sprintf(cmd, "%s %s >> comp_data!", gen_path.toAscii().data(), + fname.toAscii().data()); + break; + } - QFile f(fileName); + system(cmd); + QFile f("comp_data!"); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) return; -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - e->setAutoUpdate(FALSE); -*/ - e->clear(); - QTextStream t(&f); while (!t.atEnd()) { QString s = t.readLine(); - e->append(s); + messages->append(s); } f.close(); -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - e->setAutoUpdate(TRUE); -*/ - e->repaint(); - setWindowTitle(fileName); + messages->setReadOnly(TRUE); + + messages->repaint(); + unlink("comp_data!"); + /*}*/ +} + +/** + * Empties editor content. + */ +void Editor::on_actionNew_triggered() +{ + editor->clear(); + fname.sprintf("%s", "");} + +/** + * Displays additional window + */ +void Editor::on_actionOpen_triggered() +{ + QString fn = QFileDialog::getOpenFileName(this, "Load file", file_path, "*.log"); + if (!fn.isEmpty()) + load(fn.toAscii().data()); } /** @@ -234,7 +197,7 @@ void Editor::load(const char *fileName) * If content has been read from file, it is written to this file. Otherwise * dialog is shown to save content to the specified by user, file. */ -void Editor::save() +void Editor::on_actionSave_triggered() { if (fname.isEmpty()) { QString fn = QFileDialog::getSaveFileName(this, "Save file", @@ -254,7 +217,7 @@ void Editor::save() * Forces saving editor content to the new file. Special dialog is shown for * that purpose. */ -void Editor::save_as() +void Editor::on_actionSave_as_triggered() { QString fn = QFileDialog::getSaveFileName(this, "Save file as", file_path, "*.log"); @@ -264,134 +227,95 @@ void Editor::save_as() } setWindowTitle(fname); } - -/** - * Saves editor content to the given filename. - * @param fileName File name of the file where content should be saved. - */ -void Editor::save(const char *fileName) +void Editor::on_actionQuit_triggered() { - QFile f(fileName); - if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) - return; - f.reset(); - f.write(e->toPlainText().toAscii().data(), e->toPlainText().length()); - f.close(); + QApplication::instance()->quit(); } - -/** - * Empties editor content. - */ -void Editor::create() +void Editor::on_actionCopy_triggered() { - e->clear(); - fname.sprintf("%s", ""); } - -/** - * @attention Currently not in use - */ -void Editor::print() +void Editor::on_actionPaste_triggered() { } - -/** - * @attention Currently not in use. - * - * Saves and compiles code. - */ -void Editor::cmp() +void Editor::on_actionCut_triggered() { - save(); - compile(COMP_MODE); } - -/** - * @attention Currently not in use. - * - * Generates program. - */ -void Editor::gen() +void Editor::on_actionClear_all_triggered() { - compile(GEN_MODE); } /** - * @attention Currently not in use. - * - * Saves, compiles and generates code. + * Searches for given text in editor content. + * Displays window to set search parameters. If text is found sets cursor + * position on it. */ -void Editor::comp_all() +void Editor::on_actionFind_triggered() { - save(); - compile(ALL_MODE); -} + QDialog dlg(this, Qt::Dialog); + QString *txt; + int res, line, pom; -/** - * Invokes compiler in the giving mode. - * @param mode Mode of compilation. Possible values: - * - COMP_MODE - compilation mode - * - GEN_MODE - program generation mode - * - ALL_MODE - compilation & generation mode. - */ -void Editor::compile(int mode) -{ - char cmd[255]; -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - msg->setAutoUpdate(FALSE); -*/ - msg->setReadOnly(FALSE); - msg->clear(); - msg->repaint(); + QLineEdit *tmpQLineEdit; + tmpQLineEdit = new QLineEdit("", &dlg); + tmpQLineEdit->setGeometry(60, 10, 180, 30); - /*i = fname.find('.');*/ - /* if (i>=0) {*/ + QLabel *tmpQLabel; + tmpQLabel = new QLabel(&dlg); + tmpQLabel->setGeometry(10, 10, 50, 30); - /* fn.truncate(i);*/ - switch(mode) { - case COMP_MODE: - sprintf(cmd, "%s %s > comp_data!", compiler_path.toAscii().data(), - fname.toAscii().data()); - break; - case GEN_MODE: - sprintf(cmd, "%s %s > comp_data!", gen_path.toAscii().data(), - fname.toAscii().data()); - break; - case ALL_MODE: - sprintf(cmd, "%s %s > comp_data!", compiler_path.toAscii().data(), - fname.toAscii().data()); - system(cmd); - sprintf(cmd, "%s %s >> comp_data!", gen_path.toAscii().data(), - fname.toAscii().data()); - break; - } + tmpQLabel->setText("Text:"); - system(cmd); - QFile f("comp_data!"); - if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) - return; + QCheckBox *tmpQRadioButton; + tmpQRadioButton = new QCheckBox("Case sensitive", &dlg); + tmpQRadioButton->setGeometry(70, 50, 150, 30); + tmpQRadioButton->setAutoRepeat(FALSE); - QTextStream t(&f); - while (!t.atEnd()) { - QString s = t.readLine(); - msg->append(s); - } - f.close(); + QPushButton *okbtn, *cbtn; + okbtn = new QPushButton("Find", &dlg); + okbtn->setGeometry(260, 10, 100, 30); + okbtn->setDefault(TRUE); + connect(okbtn,SIGNAL(clicked()), &dlg, SLOT(accept())); - msg->setReadOnly(TRUE); + cbtn = new QPushButton("Close", &dlg); + cbtn->setGeometry(260, 50, 100, 30); + connect(cbtn, SIGNAL(clicked()), &dlg, SLOT(reject())); -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - msg->setAutoUpdate(TRUE); -*/ - msg->repaint(); - unlink("comp_data!"); - /*}*/ + dlg.resize(380, 90); + + if (dlg.exec()) { + sensitive = tmpQRadioButton->isChecked(); + find_text = tmpQLineEdit->text(); + + QTextDocument::FindFlags flags = 0; + + if (sensitive) { + flags |= QTextDocument::FindCaseSensitively; + } + editor->find(find_text, flags); + } +} + +/** + * Searches for next occurence of given text in editor content. + * Displays window to set search parameters. If text is found sets cursor + * position on it. + */ +void Editor::on_actionFind_Next_triggered() +{ + if (!find_text.isEmpty()) { + QTextDocument::FindFlags flags = 0; + + if (sensitive) { + flags |= QTextDocument::FindCaseSensitively; + } + editor->find(find_text, flags); + } } /** * Displays window with editor properties */ -void Editor::props() +void Editor::on_actionPreferences_triggered() { QDialog dlg(this, Qt::Dialog); @@ -443,18 +367,13 @@ void Editor::props() tmpQPushButton = new QPushButton("Ok", &dlg); tmpQPushButton->setGeometry(90, 100, 70, 30); tmpQPushButton->setAutoRepeat(FALSE); -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - tmpQPushButton->setAutoResize(FALSE); -*/ connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(accept())); tmpQPushButton = new QPushButton("Cancel", &dlg); tmpQPushButton->setGeometry(180, 100, 70, 30); tmpQPushButton->setAutoRepeat(FALSE); -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - tmpQPushButton->setAutoResize(FALSE); -*/ connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(reject())); + dlg.resize(400, 140); if (dlg.exec()) { @@ -465,9 +384,38 @@ void Editor::props() } /** - * @attention Currently not in use + * @attention Currently not in use. + * + * Saves and compiles code. + */ +void Editor::on_actionCompile_triggered() +{ + on_actionSave_triggered(); + compile(COMP_MODE); +} + +/** + * @attention Currently not in use. + * + * Generates program. + */ +void Editor::on_actionGen_triggered() +{ + compile(GEN_MODE); +} + +/** + * @attention Currently not in use. + * + * Saves, compiles and generates code. */ -void Editor::log_unit() +void Editor::on_actionCompile_Gen_triggered() +{ + on_actionSave_triggered(); + compile(ALL_MODE); +} + +void Editor::on_actionProgram_structure_triggered() { /* Code commented during Qt4 migration. @@ -475,11 +423,11 @@ void Editor::log_unit() */ /* QString txt; - QDialog dlg(this, Qt::Dialog); - int cx, cy, i; + QDialog dlg(this, "unit", TRUE); + int cx, cy; char uname[255]; - QLineEdit* files; + QLineEdit *files; files = new QLineEdit(&dlg, "f_path"); files->setGeometry(130, 20, 250, 30); files->setText(""); @@ -487,54 +435,37 @@ void Editor::log_unit() files->setEchoMode(QLineEdit::Normal); files->setFrame(TRUE); - QLabel* tmpQLabel; + QLabel *tmpQLabel; tmpQLabel = new QLabel(&dlg, "Label_1"); tmpQLabel->setGeometry(10, 20, 100, 30); - tmpQLabel->setText("Unit name:"); - tmpQLabel->setAlignment(289); - tmpQLabel->setMargin(-1); + tmpQLabel->setText("Program name:"); QPushButton* tmpQPushButton; tmpQPushButton = new QPushButton(&dlg, "OkBtn"); - tmpQPushButton->setGeometry(40, 170, 70, 30); + 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->setGeometry(130, 170, 100, 30); + tmpQPushButton->setGeometry(130, 70, 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->setGeometry(10, 50, 100, 60); - tmpQLabel->setText("Unit type:"); - - QListBox lst(&dlg, "type"); - for(i = 0; i < TYPENUM; i++) { - lst.insertItem(UnitTypes[i]); - } - lst.setGeometry(130, 60, 180, 80); - lst.setCurrentItem(0); - if (dlg.exec()) { strcpy(uname, files->text()); e->getCursorPosition(&cx, &cy); - txt.sprintf("UNIT %s : %s( );\nBEGIN\n\nEND %s;", - uname, lst.text(lst.currentItem()).ascii(), uname); + txt.sprintf("PROGRAM %s\n\nBEGIN\n\nEND ", uname); e->insertAt(txt, cx, cy); } */ } -/** - * @attention Currently not in use - */ -void Editor::log_prog() +void Editor::on_actionUnit_structure_triggered() { /* Code commented during Qt4 migration. @@ -542,11 +473,11 @@ void Editor::log_prog() */ /* QString txt; - QDialog dlg(this, "unit", TRUE); - int cx, cy; + QDialog dlg(this, Qt::Dialog); + int cx, cy, i; char uname[255]; - QLineEdit *files; + QLineEdit* files; files = new QLineEdit(&dlg, "f_path"); files->setGeometry(130, 20, 250, 30); files->setText(""); @@ -554,140 +485,50 @@ void Editor::log_prog() files->setEchoMode(QLineEdit::Normal); files->setFrame(TRUE); - QLabel *tmpQLabel; + QLabel* tmpQLabel; tmpQLabel = new QLabel(&dlg, "Label_1"); tmpQLabel->setGeometry(10, 20, 100, 30); - tmpQLabel->setText("Program name:"); + tmpQLabel->setText("Unit name:"); + tmpQLabel->setAlignment(289); + tmpQLabel->setMargin(-1); QPushButton* tmpQPushButton; tmpQPushButton = new QPushButton(&dlg, "OkBtn"); - tmpQPushButton->setGeometry(40, 70, 70, 30); + 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->setGeometry(130, 70, 100, 30); + 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->setGeometry(10, 50, 100, 60); + tmpQLabel->setText("Unit type:"); + + QListBox lst(&dlg, "type"); + for(i = 0; i < TYPENUM; i++) { + lst.insertItem(UnitTypes[i]); + } + lst.setGeometry(130, 60, 180, 80); + lst.setCurrentItem(0); + if (dlg.exec()) { strcpy(uname, files->text()); e->getCursorPosition(&cx, &cy); - txt.sprintf("PROGRAM %s\n\nBEGIN\n\nEND ", uname); + txt.sprintf("UNIT %s : %s( );\nBEGIN\n\nEND %s;", + uname, lst.text(lst.currentItem()).ascii(), uname); e->insertAt(txt, cx, cy); } */ } -/** - * Searches for given text in editor content. - * Displays window to set search parameters. If text is found sets cursor - * position on it. - */ -void Editor::findText() -{ - QDialog dlg(this, Qt::Dialog); - QString *txt; - int res, line, pom; - - QLineEdit *tmpQLineEdit; - tmpQLineEdit = new QLineEdit("", &dlg); - tmpQLineEdit->setGeometry(60, 10, 180, 30); - - QLabel *tmpQLabel; - tmpQLabel = new QLabel(&dlg); - tmpQLabel->setGeometry(10, 10, 50, 30); - - tmpQLabel->setText("Text:"); - - QCheckBox *tmpQRadioButton; - tmpQRadioButton = new QCheckBox("Case sensitive", &dlg); - tmpQRadioButton->setGeometry(70, 50, 150, 30); - tmpQRadioButton->setAutoRepeat(FALSE); - -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - tmpQRadioButton->setAutoResize(FALSE); -*/ - - QPushButton *okbtn, *cbtn; - okbtn = new QPushButton("Find", &dlg); - okbtn->setGeometry(260, 10, 100, 30); - okbtn->setDefault(TRUE); - connect(okbtn,SIGNAL(clicked()), &dlg, SLOT(accept())); - - cbtn = new QPushButton("Close", &dlg); - cbtn->setGeometry(260, 50, 100, 30); - connect(cbtn, SIGNAL(clicked()), &dlg, SLOT(reject())); - dlg.resize(380, 90); - - if (dlg.exec()) { - sensitive = tmpQRadioButton->isChecked(); - find_text = tmpQLineEdit->text(); - - QTextDocument::FindFlags flags = 0; - - if (sensitive) { - flags |= QTextDocument::FindCaseSensitively; - } - e->find(find_text, flags); - } -} - -/** - * Searches for next occurence of given text in editor content. - * Displays window to set search parameters. If text is found sets cursor - * position on it. - */ -void Editor::find_next() -{ - if (!find_text.isEmpty()) { - QTextDocument::FindFlags flags = 0; - - if (sensitive) { - flags |= QTextDocument::FindCaseSensitively; - } - e->find(find_text, flags); - } -} -void Editor::on_actionNew_triggered() -{ -} -void Editor::on_actionOpen_triggered() -{ -} -void Editor::on_actionSave_triggered() -{ -} -void Editor::on_actionSave_as_triggered() -{ -} -void Editor::on_actionQuit_triggered() -{ -} -void Editor::on_actionCopy_triggered() -{ -} -void Editor::on_actionPaste_triggered() -{ -} -void Editor::on_actionCut_triggered() -{ -} -void Editor::on_actionClear_all_triggered() -{ -} -void Editor::on_actionFind_triggered() -{ -} -void Editor::on_actionFind_Next_triggered() -{ -} - /** * Program main function. * argv[1] is mandatory and should be a path to the home directory of @@ -698,8 +539,7 @@ void Editor::on_actionFind_Next_triggered() int main(int argc, char **argv) { QApplication app(argc, argv); - editor = new Editor(argv[1], NULL); - editor->resize(600, 400); + Editor * editor = new Editor(argc, argv); editor->show(); return app.exec(); } diff --git a/src/edit/editor.h b/src/edit/editor.h index 5e253f3..7a3d85c 100644 --- a/src/edit/editor.h +++ b/src/edit/editor.h @@ -7,7 +7,6 @@ #include #include - #include "ui/editor.h" #define COMP_MODE 1 @@ -25,15 +24,6 @@ typedef struct { char name[255]; } CategoryEntry; -class My_Edit : public QTextEdit { - Q_OBJECT -public: - My_Edit(QWidget *parent = 0, const char *name = 0); - virtual void keyPressEvent(QKeyEvent *ev); -signals: - void cursorMove(); -}; - class Editor : public QMainWindow, private Ui::EditorWindow { Q_OBJECT public: @@ -41,39 +31,20 @@ public: QString gen_path; QString file_path; - Editor(char *hdir = 0, QWidget *parent = 0); + Editor(int argc, char **argv); ~Editor(); void compile(int mode); -public slots: - void load(); +public: void load(const char *fileName); - void save(); void save(const char *fileName); - void save_as(); - void create(); void props(); void print(); - void cmp(); - void gen(); - void comp_all(); void log_unit(); void log_prog(); - - void findText(); -// void find_next(); - //void gotoline(); - void updateline(); - -protected: - void resizeEvent(QResizeEvent *); - virtual void closeEvent (QCloseEvent * e); private: - My_Edit *e; - QTextEdit *msg; - QLabel *position; QString fname; QString find_text; bool sensitive; @@ -91,6 +62,17 @@ private slots: void on_actionClear_all_triggered(); void on_actionFind_triggered(); void on_actionFind_Next_triggered(); + void on_actionPreferences_triggered(); + + void on_actionCompile_triggered(); + void on_actionGen_triggered(); + void on_actionCompile_Gen_triggered(); + + void on_actionProgram_structure_triggered(); + void on_actionUnit_structure_triggered(); + + + void on_editor_cursorPositionChanged(); }; #endif // QWERTY_H diff --git a/src/edit/ui/editor.ui b/src/edit/ui/editor.ui index a669d79..cfb0376 100644 --- a/src/edit/ui/editor.ui +++ b/src/edit/ui/editor.ui @@ -30,14 +30,32 @@ - + + + + Monospace + + + + + + 0 + 0 + + + + + 0 + 0 + + 16777215 - 400 + 16777215 @@ -86,21 +104,31 @@ + + - + - Compile + Build + + + - + + + false + - Properties + Loglan + + - - + + @@ -185,6 +213,36 @@ Ctrl+L + + + Compile + + + + + Gen + + + + + Compile & Gen + + + + + Program structure + + + + + Unit structure + + + + + Preferences + + diff --git a/src/kernel/ui/kernelwindow.ui b/src/kernel/ui/kernelwindow.ui index 04e255d..615e076 100644 --- a/src/kernel/ui/kernelwindow.ui +++ b/src/kernel/ui/kernelwindow.ui @@ -162,6 +162,37 @@ Quit + + + Compile + + + + + Gen + + + + + Compile & Gen + + + + + true + + + Program structure + + + true + + + + + Unit structure + + -- 2.30.2