VLP-28 Ported logedit to QT4. 3.1.2-a1
authorRafał Długołęcki <kontakt@dlugolecki.net.pl>
Fri, 25 Oct 2013 20:53:59 +0000 (22:53 +0200)
committerRafał Długołęcki <kontakt@dlugolecki.net.pl>
Fri, 25 Oct 2013 20:53:59 +0000 (22:53 +0200)
Makefile.am
configure.ac
src/edit/editor.cpp
src/edit/editor.h

index 235d759b925a1d357ba568b4dbb7a8b0a55465bd..01ea3163d962e278c6e60795b222e2412ddd61fa 100644 (file)
@@ -121,7 +121,8 @@ bin_logedit_HEADERS =\
        src/edit/editor.h
 
 src/edit/editor.moc.cpp: src/edit/editor.h
-       $(MOC) src/edit/editor.h -o src/edit/editor.moc.cpp
+       moc-qt4 src/edit/editor.h -o src/edit/editor.moc.cpp
+#      $(MOC) src/edit/editor.h -o src/edit/editor.moc.cpp
 
 
 clean-logedit-extra:
index 6a271715760721e8aebaa0ad0c13d6e4bb34ca3f..42d96b154528182473c2fa5e3ffefb1549cabfa8 100644 (file)
@@ -15,7 +15,7 @@ PKG_CHECK_MODULES([bin_loggraph], [qt-mt < 4.0])
 PKG_CHECK_MODULES([bin_lognet], [qt-mt < 4.0 libconfig])
 PKG_CHECK_MODULES([bin_logker], [qt-mt < 4.0 libconfig])
 #PKG_CHECK_MODULES([bin_logint], [qt-mt < 4.0])
-PKG_CHECK_MODULES([bin_logedit], [qt-mt < 4.0])
+PKG_CHECK_MODULES([bin_logedit], [QtCore >= 4.0 QtGui >= 4.0 ])
 PKG_CHECK_MODULES([bin_lgconfig], [qt-mt < 4.0 libconfig])
 PKG_CHECK_MODULES([bin_logcomp], [qt-mt < 4.0])
 PKG_CHECK_MODULES([bin_loghelp], [qt-mt < 4.0])
index 2e119deb2cb4acea4b941bd757cd745426496815..b51dcc96aa6b780349379b8189787417e22bab1b 100644 (file)
@@ -1,25 +1,16 @@
-#include <qapp.h>
-#include <qmenubar.h>
-#include <qpopmenu.h>
-#include <qlabel.h>
-#include <qlistbox.h>
-#include <qfile.h>
-#include <qfiledlg.h>
-#include <qfontmet.h>
-#include <qtooltip.h>
-#include <qfont.h>
-#include <qpixmap.h>
-#include <qmsgbox.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
-#include <qscrbar.h>
-#include <qpainter.h>
-#include <qcolor.h>
-#include <qpoint.h>
-#include <qtstream.h>
-#include <qchkbox.h>
-#include <qkeycode.h>
+#include <QtCore/QTextStream>
+#include <QtGui/QApplication>
+#include <QtGui/QMenuBar>
+#include <QtGui/QFileDialog>
+#include <QtGui/QColor>
+#include <QtGui/QPalette>
+#include <QtGui/QCloseEvent>
+#include <QtGui/QTextDocument>
+#include <QtGui/QMainWindow>
+#include <QtGui/QStatusBar>
+#include <QtGui/QCheckBox>
+#include <QtGui/QVBoxLayout>
 
 #include "editor.h"
 
@@ -44,11 +35,11 @@ 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
- * @param name If set, name is sent to the Qobject constructor, so widget is
+ * @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)
-       : QMultiLineEdit(parent, name)
+       : QTextEdit(parent)
 {
        parent = NULL;
        name = NULL;
@@ -59,7 +50,7 @@ My_Edit::My_Edit(QWidget *parent, const char *name)
  */
 void My_Edit::keyPressEvent(QKeyEvent *ev)
 {
-       QMultiLineEdit::keyPressEvent(ev);
+       QTextEdit::keyPressEvent(ev);
        emit cursorMove();
 }
 
@@ -80,40 +71,33 @@ void Editor::closeEvent(QCloseEvent * e) {
  * @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 , const char * name)
-       : QWidget(parent, name)
+Editor::Editor(char *hdir, QWidget * parent)
+       : QMainWindow(parent)
 {
-       QFont f1("Helvetica", 10, QFont::Bold);
-
        strcpy(HomeDir, hdir);
-       strcpy(find_text, "");
+       find_text = "";
        sensitive = FALSE;
-       m = new QMenuBar(this, "menu");
-       m->setFont(f1);
-       QPopupMenu * file = new QPopupMenu();
-       QPopupMenu * comp = new QPopupMenu();
-       QPopupMenu * loglan = new QPopupMenu();
-       QPopupMenu *medit = new QPopupMenu();
-
-       file->setFont(f1);
-       comp->setFont(f1);
-       loglan->setFont(f1);
-       medit->setFont(f1);
-       CHECK_PTR(file);
-       CHECK_PTR(comp);
-       m->insertItem("&File ", file);
-       m->insertItem("&Edit", medit);
-       m->insertItem("&Compile", this,SLOT(cmp()));
+       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 );*/
-       m->insertItem("&Properties", this, SLOT(props()));
 
-       file->insertItem("New ", this, SLOT(create()), CTRL + Key_N);
-       file->insertItem("Open ", this, SLOT(load()), CTRL + Key_O);
-       file->insertItem("Save ", this, SLOT(save()),CTRL + Key_S);
-       file->insertItem("Save as", this, SLOT(save_as()),CTRL + Key_A);
-       file->insertSeparator();
-       file->insertItem("Quit ", qApp, SLOT(quit()));
+       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);*/
@@ -122,33 +106,38 @@ Editor::Editor(char *hdir,QWidget * parent , const char * name)
        /* 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->insertItem("Copy ",e,SLOT(copy()),CTRL + Key_Insert);
-       medit->insertItem("Paste ",e,SLOT(paste()), SHIFT + Key_Insert);
-       medit->insertItem("Cut ",e,SLOT(cut()), CTRL + Key_Delete);
-       medit->insertItem("Clear All ",e,SLOT(clear()));
-       medit->insertSeparator();
-       medit->insertItem("Find ",this,SLOT(findText()), CTRL + Key_F);
-       medit->insertItem("Find Next ",this,SLOT(find_next()),CTRL + Key_L);
-
-       msg = new QMultiLineEdit( this, "messages" );
+       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);
-       compiler_path.sprintf("%s/%s",HomeDir,"compile/logcomp");
-       gen_path.sprintf("%s/%s",HomeDir,"compile/gen");
-       file_path.sprintf("%s",HomeDir);
 
-       QFont f2("Times", 14, QFont::Bold);
-       e->setFont(f1);
+       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);
-       QColorGroup grp(black, col, col.light(), col.dark(), col.dark(), black, col);
-
-       msg->setPalette(QPalette(grp, grp, grp));
-       position = new QLabel(this);
-       position->setFont(f2);
-       position->setFrameStyle(QFrame::NoFrame);
-       position->setAutoResize(TRUE);
-       resize(400, 300);
+       QPalette grp(Qt::black, col, col.lighter(), col.darker(), col.darker(), Qt::black, col);
+
+       msg->setPalette(grp);
+
+       position = new QLabel();
+       statusBar()->addPermanentWidget(position);
 }
 
 /**
@@ -167,8 +156,9 @@ void Editor::updateline()
        int cx;
        int cy;
 
-       e->getCursorPosition(&cx, &cy);
-       sprintf(pom," %d:%d ", cx, cy);
+       cx = e->textCursor().blockNumber();
+       cy = e->textCursor().columnNumber();
+       sprintf(pom,"%d:%d ", cx, cy);
        position->setText(pom);
 }
 
@@ -179,6 +169,8 @@ void Editor::updateline()
  */
 void Editor::resizeEvent(QResizeEvent *event)
 {
+/*
+TODO: Remove entire method?
        if (e && m) {
                e->setGeometry(0, m->height(), width(),
                                3 * (int)((height() - m->height()) / 4));
@@ -191,6 +183,7 @@ void Editor::resizeEvent(QResizeEvent *event)
                                                position->width(),
                                                position->height());
        }
+*/
 }
 
 /**
@@ -198,9 +191,9 @@ void Editor::resizeEvent(QResizeEvent *event)
  */
 void Editor::load()
 {
-       QString fn = QFileDialog::getOpenFileName(file_path.data(), "*.log");
+       QString fn = QFileDialog::getOpenFileName(this, "Load file", file_path, "*.log");
        if (!fn.isEmpty())
-               load(fn);
+               load(fn.toAscii().data());
 }
 
 /**
@@ -212,22 +205,26 @@ void Editor::load(const char *fileName)
        fname.sprintf("%s", fileName);
 
        QFile f(fileName);
-       if (!f.open(IO_ReadOnly))
+       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.eof()) {
+       while (!t.atEnd()) {
                QString s = t.readLine();
                e->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();
-       setCaption(fileName);
+       setWindowTitle(fileName);
 }
 
 /**
@@ -238,16 +235,16 @@ void Editor::load(const char *fileName)
 void Editor::save()
 {
        if (fname.isEmpty()) {
-               QString fn = QFileDialog::getSaveFileName(file_path.data(),
-                                                               "*.log");
+               QString fn = QFileDialog::getSaveFileName(this, "Save file", 
+                                                       file_path, "*.log");
                if (!fn.isEmpty()) {
-                       fname.sprintf("%s",fn.data());
-                       save( fn );
+                       fname.sprintf("%s", fn.toAscii().data());
+                       save(fn.toAscii().data());
                }
        } else {
-               save(fname);
+               save(fname.toAscii().data());
        }
-       setCaption(fname);
+       setWindowTitle(fname);
 }
 
 /**
@@ -257,12 +254,13 @@ void Editor::save()
  */
 void Editor::save_as()
 {
-       QString fn = QFileDialog::getSaveFileName(file_path.data(), "*.log");
+       QString fn = QFileDialog::getSaveFileName(this, "Save file as",
+                                                       file_path, "*.log");
        if (!fn.isEmpty()) {
-               fname.sprintf("%s", fn.data());
-               save(fn);
+               fname.sprintf("%s", fn.toAscii().data());
+               save(fn.toAscii().data());
        }
-       setCaption(fname);
+       setWindowTitle(fname);
 }
 
 /**
@@ -272,10 +270,10 @@ void Editor::save_as()
 void Editor::save(const char *fileName)
 {
        QFile f(fileName);
-       if (!f.open(IO_WriteOnly))
+       if (!f.open(QIODevice::WriteOnly | QIODevice::Text))
                return;
        f.reset();
-       f.writeBlock(e->text().data(), e->text().length());
+       f.write(e->toPlainText().toAscii().data(), e->toPlainText().length());
        f.close();
 }
 
@@ -337,8 +335,9 @@ void Editor::comp_all()
 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();
@@ -346,38 +345,42 @@ void Editor::compile(int mode)
        /*i = fname.find('.');*/
        /* if (i>=0) {*/
 
-       QString fn = fname.data();
-
        /*  fn.truncate(i);*/
        switch(mode) {
        case COMP_MODE:
-               sprintf(cmd, "%s %s > comp_data!", compiler_path.data(),
-                                                               fname.data());
+               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.data(), fn.data());
+               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.data(),
-                                                               fn.data());
+               sprintf(cmd, "%s %s > comp_data!", compiler_path.toAscii().data(),
+                                                       fname.toAscii().data());
                system(cmd);
-               sprintf(cmd, "%s %s >> comp_data!", gen_path.data(), fn.data());
+               sprintf(cmd, "%s %s >> comp_data!", gen_path.toAscii().data(),
+                                                       fname.toAscii().data());
        break;
        }
 
        system(cmd);
        QFile f("comp_data!");
-       if (!f.open(IO_ReadOnly))
+       if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
                return;
 
        QTextStream t(&f);
-       while (!t.eof()) {
+       while (!t.atEnd()) {
                QString s = t.readLine();
                msg->append(s);
        }
        f.close();
+
        msg->setReadOnly(TRUE);
+
+/*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!");
        /*}*/
@@ -388,27 +391,25 @@ void Editor::compile(int mode)
  */
 void Editor::props()
 {
-       QDialog dlg(this, "Properties", TRUE);
+       QDialog dlg(this, Qt::Dialog);
 
        QLineEdit *files;
-       files = new QLineEdit(&dlg, "f_path");
+       files = new QLineEdit(&dlg);
        files->setGeometry(130, 20, 250, 30);
-       files->setText(file_path.data());
+       files->setText(file_path);
        files->setMaxLength(32767);
        files->setEchoMode(QLineEdit::Normal);
        files->setFrame(TRUE);
 
        QLabel *tmpQLabel;
-       tmpQLabel = new QLabel(&dlg, "Label_1");
+       tmpQLabel = new QLabel("Path to files:", &dlg);
        tmpQLabel->setGeometry(10, 20, 100, 30);
-       tmpQLabel->setText("Path to files:");
-       tmpQLabel->setAlignment(289);
+       tmpQLabel->setAlignment(Qt::AlignLeft);
        tmpQLabel->setMargin(-1);
 
-       tmpQLabel = new QLabel(&dlg, "Label_2");
+       tmpQLabel = new QLabel("Path to compiler:", &dlg);
        tmpQLabel->setGeometry(10, 60, 100, 30);
-       tmpQLabel->setText("Path to compiler:");
-       tmpQLabel->setAlignment(289);
+       tmpQLabel->setAlignment(Qt::AlignLeft);
        tmpQLabel->setMargin(-1);
 
        /*
@@ -420,9 +421,8 @@ void Editor::props()
        */
 
        QLineEdit *compp;
-       compp = new QLineEdit(&dlg, "l_path");
+       compp = new QLineEdit(compiler_path, &dlg);
        compp->setGeometry(130, 60, 250, 30);
-       compp->setText(compiler_path.data());
        compp->setMaxLength(32767);
        compp->setEchoMode(QLineEdit::Normal);
        compp->setFrame(TRUE);
@@ -438,25 +438,27 @@ void Editor::props()
        */
 
        QPushButton* tmpQPushButton;
-       tmpQPushButton = new QPushButton(&dlg, "OkBtn");
+       tmpQPushButton = new QPushButton("Ok", &dlg);
        tmpQPushButton->setGeometry(90, 100, 70, 30);
-       tmpQPushButton->setText("Ok");
        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(&dlg, "CancelBtn");
+       tmpQPushButton = new QPushButton("Cancel", &dlg);
        tmpQPushButton->setGeometry(180, 100, 70, 30);
-       tmpQPushButton->setText("Cancel");
        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()) {
-               compiler_path.sprintf("%s", compp->text().ascii());
+               compiler_path.sprintf("%s", compp->text().toAscii().data());
                /* gen_path.sprintf("%s",genp->text()); */
-               file_path.sprintf("%s",files->text().ascii());
+               file_path.sprintf("%s", files->text().toAscii().data());
        };
 }
 
@@ -465,8 +467,13 @@ void Editor::props()
  */
 void Editor::log_unit()
 {
+       /*
+       Code commented during Qt4 migration.
+       Code is not used, so there is no rush with this...
+       */
+       /*
        QString txt;
-       QDialog dlg(this, "unit", TRUE);
+       QDialog dlg(this, Qt::Dialog);
        int cx, cy, i;
        char uname[255];
 
@@ -519,6 +526,7 @@ void Editor::log_unit()
                        uname, lst.text(lst.currentItem()).ascii(), uname);
                e->insertAt(txt, cx, cy);
        }
+       */
 }
 
 /**
@@ -526,6 +534,11 @@ void Editor::log_unit()
  */
 void Editor::log_prog()
 {
+       /*
+       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;
@@ -566,6 +579,7 @@ void Editor::log_prog()
                txt.sprintf("PROGRAM %s\n\nBEGIN\n\nEND ", uname);
                e->insertAt(txt, cx, cy);
        }
+       */
 }
 
 /**
@@ -575,63 +589,50 @@ void Editor::log_prog()
  */
 void Editor::findText()
 {
-       QDialog dlg(this, "", TRUE);
+       QDialog dlg(this, Qt::Dialog);
        QString *txt;
        int res, line, pom;
 
        QLineEdit *tmpQLineEdit;
-       tmpQLineEdit = new QLineEdit(&dlg, "LineEdit_1");
+       tmpQLineEdit = new QLineEdit("", &dlg);
        tmpQLineEdit->setGeometry(60, 10, 180, 30);
-       tmpQLineEdit->setText("");
 
        QLabel *tmpQLabel;
-       tmpQLabel = new QLabel(&dlg, "Label_1");
+       tmpQLabel = new QLabel(&dlg);
        tmpQLabel->setGeometry(10, 10, 50, 30);
 
-       QFont font("helvetica", 12, 75, 0);
-       font.setStyleHint((QFont::StyleHint)0);
-       //font.setCharSet((QFont::CharSet)0);
-       tmpQLabel->setFont(font);
-
        tmpQLabel->setText("Text:");
 
        QCheckBox *tmpQRadioButton;
-       tmpQRadioButton = new QCheckBox(&dlg, "RadioButton_1");
+       tmpQRadioButton = new QCheckBox("Case sensitive", &dlg);
        tmpQRadioButton->setGeometry(70, 50, 150, 30);
-       tmpQRadioButton->setText("Case sensitive");
        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(&dlg, "PushButton_1");
+       okbtn = new QPushButton("Find", &dlg);
        okbtn->setGeometry(260, 10, 100, 30);
-       okbtn->setText("Find");
        okbtn->setDefault(TRUE);
        connect(okbtn,SIGNAL(clicked()), &dlg, SLOT(accept()));
 
-       cbtn = new QPushButton(&dlg, "PushButton_2");
+       cbtn = new QPushButton("Close", &dlg);
        cbtn->setGeometry(260, 50, 100, 30);
-       cbtn->setText("Close");
        connect(cbtn, SIGNAL(clicked()), &dlg, SLOT(reject()));
        dlg.resize(380, 90);
 
        if (dlg.exec()) {
-               e->getCursorPosition(&pom, &res);
                sensitive = tmpQRadioButton->isChecked();
-               for (line = pom + 1; line < e->numLines(); line++) {
-                       txt = new QString(e->textLine(line));
-                       if (tmpQRadioButton->isChecked())
-                               res = txt->find(tmpQLineEdit->text(), 0, TRUE);
-                       else
-                               res = txt->find(tmpQLineEdit->text(), 0, FALSE);
-
-                       delete txt;
-                       if (res >= 0) {
-                               e->setCursorPosition(line, 1);
-                               strcpy(find_text, tmpQLineEdit->text());
-                               break;
-                       }
+               find_text = tmpQLineEdit->text();
+               
+               QTextDocument::FindFlags flags = 0;
+               
+               if (sensitive) {
+                       flags |= QTextDocument::FindCaseSensitively;
                }
+               e->find(find_text, flags);
        }
 }
 
@@ -642,22 +643,13 @@ void Editor::findText()
  */
 void Editor::find_next()
 {
-       int pom,res,line;
-       QString *txt;
-
-       e->getCursorPosition(&pom, &res);
-       for(line = pom + 1; line < e->numLines(); line++) {
-               txt = new QString(e->textLine(line));
-               if (sensitive)
-                       res=txt->find(find_text, 0, TRUE);
-               else
-                       res=txt->find(find_text, 0, FALSE);
-
-               delete txt;
-               if (res >= 0) {
-                       e->setCursorPosition(line, 1);
-                       break;
+       if (!find_text.isEmpty()) {
+               QTextDocument::FindFlags flags = 0;
+               
+               if (sensitive) {
+                       flags |= QTextDocument::FindCaseSensitively;
                }
+               e->find(find_text, flags);
        }
 }
 
@@ -671,9 +663,7 @@ void Editor::find_next()
 int main(int argc, char **argv)
 {
        QApplication app(argc, argv);
-       //app.setStyle(WindowsStyle);
-       editor = new Editor(argv[1]);
-       app.setMainWidget(editor);
+       editor = new Editor(argv[1], NULL);
        editor->resize(600, 400);
        editor->show();
        return app.exec();
index 2a063ad55f1efa9955b5b58d129b085bfbbbd811..5c8fa502ac99929af98fc7e8e19990c3b137d18d 100644 (file)
@@ -1,17 +1,11 @@
 #ifndef QWERTY_H
 #define QWERTY_H
 
-#include <qwidget.h>
-#include <qmenubar.h>
-#include <qmlined.h>
-#include <qlist.h>
-#include <qstrlist.h>
-#include <qframe.h>
-#include <qmlined.h>
-#include <qlined.h>
-#include <qpushbt.h>
-#include <qcombo.h>
-#include <qlabel.h>
+#include <QtGui/QTextEdit>
+#include <QtGui/QMainWindow>
+#include <QtGui/QLineEdit>
+#include <QtGui/QPushButton>
+#include <QtGui/QLabel>
 
 
 #define COMP_MODE      1
@@ -25,11 +19,11 @@ typedef struct {
 
 typedef struct {
        QList<FuncEntry> dictionary;
-       QStrList names;
+       QStringList names;
        char name[255];
 } CategoryEntry;
 
-class My_Edit : public QMultiLineEdit {
+class My_Edit : public QTextEdit {
        Q_OBJECT
 public:
        My_Edit(QWidget *parent = 0, const char *name = 0);
@@ -38,14 +32,14 @@ signals:
        void cursorMove();
 };
 
-class Editor : public QWidget {
+class Editor : public QMainWindow {
        Q_OBJECT
 public:
        QString compiler_path;
        QString gen_path;
        QString file_path;
 
-       Editor(char *hdir = 0, QWidget *parent = 0, const char *name = 0);
+       Editor(char *hdir = 0, QWidget *parent = 0);
        ~Editor();
 
        void compile(int mode);
@@ -75,12 +69,11 @@ protected:
        void resizeEvent(QResizeEvent *);
        virtual void closeEvent (QCloseEvent * e);
 private:
-       QMenuBar *m;
        My_Edit *e;
-       QMultiLineEdit *msg;
+       QTextEdit *msg;
        QLabel *position;
        QString fname;
-       char find_text[256];
+       QString find_text;
        bool sensitive;
        char HomeDir[255];
 };