Back to index

scribus-ng  1.3.4.dfsg+svn20071115
smwidgets.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 
00008 #include "smwidgets.h"
00009 #include "smwidgets.moc"
00010 #include <qtooltip.h>
00011 #include <qlineedit.h>
00012 #include "units.h"
00013 
00014 /***********************************************************************/
00015 /***********************************************************************/
00016 
00017 SMSpinBox::SMSpinBox(QWidget *parent, const char *name)
00018 : QSpinBox(parent, name),
00019   hasParent_(false),
00020   useParentValue_(false),
00021   pValue_(0)
00022 {
00023 
00024 }
00025 
00026 void SMSpinBox::setValue(int val)
00027 {
00028        disconnect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00029        hasParent_ = false;
00030        pValue_ = 0;
00031        setFont(false);
00032 
00033        QSpinBox::setValue(val);
00034 }
00035 
00036 void SMSpinBox::setValue(int val, bool isParentVal)
00037 {
00038        disconnect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00039        hasParent_ = true;
00040        pValue_ = val;
00041        setFont(!isParentVal);
00042 
00043        QSpinBox::setValue(val);
00044        connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00045 }
00046 
00047 void SMSpinBox::clear()
00048 {
00049        disconnect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00050        editor()->clear();
00051        connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00052 }
00053 
00054 void SMSpinBox::setParentValue(int val)
00055 {
00056        hasParent_ = true;
00057        pValue_ = val;
00058 }
00059 
00060 bool SMSpinBox::useParentValue()
00061 {
00062        bool ret = useParentValue_;
00063        useParentValue_ = false;
00064        return ret;
00065 }
00066 
00067 void SMSpinBox::interpretText()
00068 {
00069 //     QString t = text();
00070 //     if (hasParent_ && (t == "" || t.isEmpty() || t == QString::null))
00071        if (hasParent_ && text().isEmpty())
00072        {
00073               useParentValue_ = true;
00074               setValue(pValue_, true);
00075        }
00076        QSpinBox::interpretText();
00077 }
00078 
00079 void SMSpinBox::setFont(bool wantBold)
00080 {
00081        QFont f(font());
00082        f.setBold(wantBold);
00083        QSpinBox::setFont(f);
00084 }
00085 
00086 void SMSpinBox::slotValueChanged()
00087 {
00088        if(hasParent_)
00089               setFont(true);
00090 }
00091 
00092 /***********************************************************************/
00093 /***********************************************************************/
00094 
00095 SMMSpinBox::SMMSpinBox(QWidget *pa, int s)
00096 : MSpinBox(pa, s),
00097   hasParent_(false),
00098   useParentValue_(false),
00099   pValue_(0.0)
00100 {
00101        
00102 }
00103 
00104 SMMSpinBox::SMMSpinBox(double minValue, double maxValue, QWidget *pa, int s)
00105 : MSpinBox(minValue, maxValue, pa, s),
00106   hasParent_(false),
00107   useParentValue_(false),
00108   pValue_(0.0)
00109 {
00110        
00111 }
00112 
00113 SMMSpinBox::SMMSpinBox(QWidget *parent, const char * name)
00114 : MSpinBox(parent, name),
00115   hasParent_(false),
00116   useParentValue_(false),
00117   pValue_(0.0)
00118 {
00119        
00120 }
00121 
00122 void SMMSpinBox::setValue(double val)
00123 {
00124        disconnect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00125        hasParent_ = false;
00126        pValue_ = 0.0;
00127        setFont(false);
00128 
00129        MSpinBox::setValue(val);
00130 }
00131 
00132 void SMMSpinBox::setValue(double val, bool isParentVal)
00133 {
00134        disconnect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00135        hasParent_ = true;
00136        pValue_ = val;
00137        setFont(!isParentVal);
00138 
00139        MSpinBox::setValue(val);
00140        connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00141 }
00142 
00143 void SMMSpinBox::clear()
00144 {
00145        disconnect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00146        editor()->clear();
00147        connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00148 }
00149 
00150 void SMMSpinBox::setParentValue(double val)
00151 {
00152        hasParent_ = true;
00153        pValue_ = val;
00154 }
00155 
00156 bool SMMSpinBox::useParentValue()
00157 {
00158        bool ret = useParentValue_;
00159        useParentValue_ = false;
00160        return ret;
00161 }
00162 
00163 void SMMSpinBox::interpretText()
00164 {
00165 //     QString t = text();
00166 //     if (hasParent_ && (t == "" || t.isEmpty() || t == QString::null))
00167        if (hasParent_ && text().isEmpty())
00168        {
00169               useParentValue_ = true;
00170               setValue(pValue_, true);
00171        }
00172        MSpinBox::interpretText();
00173 }
00174 
00175 void SMMSpinBox::setFont(bool wantBold)
00176 {
00177        QFont f(font());
00178        f.setBold(wantBold);
00179        MSpinBox::setFont(f);
00180 }
00181 
00182 void SMMSpinBox::slotValueChanged()
00183 {
00184        if(hasParent_)
00185               setFont(true);
00186 }
00187 
00188 /***********************************************************************/
00189 /***********************************************************************/
00190 
00191 SMScComboBox::SMScComboBox(QWidget *parent, const char *name)
00192 : ScComboBox(parent, name),
00193   hasParent_(false),
00194   useParentValue_(false),
00195   pItem_(0)
00196 {
00197        
00198 }
00199 
00200 SMScComboBox::SMScComboBox(bool rw, QWidget* parent, const char* name)
00201 : ScComboBox(rw, parent, name),
00202   hasParent_(false),
00203   useParentValue_(false),
00204   pItem_(0)
00205 {
00206        
00207 }
00208 
00209 void SMScComboBox::setCurrentItem(int i)
00210 {
00211        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00212        setFont(false);
00213        hasParent_ = false;
00214        pItem_ = 0;
00215        ScComboBox::setCurrentItem(i);
00216 }
00217 
00218 void SMScComboBox::setCurrentItem(int i, bool isParentValue)
00219 {
00220        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00221        hasParent_ = true;
00222        pItem_ = i;
00223        setFont(!isParentValue);
00224        if (!isParentValue)
00225        {
00226               useParentValue_ = true;
00227               insertItem( tr("Use Parent Value"));
00228        }
00229 
00230        ScComboBox::setCurrentItem(i);
00231        connect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00232 }
00233 
00234 void SMScComboBox::setParentItem(int i)
00235 {
00236        hasParent_ = true;
00237        pItem_ = i;
00238 }
00239 
00240 bool SMScComboBox::useParentValue()
00241 {
00242        bool ret = false;
00243 
00244        if (useParentValue_ && hasParent_)
00245        {
00246               ret = currentItem() == (count() - 1);
00247               if (ret)
00248               {
00249                      removeItem(count() - 1);
00250                      setFont(false);
00251                      setCurrentItem(pItem_, true);
00252                      useParentValue_ = false;
00253               }
00254        }
00255 
00256        return ret;
00257 }
00258 
00259 void SMScComboBox::setFont(bool wantBold)
00260 {
00261        QFont f(font());
00262        f.setBold(wantBold);
00263        ScComboBox::setFont(f);
00264 }
00265 
00266 void SMScComboBox::currentChanged()
00267 {
00268        if (hasParent_ && !useParentValue_)
00269        {
00270               setFont(true);
00271               insertItem( tr("Use Parent Value"));
00272               useParentValue_ = true;
00273        }
00274 }
00275 
00276 /***********************************************************************/
00277 /***********************************************************************/
00278 
00279 SMAlignSelect::SMAlignSelect(QWidget *parent)
00280 : AlignSelect(parent),
00281   hasParent_(false),
00282   useParentStyle_(false),
00283   pStyle_(0)
00284 {
00285        parentButton = new QToolButton(this, "parentButton");
00286        parentButton->setMaximumSize( QSize( 22, 22 ) );
00287        parentButton->setToggleButton( true );
00288        parentButton->setText( tr("P", "P as in Parent"));
00289        QToolTip::add(parentButton, tr("Use parent style's alignment instead of overriding it"));
00290        GroupAlignLayout->addWidget( parentButton, 0, 5 );
00291        resize(minimumSizeHint());
00292        parentButton->hide();
00293 }
00294 
00295 void SMAlignSelect::setStyle(int i)
00296 {
00297        disconnect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00298        disconnect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00299        setFont(false);
00300        hasParent_ = false;
00301        pStyle_ = 0;
00302        parentButton->hide();
00303        AlignSelect::setStyle(i);
00304 }
00305 
00306 void SMAlignSelect::setStyle(int i, bool isParentValue)
00307 {
00308        disconnect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00309        disconnect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00310        hasParent_ = true;
00311        pStyle_ = i;
00312        setFont(!isParentValue);
00313        if (isParentValue)
00314               parentButton->hide();
00315        else
00316               parentButton->show();
00317 
00318        AlignSelect::setStyle(i);
00319        connect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00320        connect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00321 }
00322 
00323 void SMAlignSelect::setParentItem(int i)
00324 {
00325        hasParent_ = true;
00326        pStyle_ = i;
00327 }
00328 
00329 bool SMAlignSelect::useParentValue()
00330 {
00331        bool ret = useParentStyle_;
00332        useParentStyle_ = false;
00333        if (ret)
00334               setStyle(pStyle_, true);
00335 
00336        return ret;
00337 }
00338 
00339 void SMAlignSelect::setFont(bool wantBold)
00340 {
00341        QFont f(font());
00342        f.setBold(wantBold);
00343        parentButton->setFont(f);
00344 }
00345 
00346 void SMAlignSelect::styleChanged()
00347 {
00348        if (hasParent_)
00349        {
00350               setFont(true);
00351               parentButton->show();
00352        }
00353 }
00354 
00355 void SMAlignSelect::pbPressed()
00356 {
00357        useParentStyle_ = true;
00358 }
00359 
00360 /***********************************************************************/
00361 /***********************************************************************/
00362 
00363 SMStyleSelect::SMStyleSelect(QWidget *parent)
00364 : StyleSelect(parent),
00365   hasParent_(false),
00366   useParentStyle_(false),
00367   pStyle_(0)
00368 {
00369        parentButton = new QToolButton(this, "parentButton");
00370        parentButton->setMaximumSize(QSize(22, 22));
00371        parentButton->setMinimumSize(QSize(22, 22));
00372        parentButton->setText( tr("P", "P as in Parent"));
00373        QToolTip::add(parentButton, tr("Use parent style's effects instead of overriding them"));
00374        ssLayout->addWidget(parentButton);
00375        resize(minimumSizeHint());
00376        parentButton->hide();
00377 }
00378 
00379 void SMStyleSelect::setStyle(int i)
00380 {
00381        disconnect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00382        disconnect(ShadowVal->Xoffset, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00383        disconnect(ShadowVal->Yoffset, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00384        disconnect(OutlineVal->LWidth, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00385        disconnect(UnderlineVal->LPos, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00386        disconnect(UnderlineVal->LWidth, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00387        disconnect(StrikeVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(styleChanged()));
00388        disconnect(StrikeVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(styleChanged()));
00389        disconnect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00390        setFont(false);
00391        hasParent_ = false;
00392        pStyle_ = 0;
00393        parentButton->hide();
00394        StyleSelect::setStyle(i);
00395 }
00396 
00397 void SMStyleSelect::setStyle(int i, bool isParentValue)
00398 {
00399        disconnect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00400        disconnect(ShadowVal->Xoffset, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00401        disconnect(ShadowVal->Yoffset, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00402        disconnect(OutlineVal->LWidth, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00403        disconnect(UnderlineVal->LPos, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00404        disconnect(UnderlineVal->LWidth, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00405        disconnect(StrikeVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(styleChanged()));
00406        disconnect(StrikeVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(styleChanged()));
00407        disconnect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00408        hasParent_ = true;
00409        pStyle_ = i;
00410        setFont(!isParentValue);
00411        if (isParentValue)
00412               parentButton->hide();
00413        else
00414               parentButton->show();
00415        parentButton->setOn(true);
00416        StyleSelect::setStyle(i);
00417        connect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00418        connect(ShadowVal->Xoffset, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00419        connect(ShadowVal->Yoffset, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00420        connect(OutlineVal->LWidth, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00421        connect(UnderlineVal->LPos, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00422        connect(UnderlineVal->LWidth, SIGNAL(valueChanged(int)),this, SLOT(styleChanged()));
00423        connect(StrikeVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(styleChanged()));
00424        connect(StrikeVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(styleChanged()));
00425        connect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00426 }
00427 
00428 void SMStyleSelect::setParentItem(int i)
00429 {
00430        hasParent_ = true;
00431        pStyle_ = i;
00432 }
00433 
00434 bool SMStyleSelect::useParentValue()
00435 {
00436        bool ret = useParentStyle_;
00437        useParentStyle_ = false;
00438        if (ret)
00439               setStyle(pStyle_, true);
00440 
00441        return ret;
00442 }
00443 
00444 void SMStyleSelect::setFont(bool wantBold)
00445 {
00446        QFont f(font());
00447        f.setBold(wantBold);
00448        parentButton->setFont(f);
00449        ShadowVal->Xoffset->setFont(f);
00450        ShadowVal->Yoffset->setFont(f);
00451        OutlineVal->LWidth->setFont(f);
00452        UnderlineVal->LPos->setFont(f);
00453        UnderlineVal->LWidth->setFont(f);
00454        StrikeVal->LPos->setFont(f);
00455        StrikeVal->LWidth->setFont(f);
00456        StyleSelect::setFont(f);
00457 }
00458 
00459 void SMStyleSelect::styleChanged()
00460 {
00461        if (hasParent_)
00462        {
00463               setFont(true);
00464               parentButton->show();
00465        }
00466 }
00467 
00468 void SMStyleSelect::pbPressed()
00469 {
00470        useParentStyle_ = true;
00471        emit State(getStyle());
00472 }
00473 
00474 /***********************************************************************/
00475 /***********************************************************************/
00476 
00477 /***********************************************************************/
00478 /***********************************************************************/
00479 
00480 SMShadeButton::SMShadeButton(QWidget *parent)
00481 : ShadeButton(parent),
00482   hasParent_(false),
00483   useParentValue_(false),
00484   pValue_(0)
00485 {
00486        
00487 }
00488 
00489 void SMShadeButton::setValue(int i)
00490 {
00491        disconnect(this, SIGNAL(pressed()), this, SLOT(currentChanged()));
00492        setFont(false);
00493        hasParent_ = false;
00494        pValue_ = 0;
00495        ShadeButton::setValue(i);
00496 }
00497 
00498 void SMShadeButton::setValue(int i, bool isParentValue)
00499 {
00500        disconnect(this, SIGNAL(pressed()), this, SLOT(currentChanged()));
00501        hasParent_ = true;
00502        pValue_ = i;
00503        setFont(!isParentValue);
00504        ShadeButton::setValue(i);
00505        connect(this, SIGNAL(pressed()), this, SLOT(currentChanged()));
00506 }
00507 
00508 void SMShadeButton::setParentValue(int i)
00509 {
00510        hasParent_ = true;
00511        pValue_ = i;
00512 }
00513 
00514 bool SMShadeButton::useParentValue()
00515 {
00516        bool ret = useParentValue_;
00517        useParentValue_ = false;
00518 
00519        if (ret)
00520        {
00521               setValue(pValue_, true);
00522               FillSh->removeItemAt(FillSh->count() - 1);
00523        }
00524        
00525 
00526        return ret;
00527 }
00528 
00529 void SMShadeButton::setFont(bool wantBold)
00530 {
00531        QFont f(font());
00532        f.setBold(wantBold);
00533        FillSh->setFont(f);
00534        ShadeButton::setFont(f);
00535 }
00536 
00537 void SMShadeButton::currentChanged()
00538 {
00539        if (hasParent_)
00540        {
00541               setFont(true);
00542               QString upv = tr("Use Parent Value");
00543               if (FillSh->text(FillSh->idAt(FillSh->count() - 1)) != upv)
00544                      FillSh->insertItem(upv, this, SLOT(slotUseParent()));
00545        }
00546 }
00547 
00548 void SMShadeButton::slotUseParent()
00549 {
00550        useParentValue_ = true;
00551        FillSh->removeItemAt(FillSh->count() - 1);
00552        emit clicked();
00553 }
00554 
00555 /***********************************************************************/
00556 /***********************************************************************/
00557 
00558 /***********************************************************************/
00559 /***********************************************************************/
00560 
00561 SMColorCombo::SMColorCombo(QWidget *parent, const char *name)
00562 : ColorCombo(parent, name),
00563   hasParent_(false),
00564   useParentValue_(false),
00565   pItem_(0)
00566 {
00567        
00568 }
00569 
00570 SMColorCombo::SMColorCombo(bool rw, QWidget* parent, const char* name)
00571 : ColorCombo(rw, parent, name),
00572   hasParent_(false),
00573   useParentValue_(false),
00574   pItem_(0),
00575   pText_(QString::null)
00576 {
00577        
00578 }
00579 
00580 void SMColorCombo::setCurrentItem(int i)
00581 {
00582        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00583        setFont(false);
00584        hasParent_ = false;
00585        pItem_ = 0;
00586        pText_ = QString::null;
00587        ColorCombo::setCurrentItem(i);
00588 }
00589 
00590 void SMColorCombo::setCurrentItem(int i, bool isParentValue)
00591 {
00592        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00593        hasParent_ = true;
00594        pItem_ = i;
00595        pText_ = QString::null;
00596        ColorCombo::setCurrentItem(i);
00597        setFont(!isParentValue);
00598        connect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00599 }
00600 
00601 void SMColorCombo::setCurrentText(const QString &s)
00602 {
00603        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00604        setFont(false);
00605        hasParent_ = false;
00606        pItem_ = -1;
00607        pText_ = s;
00608        ColorCombo::setCurrentText(s);
00609 }
00610 
00611 void SMColorCombo::setCurrentText(const QString &s, bool isParentValue)
00612 {
00613        disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00614        hasParent_ = true;
00615        pItem_ = -1;
00616        pText_ = s;
00617        ColorCombo::setCurrentText(s);
00618        setFont(!isParentValue);
00619        connect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00620 }
00621 
00622 void SMColorCombo::setParentItem(int i)
00623 {
00624        hasParent_ = true;
00625        pItem_ = i;
00626        pText_ = QString::null;
00627 }
00628 
00629 void SMColorCombo::setParentText(const QString &s)
00630 {
00631        hasParent_ = true;
00632        pText_ = s;
00633 }
00634 
00635 bool SMColorCombo::useParentValue()
00636 {
00637        bool ret = false;
00638 
00639        if (useParentValue_ && hasParent_)
00640        {
00641               ret = currentItem() == (count() - 1);
00642               if (ret)
00643               {
00644                      removeItem(count() - 1);
00645                      setFont(false);
00646                      if (!pText_.isNull())
00647                             setCurrentText(pText_, true);
00648                      else
00649                             setCurrentItem(pItem_, true);
00650                      useParentValue_ = false;
00651               }
00652        }
00653 
00654        return ret;
00655 }
00656 
00657 void SMColorCombo::setFont(bool wantBold)
00658 {
00659        QFont f(font());
00660        f.setBold(wantBold);
00661        ColorCombo::setFont(f);
00662 }
00663 
00664 void SMColorCombo::currentChanged()
00665 {
00666        if (hasParent_ && !useParentValue_)
00667        {
00668               setFont(true);
00669               insertItem( tr("Use Parent Value"));
00670               useParentValue_ = true;
00671        }
00672 }
00673 
00674 
00675 /***********************************************************************/
00676 /***********************************************************************/
00677 
00678 SMFontComboH::SMFontComboH(QWidget *parent)
00679 : FontComboH(parent, true),
00680   hasParent_(false),
00681   useParentValue_(false),
00682   pFont_(QString::null),
00683   usePFont_( tr("Use Parent Font"))
00684 {
00685        
00686 }
00687 
00688 void SMFontComboH::setCurrentFont(const QString &s)
00689 {
00690        disconnect(fontFamily, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00691        disconnect(fontStyle, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00692        setFont(false);
00693        hasParent_ = false;
00694        pFont_ = s;
00695        FontComboH::setCurrentFont(s);
00696 }
00697 
00698 void SMFontComboH::setCurrentFont(const QString &s, bool isParentValue)
00699 {
00700        disconnect(fontFamily, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00701        disconnect(fontStyle, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00702        hasParent_ = true;
00703        pFont_ = s;
00704        FontComboH::setCurrentFont(s);
00705        setFont(!isParentValue);
00706        connect(fontFamily, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00707        connect(fontStyle, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
00708 }
00709 
00710 void SMFontComboH::setParentFont(const QString &s)
00711 {
00712        hasParent_ = true;
00713        pFont_ = s;
00714 }
00715 
00716 bool SMFontComboH::useParentFont()
00717 {
00718        bool ret = false;
00719 
00720        if (useParentValue_ && hasParent_)
00721        {
00722               ret = fontFamily->currentItem() == (fontFamily->count() - 1) ||
00723                             fontStyle->currentItem() == (fontStyle->count() - 1);
00724 
00725               if (ret)
00726               {
00727                      fontFamily->removeItem(fontFamily->count() - 1);
00728                      fontStyle->removeItem(fontStyle->count() - 1);
00729                      setFont(false);
00730                      setCurrentFont(pFont_, true);
00731                      useParentValue_ = false;
00732               }
00733        }
00734 
00735        return ret;
00736 }
00737 
00738 void SMFontComboH::setFont(bool wantBold)
00739 {
00740        QFont f(font());
00741        f.setBold(wantBold);
00742        fontFamily->setFont(f);
00743        fontStyle->setFont(f);
00744 }
00745 
00746 void SMFontComboH::currentChanged()
00747 {
00748        if (hasParent_ && !useParentValue_)
00749        {
00750               setFont(true);
00751               fontFamily->insertItem(usePFont_);
00752               fontStyle->insertItem(usePFont_);
00753               useParentValue_ = true;
00754        }
00755        else if (hasParent_)
00756               checkStyle();
00757 }
00758 
00759 void SMFontComboH::checkStyle()
00760 {
00761        if (hasParent_ && useParentValue_)
00762        {
00763               if (fontStyle->text(fontStyle->count() - 1) != usePFont_)
00764                      fontStyle->insertItem(usePFont_);
00765        }
00766 }
00767 
00768 /***********************************************************************/
00769 /***********************************************************************/
00770 
00771 SMTabruler::SMTabruler(QWidget* parent, bool haveFirst, int dEin,
00772                                       QValueList<ParagraphStyle::TabRecord> Tabs, double wid)
00773 : Tabruler(parent, haveFirst, dEin, Tabs, wid)
00774 {
00775        parentButton_ = new QToolButton(this, "parentButton_");
00776        Q_CHECK_PTR(parentButton_);
00777        parentButton_->setText( tr(" Parent Tabs "));
00778        indentLayout->addWidget(parentButton_);
00779        parentButton_->hide();
00780        QFont f(font());
00781        f.setBold(true);
00782        parentButton_->setFont(f);
00783        connect(parentButton_, SIGNAL(clicked()), this, SLOT(pbClicked()));
00784        hasParent_ = false;
00785        tabsChanged_ = false;
00786        useParentTabs_ = false;
00787        first_ = new SMMSpinBox(-3000, 4000, this, 1);
00788        Q_CHECK_PTR(first_);
00789        left_ = new SMMSpinBox(0, 4000, this, 1);
00790        Q_CHECK_PTR(left_);
00791        right_ = new SMMSpinBox(0, 4000, this, 1);
00792        Q_CHECK_PTR(right_);
00793 
00794        indentLayout->remove(firstLineData);
00795        firstLineData->hide();
00796        indentLayout->insertWidget(1, first_);
00797        first_->show();
00798 
00799        layout4->remove(leftIndentData);
00800        leftIndentData->hide();
00801        layout4->insertWidget(1, left_);
00802        left_->show();
00803 
00804        indentLayout->remove(rightIndentData);
00805        rightIndentData->hide();
00806        indentLayout->insertWidget(3, right_);
00807        right_->show();
00808 
00809        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00810        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00811        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00812 
00813        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00814        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00815        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00816 }
00817 
00818 void SMTabruler::setTabs(QValueList<ParagraphStyle::TabRecord> Tabs, int dEin)
00819 {
00820        disconnect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
00821        disconnect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
00822        hasParent_ = false;
00823        parentButton_->hide();
00824        Tabruler::setTabs(Tabs, dEin);
00825        Tabruler::repaint();
00826        QString ein = unitGetSuffixFromIndex(dEin);
00827        if (dEin == 2)
00828        {
00829               first_->setDecimals(10000);
00830               left_->setDecimals(10000);
00831               right_->setDecimals(10000);
00832               tabData->setDecimals(10000);
00833        } // TODO else What's the decimal for other dEins?
00834        first_->setSuffix(ein);
00835        left_->setSuffix(ein);
00836        right_->setSuffix(ein);
00837        tabData->setSuffix(ein);
00838 }
00839 
00840 void SMTabruler::setTabs(QValueList<ParagraphStyle::TabRecord> Tabs, int dEin, bool isParentValue)
00841 {
00842        disconnect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
00843        disconnect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
00844        hasParent_ = true;
00845        pDein_ = dEin;
00846        if (isParentValue)
00847               parentButton_->hide();
00848        else
00849               parentButton_->show();
00850        Tabruler::setTabs(Tabs, dEin);
00851        Tabruler::repaint();
00852        QString ein = unitGetSuffixFromIndex(dEin);
00853        if (dEin == 2)
00854        {
00855               first_->setDecimals(10000);
00856               left_->setDecimals(10000);
00857               right_->setDecimals(10000);
00858               tabData->setDecimals(10000);
00859        } // TODO else What's the decimal for other dEins?
00860        first_->setSuffix(ein);
00861        left_->setSuffix(ein);
00862        right_->setSuffix(ein);
00863        tabData->setSuffix(ein);
00864 
00865        connect(this, SIGNAL(tabsChanged()), this, SLOT(slotTabsChanged()));
00866        connect(this, SIGNAL(mouseReleased()), this, SLOT(slotTabsChanged()));
00867 }
00868 
00869 void SMTabruler::setParentTabs(QValueList<ParagraphStyle::TabRecord> Tabs)
00870 {
00871        hasParent_ = true;
00872        pTabs_ = Tabs;
00873 }
00874 
00875 void SMTabruler::setFirstLineValue(double t)
00876 {
00877        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00878        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00879        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00880        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00881        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00882        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00883        first_->setValue(t);
00884        firstLineData->setValue(t);
00885        setLeftIndent();
00886        setFirstLine();
00887        setRightIndent();
00888        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00889        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00890        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00891        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00892        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00893        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00894 }
00895 
00896 void SMTabruler::setFirstLineValue(double t, bool isParentValue)
00897 {
00898        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00899        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00900        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00901        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00902        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00903        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00904        isSetupFirst_ = true;
00905        first_->setValue(t, isParentValue);
00906        firstLineData->setValue(t);
00907        setLeftIndent();
00908        setFirstLine();
00909        setRightIndent();
00910        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00911        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00912        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00913        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00914        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00915        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00916 }
00917 
00918 void SMTabruler::setParentFirstLine(double t)
00919 {
00920        first_->setParentValue(t);
00921 }
00922 
00923 void SMTabruler::setLeftIndentValue(double t)
00924 {
00925        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00926        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00927        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00928        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00929        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00930        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00931        left_->setValue(t);
00932        leftIndentData->setValue(t);
00933        setLeftIndent();
00934        setFirstLine();
00935        setRightIndent();
00936        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00937        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00938        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00939        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00940        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00941        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00942 }
00943 
00944 void SMTabruler::setLeftIndentValue(double t, bool isParentValue)
00945 {
00946        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00947        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00948        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00949        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00950        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00951        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00952        isSetupLeft_ = true;
00953        left_->setValue(t, isParentValue);
00954        leftIndentData->setValue(t);
00955        setLeftIndent();
00956        setFirstLine();
00957        setRightIndent();
00958        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00959        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00960        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00961        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00962        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00963        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00964 }
00965 
00966 void SMTabruler::setParentLeftIndent(double t)
00967 {
00968        left_->setParentValue(t);
00969 }
00970 
00971 void SMTabruler::setRightIndentValue(double t)
00972 {
00973        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00974        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00975        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00976        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00977        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00978        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00979        right_->setValue(t);
00980        rightIndentData->setValue(t);
00981        setLeftIndent();
00982        setFirstLine();
00983        setRightIndent();
00984        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00985        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00986        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00987        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00988        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00989        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
00990 }
00991 
00992 void SMTabruler::setRightIndentValue(double t, bool isParentValue)
00993 {
00994        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
00995        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
00996        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
00997        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
00998        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
00999        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
01000        isSetupRight_ = true;
01001        right_->setValue(t, isParentValue);
01002        rightIndentData->setValue(t);
01003        setLeftIndent();
01004        setFirstLine();
01005        setRightIndent();
01006        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
01007        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
01008        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
01009        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
01010        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
01011        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
01012 }
01013 
01014 void SMTabruler::setParentRightIndent(double t)
01015 {
01016        right_->setParentValue(t);
01017 }
01018 
01019 bool SMTabruler::useParentTabs()
01020 {
01021        bool ret = useParentTabs_;
01022        if (ret && hasParent_)
01023        {
01024               setTabs(pTabs_, pDein_, true);
01025               Tabruler::repaint();
01026               parentButton_->hide();
01027        }
01028        else if (hasParent_)
01029        {
01030               parentButton_->show();
01031        }
01032 
01033        return ret;
01034 }
01035 
01036 bool SMTabruler::useParentFirstLine()
01037 {
01038        return first_->useParentValue();
01039 }
01040 
01041 bool SMTabruler::useParentLeftIndent()
01042 {
01043        return left_->useParentValue();
01044 }
01045 
01046 bool SMTabruler::useParentRightIndent()
01047 {
01048        return right_->useParentValue();
01049 }
01050 
01051 void SMTabruler::slotTabsChanged()
01052 {
01053        if (hasParent_)
01054        {
01055               useParentTabs_ = false;
01056               tabsChanged_ = true;
01057        }
01058 }
01059 
01060 void SMTabruler::pbClicked()
01061 {
01062        if (hasParent_)
01063        {
01064               useParentTabs_ = true;
01065               emit mouseReleased();
01066        }
01067 }
01068 
01069 void SMTabruler::leftDataChanged()
01070 {
01071        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
01072        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
01073        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
01074        double a, b, value;
01075        int c;
01076        leftIndentData->getValues(&a, &b, &c, &value);
01077        if (hasParent_ && !isSetupLeft_)
01078               left_->setValue(value, false);
01079        else if (!hasParent_)
01080               left_->setValue(value);
01081 
01082        isSetupLeft_ = false;
01083        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
01084        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
01085        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
01086 }
01087 
01088 void SMTabruler::rightDataChanged()
01089 {
01090        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
01091        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
01092        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
01093        double a, b, value;
01094        int c;
01095        rightIndentData->getValues(&a, &b, &c, &value);
01096        if (hasParent_ && !isSetupRight_)
01097               right_->setValue(value, false);
01098        else if (!hasParent_)
01099               right_->setValue(value);
01100 
01101        isSetupRight_ = false;
01102        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
01103        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
01104        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
01105 }
01106 
01107 void SMTabruler::firstDataChanged()
01108 {
01109        disconnect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
01110        disconnect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
01111        disconnect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
01112        double a, b, value;
01113        int c;
01114        firstLineData->getValues(&a, &b, &c, &value);
01115        if (hasParent_ && !isSetupFirst_)
01116               first_->setValue(value, false);
01117        else if (!hasParent_)
01118               first_->setValue(value);
01119 
01120        isSetupFirst_ = false;
01121        connect(first_, SIGNAL(valueChanged(int)), this, SLOT(firstValueChanged()));
01122        connect(right_, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged()));
01123        connect(left_, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged()));
01124 }
01125 
01126 void SMTabruler::firstValueChanged()
01127 {
01128        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
01129        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
01130        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
01131        double a, b, value;
01132        int c;
01133        first_->getValues(&a, &b, &c, &value);
01134        setFirstLineData(value);
01135        setLeftIndent();
01136        setFirstLine();
01137        setRightIndent();
01138        isSetupFirst_ = true;
01139        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
01140        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
01141        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
01142 }
01143 
01144 void SMTabruler::leftValueChanged()
01145 {
01146        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
01147        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
01148        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
01149        double a, b, value;
01150        int c;
01151        left_->getValues(&a, &b, &c, &value);
01152        setLeftIndentData(value);
01153        setLeftIndent();
01154        setFirstLine();
01155        setRightIndent();
01156        isSetupLeft_ = true;
01157        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
01158        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
01159        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
01160 }
01161 
01162 void SMTabruler::rightValueChanged()
01163 {
01164        disconnect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
01165        disconnect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
01166        disconnect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
01167        double a, b, value;
01168        int c;
01169        right_->getValues(&a, &b, &c, &value);
01170        setRightIndentData(value);
01171        setLeftIndent();
01172        setFirstLine();
01173        setRightIndent();
01174        isSetupRight_ = true;
01175        connect(firstLineData, SIGNAL(valueChanged(int)), this, SLOT(firstDataChanged()));
01176        connect(rightIndentData, SIGNAL(valueChanged(int)), this, SLOT(rightDataChanged()));
01177        connect(leftIndentData, SIGNAL(valueChanged(int)), this, SLOT(leftDataChanged()));
01178 }
01179 
01180