summaryrefslogtreecommitdiff
path: root/libopie/ofontselector.cpp
authoralwin <alwin>2004-03-02 12:14:15 (UTC)
committer alwin <alwin>2004-03-02 12:14:15 (UTC)
commit0d59c780513da78033f4d9040475dee9db0256d4 (patch) (side-by-side diff)
tree503d320b4aa3daae9982082e7b34e3e2c48bdfb7 /libopie/ofontselector.cpp
parenta0981652d61776d70f25980f035748b21339e946 (diff)
downloadopie-0d59c780513da78033f4d9040475dee9db0256d4.zip
opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.gz
opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.bz2
run the optimize_connect script
the whole cvs is tagged with "before_optimize_connect" if there are problems you can check the diff (but it had compiled and run here)
Diffstat (limited to 'libopie/ofontselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofontselector.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp
index 7e07008..87b7869 100644
--- a/libopie/ofontselector.cpp
+++ b/libopie/ofontselector.cpp
@@ -26,207 +26,207 @@
*/
#include <qlayout.h>
#include <qlistbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qmultilineedit.h>
#include <qpe/fontdatabase.h>
#include "ofontselector.h"
class OFontSelectorPrivate {
public:
QListBox * m_font_family_list;
QComboBox * m_font_style_list;
QComboBox * m_font_size_list;
QMultiLineEdit *m_preview;
bool m_pointbug : 1;
FontDatabase m_fdb;
};
namespace {
class FontListItem : public QListBoxText {
public:
FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText ( )
{
m_name = t;
m_styles = styles;
m_sizes = sizes;
QString str = t;
str [0] = str [0]. upper ( );
setText ( str );
}
QString family ( ) const
{
return m_name;
}
const QStringList &styles ( ) const
{
return m_styles;
}
const QValueList<int> &sizes ( ) const
{
return m_sizes;
}
private:
QStringList m_styles;
QValueList<int> m_sizes;
QString m_name;
};
static int findItemCB ( QComboBox *box, const QString &str )
{
for ( int i = 0; i < box-> count ( ); i++ ) {
if ( box-> text ( i ) == str )
return i;
}
return -1;
}
}
/* static same as anon. namespace */
static int qt_version ( )
{
const char *qver = qVersion ( );
return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
}
/**
* 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 )
{
d = new OFontSelectorPrivate ( );
QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 );
gridLayout->setRowStretch ( 4, 10 );
d-> m_font_family_list = new QListBox( this, "FontListBox" );
gridLayout->addMultiCellWidget( d-> m_font_family_list, 0, 4, 0, 0 );
- connect( d-> m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) );
+ connect( d-> m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) );
QLabel *label = new QLabel( tr( "Style" ), this );
gridLayout->addWidget( label, 0, 1 );
d-> m_font_style_list = new QComboBox( this, "StyleListBox" );
- connect( d-> m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) );
+ connect( d-> m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) );
gridLayout->addWidget( d-> m_font_style_list, 1, 1 );
label = new QLabel( tr( "Size" ), this );
gridLayout->addWidget( label, 2, 1 );
d-> m_font_size_list = new QComboBox( this, "SizeListBox" );
- connect( d-> m_font_size_list, SIGNAL( activated( int ) ),
- this, SLOT( fontSizeClicked( int ) ) );
+ connect( d-> m_font_size_list, SIGNAL( activated(int) ),
+ this, SLOT( fontSizeClicked(int) ) );
gridLayout->addWidget( d-> m_font_size_list, 3, 1 );
d-> m_pointbug = ( qt_version ( ) <= 233 );
if ( withpreview ) {
d-> m_preview = new QMultiLineEdit ( this, "Preview" );
d-> m_preview-> setAlignment ( AlignCenter );
d-> m_preview-> setWordWrap ( QMultiLineEdit::WidgetWidth );
d-> m_preview-> setMargin ( 3 );
d-> m_preview-> setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
gridLayout-> addRowSpacing ( 5, 4 );
gridLayout-> addMultiCellWidget ( d-> m_preview, 6, 6, 0, 1 );
gridLayout-> setRowStretch ( 6, 5 );
}
else
d-> m_preview = 0;
loadFonts ( d-> m_font_family_list );
}
OFontSelector::~OFontSelector ( )
{
delete d;
}
/**
* This methods tries to set the font
* @param f The wishes font
* @return success or failure
*/
bool OFontSelector::setSelectedFont ( const QFont &f )
{
return setSelectedFont ( f. family ( ), d-> m_fdb. styleString ( f ), f. pointSize ( ), QFont::encodingName ( f. 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 )
{
QString sizeStr = QString::number ( sizeVal );
QListBoxItem *family = d-> m_font_family_list-> findItem ( familyStr );
if ( !family )
family = d-> m_font_family_list-> findItem ( "Helvetica" );
if ( !family )
family = d-> m_font_family_list-> firstItem ( );
d-> m_font_family_list-> setCurrentItem ( family );
fontFamilyClicked ( d-> m_font_family_list-> index ( family ));
int style = findItemCB ( d-> m_font_style_list, styleStr );
if ( style < 0 )
style = findItemCB ( d-> m_font_style_list, "Regular" );
if ( style < 0 && d-> m_font_style_list-> count ( ) > 0 )
style = 0;
d-> m_font_style_list-> setCurrentItem ( style );
fontStyleClicked ( style );
int size = findItemCB ( d-> m_font_size_list, sizeStr );
if ( size < 0 )
size = findItemCB ( d-> m_font_size_list, "10" );
if ( size < 0 && d-> m_font_size_list-> count ( ) > 0 )
size = 0;
d-> m_font_size_list-> setCurrentItem ( size );
fontSizeClicked ( size );
return (( family ) && ( style >= 0 ) && ( size >= 0 ));
}
/**
* 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 )
{
QString dummy;
return selectedFont ( family, style, size, dummy );
}
/**
* 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
{