Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

helpbrowser.cpp

Go to the documentation of this file.
00001 /*
00002  Modular Psi - A graph tracker of the Parapsychologcal scientific development
00003  Copyright (C) 2005 Leonardo Stern
00004 
00005  This program is free software; you can redistribute it and/or modify it under
00006  the terms of the Common Public License Version 1.0 or (at your option) any later version.
00007 
00008  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
00009  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00010  See the Common Public License for more details.
00011 
00012  You should have received a copy of the Common Public License along with this program;
00013 */
00014 
00015 #include <qapplication.h>
00016 #include <qlayout.h>
00017 #include <qpushbutton.h>
00018 #include <qtextbrowser.h>
00019 #include "helpbrowser.hpp"
00020 
00021 HelpBrowser::HelpBrowser(const QString &path, const QString &page,
00022 QWidget *parent, const char *name)
00023         : QWidget(parent, name, WGroupLeader | WDestructiveClose)
00024 {
00025         textBrowser = new QTextBrowser(this);
00026         homeButton = new QPushButton(tr("&Home"), this);
00027         backButton = new QPushButton(tr("&Back"), this);
00028         closeButton = new QPushButton(tr("&Close"), this);
00029         closeButton->setAccel(tr("Esc"));
00030         QVBoxLayout *mainLayout = new QVBoxLayout(this);
00031         QHBoxLayout *buttonLayout = new QHBoxLayout(mainLayout);
00032         buttonLayout->addWidget(homeButton);
00033         buttonLayout->addWidget(backButton);
00034         buttonLayout->addStretch(1);
00035         buttonLayout->addWidget(closeButton);
00036         mainLayout->addWidget(textBrowser);
00037         connect(homeButton, SIGNAL(clicked()),
00038         textBrowser, SLOT(home()));
00039         connect(backButton, SIGNAL(clicked()),
00040         textBrowser, SLOT(backward()));
00041         connect(closeButton, SIGNAL(clicked()),
00042                 this, SLOT(close()));
00043         connect(textBrowser, SIGNAL(sourceChanged(const QString &)),
00044                 this, SLOT(updateCaption()));
00045         textBrowser->mimeSourceFactory()->addFilePath(path);
00046         textBrowser->setSource(page);
00047 }
00048 
00049 void HelpBrowser::updateCaption()
00050 {
00051         setCaption(tr("Help: %1").arg(textBrowser->documentTitle()));
00052 }
00053 
00054 void HelpBrowser::showPage(const QString &page)
00055 {
00056         QString path = qApp->applicationDirPath() + tr("/help/en");
00057         HelpBrowser *browser = new HelpBrowser(path, page);
00058         browser->resize(500, 400);
00059         browser->show();
00060 }
Untitled Document Pesquisa Psi SourceForge.net Logo