dialogchanges.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 <QLineEdit>
00022 #include <QTextEdit>
00023 #include <QTableWidget>
00024 #include <QComboBox>
00025 
00026 #include "dialogchanges.h"
00027 #include "funcaux.h"
00028 
00029 
00031 
00034 dialogChanges::dialogChanges(QObject *ob) {
00035     _depura("dialogChanges::dialogChanges", 0);
00036     m_obje = ob;
00037     _depura("END dialogChanges::dialogChanges", 0);
00038 }
00039 
00040 
00042 
00044 dialogChanges::~dialogChanges() {
00045     _depura("dialogChanges::~dialogChanges", 0);
00046     _depura("END dialogChanges::~dialogChanges", 0);
00047 }
00048 
00049 
00051 
00055 bool dialogChanges::objExcluido(QObject *item) {
00056     _depura("dialogChanges::objExcluido", 0);
00057     QListIterator<QObject *> it_excluidos (m_listaExcluidos);
00059     it_excluidos.toFront();
00060     while (it_excluidos.hasNext()) {
00062         if (it_excluidos.next() == (QObject *) item)
00063             return TRUE;
00064     } // end while
00065     _depura("END dialogChanges::objExcluido", 0);
00066     return FALSE;
00067 }
00068 
00069 
00071 
00073 void dialogChanges::dialogChanges_cargaInicial() {
00074     _depura("dialogChanges::dialogChanges_cargaInicial", 0);
00075     try {
00076     m_maxQText = 0;
00077     m_maxQLine = 0;
00078     m_maxQTable = 0;
00079     m_maxQComboBox = 0;
00080 
00081     QListIterator<QObject *> it_excluidos (m_listaExcluidos);
00082 
00083     QList<QComboBox *> l4 = m_obje->findChildren<QComboBox *>();
00084     QListIterator<QComboBox *> it4 (l4);
00085     while (it4.hasNext()) {
00086         QComboBox *item = it4.next();
00087         if (item->objectName().startsWith("mui_") && !objExcluido(item)) {
00088             m_listaQComboBox[m_maxQComboBox++] = item;
00089         } // end if
00090     } // end while
00091 
00092 
00093     QList<QTextEdit *> l1 = m_obje->findChildren<QTextEdit *>();
00094     QListIterator<QTextEdit *> it1 (l1);
00095     while (it1.hasNext()) {
00096         QTextEdit *item = it1.next();
00097         if (item->objectName().startsWith("mui_") && !objExcluido(item)) {
00098             m_listaQText[m_maxQText++] = item;
00099         } // end if
00100     } // end while
00101 
00102     QList<QLineEdit *> l2 = m_obje->findChildren<QLineEdit *>();
00103     QListIterator<QLineEdit *> it2 (l2);
00104     while (it2.hasNext()) {
00105         QLineEdit *item = it2.next();
00106         if (item->objectName().startsWith("mui_") && !objExcluido(item)) {
00107             m_listaQLine[m_maxQLine++] = item;
00108         } // end if
00109     } // end while
00110 
00111     QList<QTableWidget *> l3 = m_obje->findChildren<QTableWidget *>();
00112     QListIterator<QTableWidget *> it3(l3);
00113     while (it3.hasNext()) {
00114         QTableWidget *item = it3.next();
00115         if (item->objectName().startsWith("mui_") && !objExcluido(item)) {
00116             m_listaQTable[m_maxQTable++] = item;
00117         } // end if
00118     } // end while
00119 
00120     m_valorinicial = calculateValues();
00121     _depura("END dialogChanges::dialogChanges_cargaInicial", 0, m_valorinicial.toAscii());
00122     } catch (...) {
00123         _depura("ERROR dialogChanges::dialogChanges_cargaInicial", 0, " error en el calculo");
00124         return;
00125     } // end try
00126 }
00127 
00128 
00130 
00133 bool dialogChanges::dialogChanges_hayCambios() {
00134     _depura("dialogChanges::dialogChanges_hayCambios", 0);
00135     QString valorfinal = calculateValues();
00136     _depura("END dialogChanges::dialogChanges_hayCambios", 0, m_valorinicial + "==== " + valorfinal);
00137     return (m_valorinicial != valorfinal);
00138 }
00139 
00140 
00142 
00145 QString dialogChanges::calculateValues() {
00146     _depura("dialogChanges::calculateValues", 0);
00147     QString values = retrieveValues("QTableWidget");
00148     values += retrieveValues("QLineEdit");
00149     values += retrieveValues("QTextEdit");
00150     values += retrieveValues("QComboBox");
00151     _depura("END dialogChanges::calculateValues", 0);
00152     return values;
00153 }
00154 
00155 
00157 
00160 void dialogChanges::dialogChanges_setQObjectExcluido(QObject *objetoexcluido) {
00161     _depura("dialogChanges::dialogChanges_setQObjectExcluido", 0);
00162     m_listaExcluidos.append(objetoexcluido);
00163     _depura("END dialogChanges::dialogChanges_setQObjectExcluido", 0);
00164 }
00165 
00166 
00168 
00172 QString dialogChanges::retrieveValues(QString qsWidget) {
00173     _depura("dialogChanges::retrieveValues", 0, qsWidget);
00174     try {
00175     QString values = "";
00176     QListIterator<QObject *> it_excluidos (m_listaExcluidos);
00177 
00178 
00179     if (qsWidget == "QComboBox") {
00180         for (int i = 0; i < m_maxQComboBox; i++) {
00181             if (m_listaQComboBox[i] != NULL) {
00182                 if (((QComboBox*)m_listaQComboBox[i])->objectName().startsWith("mui_")) {
00183                     values += ((QComboBox*)m_listaQComboBox[i])->objectName();
00184                     values += ((QComboBox*)m_listaQComboBox[i])->currentText();
00185                 } // end if
00186             } // end if
00187         } // end for
00188     } // end if
00189 
00190 
00191     if (qsWidget == "QLineEdit") {
00192         for (int i = 0; i < m_maxQLine; i++) {
00193             if (m_listaQLine[i] != NULL) {
00194                 if (((QLineEdit*)m_listaQLine[i])->objectName().startsWith("mui_")) {
00195                     values += ((QLineEdit*)m_listaQLine[i])->objectName();
00196                     values += ((QLineEdit*)m_listaQLine[i])->text();
00197 
00198                 } // end if
00199             } // end if
00200         } // end for
00201     } // end if
00202 
00203     if (qsWidget == "QTextEdit") {
00204         for (int i = 0; i < m_maxQText; i++) {
00205             if (m_listaQText[i] != NULL) {
00206                 if (((QTextEdit*)m_listaQText[i])->objectName().startsWith("mui_"))
00207                     values += ((QTextEdit*)m_listaQText[i])->objectName();
00208                     values += ((QTextEdit*)m_listaQText[i])->toPlainText();
00209             } // end if
00210         } // end for
00211     } // end if
00212 
00213 
00214     if (qsWidget == "QTableWidget") {
00215         for (int i = 0; i < m_maxQTable; i++) {
00216             if (m_listaQTable[i] != NULL) {
00217                 for (int k = 0; k < ((QTableWidget*)m_listaQTable[i])->rowCount(); k++) {
00218                     for (int l = 0; l < ((QTableWidget*)m_listaQTable[i])->columnCount(); l++) {
00219                         values += (((QTableWidget*)m_listaQTable[i]))->objectName();
00220                         values += (((QTableWidget*)m_listaQTable[i]))->item(k, l)->text();
00221                     } // end for
00222                 } // end for
00223             } // end if
00224         } // end for
00225     } // end if
00226 
00227     _depura("END dialogChanges::retrieveValues", 0, values);
00228     return values;
00229    } catch(...) {
00230         _depura("ERROR dialogChanges::retrieveValue", 2, "error en el calculo");
00231         return "";
00232    } // end try
00233 }
00234 

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