AlbumShaper 1.0a3
Contents Class Reference

#include <contents.h>

Inheritance diagram for Contents:
Collaboration diagram for Contents:

Signals

void setPage (HELP_PAGE page)
 

Public Member Functions

 Contents (Q3TextStream::Encoding type, QString saveCharSet, Q3MimeSourceFactory *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 (Q3TextStream::Encoding type, QString charSet)
 
void printLink (Q3TextStream &stream, QString text, HELP_PAGE anchor, QString anchorString)
 

Private Attributes

QSize optimalSize
 
HELP_PAGE currentPage
 
Q3TextStream::Encoding type
 
QString saveCharSet
 

Detailed Description

Definition at line 40 of file contents.h.

Constructor & Destructor Documentation

◆ Contents()

Contents::Contents ( Q3TextStream::Encoding type,
QString saveCharSet,
Q3MimeSourceFactory * loadingMimeSource,
QWidget * parent = 0,
const char * name = 0 )

Definition at line 26 of file contents.cpp.

28 : Q3TextBrowser(parent,name)
29{
30 this->type = type;
31 this->saveCharSet = saveCharSet;
32 this->setMimeSourceFactory( loadingMimeSource );
33
34 //generate HTML
37 //--
38 //set browser and load contents
39 setHScrollBarMode( Q3ScrollView::AlwaysOff );
40 setVScrollBarMode( Q3ScrollView::AlwaysOff );
41 setFrameStyle( Q3Frame::NoFrame );
42 setSource( filename() );
43
44 //------
45 //determine optimal size
46 int minH = heightForWidth( 1000 );
47 int w;
48 for(w=1; w<1000; w++)
49 {
50 if(heightForWidth(w) == minH ) break;
51 }
52
53 optimalSize = QSize( w, heightForWidth(w) );
54 //------
55 //handle anchor clicks
56 connect( this, SIGNAL(anchorClicked(const QString&, const QString&)),
57 this, SLOT(handleAnchorClick(const QString&, const QString&)) );
58 //------
59}
QSize optimalSize
Definition contents.h:52
QString saveCharSet
Definition contents.h:59
QString filename()
Definition contents.cpp:100
void handleAnchorClick(const QString &name, const QString &link)
Definition contents.cpp:66
void generateHTML(Q3TextStream::Encoding type, QString charSet)
Definition contents.cpp:105
HELP_PAGE currentPage
Definition contents.h:56
Q3TextStream::Encoding type
Definition contents.h:58
@ BILLBOARD
Definition contents.h:26

References BILLBOARD, currentPage, filename(), generateHTML(), handleAnchorClick(), optimalSize, saveCharSet, and type.

Member Function Documentation

◆ filename()

QString Contents::filename ( )
private

Definition at line 100 of file contents.cpp.

101{
102 return QString("%1/helpContents.html").arg(TEMP_DIR);
103}
QString TEMP_DIR
Definition config.cpp:23

References TEMP_DIR.

Referenced by Contents(), and generateHTML().

◆ generateHTML()

void Contents::generateHTML ( Q3TextStream::Encoding type,
QString charSet )
private

Definition at line 105 of file contents.cpp.

106{
107 //create/open html file
108 QFile file( filename() );
109 if(file.open(QIODevice::WriteOnly))
110 {
111 //-----
112 Q3TextStream stream;
113 stream.setEncoding( type );
114 stream.setDevice( &file );
115 //-----
116 stream << "<html><head>\n";
117 stream << "<meta http-equiv='Content-Type' content='text/html; charset=" << charSet << "'>\n";
118 stream << "</head><body>\n";
119 stream << "<center><table><tr><td>\n";
120 stream << "<font face='Arial, sans-serif' size='+1'><b>\n";
121 //-----
122 printLink( stream, QString(tr("What's New")), WHATS_NEW, "WHATS_NEW" );
123 //-----
124 stream << "<p>" << tr("Tutorials:") << "\n";
125 //------
126 stream << "<font size='+0'><ul>\n";
127
128 stream << "<li>\n";
129 printLink( stream, QString(tr("Import & Organize")),
130 IMPORTING_AND_ORGANIZING, "IMPORTING_AND_ORGANIZING" );
131 //------
132 stream << "<li>\n";
133 printLink( stream, QString(tr("Annotating Albums")),
134 ANNOTATING_ALBUMS, "ANNOTATING_ALBUMS" );
135 //------
136 stream << "<li>" << tr("Editing Photos:") << "\n";
137
138 stream << "<ol>\n";
139 stream << "<li>\n";
140 printLink( stream, QString(tr("Framing")),
141 FRAMING, "FRAMING" );
142
143 stream << "<li>\n";
144 printLink( stream, QString(tr("Fix it Fast")),
145 ENHANCING, "ENHANCING" );
146
147 stream << "<li>\n";
148 printLink( stream, QString(tr("Pro Tools")),
149 PRO_TOOLS, "PRO_TOOLS" );
150
151 stream << "<li>\n";
152 printLink( stream, QString(tr("Manipulations")),
153 MANIPULATING, "MANIPULATING" );
154 stream << "</ol>\n";
155 //------
156 stream << "<li>\n";
157 printLink( stream, QString(tr("Saving & Loading")),
158 SAVING_AND_LOADING, "SAVING_AND_LOADING" );
159 //------
160 stream << "</ul></font>\n";
161 //------
162 printLink( stream, QString(tr("Keyboard Shortcuts")), KEYBOARD_SHORTCUTS, "KEYBOARD_SHORTCUTS" );
163 //------
164 stream << "</b></font>\n";
165 stream << "</td></tr></table></center>\n";
166 stream << "</body></html>\n";
167 file.close();
168 }
169}
void printLink(Q3TextStream &stream, QString text, HELP_PAGE anchor, QString anchorString)
Definition contents.cpp:171
@ WHATS_NEW
Definition contents.h:27
@ MANIPULATING
Definition contents.h:33
@ FRAMING
Definition contents.h:30
@ IMPORTING_AND_ORGANIZING
Definition contents.h:28
@ PRO_TOOLS
Definition contents.h:32
@ SAVING_AND_LOADING
Definition contents.h:34
@ ANNOTATING_ALBUMS
Definition contents.h:29
@ KEYBOARD_SHORTCUTS
Definition contents.h:35
@ ENHANCING
Definition contents.h:31

References ANNOTATING_ALBUMS, ENHANCING, filename(), FRAMING, IMPORTING_AND_ORGANIZING, KEYBOARD_SHORTCUTS, MANIPULATING, printLink(), PRO_TOOLS, SAVING_AND_LOADING, type, and WHATS_NEW.

Referenced by Contents(), and handleAnchorClick().

◆ handleAnchorClick

void Contents::handleAnchorClick ( const QString & name,
const QString & link )
privateslot

Definition at line 66 of file contents.cpp.

67{
68 HELP_PAGE nextPage = INVALID;
69
70 //only handle clicking on anchors with actual names
71 if( name.isNull() ) return;
72 else if(name.compare("WHATS_NEW") == 0)
73 nextPage = WHATS_NEW;
74 else if(name.compare("IMPORTING_AND_ORGANIZING") == 0)
75 nextPage = IMPORTING_AND_ORGANIZING;
76 else if(name.compare("ANNOTATING_ALBUMS") == 0)
77 nextPage = ANNOTATING_ALBUMS;
78 else if(name.compare("FRAMING") == 0)
79 nextPage = FRAMING;
80 else if(name.compare("ENHANCING") == 0)
81 nextPage = ENHANCING;
82 else if(name.compare("PRO_TOOLS") == 0)
83 nextPage = PRO_TOOLS;
84 else if(name.compare("MANIPULATING") == 0)
85 nextPage = MANIPULATING;
86 else if(name.compare("SAVING_AND_LOADING") == 0)
87 nextPage = SAVING_AND_LOADING;
88 else if(name.compare("KEYBOARD_SHORTCUTS") == 0)
89 nextPage = KEYBOARD_SHORTCUTS;
90
91 if(nextPage != INVALID)
92 {
93 currentPage = nextPage;
95 reload();
96 emit setPage( currentPage );
97 }
98}
void setPage(HELP_PAGE page)
HELP_PAGE
Contents window widget.
Definition contents.h:25
@ INVALID
Definition contents.h:36

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().

◆ minimumSizeHint()

QSize Contents::minimumSizeHint ( ) const

Definition at line 61 of file contents.cpp.

62{
63 return optimalSize;
64}

References optimalSize.

Referenced by HelpWindow::HelpWindow().

◆ printLink()

void Contents::printLink ( Q3TextStream & stream,
QString text,
HELP_PAGE anchor,
QString anchorString )
private

Definition at line 171 of file contents.cpp.

172{
173 if( currentPage != anchor )
174 {
175 stream << "<font color='" << LINK_COLOR << "'>";
176 stream << "<a name='" << anchorString << "'>";
177 }
178 else
179 {
180 stream << "<font color='" << CURR_COLOR << "'>";
181 }
182
183 stream << text << "\n";
184
185 if( currentPage != anchor )
186 {
187 stream << "</a>";
188 }
189 stream << "</font>\n";
190}
#define CURR_COLOR
Definition contents.cpp:23
#define LINK_COLOR
Definition contents.cpp:22

References CURR_COLOR, currentPage, and LINK_COLOR.

Referenced by generateHTML().

◆ setPage

void Contents::setPage ( HELP_PAGE page)
signal

Referenced by handleAnchorClick().

Member Data Documentation

◆ currentPage

HELP_PAGE Contents::currentPage
private

Definition at line 56 of file contents.h.

Referenced by Contents(), handleAnchorClick(), and printLink().

◆ optimalSize

QSize Contents::optimalSize
private

Definition at line 52 of file contents.h.

Referenced by Contents(), and minimumSizeHint().

◆ saveCharSet

QString Contents::saveCharSet
private

Definition at line 59 of file contents.h.

Referenced by Contents(), and handleAnchorClick().

◆ type

Q3TextStream::Encoding Contents::type
private

Definition at line 58 of file contents.h.

Referenced by Contents(), generateHTML(), and handleAnchorClick().


The documentation for this class was generated from the following files: