fichacfg.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 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 <QWidget>
00022 
00023 #include "fichacfg.h"
00024 #include "funcaux.h"
00025 
00026 
00028 
00033 FichaCfg::FichaCfg(EmpresaBase *emp, Ficha *parent, Qt::WFlags f) : BLWidget(emp, parent, f) {
00034     _depura("FichaCfg::FichaCfg", 0);
00035     setupUi(this);
00036     setAttribute(Qt::WA_DeleteOnClose);
00037     m_ficha = parent;
00038     setGeometry(0, 0, m_ficha->width(), m_ficha->height());
00039     showMaximized();
00040     mui_tablename->setText(m_ficha->tableName());
00041 
00043     QString fields = "SELECT a.attnum AS ordinal_position, a.attname AS column_name, t.typname AS data_type, a.attlen AS character_maximum_length, a.atttypmod AS modifier, a.attnotnull AS notnull, a.atthasdef AS hasdefault FROM pg_class c, pg_attribute a, pg_type t WHERE c.relname = '" + m_ficha->tableName() + "' AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid ORDER BY a.attnum;";
00044     cursor2 *cur = empresaBase()->cargacursor(fields);
00045 
00046     mui_databasetable->setRowCount(cur->numregistros());
00047     mui_databasetable->setColumnCount(cur->numcampos());
00048     int i = 0;
00049     while (!cur->eof()) {
00050         for (int j = 0 ; j < cur->numcampos() ; j++) {
00051             QTableWidgetItem *newItem = new QTableWidgetItem(cur->valor(j, i));
00052             mui_databasetable->setItem(i, j, newItem);
00053         } // end for
00054         cur->siguienteregistro();
00055         i++;
00056     } // end while
00057     delete cur;
00058 
00060     mui_formtablename->setText(m_ficha->tableName());
00061     mui_formcampoindice->setText(m_ficha->campoId());
00062 
00063     QList<DBCampo *> *lista = m_ficha->lista();
00064 
00065     mui_formelements->setRowCount(lista->size());
00066     mui_formelements->setColumnCount(3);
00067 
00069     for (int j = 0; j < lista->size(); ++j) {
00070         DBCampo *campo = lista->at(j);
00071         QTableWidgetItem *newItem = new QTableWidgetItem(campo->nomcampo());
00072         mui_formelements->setItem(j, 0, newItem);
00073 
00074         QTableWidgetItem *newItem1 = new QTableWidgetItem(campo->nompresentacion());
00075         mui_formelements->setItem(j, 1, newItem1);
00076 
00077         QTableWidgetItem *newItem2 = new QTableWidgetItem(campo->valorcampo());
00078         mui_formelements->setItem(j, 2, newItem2);
00079     } // end for
00080 
00082     QString queryusers = "SELECT usename, has_table_privilege(pg_user.usename, '" + m_ficha->tableName() + "', 'SELECT') AS pselect" \
00083     ", has_table_privilege(pg_user.usename, '" + m_ficha->tableName() + "', 'INSERT') AS pinsert" \
00084     ", has_table_privilege(pg_user.usename, '" + m_ficha->tableName() + "', 'UPDATE') AS pupdate" \
00085     ", has_table_privilege(pg_user.usename, '" + m_ficha->tableName() + "', 'RULE') AS prules  FROM pg_user";
00086     cur = empresaBase()->cargacursor(queryusers);
00087 
00088     mui_usertable->setRowCount(cur->numregistros());
00089     mui_usertable->setColumnCount(cur->numcampos());
00090     i = 0;
00091     while (!cur->eof()) {
00092         for (int j = 0 ; j < cur->numcampos() ; j++) {
00093             QTableWidgetItem *newItem = new QTableWidgetItem(cur->valor(j, i));
00094             mui_usertable->setItem(i, j, newItem);
00095         } // end for
00096         cur->siguienteregistro();
00097         i++;
00098     } // end while
00099     delete cur;
00100 
00101     cur = empresaBase()->cargacursor("SELECT user");
00102     if (!cur) return;
00103 
00104     mui_currentuser->setText(cur->valor("current_user"));
00105     delete cur;
00106     _depura("END FichaCfg::FichaCfg", 0);
00107 }
00108 
00109 
00111 
00113 FichaCfg::~FichaCfg() {
00114     _depura("FichaCfg::~FichaCfg", 0);
00115     _depura("END FichaCfg::~FichaCfg", 0);
00116 }
00117 

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