-rw-r--r-- | libopie/ofontselector.cpp | 132 |
1 files changed, 91 insertions, 41 deletions
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp index b905474..c8471cc 100644 --- a/libopie/ofontselector.cpp +++ b/libopie/ofontselector.cpp @@ -40,3 +40,3 @@ class OFontSelectorPrivate { -public: +public: QListBox * m_font_family_list; @@ -46,3 +46,3 @@ public: - bool m_pointbug; + bool m_pointbug : 1; @@ -51,2 +51,3 @@ public: +namespace { @@ -59,3 +60,3 @@ public: m_sizes = sizes; - + QString str = t; @@ -69,3 +70,3 @@ public: } - + const QStringList &styles ( ) const @@ -74,3 +75,3 @@ public: } - + const QValueList<int> &sizes ( ) const @@ -79,3 +80,3 @@ public: } - + private: @@ -96,3 +97,4 @@ static int findItemCB ( QComboBox *box, const QString &str ) - +} +/* static same as anon. namespace */ static int qt_version ( ) @@ -104,3 +106,9 @@ static int qt_version ( ) - +/** + * Constructs the Selector object + * @param withpreview If a font preview should be given + * @param parent The parent of the Font Selector + * @param name The name of the object + * @param fl WidgetFlags + */ OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) @@ -137,3 +145,3 @@ OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *na d-> m_preview-> setWordWrap ( QMultiLineEdit::WidgetWidth ); - d-> m_preview-> setMargin ( 3 ); + d-> m_preview-> setMargin ( 3 ); d-> m_preview-> setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); @@ -154,2 +162,7 @@ OFontSelector::~OFontSelector ( ) +/** + * This methods tries to set the font + * @param f The wishes font + * @return success or failure + */ bool OFontSelector::setSelectedFont ( const QFont &f ) @@ -159,3 +172,11 @@ bool OFontSelector::setSelectedFont ( const QFont &f ) -bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & /*charset*/ ) + +/** + * This is an overloaded method @see setSelectedFont + * @param familyStr The family of the font + * @param styleStr The style of the font + * @param sizeVal The size of font + * @param charset The charset to be used. Will be deprecated by QT3 + */ +bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) { @@ -168,3 +189,3 @@ bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &s family = d-> m_font_family_list-> firstItem ( ); - d-> m_font_family_list-> setCurrentItem ( family ); + d-> m_font_family_list-> setCurrentItem ( family ); fontFamilyClicked ( d-> m_font_family_list-> index ( family )); @@ -186,3 +207,3 @@ bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &s fontSizeClicked ( size ); - + return (( family ) && ( style >= 0 ) && ( size >= 0 )); @@ -190,2 +211,10 @@ bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &s +/** + * This method returns the name, style and size of the currently selected + * font or false if no font is selected + * @param family The font family will be written there + * @param style The style will be written there + * @param size The size will be written there + * @return success or failure + */ bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) @@ -197,2 +226,7 @@ bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) +/** + * This method does return the font family or QString::null if there is + * no font item selected + * @return the font family + */ QString OFontSelector::fontFamily ( ) const @@ -200,3 +234,3 @@ QString OFontSelector::fontFamily ( ) const FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); - + return fli ? fli-> family ( ) : QString::null; @@ -204,2 +238,6 @@ QString OFontSelector::fontFamily ( ) const +/** + * This method will return the style of the font or QString::null + * @return the style of the font + */ QString OFontSelector::fontStyle ( ) const @@ -207,3 +245,3 @@ QString OFontSelector::fontStyle ( ) const FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); - int fst = d-> m_font_style_list-> currentItem ( ); + int fst = d-> m_font_style_list-> currentItem ( ); @@ -212,2 +250,5 @@ QString OFontSelector::fontStyle ( ) const +/** + * This method will return the font size or 10 if no font size is available + */ int OFontSelector::fontSize ( ) const @@ -215,3 +256,3 @@ int OFontSelector::fontSize ( ) const FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); - int fsi = d-> m_font_size_list-> currentItem ( ); + int fsi = d-> m_font_size_list-> currentItem ( ); @@ -220,2 +261,5 @@ int OFontSelector::fontSize ( ) const +/** + * returns the charset of the font or QString::null + */ QString OFontSelector::fontCharSet ( ) const @@ -227,2 +271,6 @@ QString OFontSelector::fontCharSet ( ) const +/** + * Overloaded member function see above + * @see selectedFont + */ bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) @@ -230,7 +278,7 @@ bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, Q int ffa = d-> m_font_family_list-> currentItem ( ); - int fst = d-> m_font_style_list-> currentItem ( ); + int fst = d-> m_font_style_list-> currentItem ( ); int fsi = d-> m_font_size_list-> currentItem ( ); - + FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( ffa ); - + if ( fli ) { @@ -248,3 +296,3 @@ bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, Q - + @@ -253,6 +301,6 @@ void OFontSelector::loadFonts ( QListBox *list ) QStringList f = d-> m_fdb. families ( ); - + for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) { QValueList <int> ps = d-> m_fdb. pointSizes ( *it ); - + if ( d-> m_pointbug ) { @@ -261,3 +309,3 @@ void OFontSelector::loadFonts ( QListBox *list ) } - + list-> insertItem ( new FontListItem ( *it, d-> m_fdb. styles ( *it ), ps )); @@ -270,6 +318,6 @@ void OFontSelector::fontFamilyClicked ( int index ) QString oldsize = d-> m_font_size_list-> currentText ( ); - + FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( index ); - - d-> m_font_style_list-> clear ( ); + + d-> m_font_style_list-> clear ( ); d-> m_font_style_list-> insertStringList ( fli-> styles ( )); @@ -278,3 +326,3 @@ void OFontSelector::fontFamilyClicked ( int index ) int i; - + i = findItemCB ( d-> m_font_style_list, oldstyle ); @@ -284,12 +332,12 @@ void OFontSelector::fontFamilyClicked ( int index ) i = 0; - + if ( i >= 0 ) { - d-> m_font_style_list-> setCurrentItem ( i ); + d-> m_font_style_list-> setCurrentItem ( i ); fontStyleClicked ( i ); } - + d-> m_font_size_list-> clear ( ); QValueList<int> sl = fli-> sizes ( ); - - for ( QValueList<int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) + + for ( QValueList<int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) d-> m_font_size_list-> insertItem ( QString::number ( *it )); @@ -301,8 +349,8 @@ void OFontSelector::fontFamilyClicked ( int index ) i = 0; - + if ( i >= 0 ) { - d-> m_font_size_list-> setCurrentItem ( i ); + d-> m_font_size_list-> setCurrentItem ( i ); fontSizeClicked ( i ); } - changeFont ( ); + changeFont ( ); } @@ -311,3 +359,3 @@ void OFontSelector::fontStyleClicked ( int /*index*/ ) { - changeFont ( ); + changeFont ( ); } @@ -329,3 +377,5 @@ void OFontSelector::changeFont ( ) - +/** + * Return the selected font + */ QFont OFontSelector::selectedFont ( ) @@ -333,7 +383,7 @@ QFont OFontSelector::selectedFont ( ) int ffa = d-> m_font_family_list-> currentItem ( ); - int fst = d-> m_font_style_list-> currentItem ( ); + int fst = d-> m_font_style_list-> currentItem ( ); int fsi = d-> m_font_size_list-> currentItem ( ); - + FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( ffa ); - + if ( fli ) { @@ -357,6 +407,6 @@ void OFontSelector::resizeEvent ( QResizeEvent *re ) QWidget::resizeEvent ( re ); - + if ( d-> m_preview ) d-> m_preview-> setFixedHeight ( d-> m_preview-> height ( )); - + } |