kspread Library API Documentation

kspread_dlg_preference.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
00003              (C) 2002-2003 Norbert Andres <nandres@web.de>
00004              (C) 2000-2005 Laurent Montel <montel@kde.org>
00005              (C) 2002 John Dailey <dailey@vt.edu>
00006              (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
00007              (C) 2001-2002 David Faure <faure@kde.org>
00008              (C) 2001 Werner Trobin <trobin@kde.org>
00009              (C) 2000 Bernd Johannes Wuebben <wuebben@kde.org>
00010 
00011    This library is free software; you can redistribute it and/or
00012    modify it under the terms of the GNU Library General Public
00013    License as published by the Free Software Foundation; either
00014    version 2 of the License, or (at your option) any later version.
00015 
00016    This library is distributed in the hope that it will be useful,
00017    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019    Library General Public License for more details.
00020 
00021    You should have received a copy of the GNU Library General Public License
00022    along with this library; see the file COPYING.LIB.  If not, write to
00023    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00024    Boston, MA 02111-1307, USA.
00025 */
00026 
00027 #include <qvbox.h>
00028 #include <qlayout.h>
00029 #include <qcheckbox.h>
00030 #include <qcombobox.h>
00031 #include <qvgroupbox.h>
00032 
00033 #include "kspread_dlg_preference.h"
00034 #include "kspread_sheet.h"
00035 #include "kspread_sheetprint.h"
00036 #include "kspread_doc.h"
00037 #include "kspread_canvas.h"
00038 #include "kspread_view.h"
00039 #include "kspread_locale.h"
00040 #include "kspread_editors.h"
00041 
00042 #include <kconfig.h>
00043 #include <kstatusbar.h>
00044 #include <knuminput.h>
00045 #include <kspell.h>
00046 #include <kmessagebox.h>
00047 #include <kdeversion.h>
00048 #include <kcolorbutton.h>
00049 #include <kotabbar.h>
00050 
00051 KSpreadpreference::KSpreadpreference( KSpreadView* parent, const char* /*name*/)
00052   : KDialogBase(KDialogBase::IconList,i18n("Configure KSpread") ,
00053         KDialogBase::Ok | KDialogBase::Cancel| KDialogBase::Default,
00054         KDialogBase::Ok)
00055 
00056 {
00057   m_pView=parent;
00058 
00059   connect(this, SIGNAL(okClicked()),this,SLOT(slotApply()));
00060 
00061   QVBox *page2=addVBoxPage(i18n("Locale Parameters"), QString::null,BarIcon("gohome",KIcon::SizeMedium));
00062  _localePage=new parameterLocale(parent,page2 );
00063 
00064   QVBox *page3=addVBoxPage(i18n("Interface"), QString::null,BarIcon("signature", KIcon::SizeMedium) );
00065   _configure = new  configure(parent,page3 );
00066 
00067   QVBox * page4=addVBoxPage(i18n("Misc"), QString::null,BarIcon("misc",KIcon::SizeMedium) );
00068   _miscParameter = new  miscParameters(parent,page4 );
00069 
00070   QVBox *page5=addVBoxPage(i18n("Color"), QString::null,BarIcon("colorize",KIcon::SizeMedium) );
00071   _colorParameter=new colorParameters(parent,page5 );
00072 
00073   QVBox *page6=addVBoxPage(i18n("Page Layout"), QString::null,BarIcon("edit",KIcon::SizeMedium) );
00074   _layoutPage=new configureLayoutPage(parent,page6 );
00075 
00076   QVBox *page7 = addVBoxPage( i18n("Spelling"), i18n("Spell Checker Behavior"),
00077                           BarIcon("spellcheck", KIcon::SizeMedium) );
00078   _spellPage=new configureSpellPage(parent,page7);
00079 
00080 }
00081 
00082 void KSpreadpreference::openPage(int flags)
00083 {
00084     if(flags & KS_LOCALE)
00085         showPage( 0 );
00086     else if(flags & KS_INTERFACE)
00087         showPage( 1 );
00088     else if(flags & KS_MISC)
00089         showPage( 2 );
00090     else if(flags & KS_COLOR)
00091         showPage( 3 );
00092     else if(flags & KS_LAYOUT)
00093         showPage( 4 );
00094     else if(flags & KS_SPELLING)
00095         showPage( 5 );
00096 }
00097 
00098 void KSpreadpreference::slotApply()
00099 {
00100   m_pView->doc()->emitBeginOperation( false );
00101   _configure->apply();
00102   _miscParameter->apply();
00103   _colorParameter->apply();
00104   _layoutPage->apply();
00105   _spellPage->apply();
00106   _localePage->apply();
00107   m_pView->doc()->refreshInterface();
00108   m_pView->slotUpdateView( m_pView->activeSheet() );
00109 }
00110 
00111 void KSpreadpreference::slotDefault()
00112 {
00113     switch(activePageIndex())
00114     {
00115         case 1:
00116             _configure->slotDefault();
00117             break;
00118         case 2:
00119             _miscParameter->slotDefault();
00120             break;
00121         case 3:
00122             _colorParameter->slotDefault();
00123             break;
00124         case 4:
00125             _layoutPage->slotDefault();
00126             break;
00127         case 5:
00128             _spellPage->slotDefault();
00129             break;
00130         default:
00131             break;
00132     }
00133 }
00134 
00135 
00136 parameterLocale::parameterLocale( KSpreadView* _view, QVBox *box , char *name )
00137  :QObject ( box->parent(),name)
00138 {
00139     m_pView = _view;
00140     m_bUpdateLocale=false;
00141   QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Parameters"), box, "GroupBox" );
00142 
00143   KLocale* locale=_view->doc()->locale();
00144 
00145   m_language=new QLabel( tmpQGroupBox,"label");
00146   m_language->setText( i18n("Language: %1").arg( locale->language() ));
00147   m_number=new QLabel( tmpQGroupBox,"label6");
00148   m_number->setText( i18n("Number: %1").arg( locale->formatNumber(12.55) ));
00149   m_date=new QLabel( tmpQGroupBox,"label1");
00150   m_date->setText( i18n("Date: %1").arg( locale->formatDate(QDate(2000,10,23)) ));
00151   m_shortDate=new QLabel( tmpQGroupBox,"label5");
00152   m_shortDate->setText( i18n("Short date: %1").arg( locale->formatDate(QDate(2000,10,23),true) ));
00153   m_time=new QLabel( tmpQGroupBox,"label2");
00154   m_time->setText( i18n("Time: %1").arg( locale->formatTime(QTime(15,10,53)) ));
00155   m_money=new QLabel( tmpQGroupBox,"label3");
00156   m_money->setText( i18n("Money: %1").arg( locale->formatMoney(12.55) ));
00157 
00158   m_updateButton=new QPushButton ( i18n("&Update to Locale System"), tmpQGroupBox);
00159   connect(m_updateButton, SIGNAL(clicked()),this,SLOT(updateDefaultSystemConfig()));
00160 }
00161 
00162 void parameterLocale::apply()
00163 {
00164     if (m_bUpdateLocale)
00165     {
00166         m_pView->doc()->emitBeginOperation( false );
00167         m_pView->doc()->refreshLocale();
00168         m_pView->slotUpdateView( m_pView->activeSheet() );
00169     }
00170 }
00171 
00172 void parameterLocale::updateDefaultSystemConfig()
00173 {
00174     m_bUpdateLocale=true;
00175     static_cast<KSpreadLocale*>(m_pView->doc()->locale())->defaultSystemConfig( );
00176     KLocale* locale=m_pView->doc()->locale();
00177     m_money->setText( i18n("Money: %1").arg( locale->formatMoney(12.55) ));
00178     m_time->setText( i18n("Time: %1").arg( locale->formatTime(QTime(15,10,53)) ));
00179     m_shortDate->setText( i18n("Short date: %1").arg( locale->formatDate(QDate(2000,10,23),true) ));
00180     m_date->setText( i18n("Date: %1").arg( locale->formatDate(QDate(2000,10,23)) ));
00181     m_number->setText( i18n("Number: %1").arg( locale->formatNumber(12.55) ));
00182     m_language->setText( i18n("Language: %1").arg( locale->language() ));
00183 }
00184 
00185 configure::configure( KSpreadView* _view, QVBox *box , char *name )
00186  :QObject ( box->parent(),name)
00187  {
00188   m_pView = _view;
00189 
00190   bool vertical=true;
00191   bool horizontal=true;
00192   bool rowHeader=true;
00193   bool colHeader=true;
00194   bool tabbar=true;
00195   bool formulaBar=true;
00196   bool statusBar=true;
00197   m_oldBackupFile = true;
00198 
00199   QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Configuration"), box, "GroupBox" );
00200 
00201   config = KSpreadFactory::global()->config();
00202   int _page=1;
00203 
00204   oldRecent=10;
00205   oldAutoSaveValue=KoDocument::defaultAutoSave()/60;
00206 
00207   if( config->hasGroup("Parameters" ))
00208         {
00209         config->setGroup( "Parameters" );
00210         _page=config->readNumEntry( "NbPage" ,1) ;
00211         horizontal=config->readBoolEntry("Horiz ScrollBar",true);
00212         vertical=config->readBoolEntry("Vert ScrollBar",true);
00213         colHeader=config->readBoolEntry("Column Header",true);
00214         rowHeader=config->readBoolEntry("Row Header",true);
00215     tabbar=config->readBoolEntry("Tabbar",true);
00216     formulaBar=config->readBoolEntry("Formula bar",true);
00217         statusBar=config->readBoolEntry("Status bar",true);
00218         oldRecent=config->readNumEntry( "NbRecentFile" ,10);
00219         oldAutoSaveValue=config->readNumEntry("AutoSave",KoDocument::defaultAutoSave()/60);
00220         m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile);
00221         }
00222   nbPage=new KIntNumInput(_page, tmpQGroupBox , 10);
00223   nbPage->setRange(1, 10, 1);
00224   nbPage->setLabel(i18n("Number of pages open at the &beginning:"));
00225 
00226   nbRecentFile=new KIntNumInput(oldRecent, tmpQGroupBox , 10);
00227   nbRecentFile->setRange(1, 20, 1);
00228   nbRecentFile->setLabel(i18n("&Number of recent files:"));
00229 
00230   autoSaveDelay=new KIntNumInput(oldAutoSaveValue, tmpQGroupBox , 10);
00231   autoSaveDelay->setRange(0, 60, 1);
00232   autoSaveDelay->setLabel(i18n("Au&tosave (min):"));
00233   autoSaveDelay->setSpecialValueText(i18n("No autosave"));
00234   autoSaveDelay->setSuffix(i18n("min"));
00235 
00236   m_createBackupFile = new QCheckBox( i18n("Create backup file"), tmpQGroupBox );
00237   m_createBackupFile->setChecked( m_oldBackupFile );
00238 
00239   showVScrollBar=new QCheckBox(i18n("Show &vertical scrollbar"),tmpQGroupBox);
00240   showVScrollBar->setChecked(vertical);
00241   showHScrollBar=new QCheckBox(i18n("Show &horizontal scrollbar"),tmpQGroupBox);
00242   showHScrollBar->setChecked(horizontal);
00243 
00244 
00245   showColHeader=new QCheckBox(i18n("Show c&olumn header"),tmpQGroupBox);
00246   showColHeader->setChecked(colHeader);
00247   showRowHeader=new QCheckBox(i18n("Show &row header"),tmpQGroupBox);
00248   showRowHeader->setChecked(rowHeader);
00249 
00250   showTabBar =new QCheckBox(i18n("Show ta&bs"),tmpQGroupBox);
00251   showTabBar->setChecked(tabbar);
00252 
00253   showFormulaBar =new QCheckBox(i18n("Sho&w formula toolbar"),tmpQGroupBox);
00254   showFormulaBar->setChecked(formulaBar);
00255 
00256   showStatusBar =new QCheckBox(i18n("Show stat&usbar"),tmpQGroupBox);
00257   showStatusBar->setChecked(statusBar);
00258 }
00259 
00260 
00261 void configure::slotDefault()
00262 {
00263   showHScrollBar->setChecked(true);
00264   showRowHeader->setChecked(true);
00265   showVScrollBar->setChecked(true);
00266   showColHeader->setChecked(true);
00267   showTabBar->setChecked(true);
00268   showFormulaBar->setChecked(true);
00269   showStatusBar->setChecked(true);
00270   nbPage->setValue(1);
00271   nbRecentFile->setValue(10);
00272   autoSaveDelay->setValue(KoDocument::defaultAutoSave()/60);
00273   m_createBackupFile->setChecked( true );
00274 }
00275 
00276 
00277 void configure::apply()
00278 {
00279     m_pView->doc()->emitBeginOperation( false );
00280     config->setGroup( "Parameters" );
00281     config->writeEntry( "NbPage", nbPage->value());
00282     KSpreadDoc *doc =m_pView->doc();
00283     bool active=true;
00284     active=showHScrollBar->isChecked();
00285     if( m_pView->horzScrollBar()->isVisible()!=active)
00286     {
00287         config->writeEntry( "Horiz ScrollBar",active);
00288         if( active)
00289             m_pView->horzScrollBar()->show();
00290         else
00291             m_pView->horzScrollBar()->hide();
00292         doc->setShowHorizontalScrollBar(active);
00293     }
00294     active=showVScrollBar->isChecked();
00295     if( m_pView->vertScrollBar()->isVisible()!=active)
00296     {
00297         config->writeEntry( "Vert ScrollBar", active);
00298         if(active)
00299             m_pView->vertScrollBar()->show();
00300         else
00301             m_pView->vertScrollBar()->hide();
00302         doc->setShowVerticalScrollBar(active);
00303 
00304     }
00305     active=showColHeader->isChecked();
00306     if( m_pView->hBorderWidget()->isVisible()!=active)
00307     {
00308         config->writeEntry( "Column Header", active);
00309         if( active)
00310             m_pView->hBorderWidget()->show();
00311         else
00312             m_pView->hBorderWidget()->hide();
00313         doc->setShowColHeader(active);
00314     }
00315 
00316     active=showRowHeader->isChecked();
00317     if( m_pView->vBorderWidget()->isVisible()!=active)
00318     {
00319         config->writeEntry( "Row Header", active);
00320         if( active)
00321             m_pView->vBorderWidget()->show();
00322         else
00323             m_pView->vBorderWidget()->hide();
00324         doc->setShowRowHeader(active);
00325     }
00326 
00327     active=showTabBar->isChecked();
00328     if(m_pView->tabBar()->isVisible()!=active)
00329     {
00330         config->writeEntry( "Tabbar", active);
00331         if(active)
00332             m_pView->tabBar()->show();
00333         else
00334             m_pView->tabBar()->hide();
00335         doc->setShowTabBar(active);
00336     }
00337 
00338     active=showFormulaBar->isChecked();
00339     if(m_pView->posWidget()->isVisible()!=active)
00340     {
00341         config->writeEntry( "Formula bar",active);
00342         m_pView->editWidget()->showEditWidget(active);
00343         if(active)
00344             m_pView->posWidget()->show();
00345         else
00346             m_pView->posWidget()->hide();
00347         doc->setShowFormulaBar(active);
00348     }
00349 
00350     active=showStatusBar->isChecked();
00351     config->writeEntry( "Status bar",active);
00352     m_pView->showStatusBar( active );
00353 
00354     int val=nbRecentFile->value();
00355     if( oldRecent!= val)
00356     {
00357        config->writeEntry( "NbRecentFile",val);
00358        m_pView->changeNbOfRecentFiles(val);
00359     }
00360     val=autoSaveDelay->value();
00361     if(val!=oldAutoSaveValue)
00362     {
00363         config->writeEntry( "AutoSave", val );
00364         doc->setAutoSave(val*60);
00365     }
00366 
00367     bool state =m_createBackupFile->isChecked();
00368     if(state!=m_oldBackupFile)
00369     {
00370         config->writeEntry( "BackupFile", state );
00371         doc->setBackupFile( state);
00372         m_oldBackupFile=state;
00373     }
00374 
00375     m_pView->slotUpdateView( m_pView->activeSheet() );
00376 }
00377 
00378 
00379 miscParameters::miscParameters( KSpreadView* _view,QVBox *box, char *name )
00380  :QObject ( box->parent(),name)
00381  {
00382   m_pView = _view;
00383 
00384 
00385   QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Misc"), box, "GroupBox" );
00386 
00387   config = KSpreadFactory::global()->config();
00388   double _indent = 10.0;
00389   bool m_bMsgError=false;
00390   bool m_bCommentIndicator=true;
00391   if( config->hasGroup("Parameters" ))
00392         {
00393         config->setGroup( "Parameters" );
00394         _indent = config->readNumEntry( "Indent" , 10.0 ) ;
00395         m_bMsgError=config->readBoolEntry( "Msg error" ,false) ;
00396     m_bCommentIndicator=config->readBoolEntry( "Comment Indicator",true);
00397         }
00398 
00399   QLabel *label=new QLabel(i18n("&Completion mode:"), tmpQGroupBox);
00400 
00401   typeCompletion=new QComboBox(tmpQGroupBox);
00402   label->setBuddy(typeCompletion);
00403   QStringList listType;
00404   listType+=i18n("None");
00405   listType+=i18n("Manual");
00406   listType+=i18n("Popup");
00407   listType+=i18n("Automatic");
00408   listType+=i18n("Semi-Automatic");
00409   typeCompletion->insertStringList(listType);
00410   typeCompletion->setCurrentItem(0);
00411   comboChanged=false;
00412   connect(typeCompletion,SIGNAL(activated( const QString & )),this,SLOT(slotTextComboChanged(const QString &)));
00413 
00414 //   valIndent = new KDoubleNumInput( _indent, tmpQGroupBox , 10.0 );
00415   valIndent = new KDoubleNumInput( tmpQGroupBox );
00416   valIndent->setRange( KoUnit::toUserValue( 0.0, _view->doc()->getUnit() ),
00417                        KoUnit::toUserValue( 400.0, _view->doc()->getUnit() ),
00418                        KoUnit::toUserValue( 10.0, _view->doc()->getUnit()) );
00419   valIndent->setRange( 0.0, 100.0, 10.0 );
00420   valIndent->setValue ( KoUnit::toUserValue( _indent, _view->doc()->getUnit() ) );
00421   valIndent->setLabel(i18n("&Value of indent:"));
00422 
00423   label=new QLabel(i18n("&Press enter to move selection to:"), tmpQGroupBox);
00424   typeOfMove=new QComboBox( tmpQGroupBox);
00425   label->setBuddy(typeOfMove);
00426   listType.clear();
00427   listType+=i18n("towards to", "Bottom");
00428   listType+=i18n("towards to", "Top");
00429   listType+=i18n("towards to", "Right");
00430   listType+=i18n("towards to", "Left");
00431   listType+=i18n("towards to", "Bottom, First Cell");
00432   typeOfMove->insertStringList(listType);
00433   typeOfMove->setCurrentItem(0);
00434   msgError= new QCheckBox(i18n("&Show error message"),tmpQGroupBox);
00435   msgError->setChecked(m_bMsgError);
00436 
00437   label=new QLabel(i18n("&Method of calc:"), tmpQGroupBox);
00438 
00439   typeCalc=new QComboBox( tmpQGroupBox);
00440   label->setBuddy(typeCalc);
00441   QStringList listTypeCalc;
00442   listTypeCalc+=i18n("Sum");
00443   listTypeCalc+=i18n("Min");
00444   listTypeCalc+=i18n("Max");
00445   listTypeCalc+=i18n("Average");
00446   listTypeCalc+=i18n("Count");
00447   listTypeCalc+=i18n("CountA");
00448   listTypeCalc+=i18n("None");
00449   typeCalc->insertStringList(listTypeCalc);
00450   typeCalc->setCurrentItem(0);
00451   commentIndicator=new QCheckBox(i18n("Show comment &indicator"),tmpQGroupBox);
00452   commentIndicator->setChecked(m_bCommentIndicator);
00453 
00454   initComboBox();
00455 }
00456 
00457 void miscParameters::slotTextComboChanged(const QString &)
00458 {
00459   comboChanged=true;
00460 }
00461 
00462 void miscParameters::initComboBox()
00463 {
00464   KGlobalSettings::Completion tmpCompletion=KGlobalSettings::CompletionAuto;
00465   if( config->hasGroup("Parameters" ))
00466     {
00467       config->setGroup( "Parameters" );
00468       tmpCompletion=( KGlobalSettings::Completion)config->readNumEntry( "Completion Mode" ,KGlobalSettings::CompletionAuto) ;
00469       config->writeEntry( "Completion Mode", (int)tmpCompletion);
00470     }
00471 switch(tmpCompletion )
00472         {
00473         case  KGlobalSettings::CompletionNone:
00474                 typeCompletion->setCurrentItem(0);
00475                 break;
00476         case  KGlobalSettings::CompletionAuto:
00477                 typeCompletion->setCurrentItem(3);
00478                 break;
00479         case  KGlobalSettings::CompletionMan:
00480                 typeCompletion->setCurrentItem(4);
00481                 break;
00482         case  KGlobalSettings::CompletionShell:
00483                 typeCompletion->setCurrentItem(1);
00484                 break;
00485         case  KGlobalSettings::CompletionPopup:
00486                 typeCompletion->setCurrentItem(2);
00487                 break;
00488         default :
00489                 typeCompletion->setCurrentItem(0);
00490                 break;
00491         }
00492 switch( m_pView->doc()->getMoveToValue( ))
00493         {
00494         case  KSpread::Bottom:
00495                 typeOfMove->setCurrentItem(0);
00496                 break;
00497         case  KSpread::Left:
00498                 typeOfMove->setCurrentItem(3);
00499                 break;
00500         case  KSpread::Top:
00501                 typeOfMove->setCurrentItem(1);
00502                 break;
00503         case  KSpread::Right:
00504                 typeOfMove->setCurrentItem(2);
00505                 break;
00506         case  KSpread::BottomFirst:
00507                 typeOfMove->setCurrentItem(4);
00508                 break;
00509         default :
00510                 typeOfMove->setCurrentItem(0);
00511                 break;
00512         }
00513 
00514 switch( m_pView->doc()->getTypeOfCalc())
00515         {
00516         case  SumOfNumber:
00517                 typeCalc->setCurrentItem(0);
00518                 break;
00519         case  Min:
00520                 typeCalc->setCurrentItem(1);
00521                 break;
00522         case  Max:
00523                 typeCalc->setCurrentItem(2);
00524                 break;
00525         case  Average:
00526                 typeCalc->setCurrentItem(3);
00527                 break;
00528         case  Count:
00529             typeCalc->setCurrentItem(4);
00530                 break;
00531         case  CountA:
00532             typeCalc->setCurrentItem(5);
00533                 break;
00534         case  NoneCalc:
00535             typeCalc->setCurrentItem(6);
00536                 break;
00537         default :
00538                 typeCalc->setCurrentItem(0);
00539                 break;
00540         }
00541 
00542 }
00543 
00544 void miscParameters::slotDefault()
00545 {
00546   valIndent->setValue( 10.0 );
00547   typeCompletion->setCurrentItem(3);
00548   typeOfMove->setCurrentItem(0);
00549   msgError->setChecked(false);
00550   typeCalc->setCurrentItem(0);
00551   commentIndicator->setChecked(true);
00552 }
00553 
00554 
00555 void miscParameters::apply()
00556 {
00557     config->setGroup( "Parameters" );
00558     KGlobalSettings::Completion tmpCompletion=KGlobalSettings::CompletionNone;
00559 
00560     switch(typeCompletion->currentItem())
00561     {
00562         case 0:
00563             tmpCompletion=KGlobalSettings::CompletionNone;
00564             break;
00565         case 1:
00566             tmpCompletion=KGlobalSettings::CompletionShell;
00567             break;
00568         case 2:
00569             tmpCompletion=KGlobalSettings::CompletionPopup;
00570             break;
00571         case 3:
00572             tmpCompletion=KGlobalSettings::CompletionAuto;
00573             break;
00574         case 4:
00575             tmpCompletion=KGlobalSettings::CompletionMan;
00576             break;
00577     }
00578 
00579 
00580     if(comboChanged)
00581     {
00582         m_pView->doc()->setCompletionMode(tmpCompletion);
00583         config->writeEntry( "Completion Mode", (int)tmpCompletion);
00584     }
00585 
00586     KSpread::MoveTo tmpMoveTo=KSpread::Bottom;
00587     switch(typeOfMove->currentItem())
00588     {
00589         case 0:
00590             tmpMoveTo=KSpread::Bottom;
00591             break;
00592         case 1:
00593             tmpMoveTo=KSpread::Top;
00594             break;
00595         case 2:
00596             tmpMoveTo=KSpread::Right;
00597             break;
00598         case 3:
00599             tmpMoveTo=KSpread::Left;
00600             break;
00601         case 4:
00602             tmpMoveTo=KSpread::BottomFirst;
00603             break;
00604     }
00605     if(tmpMoveTo!=m_pView->doc()->getMoveToValue())
00606     {
00607         m_pView->doc()->setMoveToValue(tmpMoveTo);
00608         config->writeEntry( "Move", (int)tmpMoveTo);
00609     }
00610 
00611     MethodOfCalc tmpMethodCalc=SumOfNumber;
00612     switch(typeCalc->currentItem())
00613     {
00614         case 0:
00615             tmpMethodCalc =SumOfNumber;
00616             break;
00617         case 1:
00618             tmpMethodCalc=Min;
00619             break;
00620         case 2:
00621             tmpMethodCalc=Max;
00622             break;
00623         case 3:
00624             tmpMethodCalc=Average;
00625             break;
00626     case 4:
00627             tmpMethodCalc=Count;
00628             break;
00629         case 5:
00630             tmpMethodCalc=CountA;
00631             break;
00632         case 6:
00633             tmpMethodCalc=NoneCalc;
00634             break;
00635 
00636     }
00637     if(tmpMethodCalc!=m_pView->doc()->getTypeOfCalc())
00638     {
00639         m_pView->doc()->setTypeOfCalc(tmpMethodCalc);
00640         config->writeEntry( "Method of Calc", (int)tmpMethodCalc);
00641     m_pView->resultOfCalc();
00642         m_pView->initCalcMenu();
00643     }
00644 
00645     double val = valIndent->value();
00646     if( val != m_pView->doc()->getIndentValue() )
00647     {
00648         m_pView->doc()->setIndentValue( val );
00649         config->writeEntry( "Indent", val );
00650     }
00651 
00652     bool active=msgError->isChecked();
00653     if(active!=m_pView->doc()->getShowMessageError())
00654     {
00655         m_pView->doc()->setShowMessageError( active);
00656         config->writeEntry( "Msg error" ,(int)active);
00657     }
00658 
00659     active=commentIndicator->isChecked();
00660     if(active!=m_pView->doc()->getShowCommentIndicator())
00661     {
00662         m_pView->doc()->setShowCommentIndicator( active);
00663         config->writeEntry( "Comment Indicator" ,(int)active);
00664     }
00665 }
00666 
00667 
00668 
00669 colorParameters::colorParameters( KSpreadView* _view,QVBox *box , char *name )
00670  :QObject ( box->parent(),name)
00671 {
00672   m_pView = _view;
00673   config = KSpreadFactory::global()->config();
00674 
00675   QColor _gridColor(Qt::lightGray);
00676 
00677   if ( config->hasGroup("KSpread Color" ) )
00678   {
00679     config->setGroup( "KSpread Color" );
00680     _gridColor = config->readColorEntry("GridColor",&_gridColor);
00681   }
00682 
00683   QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Color"), box, "GroupBox" );
00684 
00685   QLabel *label = new QLabel(i18n("&Grid color:"), tmpQGroupBox,"label20" );
00686 
00687   gridColor = new KColorButton( _gridColor,
00688                                 Qt::lightGray,
00689                                 tmpQGroupBox );
00690 
00691   label->setBuddy(gridColor);
00692 
00693   QColor _pbColor(Qt::red);
00694   if ( config->hasGroup("KSpread Color" ) )
00695   {
00696     config->setGroup( "KSpread Color" );
00697     _pbColor = config->readColorEntry("PageBorderColor", &_pbColor);
00698   }
00699 
00700   QLabel * label2 = new QLabel( i18n("&Page borders:"), tmpQGroupBox, "label21" );
00701 
00702   pageBorderColor = new KColorButton( _pbColor,
00703                                 Qt::red,
00704                                 tmpQGroupBox );
00705 
00706 
00707   label2->setBuddy(pageBorderColor);
00708 }
00709 
00710 void colorParameters::apply()
00711 {
00712   QColor _col = gridColor->color();
00713   if ( m_pView->doc()->gridColor() != _col )
00714   {
00715     m_pView->doc()->setGridColor( _col );
00716     config->setGroup( "KSpread Color" );
00717     config->writeEntry( "GridColor", _col );
00718   }
00719 
00720   QColor _pbColor = pageBorderColor->color();
00721   if ( m_pView->doc()->pageBorderColor() != _pbColor )
00722   {
00723     m_pView->doc()->changePageBorderColor( _pbColor );
00724     config->setGroup( "KSpread Color" );
00725     config->writeEntry( "PageBorderColor", _pbColor );
00726   }
00727 }
00728 
00729 void colorParameters::slotDefault()
00730 {
00731   gridColor->setColor( lightGray );
00732   pageBorderColor->setColor( red );
00733 }
00734 
00735 
00736 
00737 configureLayoutPage::configureLayoutPage( KSpreadView* _view,QVBox *box , char *name )
00738  :QObject ( box->parent(),name)
00739 {
00740   m_pView = _view;
00741 
00742   QGroupBox* tmpQGroupBox = new QGroupBox( 0, Qt::Vertical, i18n("Default Parameters"), box, "GroupBox" );
00743   tmpQGroupBox->layout()->setSpacing(KDialog::spacingHint());
00744   tmpQGroupBox->layout()->setMargin(KDialog::marginHint());
00745 
00746   QGridLayout *grid1 = new QGridLayout(tmpQGroupBox->layout(),8,1);
00747   grid1->addRowSpacing( 0, KDialog::marginHint()  );
00748   grid1->setRowStretch( 7, 10 );
00749 
00750   config = KSpreadFactory::global()->config();
00751 
00752   QLabel *label=new QLabel(i18n("Default page &size:"), tmpQGroupBox);
00753 
00754   grid1->addWidget(label,0,0);
00755 
00756   defaultSizePage=new QComboBox( tmpQGroupBox);
00757   label->setBuddy(defaultSizePage);
00758   defaultSizePage->insertStringList( KoPageFormat::allFormats() );
00759   defaultSizePage->setCurrentItem(1);
00760   grid1->addWidget(defaultSizePage,1,0);
00761 
00762   label=new QLabel(i18n("Default page &orientation:"), tmpQGroupBox);
00763   grid1->addWidget(label,2,0);
00764 
00765   defaultOrientationPage=new QComboBox( tmpQGroupBox);
00766   label->setBuddy(defaultOrientationPage);
00767   QStringList listType;
00768   listType+=i18n( "Portrait" );
00769   listType+=i18n( "Landscape" );
00770   defaultOrientationPage->insertStringList(listType);
00771   defaultOrientationPage->setCurrentItem(0);
00772   grid1->addWidget(defaultOrientationPage,3,0);
00773 
00774   label=new QLabel(tmpQGroupBox);
00775   label->setText(i18n("Default page &units:"));
00776   grid1->addWidget(label,4,0);
00777   defaultUnit=new QComboBox( tmpQGroupBox);
00778   label->setBuddy(defaultUnit);
00779   listType.clear();
00780   listType=KoUnit::unitDescription( KoUnit::U_MM );
00781   listType+=KoUnit::unitDescription( KoUnit::U_PT );
00782   listType+=KoUnit::unitDescription( KoUnit::U_INCH );
00783   listType+=KoUnit::unitDescription( KoUnit::U_CM );
00784   listType+=KoUnit::unitDescription( KoUnit::U_PI );
00785   listType+=KoUnit::unitDescription( KoUnit::U_CC );
00786   listType+=KoUnit::unitDescription( KoUnit::U_DD );
00787   listType+=KoUnit::unitDescription( KoUnit::U_DM );
00788 
00789   defaultUnit->insertStringList(listType);
00790   defaultUnit->setCurrentItem(0);
00791   grid1->addWidget(defaultUnit,5,0);
00792   initCombo();
00793 
00794 }
00795 
00796 void configureLayoutPage::slotDefault()
00797 {
00798   defaultSizePage->setCurrentItem(1);
00799   defaultOrientationPage->setCurrentItem(0);
00800   defaultUnit->setCurrentItem(0);
00801 }
00802 
00803 void configureLayoutPage::initCombo()
00804 {
00805     paper=1;
00806     orientation=0;
00807     unit=0;
00808     if( config->hasGroup("KSpread Page Layout" ))
00809     {
00810         config->setGroup( "KSpread Page Layout" );
00811         paper=config->readNumEntry( "Default size page" ,1);
00812         orientation=config->readNumEntry( "Default orientation page" ,0);
00813         unit=config->readNumEntry( "Default unit page" ,0);
00814     }
00815 
00816     switch (m_pView->doc()->getUnit() )
00817     {
00818     case KoUnit::U_MM:
00819         unit=0;
00820         break;
00821     case KoUnit::U_PT:
00822         unit=1;
00823         break;
00824     case KoUnit::U_INCH:
00825         unit=2;
00826         break;
00827     case KoUnit::U_CM:
00828         unit=3;
00829         break;
00830     case KoUnit::U_DM:
00831         unit = 4;
00832         break;
00833     case KoUnit::U_PI:
00834         unit = 5;
00835         break;
00836     case KoUnit::U_DD:
00837         unit = 6;
00838         break;
00839     case KoUnit::U_CC:
00840         unit = 7;
00841         break;
00842     default:
00843         unit=3;
00844     }
00845     defaultUnit->setCurrentItem(unit);
00846 
00847 
00848     defaultSizePage->setCurrentItem(paper);
00849     defaultOrientationPage->setCurrentItem(orientation);
00850     defaultUnit->setCurrentItem(unit);
00851 }
00852 
00853 
00854 void configureLayoutPage::apply()
00855 {
00856   m_pView->doc()->emitBeginOperation( false );
00857   config->setGroup( "KSpread Page Layout" );
00858 
00859   if( paper != defaultSizePage->currentItem() )
00860   {
00861      unsigned int sizePage = defaultSizePage->currentItem();
00862      config->writeEntry( "Default size page", sizePage );
00863      m_pView->activeSheet()->print()->setPaperFormat( (KoFormat)sizePage );
00864   }
00865   if( orientation != defaultOrientationPage->currentItem() )
00866   {
00867      unsigned int orientationPage = defaultOrientationPage->currentItem();
00868      config->writeEntry( "Default orientation page", orientationPage );
00869      m_pView->activeSheet()->print()->setPaperOrientation( (KoOrientation)orientationPage );
00870   }
00871   if( unit != defaultUnit->currentItem() )
00872   {
00873      unsigned int unitPage = defaultUnit->currentItem();
00874      config->writeEntry( "Default unit page", unitPage );
00875      m_pView->doc()->setUnit( (KoUnit::Unit)unitPage );
00876   }
00877   m_pView->slotUpdateView( m_pView->activeSheet() );
00878 }
00879 
00880 configureSpellPage::configureSpellPage( KSpreadView* _view,QVBox *box , char *name )
00881  :QObject ( box->parent(),name)
00882 {
00883   m_pView = _view;
00884 
00885   config = KSpreadFactory::global()->config();
00886 
00887 
00888   m_spellConfigWidget = new KSpellConfig( box, "spell_check",m_pView->doc()->getKSpellConfig()/*, false*/);
00889     dontCheckUpperWord = new QCheckBox( i18n("Do not check upper word"),box);
00890     dontCheckTitleCase = new QCheckBox( i18n("Do not check title case"),box);
00891 
00892   QWidget* spacer = new QWidget( box );
00893   spacer->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
00894 
00895     if( config->hasGroup("KSpell kspread") )
00896     {
00897         config->setGroup( "KSpell kspread" );
00898 
00899         dontCheckUpperWord->setChecked(config->readBoolEntry("KSpell_dont_check_upper_word",false));
00900         dontCheckTitleCase->setChecked(config->readBoolEntry("KSpell_dont_check_title_case",false));
00901     }
00902     //m_spellConfigWidget->addIgnoreList( m_pView->doc()->spellListIgnoreAll() );
00903 }
00904 
00905 
00906 void configureSpellPage::apply()
00907 {
00908   m_pView->doc()->emitBeginOperation( false );
00909 
00910   KSpellConfig *_spellConfig = m_spellConfigWidget;
00911   config->setGroup( "KSpell kspread" );
00912   config->writeEntry ("KSpell_NoRootAffix",(int) _spellConfig->noRootAffix ());
00913   config->writeEntry ("KSpell_RunTogether", (int) _spellConfig->runTogether ());
00914   config->writeEntry ("KSpell_Dictionary", _spellConfig->dictionary ());
00915   config->writeEntry ("KSpell_DictFromList",(int)  _spellConfig->dictFromList());
00916   config->writeEntry ("KSpell_Encoding", (int)  _spellConfig->encoding());
00917   config->writeEntry ("KSpell_Client",  _spellConfig->client());
00918 //  m_spellConfigWidget->saveDictionary();
00919   KSpreadDoc* doc = m_pView->doc();
00920   doc->setKSpellConfig(*_spellConfig);
00921 
00922     bool state=dontCheckUpperWord->isChecked();
00923   config->writeEntry ("KSpell_dont_check_upper_word",(int)state);
00924   doc->setDontCheckUpperWord(state);
00925 
00926   state=dontCheckTitleCase->isChecked();
00927   config->writeEntry("KSpell_dont_check_title_case",(int)state);
00928   doc->setDontCheckTitleCase(state);
00929 
00930   //m_pView->doc()->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() );
00931 
00932   m_pView->slotUpdateView( m_pView->activeSheet() );
00933 }
00934 
00935 void configureSpellPage::slotDefault()
00936 {
00937     //FIXME
00938     //m_spellConfigWidget->setDefault();
00939 }
00940 
00941 #include "kspread_dlg_preference.moc"
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:02 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003