busquedafecha.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Tomeu Borras Riera                              *
00003  *   tborras@conetxia.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 <QCalendarWidget>
00022 
00023 #include "busquedafecha.h"
00024 #include "funcaux.h"
00025 
00026 
00028 
00031 BusquedaFecha::BusquedaFecha(QWidget *parent) : BLWidget(parent) {
00032     _depura("BusquedaFecha::BusquedaFecha", 0);
00033     setupUi(this);
00034     QObject::connect(mui_busquedaFecha, SIGNAL(clicked(bool)), this, SLOT(s_searchFecha()));
00035     QObject::connect(mui_textoFecha, SIGNAL(returnPressed()), this, SLOT(s_returnPressed()));
00036     QObject::connect(mui_textoFecha, SIGNAL(editingFinished()), this, SLOT(s_fechalostFocus()));
00037     QObject::connect(mui_textoFecha, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
00038     _depura("BusquedaFecha::BusquedaFecha", 0);
00039 }
00040 
00041 
00043 
00045 BusquedaFecha::~BusquedaFecha() {
00046     _depura("BusquedaFecha::~BusquedaFecha", 0);
00047     _depura("END BusquedaFecha::~BusquedaFecha", 0);
00048 }
00049 
00050 
00052 
00055 void BusquedaFecha::setfecha(QString val) {
00056     _depura("BusquedaFecha::setfecha", 0);
00057     mui_textoFecha->setText(val);
00058     _depura("END BusquedaFecha::setfecha", 0);
00059 }
00060 
00062 
00065 void BusquedaFecha::setText(QString val) {
00066     _depura("BusquedaFecha::setText", 0);
00067     mui_textoFecha->setText(val);
00068     _depura("END BusquedaFecha::setText", 0);
00069 }
00070 
00071 
00073 
00076 void BusquedaFecha::setValorCampo(QString val) {
00077     _depura("BusquedaFecha::setValorCampo", 0);
00078     mui_textoFecha->setText(val);
00079     _depura("END BusquedaFecha::setValorCampo", 0);
00080 }
00081 
00082 
00084 
00087 QString BusquedaFecha::fecha() {
00088     _depura("BusquedaFecha::fecha", 0);
00089     _depura("END BusquedaFecha::fecha", 0);
00090     return mui_textoFecha->text();
00091 }
00092 
00093 
00095 
00098 QString BusquedaFecha::text() {
00099     _depura("BusquedaFecha::text", 0);
00100     _depura("END BusquedaFecha::text", 0);
00101     return mui_textoFecha->text();
00102 }
00103 
00104 
00106 
00109 QString BusquedaFecha::valorCampo() {
00110     _depura("BusquedaFecha::valorCampo", 0);
00111     _depura("END BusquedaFecha::valorCampo", 0);
00112     return mui_textoFecha->text();
00113 }
00114 
00115 
00117 
00119 void BusquedaFecha::s_returnPressed() {
00120     _depura("BusquedaFecha::s_returnPressed", 0);
00121     s_fechalostFocus();
00122     emit returnPressed();
00123     _depura("END BusquedaFecha::s_returnPressed", 0);
00124 }
00125 
00126 
00128 
00130 void BusquedaFecha::selectAll() {
00131     _depura("BusquedaFecha::selectAll", 0);
00132     mui_textoFecha->selectAll();
00133     _depura("END BusquedaFecha::selectAll", 0);
00134 }
00135 
00136 
00138 
00140 void BusquedaFecha::setFocus() {
00141     _depura("BusquedaFecha::setFocus", 0);
00142     mui_textoFecha->setFocus(Qt::OtherFocusReason);
00143     _depura("END BusquedaFecha::setFocus", 0);
00144 }
00145 
00146 
00148 
00150 void BusquedaFecha::s_searchFecha() {
00151     _depura("BusquedaFecha::s_searchFecha", 0);
00152 
00153     QDialog *diag = new QDialog(0);
00154     diag->setModal(true);
00155     QCalendarWidget *calend = new QCalendarWidget(diag);
00157     calend->setFirstDayOfWeek(Qt::Monday);
00158     connect(calend, SIGNAL(activated(const QDate &)), diag, SLOT(accept()));
00159 
00162     QHBoxLayout *layout = new QHBoxLayout;
00163     layout->addWidget(calend);
00164     layout->setMargin(0);
00165     layout->setSpacing(0);
00166     diag->setLayout(layout);
00167     diag->setWindowTitle(tr("Seleccione fecha"));
00168     diag->exec();
00169 
00170     mui_textoFecha->setText(calend->selectedDate().toString("dd/MM/yyyy"));
00171 
00172     delete calend;
00173     delete diag;
00174 
00175     emit(valueChanged(mui_textoFecha->text()));
00176     _depura("END BusquedaFecha::s_searchFecha", 0);
00177 }
00178 
00179 
00181 
00185 void BusquedaFecha::s_fechatextChanged(const QString &texto) {
00186     _depura("BusquedaFecha::s_fechatextChanged", 0);
00187     if (texto == "+")
00188         s_searchFecha();
00189     if (texto == "*")
00190         mui_textoFecha->setText(QDate::currentDate().toString("dd/MM/yyyy"));
00191     mui_textoFecha->setText(normalizafecha(texto).toString("dd/MM/yyyy"));
00192     if (texto == "") {
00193         mui_textoFecha->setText("");
00194         return;
00195     } // end if
00196     emit(valueChanged(mui_textoFecha->text()));
00197     _depura("END BusquedaFecha::s_fechatextChanged", 0);
00198 }
00199 
00200 
00202 
00204 void BusquedaFecha::s_fechalostFocus() {
00205     _depura("BusquedaFecha::s_fechalostFocus", 0);
00206     QString fech = mui_textoFecha->text();
00207     if (fech != "")
00208         s_fechatextChanged(fech);
00209     _depura("END BusquedaFecha::s_fechalostFocus", 0);
00210 }
00211 

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