Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'KDoubleLine (./kdelibs/kdeui/knuminput.cpp:474)
class KDoubleLine : public QLineEdit
{
public:
KDoubleLine(KDoubleNumInput* parent, const char* name)
: QLineEdit(parent, name)
{ };
void interpretText();
protected:
virtual void wheelEvent(QWheelEvent* e);
};
void KDoubleLine::wheelEvent(QWheelEvent* e)
{
KDoubleNumInput* w = static_cast<KDoubleNumInput*>(parent());
if(edited())
interpretText();
if(w->m_range) {
w->setValue(w->value() + (e->delta()/120)*w->m_step);
e->accept();
}
else
e->ignore();
}
void KDoubleLine::interpretText()
{
KDoubleNumInput* w = static_cast<KDoubleNumInput*>(parent());
QString s = QString(text()).stripWhiteSpace();
if ( !w->m_prefix.isEmpty() ) {
QString px = QString(w->m_prefix).stripWhiteSpace();
int len = px.length();
if ( len && s.left(len) == px )
s.remove( 0, len );
}
if ( !w->m_suffix.isEmpty() ) {
QString sx = QString(w->m_suffix).stripWhiteSpace();
int len = sx.length();
if ( len && s.right(len) == sx )
s.truncate( s.length() - len );
}
s = s.stripWhiteSpace();
if(edited()) {
bool ok;
double value = s.toDouble(&ok);
if(ok) {
w->m_value = value;
setEdited(false);
}
}
}
// -----------------------------------------------------------------------------
kdelibs'KDoubleLine::interpretText() (./kdelibs/kdeui/knuminput.cpp:502)
void KDoubleLine::interpretText()
{
KDoubleNumInput* w = static_cast<KDoubleNumInput*>(parent());
QString s = QString(text()).stripWhiteSpace();
if ( !w->m_prefix.isEmpty() ) {
QString px = QString(w->m_prefix).stripWhiteSpace();
int len = px.length();
if ( len && s.left(len) == px )
s.remove( 0, len );
}
if ( !w->m_suffix.isEmpty() ) {
QString sx = QString(w->m_suffix).stripWhiteSpace();
int len = sx.length();
if ( len && s.right(len) == sx )
s.truncate( s.length() - len );
}
s = s.stripWhiteSpace();
if(edited()) {
bool ok;
double value = s.toDouble(&ok);
if(ok) {
w->m_value = value;
setEdited(false);
}
}
}
// -----------------------------------------------------------------------------