Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/addon/doxywizard/inputint.cpp

Source at commit 1322 created 12 years 8 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 *
4 *
5 * Copyright (C) 1997-2011 by Dimitri van Heesch.
6 *
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
12 *
13 */
14
15#include "inputint.h"
16#include "helplabel.h"
17
18#include <QtGui>
19
20InputInt::InputInt( QGridLayout *layout,int &row,
21 const QString & id,
22 int defVal, int minVal,int maxVal,
23 const QString & docs )
24 : m_default(defVal), m_minVal(minVal), m_maxVal(maxVal), m_docs(docs), m_id(id)
25{
26 m_lab = new HelpLabel(id);
27 m_sp = new QSpinBox;
28 m_sp->setMinimum(minVal);
29 m_sp->setMaximum(maxVal);
30 m_sp->setSingleStep(1);
31 m_val=defVal-1; // force update
32 setValue(defVal);
33
34 layout->addWidget( m_lab, row, 0 );
35 layout->addWidget( m_sp, row, 1 );
36
37 connect(m_sp, SIGNAL(valueChanged(int)),
38 this, SLOT(setValue(int)) );
39 connect( m_lab, SIGNAL(enter()), SLOT(help()) );
40 connect( m_lab, SIGNAL(reset()), SLOT(reset()) );
41 row++;
42}
43
44void InputInt::help()
45{
46 showHelp(this);
47}
48
49
50void InputInt::setValue(int val)
51{
52 val = qMax(m_minVal,val);
53 val = qMin(m_maxVal,val);
54 if (val!=m_val)
55 {
56 m_val = val;
57 m_sp->setValue(val);
58 m_value = m_val;
59 if (m_val==m_default)
60 {
61 m_lab->setText(QString::fromAscii("<qt>")+m_id+QString::fromAscii("</qt"));
62 }
63 else
64 {
65 m_lab->setText(QString::fromAscii("<qt><font color='red'>")+m_id+QString::fromAscii("</font></qt>"));
66 }
67 emit changed();
68 }
69}
70
71void InputInt::setEnabled(bool state)
72{
73 m_lab->setEnabled(state);
74 m_sp->setEnabled(state);
75}
76
77QVariant &InputInt::value()
78{
79 return m_value;
80}
81
82void InputInt::update()
83{
84 setValue(m_value.toInt());
85}
86
87void InputInt::reset()
88{
89 setValue(m_default);
90}
91
92void InputInt::writeValue(QTextStream &t,QTextCodec *)
93{
94 t << m_val;
95}
96
97

Archive Download this file

Revision: 1322