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 #include "smlineedit.h"
8
SMLineEdit(QWidget * parent)9 SMLineEdit::SMLineEdit(QWidget *parent)
10 : QLineEdit(parent)
11 {
12
13 }
14
setValue(const QString & val)15 void SMLineEdit::setValue(const QString& val)
16 {
17 disconnect(this, SIGNAL(textChanged(QString)), this, SLOT(slotValueChanged()));
18 m_hasParent = false;
19 m_pValue.clear();
20 setFont(false);
21
22 QLineEdit::setText(val);
23 }
24
setValue(const QString & val,bool isParentVal)25 void SMLineEdit::setValue(const QString& val, bool isParentVal)
26 {
27 disconnect(this, SIGNAL(textChanged(QString)), this, SLOT(slotValueChanged()));
28 m_hasParent = true;
29 m_pValue = val;
30 setFont(!isParentVal);
31
32 QLineEdit::setText(val);
33 connect(this, SIGNAL(textChanged(QString)), this, SLOT(slotValueChanged()));
34 }
35
clear()36 void SMLineEdit::clear()
37 {
38 disconnect(this, SIGNAL(textChanged(QString)), this, SLOT(slotValueChanged()));
39 QLineEdit::clear();
40 connect(this, SIGNAL(textChanged(QString)), this, SLOT(slotValueChanged()));
41 }
42
setParentValue(const QString & val)43 void SMLineEdit::setParentValue(const QString& val)
44 {
45 m_hasParent = true;
46 m_pValue = val;
47 }
48
useParentValue()49 bool SMLineEdit::useParentValue()
50 {
51 bool ret = m_useParentValue;
52 m_useParentValue = false;
53 return ret;
54 }
55
setFont(bool wantBold)56 void SMLineEdit::setFont(bool wantBold)
57 {
58 QFont f(font());
59 f.setBold(wantBold);
60 QLineEdit::setFont(f);
61 }
62
slotValueChanged()63 void SMLineEdit::slotValueChanged()
64 {
65 if(m_hasParent)
66 setFont(true);
67 }
68