Back to index

scribus-ng  1.3.4.dfsg+svn20071115
search.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "search.h"
00008 #include "search.moc"
00009 
00010 #include <qvariant.h>
00011 #include <qregexp.h>
00012 #include <qcheckbox.h>
00013 #include <qcombobox.h>
00014 #include <qgroupbox.h>
00015 #include <qlineedit.h>
00016 #include <qlabel.h>
00017 #include <qpushbutton.h>
00018 #include <qlayout.h>
00019 #include <qtooltip.h>
00020 #include <qwhatsthis.h>
00021 #include <qmessagebox.h>
00022 
00023 #include "colorlistbox.h"
00024 #include "commonstrings.h"
00025 #include "colorcombo.h"
00026 #include "fontcombo.h"
00027 #include "mspinbox.h"
00028 #include "page.h"
00029 #include "prefscontext.h"
00030 #include "prefsfile.h"
00031 #include "prefsmanager.h"
00032 #include "scribus.h"
00033 #include "shadebutton.h"
00034 #include "story.h"
00035 #include "styleselect.h"
00036 #include "util.h"
00037 #include "text/nlsconfig.h"
00038 
00039 
00040 extern QPixmap loadIcon(QString nam);
00041 
00042 SearchReplace::SearchReplace( QWidget* parent, ScribusDoc *doc, PageItem* ite, bool mode )
00043        : QDialog( parent, "SearchReplace", true, 0 ),
00044        matchesFound(0)
00045 {
00046        setCaption( tr( "Search/Replace" ) );
00047        setIcon(loadIcon("AppIcon.png"));
00048        ColorList::Iterator it;
00049        Item = ite;
00050        Doc = doc;
00051        NotFound = false;
00052        SMode = mode;
00053        SearchReplaceLayout = new QVBoxLayout( this, 10, 5, "SearchReplaceLayout");
00054        SelLayout = new QHBoxLayout( 0, 0, 6, "SelLayout");
00055        Search = new QGroupBox( this, "Search" );
00056        Search->setTitle( tr( "Search for:" ) );
00057        Search->setColumnLayout(0, Qt::Vertical );
00058        Search->layout()->setSpacing( 2 );
00059        Search->layout()->setMargin( 5 );
00060        SearchLayout = new QGridLayout( Search->layout() );
00061        SearchLayout->setAlignment( Qt::AlignTop );
00062        SText = new QCheckBox( Search, "SText" );
00063        SText->setText( tr( "Text" ) );
00064        SearchLayout->addWidget( SText, 0, 0 );
00065        SStyle = new QCheckBox( Search, "SStyle" );
00066        SStyle->setText( tr( "Paragraph Style" ) );
00067        SearchLayout->addWidget( SStyle, 1, 0 );
00068        SFont = new QCheckBox( Search, "SFont" );
00069        SFont->setText( tr( "Font" ) );
00070        SearchLayout->addWidget( SFont, 2, 0 );
00071        SSize = new QCheckBox( Search, "SSize" );
00072        SSize->setText( tr( "Font Size" ) );
00073        SearchLayout->addWidget( SSize, 3, 0 );
00074        SEffect = new QCheckBox( Search, "SEffect" );
00075        SEffect->setText( tr( "Font Effects" ) );
00076        SearchLayout->addWidget( SEffect, 4, 0 );
00077        SFill = new QCheckBox( Search, "SFill" );
00078        SFill->setText( tr( "Fill Color" ) );
00079        SearchLayout->addWidget( SFill, 5, 0 );
00080        SFillS = new QCheckBox( Search, "SFillS" );
00081        SFillS->setText( tr( "Fill Shade" ) );
00082        SearchLayout->addWidget( SFillS, 6, 0 );
00083        SStroke = new QCheckBox( Search, "SStroke" );
00084        SStroke->setText( tr( "Stroke Color" ) );
00085        SearchLayout->addWidget( SStroke, 7, 0 );
00086        SStrokeS = new QCheckBox( Search, "SStrokeS" );
00087        SStrokeS->setText( tr( "Stroke Shade" ) );
00088        SearchLayout->addWidget( SStrokeS, 8, 0 );
00089        STextVal = new QLineEdit( Search, "STextVal" );
00090        STextVal->setEnabled(false);
00091        SearchLayout->addWidget( STextVal, 0, 1 );
00092        SStyleVal = new QComboBox( true, Search, "SStyleVal" );
00093        SStyleVal->setEditable(false);
00094        QString tmp_sty[] = { tr("Left"), tr("Center"), tr("Right"), tr("Block"), tr("Forced")};
00095        size_t ar_sty = sizeof(tmp_sty) / sizeof(*tmp_sty);
00096        for (uint a = 0; a < ar_sty; ++a)
00097               SStyleVal->insertItem(tmp_sty[a]);
00098 //     if (doc->docParagraphStyles.count() >5)
00099        {
00100               for (uint x = 0; x < doc->paragraphStyles().count(); ++x)
00101                      SStyleVal->insertItem(doc->paragraphStyles()[x].name());
00102        }
00103        SStyleVal->listBox()->setMinimumWidth(SStyleVal->listBox()->maxItemWidth()+24);
00104        SStyleVal->setCurrentItem(findParagraphStyle(doc, doc->currentStyle));
00105        SStyleVal->setEnabled(false);
00106        SearchLayout->addWidget( SStyleVal, 1, 1 );
00107        SFontVal = new FontCombo(Search);
00108        SFontVal->setMaximumSize(190, 30);
00109        SFontVal->setCurrentText(doc->currentStyle.charStyle().font().scName());
00110        SFontVal->setEnabled(false);
00111        SearchLayout->addWidget( SFontVal, 2, 1 );
00112        SSizeVal = new MSpinBox( Search, 1 );
00113        SSizeVal->setSuffix( tr( " pt" ) );
00114        SSizeVal->setMinValue( 0.5 );
00115        SSizeVal->setMaxValue( 2048 );
00116        SSizeVal->setValue( doc->currentStyle.charStyle().fontSize() / 10.0 );
00117        SSizeVal->setEnabled(false);
00118        SearchLayout->addWidget( SSizeVal, 3, 1 );
00119        SEffVal = new StyleSelect( Search );
00120        SEffVal->setStyle(0);
00121        SEffVal->setEnabled(false);
00122        SearchLayout->addWidget( SEffVal, 4, 1, Qt::AlignLeft );
00123        SFillVal = new ColorCombo( true, Search, "SFillVal" );
00124        SFillVal->setEditable(false);
00125        SFillVal->updateBox(doc->PageColors, ColorCombo::widePixmaps, true);
00126        SFillVal->listBox()->setMinimumWidth(SFillVal->listBox()->maxItemWidth()+24);
00127        SFillVal->setCurrentText(doc->currentStyle.charStyle().fillColor());
00128        SFillVal->setEnabled(false);
00129        SearchLayout->addWidget( SFillVal, 5, 1 );
00130        SFillSVal = new ShadeButton(Search);
00131        SFillSVal->setEnabled(false);
00132        SearchLayout->addWidget( SFillSVal, 6, 1, Qt::AlignLeft );
00133        SStrokeVal = new ColorCombo( true, Search, "SStrokeVal" );
00134        SStrokeVal->setEditable(false);
00135        SStrokeVal->updateBox(doc->PageColors, ColorCombo::widePixmaps, true);
00136        SStrokeVal->listBox()->setMinimumWidth(SStrokeVal->listBox()->maxItemWidth()+24);
00137        SStrokeVal->setCurrentText(doc->currentStyle.charStyle().strokeColor());
00138        SStrokeVal->setEnabled(false);
00139        SearchLayout->addWidget( SStrokeVal, 7, 1 );
00140        SStrokeSVal =  new ShadeButton(Search);
00141        SStrokeSVal->setEnabled(false);
00142        SearchLayout->addWidget( SStrokeSVal, 8, 1, Qt::AlignLeft );
00143        SelLayout->addWidget( Search );
00144 
00145        Replace = new QGroupBox( this, "Replace" );
00146        Replace->setTitle( tr( "Replace with:" ) );
00147        Replace->setColumnLayout(0, Qt::Vertical );
00148        Replace->layout()->setSpacing( 2 );
00149        Replace->layout()->setMargin( 5 );
00150        ReplaceLayout = new QGridLayout( Replace->layout() );
00151        ReplaceLayout->setAlignment( Qt::AlignTop );
00152        RText = new QCheckBox( Replace, "RText" );
00153        RText->setText( tr( "Text" ) );
00154        ReplaceLayout->addWidget( RText, 0, 0 );
00155        RStyle = new QCheckBox( Replace, "RStyle" );
00156        RStyle->setText( tr( "Paragraph Style" ) );
00157        ReplaceLayout->addWidget( RStyle, 1, 0 );
00158        RFont = new QCheckBox( Replace, "RFont" );
00159        RFont->setText( tr( "Font" ) );
00160        ReplaceLayout->addWidget( RFont, 2, 0 );
00161        RSize = new QCheckBox( Replace, "RSize" );
00162        RSize->setText( tr( "Font Size" ) );
00163        ReplaceLayout->addWidget( RSize, 3, 0 );
00164        REffect = new QCheckBox( Replace, "REffect" );
00165        REffect->setText( tr( "Font Effects" ) );
00166        ReplaceLayout->addWidget( REffect, 4, 0 );
00167        RFill = new QCheckBox( Replace, "RFill" );
00168        RFill->setText( tr( "Fill Color" ) );
00169        ReplaceLayout->addWidget( RFill, 5, 0 );
00170        RFillS = new QCheckBox( Replace, "RFillS" );
00171        RFillS->setText( tr( "Fill Shade" ) );
00172        ReplaceLayout->addWidget( RFillS, 6, 0 );
00173        RStroke = new QCheckBox( Replace, "RStroke" );
00174        RStroke->setText( tr( "Stroke Color" ) );
00175        ReplaceLayout->addWidget( RStroke, 7, 0 );
00176        RStrokeS = new QCheckBox( Replace, "RStrokeS" );
00177        RStrokeS->setText( tr( "Stroke Shade" ) );
00178        ReplaceLayout->addWidget( RStrokeS, 8, 0 );
00179        RTextVal = new QLineEdit( Replace, "RTextVal" );
00180        RTextVal->setEnabled(false);
00181        ReplaceLayout->addWidget( RTextVal, 0, 1 );
00182        RStyleVal = new QComboBox( true, Replace, "RStyleVal" );
00183        RStyleVal->setEditable(false);
00184        for (uint a = 0; a < ar_sty; ++a)
00185               RStyleVal->insertItem(tmp_sty[a]);
00186 //     if (doc->docParagraphStyles.count() > 5)
00187        {
00188               for (uint x = 5; x < doc->paragraphStyles().count(); ++x)
00189                      RStyleVal->insertItem(doc->paragraphStyles()[x].name());
00190        }
00191        RStyleVal->listBox()->setMinimumWidth(RStyleVal->listBox()->maxItemWidth()+24);
00192        RStyleVal->setCurrentItem(findParagraphStyle(doc, doc->currentStyle));
00193        RStyleVal->setEnabled(false);
00194        ReplaceLayout->addWidget( RStyleVal, 1, 1 );
00195        RFontVal = new FontCombo(Replace);
00196        RFontVal->setMaximumSize(190, 30);
00197        RFontVal->setCurrentText(doc->currentStyle.charStyle().font().scName());
00198        RFontVal->setEnabled(false);
00199        ReplaceLayout->addWidget( RFontVal, 2, 1 );
00200        RSizeVal = new MSpinBox( Replace, 1 );
00201        RSizeVal->setSuffix( tr( " pt" ) );
00202        RSizeVal->setMinValue( 0.5 );
00203        RSizeVal->setMaxValue( 2048 );
00204        RSizeVal->setValue( doc->currentStyle.charStyle().fontSize() / 10.0 );
00205        RSizeVal->setEnabled(false);
00206        ReplaceLayout->addWidget( RSizeVal, 3, 1 );
00207        REffVal = new StyleSelect( Replace );
00208        REffVal->setStyle(0);
00209        REffVal->setEnabled(false);
00210        ReplaceLayout->addWidget( REffVal, 4, 1, Qt::AlignLeft );
00211        RFillVal = new ColorCombo( true, Replace, "RFillVal" );
00212        RFillVal->setEditable(false);
00213        RFillVal->updateBox(doc->PageColors, ColorCombo::widePixmaps, true);
00214        RFillVal->listBox()->setMinimumWidth(RFillVal->listBox()->maxItemWidth()+24);
00215        RFillVal->setCurrentText(doc->currentStyle.charStyle().fillColor());
00216        RFillVal->setEnabled(false);
00217        ReplaceLayout->addWidget( RFillVal, 5, 1 );
00218        RFillSVal = new ShadeButton(Replace);
00219        RFillSVal->setEnabled(false);
00220        ReplaceLayout->addWidget( RFillSVal, 6, 1, Qt::AlignLeft );
00221        RStrokeVal = new ColorCombo( true, Replace, "RStrokeVal" );
00222        RStrokeVal->setEditable(false);
00223        RStrokeVal->updateBox(doc->PageColors, ColorCombo::widePixmaps, true);
00224        RStrokeVal->listBox()->setMinimumWidth(RStrokeVal->listBox()->maxItemWidth()+24);
00225        RStrokeVal->setCurrentText(doc->currentStyle.charStyle().strokeColor());
00226        RStrokeVal->setEnabled(false);
00227        ReplaceLayout->addWidget( RStrokeVal, 7, 1 );
00228        RStrokeSVal = new ShadeButton(Replace);;
00229        RStrokeSVal->setEnabled(false);
00230        ReplaceLayout->addWidget( RStrokeSVal, 8, 1, Qt::AlignLeft );
00231        SelLayout->addWidget( Replace );
00232        SearchReplaceLayout->addLayout( SelLayout );
00233 
00234        OptsLayout = new QHBoxLayout( 0, 0, 6, "OptsLayout");
00235        Word = new QCheckBox( tr( "&Whole Word" ), this, "Word" );
00236        if (mode)
00237               Word->setEnabled(false);
00238        OptsLayout->addWidget( Word );
00239        CaseIgnore = new QCheckBox( tr( "&Ignore Case" ), this, "CaseIgnore" );
00240        if (mode)
00241               CaseIgnore->setEnabled(false);
00242        OptsLayout->addWidget( CaseIgnore );
00243        SearchReplaceLayout->addLayout( OptsLayout );
00244 
00245        ButtonsLayout = new QHBoxLayout( 0, 0, 4, "ButtonsLayout");
00246        DoSearch = new QPushButton( tr( "&Search" ), this, "DoSearch" );
00247        DoSearch->setDefault( true );
00248        ButtonsLayout->addWidget( DoSearch );
00249        DoReplace = new QPushButton( tr( "&Replace" ), this, "DoReplace" );
00250        DoReplace->setEnabled(false);
00251        ButtonsLayout->addWidget( DoReplace );
00252        AllReplace = new QPushButton( tr( "Replace &All" ), this, "DoReplace" );
00253        AllReplace->setEnabled(false);
00254        ButtonsLayout->addWidget( AllReplace );
00255        clearButton = new QPushButton( tr("C&lear"), this, "clearButton");
00256        ButtonsLayout->addWidget(clearButton);
00257        Leave = new QPushButton( tr( "&Close" ), this, "Leave" );
00258        ButtonsLayout->addWidget( Leave );
00259        SearchReplaceLayout->addLayout( ButtonsLayout );
00260 
00261        resize(minimumSizeHint());
00262 
00263  // signals and slots connections
00264        connect( Leave, SIGNAL( clicked() ), this, SLOT( writePrefs() ) );
00265        connect( DoSearch, SIGNAL( clicked() ), this, SLOT( slotSearch() ) );
00266        connect( DoReplace, SIGNAL( clicked() ), this, SLOT( slotReplace() ) );
00267        connect( AllReplace, SIGNAL( clicked() ), this, SLOT( slotReplaceAll() ) );
00268        connect( SText, SIGNAL( clicked() ), this, SLOT( enableTxSearch() ) );
00269        connect( SStyle, SIGNAL( clicked() ), this, SLOT( enableStyleSearch() ) );
00270        connect( SFont, SIGNAL( clicked() ), this, SLOT( enableFontSearch() ) );
00271        connect( SSize, SIGNAL( clicked() ), this, SLOT( enableSizeSearch() ) );
00272        connect( SEffect, SIGNAL( clicked() ), this, SLOT( enableEffSearch() ) );
00273        connect( SFill, SIGNAL( clicked() ), this, SLOT( enableFillSearch() ) );
00274        connect( SFillS, SIGNAL( clicked() ), this, SLOT( enableFillSSearch() ) );
00275        connect( SStrokeS, SIGNAL( clicked() ), this, SLOT( enableStrokeSSearch() ) );
00276        connect( SStroke, SIGNAL( clicked() ), this, SLOT( enableStrokeSearch() ) );
00277        connect( RText, SIGNAL( clicked() ), this, SLOT( enableTxReplace() ) );
00278        connect( RStyle, SIGNAL( clicked() ), this, SLOT( enableStyleReplace() ) );
00279        connect( RFont, SIGNAL( clicked() ), this, SLOT( enableFontReplace() ) );
00280        connect( RSize, SIGNAL( clicked() ), this, SLOT( enableSizeReplace() ) );
00281        connect( REffect, SIGNAL( clicked() ), this, SLOT( enableEffReplace() ) );
00282        connect( RFill, SIGNAL( clicked() ), this, SLOT( enableFillReplace() ) );
00283        connect( RStroke, SIGNAL( clicked() ), this, SLOT( enableStrokeReplace() ) );
00284        connect( RFillS, SIGNAL( clicked() ), this, SLOT( enableFillSReplace() ) );
00285        connect( RStrokeS, SIGNAL( clicked() ), this, SLOT( enableStrokeSReplace() ) );
00286        connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
00287 
00288  // tab order
00289        setTabOrder( SText, SStyle );
00290        setTabOrder( SStyle, SFont );
00291        setTabOrder( SFont, SSize );
00292        setTabOrder( SSize, SEffect );
00293        setTabOrder( SEffect, SFill );
00294        setTabOrder( SFill, SStroke );
00295        setTabOrder( SStroke, STextVal );
00296        setTabOrder( STextVal, SStyleVal );
00297        setTabOrder( SStyleVal, SFontVal );
00298        setTabOrder( SFontVal, SSizeVal );
00299        setTabOrder( SSizeVal, SEffVal );
00300        setTabOrder( SEffVal, SFillVal );
00301        setTabOrder( SFillVal, SStrokeVal );
00302        setTabOrder( SStrokeVal, RText );
00303        setTabOrder( RText, RStyle );
00304        setTabOrder( RStyle, RFont );
00305        setTabOrder( RFont, RSize );
00306        setTabOrder( RSize, REffect );
00307        setTabOrder( REffect, RFill );
00308        setTabOrder( RFill, RStroke );
00309        setTabOrder( RStroke, RTextVal );
00310        setTabOrder( RTextVal, RStyleVal );
00311        setTabOrder( RStyleVal, RFontVal );
00312        setTabOrder( RFontVal, RSizeVal );
00313        setTabOrder( RSizeVal, REffVal );
00314        setTabOrder( REffVal, RFillVal );
00315        setTabOrder( RFillVal, RStrokeVal );
00316        setTabOrder( RStrokeVal, Word );
00317        setTabOrder( Word, CaseIgnore );
00318        setTabOrder( CaseIgnore, DoSearch );
00319        setTabOrder( DoSearch, DoReplace );
00320        setTabOrder( DoReplace, AllReplace );
00321        setTabOrder( AllReplace, Leave );
00322 
00323        prefs = PrefsManager::instance()->prefsFile->getContext("SearchReplace");
00324        readPrefs();
00325 }
00326 
00327 void SearchReplace::slotSearch()
00328 {
00329        if (SMode)
00330               Doc->view()->slotDoCurs(false);
00331        slotDoSearch();
00332        if (SMode)
00333        {
00334               Doc->view()->slotDoCurs(true);
00335               Doc->view()->RefreshItem(Item);
00336        }
00337 }
00338 
00339 void SearchReplace::slotDoSearch()
00340 {
00341        int maxChar = Item->itemText.length() - 1;
00342        DoReplace->setEnabled(false);
00343        AllReplace->setEnabled(false);
00344        if (SMode)
00345        {
00346               Item->itemText.deselectAll();
00347               Item->HasSel = false;
00348        }
00349        QString fCol = "";
00350        QString sCol = "";
00351        QString sFont = "";
00352        QString sText = "";
00353        NotFound = true;
00354        int sStyle = 0;
00355        int sSize = 0;
00356        int sEff = 0;
00357        int sFillSh = 100;
00358        int sStrokeSh = 100;
00359        bool rep = false;
00360        bool found = true;
00361        if ((RFill->isChecked()) || (RStroke->isChecked()) || (RStyle->isChecked()) || (RFont->isChecked())
00362               || (RStrokeS->isChecked()) || (RFillS->isChecked()) || (RSize->isChecked()) || (RText->isChecked())
00363               || (REffect->isChecked()))
00364               rep = true;
00365        if (SText->isChecked())
00366               sText = STextVal->text();
00367        if (CaseIgnore->isChecked())
00368               sText = sText.lower();
00369        if (SEffect->isChecked())
00370               sEff = SEffVal->getStyle();
00371        if (SFill->isChecked())
00372               fCol = SFillVal->currentText();
00373        if (SFillS->isChecked())
00374               sFillSh = SFillSVal->getValue();
00375        if (SStroke->isChecked())
00376               sCol = SStrokeVal->currentText();
00377        if (SStrokeS->isChecked())
00378               sStrokeSh = SStrokeSVal->getValue();
00379        if (SFont->isChecked())
00380               sFont = SFontVal->currentText();
00381        if (SStyle->isChecked())
00382               sStyle = SStyleVal->currentItem();
00383        if (SSize->isChecked())
00384               sSize = qRound(SSizeVal->value() * 10);
00385        if (sText.length() > 0)
00386               found = false;
00387        uint inde = 0;
00388        uint as = Item->CPos;
00389        ReplStart = as;
00390        int a;
00391        if (SMode)
00392        {
00393               for (a = as; a < Item->itemText.length(); ++a)
00394               {
00395                      if (SText->isChecked())
00396                      {
00397                             QString chstr = Item->itemText.text(a,1);
00398                             if (CaseIgnore->isChecked())
00399                                    chstr = chstr.lower();
00400                             found = chstr == sText.mid(inde, 1) ? true : false;
00401                             if ((Word->isChecked()) && (inde == 0) && (chstr[0].isSpace()))
00402                                    found = true;
00403                      }
00404                      else
00405                             found = true;
00406                      if (SSize->isChecked())
00407                      {
00408                             if (Item->itemText.charStyle(a).fontSize() != sSize)
00409                                    found = false;
00410                      }
00411                      if (SFont->isChecked())
00412                      {
00413                             if (Item->itemText.charStyle(a).font().scName() != sFont)
00414                                    found = false;
00415                      }
00416 #ifndef NLS_PROTO
00417                      if (SStyle->isChecked())
00418                      {
00419 //                          if (Item->itemText.item(a)->cab != sStyle)
00420 //                                 found = false;
00421                      }
00422 #endif
00423                      if (SStroke->isChecked())
00424                      {
00425                             if (Item->itemText.charStyle(a).strokeColor() != sCol)
00426                                    found = false;
00427                      }
00428                      if (SStrokeS->isChecked())
00429                      {
00430                             if (Item->itemText.charStyle(a).strokeShade() != sStrokeSh)
00431                                    found = false;
00432                      }
00433                      if (SFillS->isChecked())
00434                      {
00435                             if (Item->itemText.charStyle(a).fillShade() != sFillSh)
00436                                    found = false;
00437                      }
00438                      if (SEffect->isChecked())
00439                             {
00440                             if ((Item->itemText.charStyle(a).effects() & 1919) != sEff)
00441                                    found = false;
00442                             }
00443                      if (SFill->isChecked())
00444                      {
00445                             if (Item->itemText.charStyle(a).fillColor() != fCol)
00446                                    found = false;
00447                      }
00448                      if (found)
00449                      {
00450                             Item->itemText.select(a,1);
00451                             Item->HasSel = true;
00452                             if (rep)
00453                             {
00454                                    DoReplace->setEnabled(true);
00455                                    AllReplace->setEnabled(true);
00456                             }
00457                             Item->CPos = a+1;
00458                             if (SText->isChecked())
00459                             {
00460                                    if (inde == 0)
00461                                           ReplStart = a;
00462                                    inde++;
00463                                    if ((Word->isChecked()) && (inde == 1) && (Item->itemText.text(a).isSpace()))
00464                                    {
00465                                           inde--;
00466                                           Item->itemText.select(a, 1, false);
00467                                    }
00468                                    if ( Word->isChecked()  &&  inde == sText.length()  &&
00469                                           ! Item->itemText.text(QMIN(a+1, maxChar)).isSpace() )
00470                                    {
00471                                           for (int xx = ReplStart; xx < a+1; ++xx)
00472                                                  Item->itemText.select(QMIN(xx, maxChar), 1, false);
00473                                           Item->HasSel = false;
00474                                           inde = 0;
00475                                           found = false;
00476                                    }
00477                                    else
00478                                    {
00479                                           if (inde == sText.length())
00480                                                  break;
00481                                    }
00482                             }
00483                             else
00484                                    break;
00485                      }
00486                      else
00487                      {
00488                             if (SText->isChecked())
00489                             {
00490                                    for (int xx = ReplStart; xx < a+1; ++xx)
00491                                           Item->itemText.select(QMIN(xx, maxChar), 1, false);
00492                                    Item->HasSel = false;
00493                             }
00494                             inde = 0;
00495                      }
00496               }
00497               if ((!found) || (a == Item->itemText.length()))
00498               {
00499                      Doc->DoDrawing = true;
00500                      Doc->view()->RefreshItem(Item);
00501                      DoReplace->setEnabled(false);
00502                      AllReplace->setEnabled(false);
00503                      QMessageBox::information(this, tr("Search/Replace"), tr("Search finished"), CommonStrings::tr_OK);
00504                      Item->CPos = 0;
00505                      NotFound = false;
00506               }
00507        }
00508        else
00509        {
00510               if (Doc->scMW()->CurrStED != NULL)
00511               {
00512                      int p, i;
00513                      Doc->scMW()->CurrStED->Editor->getCursorPosition(&p, &i);
00514                      uint inde = 0;
00515                      int as = i;
00516                      uint fpa = p;
00517                      int fch = i;
00518                      found = false;
00519                      if (Doc->scMW()->CurrStED->Editor->StyledText.length() != 0)
00520                      {
00521                             for (uint pa = p; pa < Doc->scMW()->CurrStED->Editor->StyledText.nrOfParagraphs(); ++pa)
00522                             {
00523                                    int parStart = Doc->scMW()->CurrStED->Editor->StyledText.startOfParagraph(pa);
00524                                    int parEnd = Doc->scMW()->CurrStED->Editor->StyledText.endOfParagraph(pa);
00525                                    QString chars = Doc->scMW()->CurrStED->Editor->StyledText.text(parStart, parEnd - parStart);
00526 
00527                                    if (SText->isChecked())
00528                                    {
00529                                           if (Word->isChecked())
00530                                           {
00531                                                  QRegExp rx( "(\\b"+sText+"\\b)" );
00532                                                  if (CaseIgnore->isChecked())
00533                                                         as = rx.search( chars.lower(), i );
00534                                                  else
00535                                                         as = rx.search( chars, i );
00536                                           }
00537                                           else
00538                                           {
00539                                                  if (CaseIgnore->isChecked())
00540                                                         as = chars.lower().find(sText, i);
00541                                                  else
00542                                                         as = chars.find(sText, i);
00543                                           }
00544                                           if (as != -1)
00545                                           {
00546                                                  fch = as;
00547                                                  fpa = pa;
00548                                                  found = true;
00549                                                  inde = 0;
00550                                                  for (uint ap = 0; ap < sText.length(); ++ap)
00551                                                  {
00552                                                         const CharStyle& charStyle(Doc->scMW()->CurrStED->Editor->StyledText.charStyle(parStart + as + ap));
00553                                                         if ((SSize->isChecked()) && (charStyle.fontSize() != sSize))
00554                                                                found = false;
00555                                                         if ((SFont->isChecked()) && (charStyle.font().scName() != sFont))
00556                                                                found = false;
00557 //                                                      if ((SStyle->isChecked()) && (hg->cab != sStyle))
00558 //                                                             found = false;
00559                                                         if ((SStroke->isChecked()) && (charStyle.strokeColor() != sCol))
00560                                                                found = false;
00561                                                         if ((SStrokeS->isChecked()) && (charStyle.strokeShade() != sStrokeSh))
00562                                                                found = false;
00563                                                         if ((SFillS->isChecked()) && (charStyle.fillShade() != sFillSh))
00564                                                                found = false;
00565                                                         if ((SEffect->isChecked()) && ((charStyle.effects() & 1919) != sEff))
00566                                                                found = false;
00567                                                         if ((SFill->isChecked()) && (charStyle.fillColor() != fCol))
00568                                                                found = false;
00569                                                         inde++;
00570                                                  }
00571                                                  i = as + inde;
00572                                                  if (found)
00573                                                         break;
00574                                           }
00575                                           else
00576                                           {
00577                                                  i = 0;
00578                                                  inde = 0;
00579                                           }
00580                                    }
00581                                    else
00582                                    {
00583                                           for (int e = parStart + i; e < parEnd; ++e)
00584                                           {
00585                                                  found = true;
00586                                                  inde = 1;
00587                                                  const CharStyle& charStyle(Doc->scMW()->CurrStED->Editor->StyledText.charStyle(e));
00588                                                  if ((SSize->isChecked()) && (charStyle.fontSize() != sSize))
00589                                                         found = false;
00590                                                  if ((SFont->isChecked()) && (charStyle.font().scName() != sFont))
00591                                                         found = false;
00592 //                                               if ((SStyle->isChecked()) && (hg->cab != sStyle))
00593 //                                                      found = false;
00594                                                  if ((SStroke->isChecked()) && (charStyle.strokeColor() != sCol))
00595                                                         found = false;
00596                                                  if ((SStrokeS->isChecked()) && (charStyle.strokeShade() != sStrokeSh))
00597                                                         found = false;
00598                                                  if ((SFillS->isChecked()) && (charStyle.fillShade() != sFillSh))
00599                                                         found = false;
00600                                                  if ((SEffect->isChecked()) && ((charStyle.effects() & 1919) != sEff))
00601                                                         found = false;
00602                                                  if ((SFill->isChecked()) && (charStyle.fillColor() != fCol))
00603                                                         found = false;
00604                                                  if (found)
00605                                                  {
00606                                                         fch = e - parStart;
00607                                                         fpa = pa;
00608                                                         break;
00609                                                  }
00610                                           }
00611                                           if (found)
00612                                                  break;
00613                                           else
00614                                                  i = 0;
00615                                    }
00616                             }
00617                             if (found)
00618                             {
00619                                    Doc->scMW()->CurrStED->Editor->setSelection(fpa, fch, fpa, fch+inde);
00620 //                                 Doc->scMW()->CurrStED->updateProps(fpa, fch);
00621                                    Doc->scMW()->CurrStED->Editor->setCursorPosition(fpa, fch+inde);
00622                                    if (rep)
00623                                    {
00624                                           DoReplace->setEnabled(true);
00625                                           AllReplace->setEnabled(true);
00626                                    }
00627                                    matchesFound++;
00628                             }
00629                             else
00630                             {
00631                                    QMessageBox::information(this, tr("Search/Replace"),
00632                                                  tr("Search finished, found %1 matches").arg(matchesFound),
00633                                                  CommonStrings::tr_OK);
00634                                    matchesFound = 0;
00635                                    NotFound = false;
00636                                    Doc->scMW()->CurrStED->Editor->removeSelection();
00637                                    Doc->scMW()->CurrStED->Editor->setCursorPosition(0, 0);
00638                             }
00639                      }
00640               }
00641        }
00642 }
00643 
00644 void SearchReplace::slotReplace()
00645 {
00646        if (SMode)
00647               Doc->view()->slotDoCurs(false);
00648        slotDoReplace();
00649        if (SMode)
00650        {
00651               Doc->view()->slotDoCurs(true);
00652               Doc->view()->RefreshItem(Item);
00653        }
00654 }
00655 
00656 void SearchReplace::slotDoReplace()
00657 {
00658        if (SMode)
00659        {
00660               QString repl, sear;
00661               uint cs, cx;
00662 //            ScText *hg;
00663               if (RText->isChecked())
00664               {
00665                      repl = RTextVal->text();
00666                      sear = STextVal->text();
00667                      if (sear.length() == repl.length())
00668                      {
00669                             for (cs = 0; cs < sear.length(); ++cs)
00670                                    Item->itemText.replaceChar(ReplStart+cs, repl[cs]);
00671                      }
00672                      else
00673                      {
00674                             if (sear.length() < repl.length())
00675                             {
00676                                    for (cs = 0; cs < sear.length(); ++cs)
00677                                           Item->itemText.replaceChar(ReplStart+cs, repl[cs]);
00678                                    for (cx = cs; cx < repl.length(); ++cx)
00679                                    {
00680 #if 0
00681                                           hg = new ScText;
00682                                           hg->ch = repl[cx];
00683                                           if (RSize->isChecked())
00684                                                  hg->setFontSize(qRound(RSizeVal->value() * 10.0));
00685                                           else
00686                                                  hg->setFontSize(Doc->currentStyle.charStyle().fontSize());
00687                                           if (RFill->isChecked())
00688                                                  hg->setFillColor(RFillVal->currentText());
00689                                           else
00690                                                  hg->setFillColor(Doc->currentStyle.charStyle().fillColor());
00691                                           hg->setFillShade(Doc->currentStyle.charStyle().fillShade());
00692                                           if (RStroke->isChecked())
00693                                                  hg->setStrokeColor(RStrokeVal->currentText());
00694                                           else
00695                                                  hg->setStrokeColor(Doc->currentStyle.charStyle().strokeColor());
00696                                           hg->setStrokeShade(Doc->currentStyle.charStyle().strokeShade());
00697                                           hg->setScaleH(Doc->currentStyle.charStyle().scaleH());
00698                                           hg->setScaleV(Doc->currentStyle.charStyle().scaleV());
00699                                           hg->setBaselineOffset(Doc->currentStyle.charStyle().baselineOffset());
00700                                           hg->setShadowXOffset(Doc->currentStyle.charStyle().shadowXOffset());
00701                                           hg->setShadowYOffset(Doc->currentStyle.charStyle().shadowYOffset());
00702                                           hg->setOutlineWidth(Doc->currentStyle.charStyle().outlineWidth());
00703                                           hg->setUnderlineOffset(Doc->currentStyle.charStyle().underlineOffset());
00704                                           hg->setUnderlineWidth(Doc->currentStyle.charStyle().underlineWidth());
00705                                           hg->setStrikethruOffset(Doc->currentStyle.charStyle().strikethruOffset());
00706                                           hg->setStrikethruWidth(Doc->currentStyle.charStyle().strikethruWidth());
00707                                           hg->setFeatures(Doc->currentStyle.charStyle().features());
00708 /* FIXME NLS
00709                                                  if (RStyle->isChecked())
00710                                                  hg->cab = RStyleVal->currentItem();
00711                                           else
00712                                                  hg->cab = findParagraphStyle(Doc, Doc->currentStyle);
00713                                           if (!Doc->docParagraphStyles[hg->cab].charStyle().font()->isNone())
00714                                           {
00715                                                  hg->setFont((*Doc->AllFonts)[Doc->docParagraphStyles[hg->cab].charStyle().font()->scName()]);
00716                                                  hg->setFontSize(Doc->docParagraphStyles[hg->cab].charStyle().fontSize());
00717                                                  hg->setFeatures(Doc->docParagraphStyles[hg->cab].charStyle().features());
00718                                           }
00719 */
00720                                           if (RFont->isChecked())
00721                                                  hg->setFont((*Doc->AllFonts)[RFontVal->currentText()]);
00722                                           else
00723                                                  hg->setFont((*Doc->AllFonts)[Doc->currentStyle.charStyle().font()->scName()]);
00724                                           hg->setTracking(0);
00725                                           Item->itemText.insert(ReplStart+cx, hg);
00726 #else
00727                                           Item->itemText.insertChars(ReplStart+cx, repl.mid(cx,1), true); 
00728 #endif
00729                                    }
00730                                    // FIXME:NLS also replace styles!!
00731                                    Item->CPos = ReplStart+cx;
00732                             }
00733                             else
00734                             {
00735                                    for (cs = 0; cs < repl.length(); ++cs)
00736                                           Item->itemText.replaceChar(ReplStart+cs, repl[cs]);
00737                                    Item->itemText.removeChars(ReplStart+cs, sear.length() - cs);
00738                                    Item->CPos = ReplStart+cs;
00739                             }
00740                      }
00741               }
00742               if (RStyle->isChecked())
00743                      Doc->itemSelection_SetNamedParagraphStyle(Doc->paragraphStyles()[RStyleVal->currentItem()].name());
00744               if (RFill->isChecked())
00745                      Doc->itemSelection_SetFillColor(RFillVal->currentText());
00746               if (RFillS->isChecked())
00747                      Doc->itemSelection_SetFillShade(RFillSVal->getValue());
00748               if (RStroke->isChecked())
00749                      Doc->itemSelection_SetStrokeColor(RStrokeVal->currentText());
00750               if (RStrokeS->isChecked())
00751                      Doc->itemSelection_SetStrokeShade(RStrokeSVal->getValue());
00752               if (RFont->isChecked())
00753                      Doc->itemSelection_SetFont(RFontVal->currentText());
00754               if (RSize->isChecked())
00755                      Doc->itemSelection_SetFontSize(qRound(RSizeVal->value() * 10.0));
00756               if (REffect->isChecked())
00757               {
00758 #ifndef NLS_PROTO
00759                      int s = REffVal->getStyle();
00760                      Doc->currentStyle.charStyle().setFeatures(static_cast<StyleFlag>(s).featureList()); // ???
00761                      for (int a = 0; a < Item->itemText.length(); ++a)
00762                      {
00763                             if (Item->itemText.selected(a))
00764                             {
00765                                    StyleFlag fl = Item->itemText.item(a)->effects();
00766                                    fl &= static_cast<StyleFlag>(~1919);
00767                                    fl |= static_cast<StyleFlag>(s);
00768                                    Item->itemText.item(a)->setFeatures(fl.featureList());
00769                             }
00770                      }
00771 #endif
00772               }
00773               Item->itemText.deselectAll();
00774        }
00775        else
00776        {
00777               if (Doc->scMW()->CurrStED != NULL)
00778               {
00779                      StoryEditor* se=Doc->scMW()->CurrStED;
00780                      if (RStyle->isChecked())
00781                             se->newAlign(RStyleVal->currentItem());
00782                      if (RFill->isChecked())
00783                             se->newTxFill(RFillVal->currentItem(), -1);
00784                      if (RFillS->isChecked())
00785                             se->newTxFill(-1, RFillSVal->getValue());
00786                      if (RStroke->isChecked())
00787                             se->newTxStroke(RStrokeVal->currentItem(), -1);
00788                      if (RStrokeS->isChecked())
00789                             se->newTxStroke(-1, RStrokeSVal->getValue());
00790                      if (RFont->isChecked())
00791                             se->newTxFont(RFontVal->currentText());
00792                      if (RSize->isChecked())
00793                             se->newTxSize(RSizeVal->value());
00794                      if (REffect->isChecked())
00795                             se->newTxStyle(REffVal->getStyle());
00796                      if (RText->isChecked())
00797                      {
00798                             disconnect(se->Editor, SIGNAL(cursorPositionChanged(int, int)), se, SLOT(updateProps(int, int)));
00799                             int PStart, PEnd, SelStart, SelEnd;
00800                             se->Editor->getSelection(&PStart, &SelStart, &PEnd, &SelEnd);
00801                             se->Editor->insChars(RTextVal->text());
00802                             se->Editor->setSelection(PStart, SelStart, PEnd, SelEnd);
00803                             se->Editor->removeSelectedText();
00804 //FIXME                            se->Editor->setStyle(se->Editor->CurrentStyle);
00805                             se->Editor->insert(RTextVal->text());
00806                             connect(se->Editor, SIGNAL(cursorPositionChanged(int, int)), se, SLOT(updateProps(int, int)));
00807 //                          se->newAlign(se->Editor->currentParaStyle);
00808                      }
00809               }
00810        }
00811        DoReplace->setEnabled(false);
00812        AllReplace->setEnabled(false);
00813               slotDoSearch();
00814 }
00815 
00816 void SearchReplace::slotReplaceAll()
00817 {
00818        if (SMode)
00819        {
00820               Doc->view()->slotDoCurs(false);
00821               Doc->DoDrawing = false;
00822        }
00823        do
00824        {
00825               slotDoReplace();
00826 //            slotDoSearch();
00827        }
00828        while (NotFound);
00829        if (SMode)
00830        {
00831               Doc->DoDrawing = true;
00832               Doc->view()->slotDoCurs(true);
00833               Doc->view()->RefreshItem(Item);
00834        }
00835 }
00836 
00837 void SearchReplace::enableTxSearch()
00838 {
00839        bool setter = SText->isChecked();
00840        STextVal->setEnabled(setter);
00841        Word->setEnabled(setter);
00842        CaseIgnore->setEnabled(setter);
00843        if (setter)
00844               STextVal->setFocus();
00845 }
00846 
00847 void SearchReplace::enableStyleSearch()
00848 {
00849        SStyleVal->setEnabled(SStyle->isChecked());
00850 }
00851 
00852 void SearchReplace::enableFontSearch()
00853 {
00854        SFontVal->setEnabled(SFont->isChecked());
00855 }
00856 
00857 void SearchReplace::enableSizeSearch()
00858 {
00859        SSizeVal->setEnabled(SSize->isChecked());
00860 }
00861 
00862 void SearchReplace::enableEffSearch()
00863 {
00864        SEffVal->setEnabled(SEffect->isChecked());
00865 }
00866 
00867 void SearchReplace::enableFillSearch()
00868 {
00869        SFillVal->setEnabled(SFill->isChecked());
00870 }
00871 
00872 void SearchReplace::enableFillSSearch()
00873 {
00874        SFillSVal->setEnabled(SFillS->isChecked());
00875 }
00876 
00877 void SearchReplace::enableStrokeSearch()
00878 {
00879        SStrokeVal->setEnabled(SStroke->isChecked());
00880 }
00881 
00882 void SearchReplace::enableStrokeSSearch()
00883 {
00884        SStrokeSVal->setEnabled(SStrokeS->isChecked());
00885 }
00886 
00887 void SearchReplace::enableTxReplace()
00888 {
00889        RTextVal->setEnabled(RText->isChecked());
00890        if (RText->isChecked())
00891               RTextVal->setFocus();
00892 }
00893 
00894 void SearchReplace::enableStyleReplace()
00895 {
00896        RStyleVal->setEnabled(RStyle->isChecked());
00897 }
00898 
00899 void SearchReplace::enableFontReplace()
00900 {
00901        RFontVal->setEnabled(RFont->isChecked());
00902 }
00903 
00904 void SearchReplace::enableSizeReplace()
00905 {
00906        RSizeVal->setEnabled(RSize->isChecked());
00907 }
00908 
00909 void SearchReplace::enableEffReplace()
00910 {
00911        REffVal->setEnabled(REffect->isChecked());
00912 }
00913 
00914 void SearchReplace::enableFillReplace()
00915 {
00916        RFillVal->setEnabled(RFill->isChecked());
00917 }
00918 
00919 void SearchReplace::enableFillSReplace()
00920 {
00921        RFillSVal->setEnabled(RFillS->isChecked());
00922 }
00923 
00924 void SearchReplace::enableStrokeReplace()
00925 {
00926        RStrokeVal->setEnabled(RStroke->isChecked());
00927 }
00928 
00929 void SearchReplace::enableStrokeSReplace()
00930 {
00931        RStrokeSVal->setEnabled(RStrokeS->isChecked());
00932 }
00933 
00934 void SearchReplace::clear()
00935 {
00936 
00937        SStroke->setChecked(false);
00938        SFill->setChecked(false);
00939        SStrokeS->setChecked(false);
00940        SFillS->setChecked(false);
00941        SSize->setChecked(false);
00942        SFont->setChecked(false);
00943        SStyle->setChecked(false);
00944        SText->setChecked(false);
00945        SEffect->setChecked(false);
00946        REffect->setChecked(false);
00947        STextVal->setText("");
00948        int currentParaStyle = findParagraphStyle(Doc, Doc->currentStyle);
00949        SStyleVal->setCurrentItem(currentParaStyle);
00950        SFontVal->setCurrentText(Doc->currentStyle.charStyle().font().scName());
00951        SSizeVal->setValue(Doc->currentStyle.charStyle().fontSize() / 10.0);
00952        SFillVal->setCurrentText(Doc->currentStyle.charStyle().fillColor());
00953        SStrokeVal->setCurrentText(Doc->currentStyle.charStyle().strokeColor());
00954        RStroke->setChecked(false);
00955        RStrokeS->setChecked(false);
00956        RFill->setChecked(false);
00957        RFillS->setChecked(false);
00958        RSize->setChecked(false);
00959        RFont->setChecked(false);
00960        RStyle->setChecked(false);
00961        RText->setChecked(false);
00962        RTextVal->setText("");
00963        RStyleVal->setCurrentItem(currentParaStyle);
00964        RFontVal->setCurrentText(Doc->currentStyle.charStyle().font().scName());
00965        RSizeVal->setValue(Doc->currentStyle.charStyle().fontSize() / 10.0);
00966        RFillVal->setCurrentText(Doc->currentStyle.charStyle().fillColor());
00967        RStrokeVal->setCurrentText(Doc->currentStyle.charStyle().strokeColor());
00968        Word->setChecked(false);
00969        CaseIgnore->setChecked(false);
00970        enableTxSearch();
00971        enableStyleSearch();
00972        enableFontSearch();
00973        enableSizeSearch();
00974        enableEffSearch();
00975        enableFillSearch();
00976        enableFillSSearch();
00977        enableStrokeSearch();
00978        enableStrokeSSearch();
00979        enableTxReplace();
00980        enableStyleReplace();
00981        enableFontReplace();
00982        enableSizeReplace();
00983        enableEffReplace();
00984        enableFillReplace();
00985        enableFillSReplace();
00986        enableStrokeReplace();
00987        enableStrokeSReplace();
00988 }
00989 
00990 void SearchReplace::readPrefs()
00991 {
00992        SStroke->setChecked(prefs->getBool("SStroke", false));
00993        SFill->setChecked(prefs->getBool("SFill", false));
00994        SStrokeS->setChecked(prefs->getBool("SStrokeS", false));
00995        SFillS->setChecked(prefs->getBool("SFillS", false));
00996        SSize->setChecked(prefs->getBool("SSize", false));
00997        SFont->setChecked(prefs->getBool("SFont", false));
00998        SStyle->setChecked(prefs->getBool("SStyle", false));
00999        SText->setChecked(prefs->getBool("SText", false));
01000        SEffect->setChecked(prefs->getBool("SEffect", false));
01001        REffect->setChecked(prefs->getBool("REffect", false));
01002        STextVal->setText(prefs->get("STextVal", ""));
01003        int tmp = prefs->getInt("SStyleVal", findParagraphStyle(Doc, Doc->currentStyle));
01004        if (tmp < 0 || tmp >= SStyleVal->count())
01005               SStyleVal->setCurrentItem(0);
01006        else
01007               SStyleVal->setCurrentItem(tmp);
01008 
01009        SFontVal->setCurrentText(prefs->get("SFontVal", Doc->currentStyle.charStyle().font().scName()));
01010        SSizeVal->setValue(prefs->getDouble("SSizeVal", Doc->currentStyle.charStyle().fontSize() / 10.0));
01011        SFillVal->setCurrentText(prefs->get("SFillVal", Doc->currentStyle.charStyle().fillColor()));
01012        SStrokeVal->setCurrentText(prefs->get("SStrokeVal", Doc->currentStyle.charStyle().strokeColor()));
01013        RStroke->setChecked(prefs->getBool("RStroke", false));
01014        RStrokeS->setChecked(prefs->getBool("RStrokeS", false));
01015        RFill->setChecked(prefs->getBool("RFill", false));
01016        RFillS->setChecked(prefs->getBool("RFillS", false));
01017        RSize->setChecked(prefs->getBool("RSize", false));
01018        RFont->setChecked(prefs->getBool("RFont", false));
01019        RStyle->setChecked(prefs->getBool("RStyle", false));
01020        RText->setChecked(prefs->getBool("RText", false));
01021        RTextVal->setText(prefs->get("RTextVal", ""));
01022        tmp = prefs->getInt("RStyleVal", findParagraphStyle(Doc, Doc->currentStyle));
01023        if (tmp < 0 || tmp >= RStyleVal->count())
01024               RStyleVal->setCurrentItem(0);
01025        else
01026               RStyleVal->setCurrentItem(tmp);
01027        RFontVal->setCurrentText(prefs->get("RFontVal", Doc->currentStyle.charStyle().font().scName()));
01028        RSizeVal->setValue(prefs->getDouble("RSizeVal", Doc->currentStyle.charStyle().fontSize() / 10.0));
01029        RFillVal->setCurrentText(prefs->get("RFillVal", Doc->currentStyle.charStyle().fillColor()));
01030        RStrokeVal->setCurrentText(prefs->get("RStrokeVal", Doc->currentStyle.charStyle().strokeColor()));
01031        Word->setChecked(prefs->getBool("Word", false));
01032        CaseIgnore->setChecked(prefs->getBool("CaseIgnore", false));
01033        enableTxSearch();
01034        enableStyleSearch();
01035        enableFontSearch();
01036        enableSizeSearch();
01037        enableEffSearch();
01038        enableFillSearch();
01039        enableFillSSearch();
01040        enableStrokeSearch();
01041        enableStrokeSSearch();
01042        enableTxReplace();
01043        enableStyleReplace();
01044        enableFontReplace();
01045        enableSizeReplace();
01046        enableEffReplace();
01047        enableFillReplace();
01048        enableFillSReplace();
01049        enableStrokeReplace();
01050        enableStrokeSReplace();
01051 }
01052 
01053 void SearchReplace::writePrefs()
01054 {
01055        prefs->set("SStroke", SStroke->isChecked());
01056        prefs->set("SFill", SFill->isChecked());
01057        prefs->set("SStrokeS", SStrokeS->isChecked());
01058        prefs->set("SFillS", SFillS->isChecked());
01059        prefs->set("SSize", SSize->isChecked());
01060        prefs->set("SFont", SFont->isChecked());
01061        prefs->set("SStyle", SStyle->isChecked());
01062        prefs->set("SText", SText->isChecked());
01063        prefs->set("SEffect", SEffect->isChecked());
01064        prefs->set("REffect", REffect->isChecked());
01065        prefs->set("STextVal", STextVal->text());
01066        prefs->set("SStyleVal", SStyleVal->currentItem());
01067        prefs->set("SFontVal", SFontVal->currentText());
01068        prefs->set("SSizeVal", SSizeVal->value());
01069        prefs->set("SFillVal", SFillVal->currentText());
01070        prefs->set("SStrokeVal", SStrokeVal->currentText());
01071        prefs->set("RStroke", RStroke->isChecked());
01072        prefs->set("RStrokeS", RStrokeS->isChecked());
01073        prefs->set("RFill", RFill->isChecked());
01074        prefs->set("RFillS", RFillS->isChecked());
01075        prefs->set("RSize", RSize->isChecked());
01076        prefs->set("RFont", RFont->isChecked());
01077        prefs->set("RStyle", RStyle->isChecked());
01078        prefs->set("RText", RText->isChecked());
01079        prefs->set("RTextVal", RTextVal->text());
01080        prefs->set("RStyleVal", RStyleVal->currentText());
01081        prefs->set("RFontVal", RFontVal->currentText());
01082        prefs->set("RSizeVal", RSizeVal->value());
01083        prefs->set("RFillVal", RFillVal->currentText());
01084        prefs->set("RStrokeVal", RStrokeVal->currentText());
01085        prefs->set("Word", Word->isChecked());
01086        prefs->set("CaseIgnore", CaseIgnore->isChecked());
01087        accept();
01088 }