AlbumShaper
1.0a3
|
#include <contents.h>
Signals | |
void | setPage (HELP_PAGE page) |
Public Member Functions | |
Contents (QTextStream::Encoding type, QString saveCharSet, QMimeSourceFactory *loadingMimeSource, QWidget *parent=0, const char *name=0) | |
QSize | minimumSizeHint () const |
Private Slots | |
void | handleAnchorClick (const QString &name, const QString &link) |
Private Member Functions | |
QString | filename () |
void | generateHTML (QTextStream::Encoding type, QString charSet) |
void | printLink (QTextStream &stream, QString text, HELP_PAGE anchor, QString anchorString) |
Private Attributes | |
QSize | optimalSize |
HELP_PAGE | currentPage |
QTextStream::Encoding | type |
QString | saveCharSet |
Definition at line 40 of file contents.h.
Contents::Contents | ( | QTextStream::Encoding | type, |
QString | saveCharSet, | ||
QMimeSourceFactory * | loadingMimeSource, | ||
QWidget * | parent = 0 , |
||
const char * | name = 0 |
||
) |
Definition at line 23 of file contents.cpp.
References BILLBOARD, currentPage, filename(), generateHTML(), handleAnchorClick(), optimalSize, saveCharSet, and type.
: QTextBrowser(parent,name) { this->type = type; this->saveCharSet = saveCharSet; this->setMimeSourceFactory( loadingMimeSource ); //generate HTML currentPage = BILLBOARD; generateHTML(type, saveCharSet); //-- //set browser and load contents setHScrollBarMode( QScrollView::AlwaysOff ); setVScrollBarMode( QScrollView::AlwaysOff ); setFrameStyle( QFrame::NoFrame ); setSource( filename() ); //------ //determine optimal size int minH = heightForWidth( 1000 ); int w; for(w=1; w<1000; w++) { if(heightForWidth(w) == minH ) break; } optimalSize = QSize( w, heightForWidth(w) ); //------ //handle anchor clicks connect( this, SIGNAL(anchorClicked(const QString&, const QString&)), this, SLOT(handleAnchorClick(const QString&, const QString&)) ); //------ }
QString Contents::filename | ( | ) | [private] |
Definition at line 97 of file contents.cpp.
References TEMP_DIR.
Referenced by Contents(), and generateHTML().
{ return QString("%1/helpContents.html").arg(TEMP_DIR); }
void Contents::generateHTML | ( | QTextStream::Encoding | type, |
QString | charSet | ||
) | [private] |
Definition at line 102 of file contents.cpp.
References ANNOTATING_ALBUMS, ENHANCING, filename(), FRAMING, IMPORTING_AND_ORGANIZING, KEYBOARD_SHORTCUTS, MANIPULATING, printLink(), PRO_TOOLS, SAVING_AND_LOADING, and WHATS_NEW.
Referenced by Contents(), and handleAnchorClick().
{ //create/open html file QFile file( filename() ); if(file.open(IO_WriteOnly)) { //----- QTextStream stream; stream.setEncoding( type ); stream.setDevice( &file ); //----- stream << "<html><head>\n"; stream << "<meta http-equiv='Content-Type' content='text/html; charset=" << charSet << "'>\n"; stream << "</head><body>\n"; stream << "<center><table><tr><td>\n"; stream << "<font face='Arial, sans-serif' size='+1'><b>\n"; //----- printLink( stream, QString(tr("What's New")), WHATS_NEW, "WHATS_NEW" ); //----- stream << "<p>" << tr("Tutorials:") << "\n"; //------ stream << "<font size='+0'><ul>\n"; stream << "<li>\n"; printLink( stream, QString(tr("Import & Organize")), IMPORTING_AND_ORGANIZING, "IMPORTING_AND_ORGANIZING" ); //------ stream << "<li>\n"; printLink( stream, QString(tr("Annotating Albums")), ANNOTATING_ALBUMS, "ANNOTATING_ALBUMS" ); //------ stream << "<li>" << tr("Editing Photos:") << "\n"; stream << "<ol>\n"; stream << "<li>\n"; printLink( stream, QString(tr("Framing")), FRAMING, "FRAMING" ); stream << "<li>\n"; printLink( stream, QString(tr("Fix it Fast")), ENHANCING, "ENHANCING" ); stream << "<li>\n"; printLink( stream, QString(tr("Pro Tools")), PRO_TOOLS, "PRO_TOOLS" ); stream << "<li>\n"; printLink( stream, QString(tr("Manipulations")), MANIPULATING, "MANIPULATING" ); stream << "</ol>\n"; //------ stream << "<li>\n"; printLink( stream, QString(tr("Saving & Loading")), SAVING_AND_LOADING, "SAVING_AND_LOADING" ); //------ stream << "</ul></font>\n"; //------ printLink( stream, QString(tr("Keyboard Shortcuts")), KEYBOARD_SHORTCUTS, "KEYBOARD_SHORTCUTS" ); //------ stream << "</b></font>\n"; stream << "</td></tr></table></center>\n"; stream << "</body></html>\n"; file.close(); } }
void Contents::handleAnchorClick | ( | const QString & | name, |
const QString & | link | ||
) | [private, slot] |
Definition at line 63 of file contents.cpp.
References ANNOTATING_ALBUMS, currentPage, ENHANCING, FRAMING, generateHTML(), IMPORTING_AND_ORGANIZING, INVALID, KEYBOARD_SHORTCUTS, MANIPULATING, PRO_TOOLS, saveCharSet, SAVING_AND_LOADING, setPage(), type, and WHATS_NEW.
Referenced by Contents().
{ HELP_PAGE nextPage = INVALID; //only handle clicking on anchors with actual names if( name.isNull() ) return; else if(name.compare("WHATS_NEW") == 0) nextPage = WHATS_NEW; else if(name.compare("IMPORTING_AND_ORGANIZING") == 0) nextPage = IMPORTING_AND_ORGANIZING; else if(name.compare("ANNOTATING_ALBUMS") == 0) nextPage = ANNOTATING_ALBUMS; else if(name.compare("FRAMING") == 0) nextPage = FRAMING; else if(name.compare("ENHANCING") == 0) nextPage = ENHANCING; else if(name.compare("PRO_TOOLS") == 0) nextPage = PRO_TOOLS; else if(name.compare("MANIPULATING") == 0) nextPage = MANIPULATING; else if(name.compare("SAVING_AND_LOADING") == 0) nextPage = SAVING_AND_LOADING; else if(name.compare("KEYBOARD_SHORTCUTS") == 0) nextPage = KEYBOARD_SHORTCUTS; if(nextPage != INVALID) { currentPage = nextPage; generateHTML(type, saveCharSet); reload(); emit setPage( currentPage ); } }
QSize Contents::minimumSizeHint | ( | ) | const |
Definition at line 58 of file contents.cpp.
References optimalSize.
Referenced by HelpWindow::HelpWindow().
{ return optimalSize; }
void Contents::printLink | ( | QTextStream & | stream, |
QString | text, | ||
HELP_PAGE | anchor, | ||
QString | anchorString | ||
) | [private] |
Definition at line 168 of file contents.cpp.
References CURR_COLOR, currentPage, and LINK_COLOR.
Referenced by generateHTML().
{ if( currentPage != anchor ) { stream << "<font color='" << LINK_COLOR << "'>"; stream << "<a name='" << anchorString << "'>"; } else { stream << "<font color='" << CURR_COLOR << "'>"; } stream << text << "\n"; if( currentPage != anchor ) { stream << "</a>"; } stream << "</font>\n"; }
void Contents::setPage | ( | HELP_PAGE | page | ) | [signal] |
Referenced by handleAnchorClick().
HELP_PAGE Contents::currentPage [private] |
Definition at line 56 of file contents.h.
Referenced by Contents(), handleAnchorClick(), and printLink().
QSize Contents::optimalSize [private] |
Definition at line 52 of file contents.h.
Referenced by Contents(), and minimumSizeHint().
QString Contents::saveCharSet [private] |
Definition at line 59 of file contents.h.
Referenced by Contents(), and handleAnchorClick().
QTextStream::Encoding Contents::type [private] |
Definition at line 58 of file contents.h.
Referenced by Contents(), and handleAnchorClick().