lib

kformulaconfigpage.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
00003                   Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <qvariant.h>   // first for gcc 2.7.2
00022 #include <qbuttongroup.h>
00023 #include <qcheckbox.h>
00024 #include <qgroupbox.h>
00025 #include <qlabel.h>
00026 #include <qlayout.h>
00027 #include <qmap.h>
00028 #include <qradiobutton.h>
00029 #include <qspinbox.h>
00030 #include <qstringlist.h>
00031 #include <qvbox.h>
00032 #include <qwidget.h>
00033 
00034 //#include <algorithm>
00035 
00036 #include <kcolorbutton.h>
00037 #include <kconfig.h>
00038 #include <kdebug.h>
00039 #include <kdialog.h>
00040 #include <kfontdialog.h>
00041 #include <klistview.h>
00042 #include <klocale.h>
00043 #include <kmessagebox.h>
00044 #include <knuminput.h>
00045 #include <kpushbutton.h>
00046 
00047 #include "contextstyle.h"
00048 #include "kformulaconfigpage.h"
00049 #include "kformuladocument.h"
00050 #include "symboltable.h"
00051 #include "esstixfontstyle.h"
00052 #include "cmstyle.h"
00053 #include "symbolfontstyle.h"
00054 
00055 
00056 KFORMULA_NAMESPACE_BEGIN
00057 
00058 
00059 ConfigurePage::ConfigurePage( Document* document, QWidget* view, KConfig* config, QVBox* box, char* name )
00060     : QObject( box->parent(), name ), m_document( document ), m_view( view ), m_config( config ), m_changed( false )
00061 {
00062     const ContextStyle& contextStyle = document->getContextStyle( true );
00063 
00064     // fonts
00065 
00066     QGroupBox *gbox = new QGroupBox( i18n( "Fonts" ), box );
00067     gbox->setColumnLayout( 0, Qt::Horizontal );
00068 
00069     QGridLayout* grid = new QGridLayout( gbox->layout(), 5, 3 );
00070     grid->setSpacing( KDialog::spacingHint() );
00071 
00072     grid->setColStretch(1, 1);
00073 
00074     defaultFont = contextStyle.getDefaultFont();
00075     nameFont = contextStyle.getNameFont();
00076     numberFont = contextStyle.getNumberFont();
00077     operatorFont = contextStyle.getOperatorFont();
00078 
00079     connect( buildFontLine( gbox, grid, 0, defaultFont,
00080             i18n( "Default font:" ), defaultFontName ),
00081             SIGNAL( clicked() ), SLOT( selectNewDefaultFont() ) );
00082 
00083     connect( buildFontLine( gbox, grid, 1, nameFont,
00084             i18n( "Name font:" ), nameFontName ),
00085             SIGNAL( clicked() ), SLOT( selectNewNameFont() ) );
00086 
00087     connect( buildFontLine( gbox, grid, 2, numberFont,
00088             i18n( "Number font:" ), numberFontName ),
00089             SIGNAL( clicked() ), SLOT( selectNewNumberFont() ) );
00090 
00091     connect( buildFontLine( gbox, grid, 3, operatorFont,
00092             i18n( "Operator font:" ), operatorFontName ),
00093             SIGNAL( clicked() ), SLOT( selectNewOperatorFont() ) );
00094 
00095     QLabel* sizeTitle = new QLabel( i18n( "Default base size:" ), gbox );
00096     grid->addWidget( sizeTitle, 4, 0 );
00097 
00098     sizeSpin = new KIntNumInput( contextStyle.baseSize(), gbox );
00099     sizeSpin->setRange( 8, 72, 1, true );
00100 
00101     grid->addMultiCellWidget( sizeSpin, 4, 4, 1, 2 );
00102 
00103     connect( sizeSpin, SIGNAL( valueChanged( int ) ),
00104             SLOT( baseSizeChanged( int ) ) );
00105 
00106     // syntax highlighting
00107 
00108     syntaxHighlighting = new QCheckBox( i18n( "Use syntax highlighting" ),box );
00109     syntaxHighlighting->setChecked( contextStyle.syntaxHighlighting() );
00110 
00111 //     hlBox = new QGroupBox( i18n( "Highlight Colors" ), box );
00112 //     hlBox->setColumnLayout( 0, Qt::Horizontal );
00113 
00114 //     grid = new QGridLayout( hlBox->layout(), 5, 2 );
00115 //     grid->setSpacing( KDialog::spacingHint() );
00116 
00117 //     QLabel* defaultLabel = new QLabel( hlBox, "defaultLabel" );
00118 //     defaultLabel->setText( i18n( "Default color:" ) );
00119 //     grid->addWidget( defaultLabel, 0, 0 );
00120 
00121 //     defaultColorBtn = new KColorButton( hlBox, "defaultColor" );
00122 //     defaultColorBtn->setColor( contextStyle.getDefaultColor() );
00123 //     grid->addWidget( defaultColorBtn, 0, 1 );
00124 
00125 
00126 //     QLabel* numberLabel = new QLabel( hlBox, "numberLabel" );
00127 //     numberLabel->setText( i18n( "Number color:" ) );
00128 //     grid->addWidget( numberLabel, 1, 0 );
00129 
00130 //     numberColorBtn = new KColorButton( hlBox, "numberColor" );
00131 //     numberColorBtn->setColor( contextStyle.getNumberColorPlain() );
00132 //     grid->addWidget( numberColorBtn, 1, 1 );
00133 
00134 
00135 //     QLabel* operatorLabel = new QLabel( hlBox, "operatorLabel" );
00136 //     operatorLabel->setText( i18n( "Operator color:" ) );
00137 //     grid->addWidget( operatorLabel, 2, 0 );
00138 
00139 //     operatorColorBtn = new KColorButton( hlBox, "operatorColor" );
00140 //     operatorColorBtn->setColor( contextStyle.getOperatorColorPlain() );
00141 //     grid->addWidget( operatorColorBtn, 2, 1 );
00142 
00143 
00144 //     QLabel* emptyLabel = new QLabel( hlBox, "emptyLabel" );
00145 //     emptyLabel->setText( i18n( "Empty color:" ) );
00146 //     grid->addWidget( emptyLabel, 3, 0 );
00147 
00148 //     emptyColorBtn = new KColorButton( hlBox, "emptyColor" );
00149 //     emptyColorBtn->setColor( contextStyle.getEmptyColorPlain() );
00150 //     grid->addWidget( emptyColorBtn, 3, 1 );
00151 
00152 
00153 //     QLabel* errorLabel = new QLabel( hlBox, "errorLabel" );
00154 //     errorLabel->setText( i18n( "Error color:" ) );
00155 //     grid->addWidget( errorLabel, 4, 0 );
00156 
00157 //     errorColorBtn = new KColorButton( hlBox, "errorColor" );
00158 //     errorColorBtn->setColor( contextStyle.getErrorColorPlain() );
00159 //     grid->addWidget( errorColorBtn, 4, 1 );
00160 
00161     connect( syntaxHighlighting, SIGNAL( clicked() ),
00162             SLOT( syntaxHighlightingClicked() ) );
00163 
00164     syntaxHighlightingClicked();
00165 
00166     styleBox = new QButtonGroup( i18n( "Font Style" ), box );
00167     styleBox->setColumnLayout( 0, Qt::Horizontal );
00168 
00169     grid = new QGridLayout( styleBox->layout(), 3, 1 );
00170     grid->setSpacing( KDialog::spacingHint() );
00171 
00172     esstixStyle = new QRadioButton( i18n( "Esstix font style" ), styleBox, "esstixStyle" );
00173     esstixStyle->setChecked( contextStyle.getFontStyle() == "esstix" );
00174 
00175     cmStyle = new QRadioButton( i18n( "Computer modern (TeX) style" ), styleBox, "cmStyle" );
00176     cmStyle->setChecked( contextStyle.getFontStyle() == "tex" );
00177 
00178     symbolStyle = new QRadioButton( i18n( "Symbol font style" ), styleBox, "symbolStyle" );
00179     symbolStyle->setChecked( !esstixStyle->isChecked() && !cmStyle->isChecked() );
00180 
00181     grid->addWidget( symbolStyle, 0, 0 );
00182     grid->addWidget( esstixStyle, 1, 0 );
00183     grid->addWidget( cmStyle, 2, 0 );
00184 
00185     connect( styleBox, SIGNAL( clicked( int ) ), this, SLOT( slotChanged() ) );
00186     connect( syntaxHighlighting, SIGNAL( clicked() ), this, SLOT( slotChanged() ) );
00187     connect( sizeSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
00188 
00189     Q_ASSERT( !m_changed );
00190 }
00191 
00192 
00193 QPushButton* ConfigurePage::buildFontLine( QWidget* parent,
00194             QGridLayout* layout, int number, QFont font, QString name,
00195             QLabel*& fontName )
00196 {
00197     QLabel* fontTitle = new QLabel( name, parent );
00198 
00199     QString labelName = font.family() + ' ' + QString::number( font.pointSize() );
00200     fontName = new QLabel( labelName, parent );
00201     fontName->setFont( font );
00202     fontName->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
00203 
00204     QPushButton* chooseButton = new QPushButton( i18n( "Choose..." ), parent );
00205 
00206     layout->addWidget( fontTitle, number, 0 );
00207     layout->addWidget( fontName, number, 1 );
00208     layout->addWidget( chooseButton, number, 2 );
00209 
00210     return chooseButton;
00211 }
00212 
00213 
00214 void ConfigurePage::apply()
00215 {
00216     if ( !m_changed )
00217         return;
00218     QString fontStyle;
00219     if ( esstixStyle->isChecked() ) {
00220         fontStyle = "esstix";
00221 
00222         QStringList missing = EsstixFontStyle::missingFonts();
00223 
00224         if ( missing.count() > 0 ) {
00225             QString text = i18n( "The fonts '%1' are missing."
00226                                  " Do you want to change the font style anyway?" )
00227                            .arg( missing.join( "', '" ) );
00228             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00229                  KMessageBox::Cancel ) {
00230                 return;
00231             }
00232         }
00233     }
00234     else if ( cmStyle->isChecked() ) {
00235         fontStyle = "tex";
00236 
00237         QStringList missing = CMStyle::missingFonts();
00238 
00239         if ( missing.count() > 0 && !CMStyle::m_installed) {
00240             QString text = i18n( "The fonts '%1' are missing."
00241                                  " Do you want to change the font style anyway?" )
00242                            .arg( missing.join( "', '" ) );
00243             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00244                  KMessageBox::Cancel ) {
00245                 return;
00246             }
00247         }
00248     }
00249     else { // symbolStyle->isChecked ()
00250         fontStyle = "symbol";
00251 
00252         QStringList missing = SymbolFontStyle::missingFonts();
00253 
00254         if ( missing.count() > 0 ) {
00255             QString text = i18n( "The font 'symbol' is missing."
00256                                  " Do you want to change the font style anyway?" );
00257             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00258                  KMessageBox::Cancel ) {
00259                 return;
00260             }
00261 
00262         }
00263     }
00264 
00265     ContextStyle& contextStyle = m_document->getContextStyle( true );
00266 
00267     contextStyle.setDefaultFont( defaultFont );
00268     contextStyle.setNameFont( nameFont );
00269     contextStyle.setNumberFont( numberFont );
00270     contextStyle.setOperatorFont( operatorFont );
00271     contextStyle.setBaseSize( sizeSpin->value() );
00272 
00273     contextStyle.setFontStyle( fontStyle );
00274 
00275     contextStyle.setSyntaxHighlighting( syntaxHighlighting->isChecked() );
00276 //     contextStyle.setDefaultColor( defaultColorBtn->color() );
00277 //     contextStyle.setNumberColor( numberColorBtn->color() );
00278 //     contextStyle.setOperatorColor( operatorColorBtn->color() );
00279 //     contextStyle.setEmptyColor( emptyColorBtn->color() );
00280 //     contextStyle.setErrorColor( errorColorBtn->color() );
00281 
00282     m_config->setGroup( "kformula Font" );
00283     m_config->writeEntry( "defaultFont", defaultFont.toString() );
00284     m_config->writeEntry( "nameFont", nameFont.toString() );
00285     m_config->writeEntry( "numberFont", numberFont.toString() );
00286     m_config->writeEntry( "operatorFont", operatorFont.toString() );
00287     m_config->writeEntry( "baseSize", QString::number( sizeSpin->value() ) );
00288 
00289     m_config->writeEntry( "fontStyle", fontStyle );
00290 
00291 //     m_config->setGroup( "kformula Color" );
00292 //     m_config->writeEntry( "syntaxHighlighting", syntaxHighlighting->isChecked() );
00293 //     m_config->writeEntry( "defaultColor", defaultColorBtn->color() );
00294 //     m_config->writeEntry( "numberColor",  numberColorBtn->color() );
00295 //     m_config->writeEntry( "operatorColor", operatorColorBtn->color() );
00296 //     m_config->writeEntry( "emptyColor", emptyColorBtn->color() );
00297 //     m_config->writeEntry( "errorColor", errorColorBtn->color() );
00298 
00299     // notify!!!
00300     m_document->updateConfig();
00301     m_changed = false;
00302 }
00303 
00304 void ConfigurePage::slotDefault()
00305 {
00306     defaultFont = QFont( "Times", 12, QFont::Normal, true );
00307     nameFont = QFont( "Times" );
00308     numberFont = nameFont;
00309     operatorFont = nameFont;
00310 
00311     sizeSpin->setValue( 20 );
00312 
00313     updateFontLabel( defaultFont, defaultFontName );
00314     updateFontLabel( nameFont, nameFontName );
00315     updateFontLabel( numberFont, numberFontName );
00316     updateFontLabel( operatorFont, operatorFontName );
00317 
00318     symbolStyle->setChecked( true );
00319     if (CMStyle::missingFonts().isEmpty())
00320         cmStyle->setChecked( true );
00321     else if (EsstixFontStyle::missingFonts().isEmpty())
00322         esstixStyle->setChecked( true );
00323     else
00324         symbolStyle->setChecked( true );
00325 
00326     syntaxHighlighting->setChecked( true );
00327     syntaxHighlightingClicked();
00328 
00329 //     defaultColorBtn->setColor( Qt::black );
00330 //     numberColorBtn->setColor( Qt::blue );
00331 //     operatorColorBtn->setColor( Qt::darkGreen );
00332 //     emptyColorBtn->setColor( Qt::blue );
00333 //     errorColorBtn->setColor( Qt::darkRed );
00334     slotChanged();
00335 }
00336 
00337 void ConfigurePage::syntaxHighlightingClicked()
00338 {
00339 //     bool checked = syntaxHighlighting->isChecked();
00340 //     hlBox->setEnabled( checked );
00341 }
00342 
00343 void ConfigurePage::selectNewDefaultFont()
00344 {
00345     if ( selectFont( defaultFont ) )
00346         updateFontLabel( defaultFont, defaultFontName );
00347 }
00348 
00349 void ConfigurePage::selectNewNameFont()
00350 {
00351     if ( selectFont( nameFont ) )
00352         updateFontLabel( nameFont, nameFontName );
00353 }
00354 
00355 void ConfigurePage::selectNewNumberFont()
00356 {
00357     if ( selectFont( numberFont ) )
00358         updateFontLabel( numberFont, numberFontName );
00359 }
00360 
00361 void ConfigurePage::selectNewOperatorFont()
00362 {
00363     if ( selectFont( operatorFont ) )
00364         updateFontLabel( operatorFont, operatorFontName );
00365 }
00366 
00367 bool ConfigurePage::selectFont( QFont & font )
00368 {
00369     QStringList list;
00370 
00371     KFontChooser::getFontList( list, KFontChooser::SmoothScalableFonts );
00372 
00373     KFontDialog dlg( m_view, 0, false, true, list );
00374     dlg.setFont( font );
00375 
00376     int result = dlg.exec();
00377     if (  KDialog::Accepted == result ) {
00378         font = dlg.font();
00379         slotChanged();
00380         return true;
00381     }
00382 
00383     return false;
00384 }
00385 
00386 void ConfigurePage::baseSizeChanged( int /*value*/ )
00387 {
00388 }
00389 
00390 void ConfigurePage::updateFontLabel( QFont font, QLabel* label )
00391 {
00392     label->setText( font.family() + ' ' + QString::number( font.pointSize() ) );
00393     label->setFont( font );
00394 }
00395 
00396 void ConfigurePage::slotChanged()
00397 {
00398     m_changed = true;
00399 }
00400 
00401 // class UsedFontItem : public KListViewItem {
00402 // public:
00403 //     UsedFontItem( MathFontsConfigurePage* page, QListView* parent, QString font )
00404 //         : KListViewItem( parent, font ), m_page( page ) {}
00405 
00406 //     int compare( QListViewItem* i, int col, bool ascending ) const;
00407 
00408 // private:
00409 //     MathFontsConfigurePage* m_page;
00410 // };
00411 
00412 // int UsedFontItem::compare( QListViewItem* i, int, bool ) const
00413 // {
00414 //     QValueVector<QString>::iterator lhsIt = m_page->findUsedFont( text( 0 ) );
00415 //     QValueVector<QString>::iterator rhsIt = m_page->findUsedFont( i->text( 0 ) );
00416 //     if ( lhsIt < rhsIt ) {
00417 //         return -1;
00418 //     }
00419 //     else if ( lhsIt > rhsIt ) {
00420 //         return 1;
00421 //     }
00422 //     return 0;
00423 // }
00424 
00425 // MathFontsConfigurePage::MathFontsConfigurePage( Document* document, QWidget* view,
00426 //                                                 KConfig* config, QVBox* box, char* name )
00427 //     : QObject( box->parent(), name ), m_document( document ), m_view( view ), m_config( config )
00428 // {
00429 //     QWidget* fontWidget = new QWidget( box );
00430 //     QGridLayout* fontLayout = new QGridLayout( fontWidget, 1, 1, KDialog::marginHint(), KDialog::spacingHint() );
00431 
00432 //     QHBoxLayout* hLayout = new QHBoxLayout( 0, 0, 6 );
00433 
00434 //     availableFonts = new KListView( fontWidget );
00435 //     availableFonts->addColumn( i18n( "Available Fonts" ) );
00436 //     hLayout->addWidget( availableFonts );
00437 
00438 //     QVBoxLayout* vLayout = new QVBoxLayout( 0, 0, 6 );
00439 //     QSpacerItem* spacer1 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
00440 //     vLayout->addItem( spacer1 );
00441 
00442 //     addFont = new KPushButton( fontWidget );
00443 //     addFont->setText( "->" );
00444 //     vLayout->addWidget( addFont );
00445 
00446 //     removeFont = new KPushButton( fontWidget );
00447 //     removeFont->setText( "<-" );
00448 //     vLayout->addWidget( removeFont );
00449 
00450 //     QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
00451 //     vLayout->addItem( spacer2 );
00452 
00453 //     hLayout->addLayout( vLayout );
00454 
00455 //     vLayout = new QVBoxLayout( 0, 0, 6 );
00456 
00457 //     moveUp = new KPushButton( fontWidget );
00458 //     moveUp->setText( i18n( "Up" ) );
00459 //     vLayout->addWidget( moveUp );
00460 
00461 //     requestedFonts = new KListView( fontWidget );
00462 //     requestedFonts->addColumn( i18n( "Used Fonts" ) );
00463 //     vLayout->addWidget( requestedFonts );
00464 
00465 //     moveDown = new KPushButton( fontWidget );
00466 //     moveDown->setText( i18n( "Down" ) );
00467 //     vLayout->addWidget( moveDown );
00468 
00469 //     hLayout->addLayout( vLayout );
00470 
00471 //     fontLayout->addLayout( hLayout, 0, 0 );
00472 
00473 // //     connect( availableFonts, SIGNAL( executed( QListViewItem* ) ),
00474 // //              this, SLOT( slotAddFont() ) );
00475 // //     connect( requestedFonts, SIGNAL( executed( QListViewItem* ) ),
00476 // //              this, SLOT( slotRemoveFont() ) );
00477 //     connect( addFont, SIGNAL( clicked() ), this, SLOT( slotAddFont() ) );
00478 //     connect( removeFont, SIGNAL( clicked() ), this, SLOT( slotRemoveFont() ) );
00479 //     connect( moveUp, SIGNAL( clicked() ), this, SLOT( slotMoveUp() ) );
00480 //     connect( moveDown, SIGNAL( clicked() ), this, SLOT( slotMoveDown() ) );
00481 
00482 //     const ContextStyle& contextStyle = document->getContextStyle( true );
00483 //     const SymbolTable& symbolTable = contextStyle.symbolTable();
00484 //     const QStringList& usedFonts = contextStyle.requestedFonts();
00485 
00486 //     QMap<QString, QString> fontMap;
00487 // //    symbolTable.findAvailableFonts( &fontMap );
00488 
00489 //     setupLists( usedFonts );
00490 // }
00491 
00492 // void MathFontsConfigurePage::apply()
00493 // {
00494 //     QStringList strings;
00495 //     std::copy( usedFontList.begin(), usedFontList.end(), std::back_inserter( strings ) );
00496 
00497 //     m_config->setGroup( "kformula Font" );
00498 //     m_config->writeEntry( "usedMathFonts", strings );
00499 
00500 //     ContextStyle& contextStyle = m_document->getContextStyle( true );
00501 //     contextStyle.setRequestedFonts( strings );
00502 // }
00503 
00504 // void MathFontsConfigurePage::slotDefault()
00505 // {
00506 //     QStringList usedFonts;
00507 
00508 //     usedFonts.push_back( "esstixone" );
00509 //     usedFonts.push_back( "esstixtwo" );
00510 //     usedFonts.push_back( "esstixthree" );
00511 //     usedFonts.push_back( "esstixfour" );
00512 //     usedFonts.push_back( "esstixfive" );
00513 //     usedFonts.push_back( "esstixsix" );
00514 //     usedFonts.push_back( "esstixseven" );
00515 //     usedFonts.push_back( "esstixeight" );
00516 //     usedFonts.push_back( "esstixnine" );
00517 //     usedFonts.push_back( "esstixten" );
00518 //     usedFonts.push_back( "esstixeleven" );
00519 //     usedFonts.push_back( "esstixtwelve" );
00520 //     usedFonts.push_back( "esstixthirteen" );
00521 //     usedFonts.push_back( "esstixfourteen" );
00522 //     usedFonts.push_back( "esstixfifteen" );
00523 //     usedFonts.push_back( "esstixsixteen" );
00524 //     usedFonts.push_back( "esstixseventeen" );
00525 
00526 //     usedFontList.clear();
00527 //     requestedFonts->clear();
00528 //     availableFonts->clear();
00529 
00530 //     setupLists( usedFonts );
00531 // }
00532 
00533 // QValueVector<QString>::iterator MathFontsConfigurePage::findUsedFont( QString name )
00534 // {
00535 //     return std::find( usedFontList.begin(), usedFontList.end(), name );
00536 // }
00537 
00538 // void MathFontsConfigurePage::setupLists( const QStringList& usedFonts )
00539 // {
00540 //     const ContextStyle& contextStyle = m_document->getContextStyle( true );
00541 //     const SymbolTable& symbolTable = contextStyle.symbolTable();
00542 
00543 //     QMap<QString, QString> fontMap;
00544 // //    symbolTable.findAvailableFonts( &fontMap );
00545 
00546 //     for ( QStringList::const_iterator it = usedFonts.begin(); it != usedFonts.end(); ++it ) {
00547 //         QMap<QString, QString>::iterator font = fontMap.find( *it );
00548 //         if ( font != fontMap.end() ) {
00549 //             fontMap.erase( font );
00550 //             new UsedFontItem( this, requestedFonts, *it );
00551 //             usedFontList.push_back( *it );
00552 //         }
00553 //     }
00554 //     for ( QMap<QString, QString>::iterator it = fontMap.begin(); it != fontMap.end(); ++it ) {
00555 //         new KListViewItem( availableFonts, it.key() );
00556 //     }
00557 // }
00558 
00559 // void MathFontsConfigurePage::slotAddFont()
00560 // {
00561 //     QListViewItem* fontItem = availableFonts->selectedItem();
00562 //     if ( fontItem ) {
00563 //         QString fontName = fontItem->text( 0 );
00564 //         //availableFonts->takeItem( fontItem );
00565 //         delete fontItem;
00566 
00567 //         new UsedFontItem( this, requestedFonts, fontName );
00568 //         usedFontList.push_back( fontName );
00569 //     }
00570 // }
00571 
00572 // void MathFontsConfigurePage::slotRemoveFont()
00573 // {
00574 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00575 //     if ( fontItem ) {
00576 //         QString fontName = fontItem->text( 0 );
00577 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00578 //         if ( it != usedFontList.end() ) {
00579 //             usedFontList.erase( it );
00580 //         }
00581 //         //requestedFonts->takeItem( fontItem );
00582 //         delete fontItem;
00583 //         new KListViewItem( availableFonts, fontName );
00584 //     }
00585 // }
00586 
00587 // void MathFontsConfigurePage::slotMoveUp()
00588 // {
00589 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00590 //     if ( fontItem ) {
00591 //         QString fontName = fontItem->text( 0 );
00592 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00593 //         if ( it != usedFontList.end() ) {
00594 //             uint pos = it - usedFontList.begin();
00595 //             if ( pos > 0 ) {
00596 //                 QValueVector<QString>::iterator before = it-1;
00597 //                 std::swap( *it, *before );
00598 //                 requestedFonts->sort();
00599 //             }
00600 //         }
00601 //     }
00602 // }
00603 
00604 // void MathFontsConfigurePage::slotMoveDown()
00605 // {
00606 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00607 //     if ( fontItem ) {
00608 //         QString fontName = fontItem->text( 0 );
00609 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00610 //         if ( it != usedFontList.end() ) {
00611 //             uint pos = it - usedFontList.begin();
00612 //             if ( pos < usedFontList.size()-1 ) {
00613 //                 QValueVector<QString>::iterator after = it+1;
00614 //                 std::swap( *it, *after );
00615 //                 requestedFonts->sort();
00616 //             }
00617 //         }
00618 //     }
00619 // }
00620 
00621 KFORMULA_NAMESPACE_END
00622 
00623 using namespace KFormula;
00624 #include "kformulaconfigpage.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys