qdoublespinbox2.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Fco. Javier M. C.                               *
00003  *   fcojavmc@todo-redes.com                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include "qdoublespinbox2.h"
00022 
00023 
00025 
00028 QDoubleSpinBox2::QDoubleSpinBox2(QWidget *parent) : QDoubleSpinBox(parent) {
00029     _depura("QDoubleSpinBox2::QDoubleSpinBox2", 0);
00030     installEventFilter(this);
00031     setAlignment(Qt::AlignRight);
00032     setButtonSymbols(QAbstractSpinBox::PlusMinus);
00033     _depura("EDN QDoubleSpinBox2::QDoubleSpinBox2", 0);
00034 }
00035 
00036 
00038 
00040 QDoubleSpinBox2::~QDoubleSpinBox2() {
00041     _depura("QDoubleSpinBox2::~QDoubleSpinBox2", 0);
00042     _depura("END QDoubleSpinBox2::~QDoubleSpinBox2", 0);
00043 }
00044 
00046 
00049 QString const QDoubleSpinBox2::text() {
00050     _depura("QDoubleSpinBox2::text", 0);
00051     QString a = QDoubleSpinBox::text();
00052     //a = a.replace(",", ".");
00053     _depura("END QDoubleSpinBox2::text", 0);
00054     return a;
00055 }
00056 
00057 
00059 
00062 void QDoubleSpinBox2::setValue(double valor) {
00063     _depura("QDoubleSpinBox2::setValue", 0);
00064     QDoubleSpinBox::setValue(valor);
00065     _depura("END QDoubleSpinBox2::setValue", 0);
00066 }
00067 
00069 
00074 bool QDoubleSpinBox2::eventFilter(QObject *obj, QEvent *event) {
00075     _depura("QDoubleSpinBox2::eventFilter", 0);
00077     if (event->type() == QEvent::KeyPress) {
00078         QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
00079         int key = keyEvent->key();
00080         Qt::KeyboardModifiers mod = keyEvent->modifiers();
00081         switch (key) {
00082             case Qt::Key_Period:
00085                 QLineEdit *linea = QAbstractSpinBox::lineEdit();
00087                 QString strLinea = linea->text();
00088                 if (!strLinea.contains(",", Qt::CaseInsensitive)) {
00089                     linea->setText(linea->text() + ",");
00090                 } // end if
00091                 return TRUE;
00092         } // end switch
00093     } // end if
00094     _depura("END QDoubleSpinBox2::eventFilter", 0);
00095     return QDoubleSpinBox::eventFilter(obj, event);
00096 }
00097 

Generated on Sat Dec 15 00:01:22 2007 for BulmaGes by  doxygen 1.5.1