Changeset View
Changeset View
Standalone View
Standalone View
src/editors/spinbox.cpp
Show All 19 Lines | |||||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "spinbox.h" | 22 | #include "spinbox.h" | ||
23 | #include "KProperty.h" | 23 | #include "KProperty.h" | ||
24 | #include "KProperty_p.h" | 24 | #include "KProperty_p.h" | ||
25 | #include "KPropertyEditorDataModel.h" | 25 | #include "KPropertyEditorDataModel.h" | ||
26 | #include "KPropertyEditorView.h" | 26 | #include "KPropertyEditorView.h" | ||
27 | #include "KPropertyUnit_p.h" | 27 | #include "KPropertyUnit_p.h" | ||
28 | #include "kproperty_debug.h" | 28 | #include "KPropertyWidgetsFactory.h" | ||
29 | #include "kpropertywidgets_debug.h" | ||||
29 | 30 | | |||
30 | #include <QVariant> | 31 | #include <QVariant> | ||
31 | #include <QLineEdit> | 32 | #include <QLineEdit> | ||
32 | #include <QLocale> | 33 | #include <QLocale> | ||
33 | 34 | | |||
34 | #include <climits> | 35 | #include <climits> | ||
35 | 36 | | |||
36 | //! @return font size expressed in points (pt) | 37 | //! @return font size expressed in points (pt) | ||
Show All 29 Lines | 64 | // kprDebug() << "itemHeight:" << itemHeight; | |||
66 | if (le) { | 67 | if (le) { | ||
67 | // le->setFixedHeight(itemHeight); | 68 | // le->setFixedHeight(itemHeight); | ||
68 | le->setAlignment(Qt::AlignLeft); | 69 | le->setAlignment(Qt::AlignLeft); | ||
69 | le->setContentsMargins(0,0,0,0); | 70 | le->setContentsMargins(0,0,0,0); | ||
70 | } | 71 | } | ||
71 | // kprDebug() << parent->font().pointSize(); | 72 | // kprDebug() << parent->font().pointSize(); | ||
72 | setFrame(true); | 73 | setFrame(true); | ||
73 | QString css = cssForSpinBox("QSpinBox", font(), itemHeight); | 74 | QString css = cssForSpinBox("QSpinBox", font(), itemHeight); | ||
74 | KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); | 75 | KPropertyWidgetsFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); | ||
75 | setStyleSheet(css); | 76 | setStyleSheet(css); | ||
76 | 77 | | |||
77 | QVariant minVal(prop->option("min", m_unsigned ? 0 : -INT_MAX)); | 78 | QVariant minVal(prop->option("min", m_unsigned ? 0 : -INT_MAX)); | ||
78 | QVariant maxVal(prop->option("max", INT_MAX)); | 79 | QVariant maxVal(prop->option("max", INT_MAX)); | ||
79 | setMinimum(minVal.toInt()); | 80 | setMinimum(minVal.toInt()); | ||
80 | setMaximum(maxVal.toInt()); | 81 | setMaximum(maxVal.toInt()); | ||
81 | QString minValueText(prop->option("minValueText").toString()); | 82 | QString minValueText(prop->option("minValueText").toString()); | ||
82 | if (!minValueText.isEmpty()) | 83 | if (!minValueText.isEmpty()) | ||
Show All 11 Lines | 94 | if (m_unsigned) | |||
94 | return uint(QSpinBox::value()); | 95 | return uint(QSpinBox::value()); | ||
95 | return QSpinBox::value(); | 96 | return QSpinBox::value(); | ||
96 | } | 97 | } | ||
97 | 98 | | |||
98 | void KPropertyIntSpinBox::setValue(const QVariant& value) | 99 | void KPropertyIntSpinBox::setValue(const QVariant& value) | ||
99 | { | 100 | { | ||
100 | int v( value.toInt() ); | 101 | int v( value.toInt() ); | ||
101 | if (m_unsigned && v<0) { | 102 | if (m_unsigned && v<0) { | ||
102 | kprWarning() << "could not assign negative value" << v << "- assigning 0"; | 103 | kprwWarning() << "could not assign negative value" << v << "- assigning 0"; | ||
103 | v = 0; | 104 | v = 0; | ||
104 | } | 105 | } | ||
105 | QSpinBox::setValue(v); | 106 | QSpinBox::setValue(v); | ||
106 | } | 107 | } | ||
107 | 108 | | |||
108 | void KPropertyIntSpinBox::slotValueChanged(int value) | 109 | void KPropertyIntSpinBox::slotValueChanged(int value) | ||
109 | { | 110 | { | ||
110 | Q_UNUSED(value); | 111 | Q_UNUSED(value); | ||
Show All 34 Lines | |||||
145 | /* KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(sb, parent, | 146 | /* KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(sb, parent, | ||
146 | QString::fromLatin1( | 147 | QString::fromLatin1( | ||
147 | "QDoubleSpinBox { border-left: 0; border-right: 0; } " | 148 | "QDoubleSpinBox { border-left: 0; border-right: 0; } " | ||
148 | "QDoubleSpinBox::down-button { height: %1px; } " | 149 | "QDoubleSpinBox::down-button { height: %1px; } " | ||
149 | "QDoubleSpinBox::up-button { height: %2px; }" | 150 | "QDoubleSpinBox::up-button { height: %2px; }" | ||
150 | ).arg(itemHeight/2).arg(itemHeight - itemHeight/2) | 151 | ).arg(itemHeight/2).arg(itemHeight - itemHeight/2) | ||
151 | );*/ | 152 | );*/ | ||
152 | QString css = cssForSpinBox("QDoubleSpinBox", font(), itemHeight); | 153 | QString css = cssForSpinBox("QDoubleSpinBox", font(), itemHeight); | ||
153 | KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); | 154 | KPropertyWidgetsFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); | ||
154 | setStyleSheet(css); | 155 | setStyleSheet(css); | ||
155 | 156 | | |||
156 | QVariant minVal(prop->option("min")); | 157 | QVariant minVal(prop->option("min")); | ||
157 | if (minVal.canConvert(QMetaType::Double)) { | 158 | if (minVal.canConvert(QMetaType::Double)) { | ||
158 | setMinimum(minVal.toDouble()); | 159 | setMinimum(minVal.toDouble()); | ||
159 | } | 160 | } | ||
160 | QVariant maxVal(prop->option("max", double(INT_MAX / 100))); | 161 | QVariant maxVal(prop->option("max", double(INT_MAX / 100))); | ||
161 | if (maxVal.canConvert(QMetaType::Double)) { | 162 | if (maxVal.canConvert(QMetaType::Double)) { | ||
▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines |