summaryrefslogtreecommitdiff
path: root/libopie2/opieui/ofontselector.cpp
authorzecke <zecke>2004-09-10 11:06:50 (UTC)
committer zecke <zecke>2004-09-10 11:06:50 (UTC)
commit00b7879d0d886b642b1f1102e3a811e67f928df7 (patch) (unidiff)
tree15a9a6b1ba3ddf64a94265556cd9140916a47811 /libopie2/opieui/ofontselector.cpp
parentd416ff23ea50303173d07ea243498a163f5995b5 (diff)
downloadopie-00b7879d0d886b642b1f1102e3a811e67f928df7.zip
opie-00b7879d0d886b642b1f1102e3a811e67f928df7.tar.gz
opie-00b7879d0d886b642b1f1102e3a811e67f928df7.tar.bz2
Fix warnings about unused parameters and no newline at the end of file
Diffstat (limited to 'libopie2/opieui/ofontselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/ofontselector.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp
index 6763ee6..4870cd9 100644
--- a/libopie2/opieui/ofontselector.cpp
+++ b/libopie2/opieui/ofontselector.cpp
@@ -100,192 +100,193 @@ using namespace Opie::Ui::Internal;
100 100
101static int findItemCB( QComboBox *box, const QString &str ) 101static int findItemCB( QComboBox *box, const QString &str )
102{ 102{
103 for ( int i = 0; i < box->count(); i++ ) 103 for ( int i = 0; i < box->count(); i++ )
104 { 104 {
105 if ( box->text ( i ) == str ) 105 if ( box->text ( i ) == str )
106 return i; 106 return i;
107 } 107 }
108 return -1; 108 return -1;
109} 109}
110 110
111/* static same as anon. namespace */ 111/* static same as anon. namespace */
112static int qt_version() 112static int qt_version()
113{ 113{
114 const char *qver = qVersion(); 114 const char *qver = qVersion();
115 115
116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); 116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
117} 117}
118 118
119/** 119/**
120 * Constructs the Selector object 120 * Constructs the Selector object
121 * @param withpreview If a font preview should be given 121 * @param withpreview If a font preview should be given
122 * @param parent The parent of the Font Selector 122 * @param parent The parent of the Font Selector
123 * @param name The name of the object 123 * @param name The name of the object
124 * @param fl WidgetFlags 124 * @param fl WidgetFlags
125 */ 125 */
126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
127{ 127{
128 d = new OFontSelectorPrivate(); 128 d = new OFontSelectorPrivate();
129 129
130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); 130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 );
131 gridLayout->setRowStretch( 4, 10 ); 131 gridLayout->setRowStretch( 4, 10 );
132 132
133 d->m_font_family_list = new QListBox( this, "FontListBox" ); 133 d->m_font_family_list = new QListBox( this, "FontListBox" );
134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); 134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 );
135 connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) ); 135 connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) );
136 136
137 QLabel *label = new QLabel( tr( "Style" ), this ); 137 QLabel *label = new QLabel( tr( "Style" ), this );
138 gridLayout->addWidget( label, 0, 1 ); 138 gridLayout->addWidget( label, 0, 1 );
139 139
140 d->m_font_style_list = new QComboBox( this, "StyleListBox" ); 140 d->m_font_style_list = new QComboBox( this, "StyleListBox" );
141 connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) ); 141 connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) );
142 gridLayout->addWidget( d->m_font_style_list, 1, 1 ); 142 gridLayout->addWidget( d->m_font_style_list, 1, 1 );
143 143
144 label = new QLabel( tr( "Size" ), this ); 144 label = new QLabel( tr( "Size" ), this );
145 gridLayout->addWidget( label, 2, 1 ); 145 gridLayout->addWidget( label, 2, 1 );
146 146
147 d->m_font_size_list = new QComboBox( this, "SizeListBox" ); 147 d->m_font_size_list = new QComboBox( this, "SizeListBox" );
148 connect( d->m_font_size_list, SIGNAL( activated(int) ), 148 connect( d->m_font_size_list, SIGNAL( activated(int) ),
149 this, SLOT( fontSizeClicked(int) ) ); 149 this, SLOT( fontSizeClicked(int) ) );
150 gridLayout->addWidget( d->m_font_size_list, 3, 1 ); 150 gridLayout->addWidget( d->m_font_size_list, 3, 1 );
151 151
152 d->m_pointbug = ( qt_version() <= 233 ); 152 d->m_pointbug = ( qt_version() <= 233 );
153 153
154 if ( withpreview ) 154 if ( withpreview )
155 { 155 {
156 d->m_preview = new QMultiLineEdit ( this, "Preview" ); 156 d->m_preview = new QMultiLineEdit ( this, "Preview" );
157 d->m_preview->setAlignment ( AlignCenter ); 157 d->m_preview->setAlignment ( AlignCenter );
158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); 158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth );
159 d->m_preview->setMargin ( 3 ); 159 d->m_preview->setMargin ( 3 );
160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); 160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
161 gridLayout->addRowSpacing ( 5, 4 ); 161 gridLayout->addRowSpacing ( 5, 4 );
162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); 162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 );
163 gridLayout->setRowStretch ( 6, 5 ); 163 gridLayout->setRowStretch ( 6, 5 );
164 } 164 }
165 else 165 else
166 d->m_preview = 0; 166 d->m_preview = 0;
167 167
168 loadFonts ( d->m_font_family_list ); 168 loadFonts ( d->m_font_family_list );
169} 169}
170 170
171OFontSelector::~OFontSelector() 171OFontSelector::~OFontSelector()
172{ 172{
173 delete d; 173 delete d;
174} 174}
175 175
176/** 176/**
177 * This methods tries to set the font 177 * This methods tries to set the font
178 * @param f The wishes font 178 * @param f The wishes font
179 * @return success or failure 179 * @return success or failure
180 */ 180 */
181bool OFontSelector::setSelectedFont ( const QFont &f ) 181bool OFontSelector::setSelectedFont ( const QFont &f )
182{ 182{
183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); 183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet()));
184} 184}
185 185
186 186
187/** 187/**
188 * This is an overloaded method @see setSelectedFont 188 * This is an overloaded method @see setSelectedFont
189 * @param familyStr The family of the font 189 * @param familyStr The family of the font
190 * @param styleStr The style of the font 190 * @param styleStr The style of the font
191 * @param sizeVal The size of font 191 * @param sizeVal The size of font
192 * @param charset The charset to be used. Will be deprecated by QT3 192 * @param charset The charset to be used. Will be deprecated by QT3
193 */ 193 */
194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) 194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset )
195{ 195{
196 Q_CONST_UNUSED( charset )
196 QString sizeStr = QString::number ( sizeVal ); 197 QString sizeStr = QString::number ( sizeVal );
197 198
198 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); 199 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr );
199 if ( !family ) 200 if ( !family )
200 family = d->m_font_family_list->findItem ( "Helvetica" ); 201 family = d->m_font_family_list->findItem ( "Helvetica" );
201 if ( !family ) 202 if ( !family )
202 family = d->m_font_family_list->firstItem(); 203 family = d->m_font_family_list->firstItem();
203 d->m_font_family_list->setCurrentItem ( family ); 204 d->m_font_family_list->setCurrentItem ( family );
204 fontFamilyClicked ( d->m_font_family_list->index ( family )); 205 fontFamilyClicked ( d->m_font_family_list->index ( family ));
205 206
206 int style = findItemCB ( d->m_font_style_list, styleStr ); 207 int style = findItemCB ( d->m_font_style_list, styleStr );
207 if ( style < 0 ) 208 if ( style < 0 )
208 style = findItemCB ( d->m_font_style_list, "Regular" ); 209 style = findItemCB ( d->m_font_style_list, "Regular" );
209 if ( style < 0 && d->m_font_style_list->count() > 0 ) 210 if ( style < 0 && d->m_font_style_list->count() > 0 )
210 style = 0; 211 style = 0;
211 d->m_font_style_list->setCurrentItem ( style ); 212 d->m_font_style_list->setCurrentItem ( style );
212 fontStyleClicked ( style ); 213 fontStyleClicked ( style );
213 214
214 int size = findItemCB ( d->m_font_size_list, sizeStr ); 215 int size = findItemCB ( d->m_font_size_list, sizeStr );
215 if ( size < 0 ) 216 if ( size < 0 )
216 size = findItemCB ( d->m_font_size_list, "10" ); 217 size = findItemCB ( d->m_font_size_list, "10" );
217 if ( size < 0 && d->m_font_size_list->count() > 0 ) 218 if ( size < 0 && d->m_font_size_list->count() > 0 )
218 size = 0; 219 size = 0;
219 d->m_font_size_list->setCurrentItem ( size ); 220 d->m_font_size_list->setCurrentItem ( size );
220 fontSizeClicked ( size ); 221 fontSizeClicked ( size );
221 222
222 return (( family ) && ( style >= 0 ) && ( size >= 0 )); 223 return (( family ) && ( style >= 0 ) && ( size >= 0 ));
223} 224}
224 225
225/** 226/**
226 * This method returns the name, style and size of the currently selected 227 * This method returns the name, style and size of the currently selected
227 * font or false if no font is selected 228 * font or false if no font is selected
228 * @param family The font family will be written there 229 * @param family The font family will be written there
229 * @param style The style will be written there 230 * @param style The style will be written there
230 * @param size The size will be written there 231 * @param size The size will be written there
231 * @return success or failure 232 * @return success or failure
232 */ 233 */
233bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) 234bool OFontSelector::selectedFont ( QString &family, QString &style, int &size )
234{ 235{
235 QString dummy; 236 QString dummy;
236 return selectedFont ( family, style, size, dummy ); 237 return selectedFont ( family, style, size, dummy );
237} 238}
238 239
239 240
240/** 241/**
241 * This method does return the font family or QString::null if there is 242 * This method does return the font family or QString::null if there is
242 * no font item selected 243 * no font item selected
243 * @return the font family 244 * @return the font family
244 */ 245 */
245QString OFontSelector::fontFamily() const 246QString OFontSelector::fontFamily() const
246{ 247{
247 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 248 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
248 249
249 return fli ? fli->family() : QString::null; 250 return fli ? fli->family() : QString::null;
250} 251}
251 252
252/** 253/**
253 * This method will return the style of the font or QString::null 254 * This method will return the style of the font or QString::null
254 * @return the style of the font 255 * @return the style of the font
255 */ 256 */
256QString OFontSelector::fontStyle() const 257QString OFontSelector::fontStyle() const
257{ 258{
258 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 259 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
259 int fst = d->m_font_style_list->currentItem(); 260 int fst = d->m_font_style_list->currentItem();
260 261
261 return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null; 262 return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null;
262} 263}
263 264
264/** 265/**
265 * This method will return the font size or 10 if no font size is available 266 * This method will return the font size or 10 if no font size is available
266 */ 267 */
267int OFontSelector::fontSize() const 268int OFontSelector::fontSize() const
268{ 269{
269 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 270 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
270 int fsi = d->m_font_size_list->currentItem(); 271 int fsi = d->m_font_size_list->currentItem();
271 272
272 return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10; 273 return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10;
273} 274}
274 275
275/** 276/**
276 * returns the charset of the font or QString::null 277 * returns the charset of the font or QString::null
277 */ 278 */
278QString OFontSelector::fontCharSet() const 279QString OFontSelector::fontCharSet() const
279{ 280{
280 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 281 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
281 282
282 return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null; 283 return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null;
283} 284}
284 285
285/** 286/**
286 * Overloaded member function see above 287 * Overloaded member function see above
287 * @see selectedFont 288 * @see selectedFont
288 */ 289 */
289bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) 290bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset )
290{ 291{
291 int ffa = d->m_font_family_list->currentItem(); 292 int ffa = d->m_font_family_list->currentItem();