X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fhelp%2Fhelp.cpp;h=714589266c167de22ab98d6b6e9a653731118c1e;hb=6366db627acac20a841f420cd7548f1ce40ebb0f;hp=01ccd377b1fff7b60b9c2cf41cb892190665330e;hpb=b2bcd7aad84b87e82c1029ba9741953f559e317d;p=vlp.git 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(); }