1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7
8 #include "smnumformatcombo.h"
9
SMNumFormatCombo(QWidget * parent)10 SMNumFormatCombo::SMNumFormatCombo(QWidget *parent)
11 : NumFormatCombo(parent)
12 {
13
14 }
15
setCurrentFormat(NumFormat format)16 void SMNumFormatCombo::setCurrentFormat(NumFormat format)
17 {
18 disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
19 setFont(false);
20 m_hasParent = false;
21 m_parentFormat = Type_1_2_3;
22
23 NumFormatCombo::setCurrentFormat(format);
24 }
25
setCurrentFormat(NumFormat format,bool isParentValue)26 void SMNumFormatCombo::setCurrentFormat(NumFormat format, bool isParentValue)
27 {
28 disconnect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
29 m_hasParent = true;
30 m_parentFormat = format;
31 setFont(!isParentValue);
32 if (!isParentValue && !m_useParentValue)
33 {
34 m_useParentValue = true;
35 addItem( tr("Use Parent Value"));
36 }
37
38 NumFormatCombo::setCurrentFormat(format);
39 connect(this, SIGNAL(highlighted(int)), this, SLOT(currentChanged()));
40 }
41
setParentFormat(NumFormat format)42 void SMNumFormatCombo::setParentFormat(NumFormat format)
43 {
44 m_hasParent = true;
45 m_parentFormat = format;
46 }
47
useParentFormat()48 bool SMNumFormatCombo::useParentFormat()
49 {
50 bool ret = false;
51
52 if (m_useParentValue && m_hasParent)
53 {
54 ret = currentIndex() == (count() - 1);
55 if (ret)
56 {
57 removeItem(count() - 1);
58 setFont(false);
59 setCurrentFormat(m_parentFormat, true);
60 m_useParentValue = false;
61 }
62 }
63
64 return ret;
65 }
66
setFont(bool wantBold)67 void SMNumFormatCombo::setFont(bool wantBold)
68 {
69 QFont f(font());
70 f.setBold(wantBold);
71 NumFormatCombo::setFont(f);
72 }
73
currentChanged()74 void SMNumFormatCombo::currentChanged()
75 {
76 if (m_hasParent && !m_useParentValue)
77 {
78 setFont(true);
79 addItem( tr("Use Parent Value"));
80 m_useParentValue = true;
81 }
82 }
83