X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fedit%2Feditor.cpp;fp=src%2Fedit%2Feditor.cpp;h=f6808a431810f29e83b2407ecbdd94a2b7e60e1f;hb=fea671e0abd75fbbd90946d759e45e1b1a4d3444;hp=bf1360cf1349848715d8c8b9c0d205d7db898de1;hpb=f99b2f0701a9a0603f29f9c790326ec2a8fe5153;p=vlp.git diff --git a/src/edit/editor.cpp b/src/edit/editor.cpp index bf1360c..f6808a4 100644 --- a/src/edit/editor.cpp +++ b/src/edit/editor.cpp @@ -17,8 +17,6 @@ #define TYPENUM 5 -Editor *editor; - /** * @attention Currently not in use */ @@ -36,14 +34,10 @@ char *UnitTypes[TYPENUM] = { * @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 - * @deprecated @param name 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) +My_Edit::My_Edit(QWidget *parent = NULL) : QTextEdit(parent) { - parent = NULL; - name = NULL; } /** @@ -69,8 +63,6 @@ void Editor::closeEvent(QCloseEvent * e) { * @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) */ Editor::Editor(char *hdir, QWidget * parent) : QMainWindow(parent) @@ -80,28 +72,10 @@ Editor::Editor(char *hdir, QWidget * parent) strcpy(HomeDir, hdir); 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(); connect(actionQuit, SIGNAL(triggered()), this, SLOT(close())); -// file->addAction("Quit ", this, SLOT(close())); /* comp->insertItem("Compile ", this, SLOT(cmp()), CTRL + Key_C);*/ /* comp->insertItem("Gen ", this, SLOT(gen()), CTRL + Key_G);*/ @@ -110,40 +84,18 @@ Editor::Editor(char *hdir, QWidget * parent) /* 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())); + connect(actionUndo, SIGNAL(triggered()), e, SLOT(undo())); + connect(actionRedo, SIGNAL(triggered()), e, SLOT(redo())); connect(actionCopy, SIGNAL(triggered()), e, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), e, SLOT(paste())); connect(actionCut, SIGNAL(triggered()), e, SLOT(cut())); connect(actionClear_all, SIGNAL(triggered()), e, SLOT(clear())); -// 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); } @@ -170,30 +122,6 @@ void Editor::updateline() position->setText(pom); } -/** - * Event invoked on resizing editor application window. - * @copydoc QWidget::resizeEvent(QResizeEvent*) - * @param event Currently does nothing - */ -void Editor::resizeEvent(QResizeEvent *event) -{ -/* -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()); - } -*/ -} - /** * Displays additional window */ @@ -671,9 +599,10 @@ 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->show(); + + Editor editor(argv[1], NULL); + editor.show(); + return app.exec(); }