From: Rafał Długołęcki Date: Wed, 20 Jan 2016 23:19:40 +0000 (+0100) Subject: Small changes in loggraph porting to Qt4 X-Git-Tag: 3.4-b1~60 X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=6366db627acac20a841f420cd7548f1ce40ebb0f;p=vlp.git Small changes in loggraph porting to Qt4 --- diff --git a/.gitignore b/.gitignore index e69de29..912c60b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,14 @@ +*.o +.deps +Doxyfile +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +doc/doxygen +doc/doxygen_sqlite3.db +doc/html +doc/latex +doc/man +doxyfile.stamp +.dirstamp diff --git a/Makefile.am b/Makefile.am index c1005c7..2a77e83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,16 +18,17 @@ EXTRA_DIST = \ doc/CodingStyle \ doc/vlp.cfg.sample -# bin/loggraph +# bin/loggraph \ +# bin/loghelp + bin_PROGRAMS = \ + bin/loggraph \ bin/lognet \ bin/logker \ bin/logint \ bin/logedit \ bin/lgconfig \ bin/logcomp -# \ -# bin/loghelp BUILT_SOURCES = \ src/graph/loggraph.moc \ diff --git a/src/graph/loggraph.cpp b/src/graph/loggraph.cpp index 461669f..7528284 100644 --- a/src/graph/loggraph.cpp +++ b/src/graph/loggraph.cpp @@ -7,20 +7,21 @@ //#include */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -28,14 +29,14 @@ #include "comm.h" #include "socu.h" #include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +// #include +#include #define MAXWIDTH 640 #define MAXHEIGHT 480 @@ -55,7 +56,7 @@ public: }; }; -class VGR : public QFrame { +class VGR : public QMainWindow { Q_OBJECT public: VGR(char*); @@ -187,7 +188,7 @@ void VGR::MakeColors() * Construct the DrawView with buttons. */ VGR::VGR(char *sockname) - :QFrame() + :QMainWindow() { QPixmap mp; struct sockaddr_un svr; @@ -204,7 +205,7 @@ VGR::VGR(char *sockname) MakeColors(); setCaption("graphic resource"); - setBackgroundColor(white); +// setBackgroundColor(white); canvas = new QPixmap(640, 480); canvas->fill(backgroundColor()); @@ -280,7 +281,7 @@ VGR::VGR(char *sockname) setMaximumSize(MAXWIDTH + 16, MAXHEIGHT + 16); setUpdatesEnabled(FALSE); -}; +} VGR::~VGR() { @@ -426,61 +427,61 @@ void VGR::keyPressEvent(QKeyEvent *ev) *pom=ev->ascii(); if (*pom==0) { switch(ev->key()) { - case Key_F1: + case Qt::Key_F1: *pom = -10; break; - case Key_F2: + case Qt::Key_F2: *pom = -11; break; - case Key_F3: + case Qt::Key_F3: *pom = -12; break; - case Key_F4: + case Qt::Key_F4: *pom = -13; break; - case Key_F5: + case Qt::Key_F5: *pom = -14; break; - case Key_F6: + case Qt::Key_F6: *pom = -15; break; - case Key_F7: + case Qt::Key_F7: *pom = -16; break; - case Key_F8: + case Qt::Key_F8: *pom = -17; break; - case Key_F9: + case Qt::Key_F9: *pom = -18; break; - case Key_F10: + case Qt::Key_F10: *pom = -19; break; - case Key_Insert: + case Qt::Key_Insert: *pom = -20; break; - case Key_Home: + case Qt::Key_Home: *pom = -21; break; - case Key_End: + case Qt::Key_End: *pom = -22; break; - case Key_PageUp: + case Qt::Key_PageUp: *pom = -23; break; - case Key_PageDown: + case Qt::Key_PageDown: *pom = -24; break; - case Key_Left: + case Qt::Key_Left: *pom = -25; break; - case Key_Right: + case Qt::Key_Right: *pom = -26; break; - case Key_Up: + case Qt::Key_Up: *pom = -27; break; - case Key_Down: + case Qt::Key_Down: *pom = -28; break; }/* switch */ @@ -660,7 +661,7 @@ void VGR::TextXY(int x, int y, char *s) p.begin(canvas); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(x, y + fm.height(), s, strlen(s)); p.end(); @@ -669,7 +670,7 @@ void VGR::TextXY(int x, int y, char *s) p.begin(this); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(x - ox, y - oy + fm.height(), s, strlen(s)); p.end(); @@ -687,7 +688,7 @@ void VGR::CharXY(int x, int y, char a) p.begin(canvas); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(x , y + fm.height(), s, strlen(s)); p.end(); @@ -695,7 +696,7 @@ void VGR::CharXY(int x, int y, char a) p.begin(this); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(x - ox, y - oy + fm.height(), s, strlen(s)); p.end(); @@ -712,7 +713,7 @@ void VGR::IntXY(int x, int y, int val) p.begin(canvas); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(x, y + fm.height(), s, strlen(s)); p.end(); @@ -720,7 +721,7 @@ void VGR::IntXY(int x, int y, int val) p.begin(this); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(x - ox, y - oy + fm.height(), s, strlen(s)); p.end(); @@ -734,7 +735,7 @@ void VGR::WriteText(char *s) p.begin(canvas); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s)); p.end(); @@ -742,7 +743,7 @@ void VGR::WriteText(char *s) p.begin(this); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s, strlen(s)); @@ -771,7 +772,7 @@ void VGR::WriteChar(char a) p.begin(canvas); p.setPen(*lcolors[gfcol]); p.setBackgroundColor(*lcolors[gbcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(gx, gy + fm.height(), s, strlen(s)); p.end(); @@ -779,7 +780,7 @@ void VGR::WriteChar(char a) p.begin(this); p.setPen(*lcolors[gfcol]); p.setBackgroundColor(*lcolors[gbcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(gx - ox, gy - oy + fm.height(), s, strlen(s)); p.end(); @@ -796,7 +797,7 @@ void VGR::WriteChar(char a) p.begin(canvas); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s)); @@ -805,7 +806,7 @@ void VGR::WriteChar(char a) p.begin(this); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s, strlen(s)); @@ -876,7 +877,7 @@ void VGR::PutChar(char a) p.begin(canvas); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(tx * fm.maxWidth(), (ty + 1) * fm.height(), s, strlen(s)); p.end(); @@ -884,7 +885,7 @@ void VGR::PutChar(char a) p.begin(this); p.setPen(*lcolors[fcol]); p.setBackgroundColor(*lcolors[bcol]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(tx * fm.maxWidth() - ox, (ty + 1) * fm.height() - oy, s, strlen(s)); @@ -978,7 +979,7 @@ void VGR::Outstring(int x, int y, char *s, int b, int f) p.begin(canvas); p.setPen(*lcolors[f]); p.setBackgroundColor(*lcolors[b]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.setFont(*prv_font); p.drawText(x, y + fm.height(), s, strlen(s)); p.end(); @@ -987,7 +988,7 @@ void VGR::Outstring(int x, int y, char *s, int b, int f) p.setPen(*lcolors[f]); p.setFont(*prv_font); p.setBackgroundColor(*lcolors[b]); - p.setBackgroundMode(OpaqueMode); + p.setBackgroundMode(Qt::OpaqueMode); p.drawText(x - ox, y - oy + fm.height(), s, strlen(s)); p.end(); @@ -1311,7 +1312,7 @@ int main(int argc, char **argv) { QApplication app(argc, argv); VGR gs(argv[1]); - app.setMainWidget(&gs); +// app.setMainWidget(&gs); gs.show(); return app.exec(); } diff --git a/src/help/help.cpp b/src/help/help.cpp index 01ccd37..7145892 100644 --- a/src/help/help.cpp +++ b/src/help/help.cpp @@ -1,32 +1,31 @@ #include -#include +#include #include -#include -#include -#include -#include +#include +// #include +#include +#include #include -#include -#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include -#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define TAG_TEXT 0 @@ -73,7 +72,7 @@ public: class HTMLAnalyzer { public: - QList tags; + QList tags; bool verbatim; HTMLAnalyzer(); @@ -106,7 +105,7 @@ bool HTMLAnalyzer::LoadFile(char *fname) QTextStream fs(&f); - while (!fs.eof()) { + while (!fs.atEnd()) { poms = fs.readLine(); while (poms.length()>0) { i = poms.find('<'); @@ -119,8 +118,7 @@ bool HTMLAnalyzer::LoadFile(char *fname) poms1 = poms1.simplifyWhiteSpace(); } - sprintf(pomt->tag_text, " %s", - poms1.data()); + sprintf(pomt->tag_text, " %s", poms1.toStdString().c_str()); tags.append(pomt); } poms = poms.right(poms.length() - i); @@ -140,7 +138,7 @@ bool HTMLAnalyzer::LoadFile(char *fname) if (!verbatim) poms=poms.simplifyWhiteSpace(); - sprintf(pomt->tag_text, " %s", poms.data()); + sprintf(pomt->tag_text, " %s", poms.toStdString().c_str()); tags.append(pomt); break; } @@ -164,42 +162,42 @@ void HTMLAnalyzer::AnalyzeTag(QString *t) *t = t->simplifyWhiteSpace(); pom = new Tag; - if ((t->data()[0] != 'A') && (t->data()[0] != 'a')) { + if ((t->toStdString().c_str()[0] != 'A') && (t->toStdString().c_str()[0] != 'a')) { *t = t->upper(); - if (strcmp(t->data(), "B") ==0 ) { + if (strcmp(t->toStdString().c_str(), "B") ==0 ) { pom->tag_type = TAG_BOLD_ON; } - else if (strcmp(t->data(), "/B") == 0) { + else if (strcmp(t->toStdString().c_str(), "/B") == 0) { pom->tag_type = TAG_BOLD_OFF; } - else if (strcmp(t->data(), "I") == 0) { + else if (strcmp(t->toStdString().c_str(), "I") == 0) { pom->tag_type = TAG_ITALIC_ON; } - else if (strcmp(t->data(), "/I") == 0) { + else if (strcmp(t->toStdString().c_str(), "/I") == 0) { pom->tag_type = TAG_ITALIC_OFF; } - else if (strcmp(t->data(), "BR") == 0) { + else if (strcmp(t->toStdString().c_str(), "BR") == 0) { pom->tag_type = TAG_BREAK; } - else if (strcmp(t->data(), "HR") == 0) { + else if (strcmp(t->toStdString().c_str(), "HR") == 0) { pom->tag_type = TAG_LINE; } - else if (strcmp(t->data(), "/A") == 0) { + else if (strcmp(t->toStdString().c_str(), "/A") == 0) { pom->tag_type = TAG_LINK_END; } - else if (strcmp(t->data(), "UL") == 0) { + else if (strcmp(t->toStdString().c_str(), "UL") == 0) { pom->tag_type = TAG_LIST_ON; } - else if (strcmp(t->data(), "/UL") == 0) { + else if (strcmp(t->toStdString().c_str(), "/UL") == 0) { pom->tag_type = TAG_LIST_OFF; } - else if (strcmp(t->data(), "LI") == 0) { + else if (strcmp(t->toStdString().c_str(), "LI") == 0) { pom->tag_type = TAG_LIST_ITEM; } - else if (strcmp(t->data(), "PRE") == 0) { + else if (strcmp(t->toStdString().c_str(), "PRE") == 0) { verbatim=TRUE; } - else if (strcmp(t->data(),"/PRE") == 0) { + else if (strcmp(t->toStdString().c_str(),"/PRE") == 0) { verbatim=FALSE; } } else { @@ -215,17 +213,17 @@ void HTMLAnalyzer::AnalyzeTag(QString *t) poms1 = t->right(t->length() - i - 1); poms1 = poms1.simplifyWhiteSpace(); - if (strcmp(poms.data(),"HREF") == 0) { + if (poms == "HREF") { pom->tag_type = TAG_LINK; - strcpy(pom->tag_link,poms1.data()); + strcpy(pom->tag_link,poms1.toStdString().c_str()); } - else if (strcmp(poms.data(), "NAME") == 0) { + else if (poms == "NAME") { pom->tag_type = TAG_ANCHOR; - if (poms1.data()[0] == '"') + if (poms1[0] == '"') poms1=poms1.right(poms1.length() - 1); - if (poms1.data()[poms1.length() - 1] == '"') + if (poms1[poms1.length() - 1] == '"') poms1=poms1.left(poms1.length() - 1); - strcpy(pom->tag_label, poms1.data()); + strcpy(pom->tag_label, poms1.toStdString().c_str()); } } } @@ -239,7 +237,7 @@ void HTMLAnalyzer::DumpList() while (pom != NULL) { fprintf(stderr, "%s:%s,%s,%s\n", names[pom->tag_type], pom->tag_text, pom->tag_link, pom->tag_label); - pom=tags.next(); + pom=tags.takeFirst(); } } @@ -252,20 +250,20 @@ void HTMLAnalyzer::PackLinks() while (pom!=NULL) { if ((pom->tag_type == TAG_LINK) || (pom->tag_type == TAG_ANCHOR)) { - pom1 = tags.next(); + pom1 = tags.takeFirst(); strcpy(s, ""); while ((pom1 != NULL) && (pom1->tag_type != TAG_LINK_END)) { if (pom1->tag_type == TAG_TEXT) strcat(s,pom1->tag_text); - tags.remove(pom1); + tags.removeOne(pom1); pom1 = tags.current(); } strcpy(pom->tag_text,s); - tags.remove(pom1); + tags.removeOne(pom1); pom = tags.current(); } else { - pom = tags.next(); + pom = tags.takeFirst(); } } } @@ -281,7 +279,7 @@ Tag *HTMLAnalyzer::CheckTag(int x,int y) (y >= pom->y) && (y <= pom->y + pom->h)) { return pom; } - pom=tags.next(); + pom=tags.takeFirst(); } return NULL; } @@ -295,13 +293,13 @@ Tag *HTMLAnalyzer::FindAnchor(char *name) (strcmp(pom->tag_label, name) == 0)) { return(pom); } - pom=tags.next(); + pom=tags.takeFirst(); } return pom; } /********************************/ -class QHTML: public QFrame { +class QHTML: public QMainWindow { Q_OBJECT public: QScrollBar *vscroll; @@ -332,7 +330,6 @@ QApplication *app; QHTML::QHTML(char *d) { - QPopupMenu *pp; char s[255]; QFont f("Helvetica", 12, QFont::Bold); @@ -343,19 +340,18 @@ QHTML::QHTML(char *d) strcpy(homedir, d); actual_font = normal; - bar = new QMenuBar(this); - pp = new QPopupMenu; - pp->insertItem("Index", this, SLOT(contents())); - pp->insertItem("User Guide", this, SLOT(user_guide())); - pp->insertItem("Language reference", this, SLOT(lang_guide())); - pp->setFont(f); - /*pp->setStyle(WindowsStyle);*/ - bar->insertItem("File", this, SLOT(load())); - bar->insertItem("Contents", pp); - bar->insertItem("Quit", app, SLOT(quit())); - bar->setFont(f); - setCaption("LOGLAN Help"); - setBackgroundColor(gray); + + setWindowTitle("LOGLAN Help"); + + QMenu * contentsMenu = NULL; + menuBar()->addAction("File", this, SLOT(load())); + contentsMenu = menuBar()->addMenu("&Contents"); + contentsMenu->addAction("Index", this, SLOT(contents())); + contentsMenu->addAction("User Guide", this, SLOT(user_guide())); + contentsMenu->addAction("Language reference", this, SLOT(lang_guide())); + + menuBar()->addAction("Quit", app, SLOT(quit())); + analyzer = new HTMLAnalyzer; map = new QPixmap(500, PIX_HEIGHT); map->fill(backgroundColor()); @@ -364,12 +360,10 @@ QHTML::QHTML(char *d) oy = 0; lstep = 10; pstep = height() - bar->height(); - vscroll = new QScrollBar(0, PIX_HEIGHT, lstep, pstep, 0, - QScrollBar::Vertical, this); + vscroll = new QScrollBar(0, PIX_HEIGHT, lstep, pstep, 0, QScrollBar::Vertical, this); vscroll->setTracking(TRUE); - vscroll->setGeometry(width() - 16, bar->height(), 16, - height()-bar->height()); - connect(vscroll, SIGNAL(valueChanged(int)), this, SLOT(vscrolled(int))); + vscroll->setGeometry(width() - 16, bar->height(), 16, height()-bar->height()); + connect(vscroll, SIGNAL(valueChanged(int)), this, SLOT(vscrolled(int))); sprintf(s, "%s/index.html", homedir); analyzer->LoadFile(s); analyzer->PackLinks(); @@ -442,18 +436,18 @@ void QHTML::mousePressEvent(QMouseEvent *ev) pom = analyzer->CheckTag(ev->x(), ev->y() + oy); if (pom != NULL) { poms.sprintf(pom->tag_link); - if (poms.data()[0] == '"') + if (poms[0] == '"') poms = poms.right(poms.length() - 1); - if (poms.data()[poms.length() - 1] == '"') + if (poms[poms.length() - 1] == '"') poms=poms.left(poms.length() - 1); - if (poms.data()[0] == '#') { + if (poms[0] == '#') { poms = poms.right(poms.length() - 1); pom1 = analyzer->FindAnchor((char*)poms.ascii()); if (pom1 != NULL) { vscroll->setValue(pom1->y); } } else { - sprintf(ss, "%s/%s", homedir, poms.data()); + sprintf(ss, "%s/%s", homedir, poms.toStdString().c_str()); analyzer->LoadFile(ss); analyzer->PackLinks(); DrawList(); @@ -582,7 +576,7 @@ void QHTML::DrawList() cy = cy + p.fontMetrics().height(); break; } - pom = analyzer->tags.next(); + pom = analyzer->tags.takeFirst(); } p.end(); repaint(); @@ -602,7 +596,7 @@ int main( int argc, char **argv ) ps.sprintf("."); QHTML cfg((char*)ps.ascii()); //app->setStyle(WindowsStyle); - app->setMainWidget(&cfg); +// app->setMainWidget(&cfg); cfg.show(); return app->exec(); } diff --git a/src/lgconfig/lgconfig.cpp b/src/lgconfig/lgconfig.cpp index 70a8bbc..2ef36ed 100644 --- a/src/lgconfig/lgconfig.cpp +++ b/src/lgconfig/lgconfig.cpp @@ -153,8 +153,6 @@ void QInstall::AddNode() QComboBox* tmpQComboBox; tmpQComboBox = new QComboBox(&dlg); tmpQComboBox->setGeometry(130, 130, 100, 30); -// tmpQComboBox->setSizeLimit(2); -// tmpQComboBox->setAutoResize(FALSE); tmpQComboBox->insertItem(0, "Explicit"); tmpQLabel = new QLabel(&dlg); @@ -334,8 +332,6 @@ int main(int argc, char **argv) { app = new QApplication(argc,argv); QInstall cfg; - //app->setStyle(WindowsStyle); -// app->setMainWidget(&cfg); cfg.show(); return app->exec(); }