~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to lib/kformula/kformulaconfigpage.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
 
3
                      Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Library General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Library General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Library General Public License
 
16
   along with this library; see the file COPYING.LIB.  If not, write to
 
17
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
   Boston, MA 02111-1307, USA.
 
19
*/
 
20
 
 
21
#include <qvariant.h>   // first for gcc 2.7.2
 
22
#include <qbuttongroup.h>
 
23
#include <qcheckbox.h>
 
24
#include <qgroupbox.h>
 
25
#include <qlabel.h>
 
26
#include <qlayout.h>
 
27
#include <qmap.h>
 
28
#include <qradiobutton.h>
 
29
#include <qspinbox.h>
 
30
#include <qstringlist.h>
 
31
#include <qvbox.h>
 
32
#include <qwidget.h>
 
33
 
 
34
//#include <algorithm>
 
35
 
 
36
#include <kcolorbutton.h>
 
37
#include <kconfig.h>
 
38
#include <kdebug.h>
 
39
#include <kdialog.h>
 
40
#include <kfontdialog.h>
 
41
#include <klistview.h>
 
42
#include <klocale.h>
 
43
#include <kmessagebox.h>
 
44
#include <knuminput.h>
 
45
#include <kpushbutton.h>
 
46
 
 
47
#include "contextstyle.h"
 
48
#include "kformulaconfigpage.h"
 
49
#include "kformuladocument.h"
 
50
#include "symboltable.h"
 
51
 
 
52
KFORMULA_NAMESPACE_BEGIN
 
53
 
 
54
class ConfigurePage::Private
 
55
{
 
56
public:
 
57
    QCheckBox* syntaxHighlighting;
 
58
    bool m_changed;
 
59
};
 
60
 
 
61
ConfigurePage::ConfigurePage( Document* document, QWidget* view, KConfig* config, QVBox* box, char* name )
 
62
    : QObject( box->parent(), name ), m_document( document ), m_view( view ), m_config( config )
 
63
{
 
64
    d = new Private;
 
65
    d->m_changed = false;
 
66
    const ContextStyle& contextStyle = document->getContextStyle( true );
 
67
 
 
68
    // fonts
 
69
 
 
70
    QGroupBox *gbox = new QGroupBox( i18n( "Fonts" ), box );
 
71
    gbox->setColumnLayout( 0, Qt::Horizontal );
 
72
 
 
73
    QGridLayout* grid = new QGridLayout( gbox->layout(), 5, 3 );
 
74
    grid->setSpacing( KDialog::spacingHint() );
 
75
 
 
76
    grid->setColStretch(1, 1);
 
77
 
 
78
    defaultFont = contextStyle.getDefaultFont();
 
79
    nameFont = contextStyle.getNameFont();
 
80
    numberFont = contextStyle.getNumberFont();
 
81
    operatorFont = contextStyle.getOperatorFont();
 
82
 
 
83
    connect( buildFontLine( gbox, grid, 0, defaultFont,
 
84
            i18n( "Default font:" ), defaultFontName ),
 
85
            SIGNAL( clicked() ), SLOT( selectNewDefaultFont() ) );
 
86
 
 
87
    connect( buildFontLine( gbox, grid, 1, nameFont,
 
88
            i18n( "Name font:" ), nameFontName ),
 
89
            SIGNAL( clicked() ), SLOT( selectNewNameFont() ) );
 
90
 
 
91
    connect( buildFontLine( gbox, grid, 2, numberFont,
 
92
            i18n( "Number font:" ), numberFontName ),
 
93
            SIGNAL( clicked() ), SLOT( selectNewNumberFont() ) );
 
94
 
 
95
    connect( buildFontLine( gbox, grid, 3, operatorFont,
 
96
            i18n( "Operator font:" ), operatorFontName ),
 
97
            SIGNAL( clicked() ), SLOT( selectNewOperatorFont() ) );
 
98
 
 
99
    QLabel* sizeTitle = new QLabel( i18n( "Default base size:" ), gbox );
 
100
    grid->addWidget( sizeTitle, 4, 0 );
 
101
 
 
102
    sizeSpin = new KIntNumInput( contextStyle.baseSize(), gbox );
 
103
    sizeSpin->setRange( 8, 72, 1, true );
 
104
 
 
105
    grid->addMultiCellWidget( sizeSpin, 4, 4, 1, 2 );
 
106
 
 
107
    connect( sizeSpin, SIGNAL( valueChanged( int ) ),
 
108
            SLOT( baseSizeChanged( int ) ) );
 
109
 
 
110
    // syntax highlighting
 
111
 
 
112
    d->syntaxHighlighting = new QCheckBox( i18n( "Use syntax highlighting" ),box );
 
113
    d->syntaxHighlighting->setChecked( contextStyle.syntaxHighlighting() );
 
114
 
 
115
//     hlBox = new QGroupBox( i18n( "Highlight Colors" ), box );
 
116
//     hlBox->setColumnLayout( 0, Qt::Horizontal );
 
117
 
 
118
//     grid = new QGridLayout( hlBox->layout(), 5, 2 );
 
119
//     grid->setSpacing( KDialog::spacingHint() );
 
120
 
 
121
//     QLabel* defaultLabel = new QLabel( hlBox, "defaultLabel" );
 
122
//     defaultLabel->setText( i18n( "Default color:" ) );
 
123
//     grid->addWidget( defaultLabel, 0, 0 );
 
124
 
 
125
//     defaultColorBtn = new KColorButton( hlBox, "defaultColor" );
 
126
//     defaultColorBtn->setColor( contextStyle.getDefaultColor() );
 
127
//     grid->addWidget( defaultColorBtn, 0, 1 );
 
128
 
 
129
 
 
130
//     QLabel* numberLabel = new QLabel( hlBox, "numberLabel" );
 
131
//     numberLabel->setText( i18n( "Number color:" ) );
 
132
//     grid->addWidget( numberLabel, 1, 0 );
 
133
 
 
134
//     numberColorBtn = new KColorButton( hlBox, "numberColor" );
 
135
//     numberColorBtn->setColor( contextStyle.getNumberColorPlain() );
 
136
//     grid->addWidget( numberColorBtn, 1, 1 );
 
137
 
 
138
 
 
139
//     QLabel* operatorLabel = new QLabel( hlBox, "operatorLabel" );
 
140
//     operatorLabel->setText( i18n( "Operator color:" ) );
 
141
//     grid->addWidget( operatorLabel, 2, 0 );
 
142
 
 
143
//     operatorColorBtn = new KColorButton( hlBox, "operatorColor" );
 
144
//     operatorColorBtn->setColor( contextStyle.getOperatorColorPlain() );
 
145
//     grid->addWidget( operatorColorBtn, 2, 1 );
 
146
 
 
147
 
 
148
//     QLabel* emptyLabel = new QLabel( hlBox, "emptyLabel" );
 
149
//     emptyLabel->setText( i18n( "Empty color:" ) );
 
150
//     grid->addWidget( emptyLabel, 3, 0 );
 
151
 
 
152
//     emptyColorBtn = new KColorButton( hlBox, "emptyColor" );
 
153
//     emptyColorBtn->setColor( contextStyle.getEmptyColorPlain() );
 
154
//     grid->addWidget( emptyColorBtn, 3, 1 );
 
155
 
 
156
 
 
157
//     QLabel* errorLabel = new QLabel( hlBox, "errorLabel" );
 
158
//     errorLabel->setText( i18n( "Error color:" ) );
 
159
//     grid->addWidget( errorLabel, 4, 0 );
 
160
 
 
161
//     errorColorBtn = new KColorButton( hlBox, "errorColor" );
 
162
//     errorColorBtn->setColor( contextStyle.getErrorColorPlain() );
 
163
//     grid->addWidget( errorColorBtn, 4, 1 );
 
164
 
 
165
    connect( d->syntaxHighlighting, SIGNAL( clicked() ),
 
166
            SLOT( syntaxHighlightingClicked() ) );
 
167
 
 
168
    syntaxHighlightingClicked();
 
169
 
 
170
    styleBox = new QButtonGroup( i18n( "Font Style" ), box );
 
171
    styleBox->setColumnLayout( 0, Qt::Horizontal );
 
172
 
 
173
    grid = new QGridLayout( styleBox->layout(), 3, 1 );
 
174
    grid->setSpacing( KDialog::spacingHint() );
 
175
 
 
176
    esstixStyle = new QRadioButton( i18n( "Esstix font style" ), styleBox, "esstixStyle" );
 
177
    esstixStyle->setChecked( contextStyle.getFontStyle() == "esstix" );
 
178
 
 
179
    cmStyle = new QRadioButton( i18n( "Computer modern (TeX) style" ), styleBox, "cmStyle" );
 
180
    cmStyle->setChecked( contextStyle.getFontStyle() == "tex" );
 
181
 
 
182
    symbolStyle = new QRadioButton( i18n( "Symbol font style" ), styleBox, "symbolStyle" );
 
183
    symbolStyle->setChecked( !esstixStyle->isChecked() && !cmStyle->isChecked() );
 
184
 
 
185
    grid->addWidget( symbolStyle, 0, 0 );
 
186
    grid->addWidget( esstixStyle, 1, 0 );
 
187
    grid->addWidget( cmStyle, 2, 0 );
 
188
 
 
189
    connect( styleBox, SIGNAL( clicked( int ) ), this, SLOT( slotChanged() ) );
 
190
    connect( d->syntaxHighlighting, SIGNAL( clicked() ), this, SLOT( slotChanged() ) );
 
191
    connect( sizeSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
 
192
 
 
193
    Q_ASSERT( !d->m_changed );
 
194
}
 
195
 
 
196
ConfigurePage::~ConfigurePage()
 
197
{
 
198
    delete d;
 
199
}
 
200
 
 
201
QPushButton* ConfigurePage::buildFontLine( QWidget* parent,
 
202
            QGridLayout* layout, int number, QFont font, QString name,
 
203
            QLabel*& fontName )
 
204
{
 
205
    QLabel* fontTitle = new QLabel( name, parent );
 
206
 
 
207
    QString labelName = font.family() + ' ' + QString::number( font.pointSize() );
 
208
    fontName = new QLabel( labelName, parent );
 
209
    fontName->setFont( font );
 
210
    fontName->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
 
211
 
 
212
    QPushButton* chooseButton = new QPushButton( i18n( "Choose..." ), parent );
 
213
 
 
214
    layout->addWidget( fontTitle, number, 0 );
 
215
    layout->addWidget( fontName, number, 1 );
 
216
    layout->addWidget( chooseButton, number, 2 );
 
217
 
 
218
    return chooseButton;
 
219
}
 
220
 
 
221
 
 
222
static bool fontAvailable( QString fontName )
 
223
{
 
224
    QFont f( fontName );
 
225
    QStringList fields = QStringList::split( '-', f.rawName() );
 
226
    if ( ( fields.size() > 1 ) &&
 
227
         ( ( fields[1].upper() == fontName.upper() ) ||
 
228
           ( fields[0].upper() == fontName.upper() ) ) ) {
 
229
        return true;
 
230
    }
 
231
    else {
 
232
        kdWarning(39001) << "Font '" << fontName << "' not found but '" << f.rawName() << "'." << endl;
 
233
        return false;
 
234
    }
 
235
}
 
236
 
 
237
 
 
238
inline void testFont( QStringList& missing, const QString& fontName ) {
 
239
    if ( !fontAvailable( fontName ) ) {
 
240
        missing.append( fontName );
 
241
    }
 
242
}
 
243
 
 
244
void ConfigurePage::apply()
 
245
{
 
246
    if ( !d->m_changed )
 
247
        return;
 
248
    QString fontStyle;
 
249
    if ( esstixStyle->isChecked() ) {
 
250
        fontStyle = "esstix";
 
251
 
 
252
        QStringList missing;
 
253
        testFont( missing, "esstixeight" );
 
254
        testFont( missing, "esstixeleven" );
 
255
        testFont( missing, "esstixfifteen" );
 
256
        testFont( missing, "esstixfive" );
 
257
        testFont( missing, "esstixfour" );
 
258
        testFont( missing, "esstixfourteen" );
 
259
        testFont( missing, "esstixnine" );
 
260
        testFont( missing, "esstixone" );
 
261
        testFont( missing, "esstixseven" );
 
262
        testFont( missing, "esstixseventeen" );
 
263
        testFont( missing, "esstixsix" );
 
264
        testFont( missing, "esstixsixteen" );
 
265
        testFont( missing, "esstixten" );
 
266
        testFont( missing, "esstixthirteen" );
 
267
        testFont( missing, "esstixthree" );
 
268
        testFont( missing, "esstixtwelve" );
 
269
        testFont( missing, "esstixtwo" );
 
270
 
 
271
        if ( missing.count() > 0 ) {
 
272
            QString text = i18n( "The fonts '%1' are missing."
 
273
                                 " Do you want to change the font style anyway?" )
 
274
                           .arg( missing.join( "', '" ) );
 
275
            if ( KMessageBox::warningContinueCancel( m_view, text ) ==
 
276
                 KMessageBox::Cancel ) {
 
277
                return;
 
278
            }
 
279
        }
 
280
    }
 
281
    else if ( cmStyle->isChecked() ) {
 
282
        fontStyle = "tex";
 
283
 
 
284
        QStringList missing;
 
285
        testFont( missing, "cmbx10" );
 
286
        testFont( missing, "cmex10" );
 
287
        testFont( missing, "cmmi10" );
 
288
        testFont( missing, "cmr10" );
 
289
        testFont( missing, "cmsy10" );
 
290
        testFont( missing, "msam10" );
 
291
        testFont( missing, "msbm10" );
 
292
 
 
293
        if ( missing.count() > 0 ) {
 
294
            QString text = i18n( "The fonts '%1' are missing."
 
295
                                 " Do you want to change the font style anyway?" )
 
296
                           .arg( missing.join( "', '" ) );
 
297
            if ( KMessageBox::warningContinueCancel( m_view, text ) ==
 
298
                 KMessageBox::Cancel ) {
 
299
                return;
 
300
            }
 
301
        }
 
302
    }
 
303
    else { // symbolStyle->isChecked ()
 
304
        fontStyle = "symbol";
 
305
 
 
306
        QStringList missing;
 
307
        testFont( missing, "symbol" );
 
308
 
 
309
        if ( missing.count() > 0 ) {
 
310
            QString text = i18n( "The font 'symbol' is missing."
 
311
                                 " Do you want to change the font style anyway?" );
 
312
            if ( KMessageBox::warningContinueCancel( m_view, text ) ==
 
313
                 KMessageBox::Cancel ) {
 
314
                return;
 
315
            }
 
316
 
 
317
        }
 
318
    }
 
319
 
 
320
    ContextStyle& contextStyle = m_document->getContextStyle( true );
 
321
 
 
322
    contextStyle.setDefaultFont( defaultFont );
 
323
    contextStyle.setNameFont( nameFont );
 
324
    contextStyle.setNumberFont( numberFont );
 
325
    contextStyle.setOperatorFont( operatorFont );
 
326
    contextStyle.setBaseSize( sizeSpin->value() );
 
327
 
 
328
    contextStyle.setFontStyle( fontStyle );
 
329
 
 
330
    contextStyle.setSyntaxHighlighting( d->syntaxHighlighting->isChecked() );
 
331
//     contextStyle.setDefaultColor( defaultColorBtn->color() );
 
332
//     contextStyle.setNumberColor( numberColorBtn->color() );
 
333
//     contextStyle.setOperatorColor( operatorColorBtn->color() );
 
334
//     contextStyle.setEmptyColor( emptyColorBtn->color() );
 
335
//     contextStyle.setErrorColor( errorColorBtn->color() );
 
336
 
 
337
    m_config->setGroup( "kformula Font" );
 
338
    m_config->writeEntry( "defaultFont", defaultFont.toString() );
 
339
    m_config->writeEntry( "nameFont", nameFont.toString() );
 
340
    m_config->writeEntry( "numberFont", numberFont.toString() );
 
341
    m_config->writeEntry( "operatorFont", operatorFont.toString() );
 
342
    m_config->writeEntry( "baseSize", QString::number( sizeSpin->value() ) );
 
343
 
 
344
    m_config->writeEntry( "fontStyle", fontStyle );
 
345
 
 
346
//     m_config->setGroup( "kformula Color" );
 
347
//     m_config->writeEntry( "syntaxHighlighting", d->syntaxHighlighting->isChecked() );
 
348
//     m_config->writeEntry( "defaultColor", defaultColorBtn->color() );
 
349
//     m_config->writeEntry( "numberColor",  numberColorBtn->color() );
 
350
//     m_config->writeEntry( "operatorColor", operatorColorBtn->color() );
 
351
//     m_config->writeEntry( "emptyColor", emptyColorBtn->color() );
 
352
//     m_config->writeEntry( "errorColor", errorColorBtn->color() );
 
353
 
 
354
    // notify!!!
 
355
    m_document->updateConfig();
 
356
    d->m_changed = false;
 
357
}
 
358
 
 
359
void ConfigurePage::slotDefault()
 
360
{
 
361
    defaultFont = QFont( "Times", 12, QFont::Normal, true );
 
362
    nameFont = QFont( "Times" );
 
363
    numberFont = nameFont;
 
364
    operatorFont = nameFont;
 
365
 
 
366
    sizeSpin->setValue( 20 );
 
367
 
 
368
    updateFontLabel( defaultFont, defaultFontName );
 
369
    updateFontLabel( nameFont, nameFontName );
 
370
    updateFontLabel( numberFont, numberFontName );
 
371
    updateFontLabel( operatorFont, operatorFontName );
 
372
 
 
373
    symbolStyle->setChecked( true );
 
374
 
 
375
    d->syntaxHighlighting->setChecked( true );
 
376
    syntaxHighlightingClicked();
 
377
 
 
378
//     defaultColorBtn->setColor( Qt::black );
 
379
//     numberColorBtn->setColor( Qt::blue );
 
380
//     operatorColorBtn->setColor( Qt::darkGreen );
 
381
//     emptyColorBtn->setColor( Qt::blue );
 
382
//     errorColorBtn->setColor( Qt::darkRed );
 
383
    slotChanged();
 
384
}
 
385
 
 
386
void ConfigurePage::syntaxHighlightingClicked()
 
387
{
 
388
//     bool checked = d->syntaxHighlighting->isChecked();
 
389
//     hlBox->setEnabled( checked );
 
390
}
 
391
 
 
392
void ConfigurePage::selectNewDefaultFont()
 
393
{
 
394
    if ( selectFont( defaultFont ) )
 
395
        updateFontLabel( defaultFont, defaultFontName );
 
396
}
 
397
 
 
398
void ConfigurePage::selectNewNameFont()
 
399
{
 
400
    if ( selectFont( nameFont ) )
 
401
        updateFontLabel( nameFont, nameFontName );
 
402
}
 
403
 
 
404
void ConfigurePage::selectNewNumberFont()
 
405
{
 
406
    if ( selectFont( numberFont ) )
 
407
        updateFontLabel( numberFont, numberFontName );
 
408
}
 
409
 
 
410
void ConfigurePage::selectNewOperatorFont()
 
411
{
 
412
    if ( selectFont( operatorFont ) )
 
413
        updateFontLabel( operatorFont, operatorFontName );
 
414
}
 
415
 
 
416
bool ConfigurePage::selectFont( QFont & font )
 
417
{
 
418
    QStringList list;
 
419
 
 
420
    KFontChooser::getFontList( list, KFontChooser::SmoothScalableFonts );
 
421
 
 
422
    KFontDialog dlg( m_view, 0, false, true, list );
 
423
    dlg.setFont( font );
 
424
 
 
425
    int result = dlg.exec();
 
426
    if (  KDialog::Accepted == result ) {
 
427
        font = dlg.font();
 
428
        slotChanged();
 
429
        return true;
 
430
    }
 
431
 
 
432
    return false;
 
433
}
 
434
 
 
435
void ConfigurePage::baseSizeChanged( int /*value*/ )
 
436
{
 
437
}
 
438
 
 
439
void ConfigurePage::updateFontLabel( QFont font, QLabel* label )
 
440
{
 
441
    label->setText( font.family() + ' ' + QString::number( font.pointSize() ) );
 
442
    label->setFont( font );
 
443
}
 
444
 
 
445
void ConfigurePage::slotChanged()
 
446
{
 
447
    d->m_changed = true;
 
448
}
 
449
 
 
450
// class UsedFontItem : public KListViewItem {
 
451
// public:
 
452
//     UsedFontItem( MathFontsConfigurePage* page, QListView* parent, QString font )
 
453
//         : KListViewItem( parent, font ), m_page( page ) {}
 
454
 
 
455
//     int compare( QListViewItem* i, int col, bool ascending ) const;
 
456
 
 
457
// private:
 
458
//     MathFontsConfigurePage* m_page;
 
459
// };
 
460
 
 
461
// int UsedFontItem::compare( QListViewItem* i, int, bool ) const
 
462
// {
 
463
//     QValueVector<QString>::iterator lhsIt = m_page->findUsedFont( text( 0 ) );
 
464
//     QValueVector<QString>::iterator rhsIt = m_page->findUsedFont( i->text( 0 ) );
 
465
//     if ( lhsIt < rhsIt ) {
 
466
//         return -1;
 
467
//     }
 
468
//     else if ( lhsIt > rhsIt ) {
 
469
//         return 1;
 
470
//     }
 
471
//     return 0;
 
472
// }
 
473
 
 
474
// MathFontsConfigurePage::MathFontsConfigurePage( Document* document, QWidget* view,
 
475
//                                                 KConfig* config, QVBox* box, char* name )
 
476
//     : QObject( box->parent(), name ), m_document( document ), m_view( view ), m_config( config )
 
477
// {
 
478
//     QWidget* fontWidget = new QWidget( box );
 
479
//     QGridLayout* fontLayout = new QGridLayout( fontWidget, 1, 1, KDialog::marginHint(), KDialog::spacingHint() );
 
480
 
 
481
//     QHBoxLayout* hLayout = new QHBoxLayout( 0, 0, 6 );
 
482
 
 
483
//     availableFonts = new KListView( fontWidget );
 
484
//     availableFonts->addColumn( i18n( "Available Fonts" ) );
 
485
//     hLayout->addWidget( availableFonts );
 
486
 
 
487
//     QVBoxLayout* vLayout = new QVBoxLayout( 0, 0, 6 );
 
488
//     QSpacerItem* spacer1 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
489
//     vLayout->addItem( spacer1 );
 
490
 
 
491
//     addFont = new KPushButton( fontWidget );
 
492
//     addFont->setText( "->" );
 
493
//     vLayout->addWidget( addFont );
 
494
 
 
495
//     removeFont = new KPushButton( fontWidget );
 
496
//     removeFont->setText( "<-" );
 
497
//     vLayout->addWidget( removeFont );
 
498
 
 
499
//     QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
500
//     vLayout->addItem( spacer2 );
 
501
 
 
502
//     hLayout->addLayout( vLayout );
 
503
 
 
504
//     vLayout = new QVBoxLayout( 0, 0, 6 );
 
505
 
 
506
//     moveUp = new KPushButton( fontWidget );
 
507
//     moveUp->setText( i18n( "Up" ) );
 
508
//     vLayout->addWidget( moveUp );
 
509
 
 
510
//     requestedFonts = new KListView( fontWidget );
 
511
//     requestedFonts->addColumn( i18n( "Used Fonts" ) );
 
512
//     vLayout->addWidget( requestedFonts );
 
513
 
 
514
//     moveDown = new KPushButton( fontWidget );
 
515
//     moveDown->setText( i18n( "Down" ) );
 
516
//     vLayout->addWidget( moveDown );
 
517
 
 
518
//     hLayout->addLayout( vLayout );
 
519
 
 
520
//     fontLayout->addLayout( hLayout, 0, 0 );
 
521
 
 
522
// //     connect( availableFonts, SIGNAL( executed( QListViewItem* ) ),
 
523
// //              this, SLOT( slotAddFont() ) );
 
524
// //     connect( requestedFonts, SIGNAL( executed( QListViewItem* ) ),
 
525
// //              this, SLOT( slotRemoveFont() ) );
 
526
//     connect( addFont, SIGNAL( clicked() ), this, SLOT( slotAddFont() ) );
 
527
//     connect( removeFont, SIGNAL( clicked() ), this, SLOT( slotRemoveFont() ) );
 
528
//     connect( moveUp, SIGNAL( clicked() ), this, SLOT( slotMoveUp() ) );
 
529
//     connect( moveDown, SIGNAL( clicked() ), this, SLOT( slotMoveDown() ) );
 
530
 
 
531
//     const ContextStyle& contextStyle = document->getContextStyle( true );
 
532
//     const SymbolTable& symbolTable = contextStyle.symbolTable();
 
533
//     const QStringList& usedFonts = contextStyle.requestedFonts();
 
534
 
 
535
//     QMap<QString, QString> fontMap;
 
536
// //    symbolTable.findAvailableFonts( &fontMap );
 
537
 
 
538
//     setupLists( usedFonts );
 
539
// }
 
540
 
 
541
// void MathFontsConfigurePage::apply()
 
542
// {
 
543
//     QStringList strings;
 
544
//     std::copy( usedFontList.begin(), usedFontList.end(), std::back_inserter( strings ) );
 
545
 
 
546
//     m_config->setGroup( "kformula Font" );
 
547
//     m_config->writeEntry( "usedMathFonts", strings );
 
548
 
 
549
//     ContextStyle& contextStyle = m_document->getContextStyle( true );
 
550
//     contextStyle.setRequestedFonts( strings );
 
551
// }
 
552
 
 
553
// void MathFontsConfigurePage::slotDefault()
 
554
// {
 
555
//     QStringList usedFonts;
 
556
 
 
557
//     usedFonts.push_back( "esstixone" );
 
558
//     usedFonts.push_back( "esstixtwo" );
 
559
//     usedFonts.push_back( "esstixthree" );
 
560
//     usedFonts.push_back( "esstixfour" );
 
561
//     usedFonts.push_back( "esstixfive" );
 
562
//     usedFonts.push_back( "esstixsix" );
 
563
//     usedFonts.push_back( "esstixseven" );
 
564
//     usedFonts.push_back( "esstixeight" );
 
565
//     usedFonts.push_back( "esstixnine" );
 
566
//     usedFonts.push_back( "esstixten" );
 
567
//     usedFonts.push_back( "esstixeleven" );
 
568
//     usedFonts.push_back( "esstixtwelve" );
 
569
//     usedFonts.push_back( "esstixthirteen" );
 
570
//     usedFonts.push_back( "esstixfourteen" );
 
571
//     usedFonts.push_back( "esstixfifteen" );
 
572
//     usedFonts.push_back( "esstixsixteen" );
 
573
//     usedFonts.push_back( "esstixseventeen" );
 
574
 
 
575
//     usedFontList.clear();
 
576
//     requestedFonts->clear();
 
577
//     availableFonts->clear();
 
578
 
 
579
//     setupLists( usedFonts );
 
580
// }
 
581
 
 
582
// QValueVector<QString>::iterator MathFontsConfigurePage::findUsedFont( QString name )
 
583
// {
 
584
//     return std::find( usedFontList.begin(), usedFontList.end(), name );
 
585
// }
 
586
 
 
587
// void MathFontsConfigurePage::setupLists( const QStringList& usedFonts )
 
588
// {
 
589
//     const ContextStyle& contextStyle = m_document->getContextStyle( true );
 
590
//     const SymbolTable& symbolTable = contextStyle.symbolTable();
 
591
 
 
592
//     QMap<QString, QString> fontMap;
 
593
// //    symbolTable.findAvailableFonts( &fontMap );
 
594
 
 
595
//     for ( QStringList::const_iterator it = usedFonts.begin(); it != usedFonts.end(); ++it ) {
 
596
//         QMap<QString, QString>::iterator font = fontMap.find( *it );
 
597
//         if ( font != fontMap.end() ) {
 
598
//             fontMap.erase( font );
 
599
//             new UsedFontItem( this, requestedFonts, *it );
 
600
//             usedFontList.push_back( *it );
 
601
//         }
 
602
//     }
 
603
//     for ( QMap<QString, QString>::iterator it = fontMap.begin(); it != fontMap.end(); ++it ) {
 
604
//         new KListViewItem( availableFonts, it.key() );
 
605
//     }
 
606
// }
 
607
 
 
608
// void MathFontsConfigurePage::slotAddFont()
 
609
// {
 
610
//     QListViewItem* fontItem = availableFonts->selectedItem();
 
611
//     if ( fontItem ) {
 
612
//         QString fontName = fontItem->text( 0 );
 
613
//         //availableFonts->takeItem( fontItem );
 
614
//         delete fontItem;
 
615
 
 
616
//         new UsedFontItem( this, requestedFonts, fontName );
 
617
//         usedFontList.push_back( fontName );
 
618
//     }
 
619
// }
 
620
 
 
621
// void MathFontsConfigurePage::slotRemoveFont()
 
622
// {
 
623
//     QListViewItem* fontItem = requestedFonts->selectedItem();
 
624
//     if ( fontItem ) {
 
625
//         QString fontName = fontItem->text( 0 );
 
626
//         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
 
627
//         if ( it != usedFontList.end() ) {
 
628
//             usedFontList.erase( it );
 
629
//         }
 
630
//         //requestedFonts->takeItem( fontItem );
 
631
//         delete fontItem;
 
632
//         new KListViewItem( availableFonts, fontName );
 
633
//     }
 
634
// }
 
635
 
 
636
// void MathFontsConfigurePage::slotMoveUp()
 
637
// {
 
638
//     QListViewItem* fontItem = requestedFonts->selectedItem();
 
639
//     if ( fontItem ) {
 
640
//         QString fontName = fontItem->text( 0 );
 
641
//         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
 
642
//         if ( it != usedFontList.end() ) {
 
643
//             uint pos = it - usedFontList.begin();
 
644
//             if ( pos > 0 ) {
 
645
//                 QValueVector<QString>::iterator before = it-1;
 
646
//                 std::swap( *it, *before );
 
647
//                 requestedFonts->sort();
 
648
//             }
 
649
//         }
 
650
//     }
 
651
// }
 
652
 
 
653
// void MathFontsConfigurePage::slotMoveDown()
 
654
// {
 
655
//     QListViewItem* fontItem = requestedFonts->selectedItem();
 
656
//     if ( fontItem ) {
 
657
//         QString fontName = fontItem->text( 0 );
 
658
//         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
 
659
//         if ( it != usedFontList.end() ) {
 
660
//             uint pos = it - usedFontList.begin();
 
661
//             if ( pos < usedFontList.size()-1 ) {
 
662
//                 QValueVector<QString>::iterator after = it+1;
 
663
//                 std::swap( *it, *after );
 
664
//                 requestedFonts->sort();
 
665
//             }
 
666
//         }
 
667
//     }
 
668
// }
 
669
 
 
670
KFORMULA_NAMESPACE_END
 
671
 
 
672
using namespace KFormula;
 
673
#include "kformulaconfigpage.moc"