00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <QMenu>
00022 #include "listado.h"
00023 #include "empresabase.h"
00024
00025
00027
00029 void Listado::setModoConsulta() {
00030 _depura("Listado::setModoConsulta", 0);
00031 m_modo = SelectMode;
00032 _depura("END Listado::setModoConsulta", 0);
00033
00034 }
00035
00036
00038
00040 void Listado::setModoEdicion() {
00041 _depura("Listado::setModoEdicion", 0);
00042 m_modo = EditMode;
00043 _depura("END Listado::setModoEdicion", 0);
00044 }
00045
00046
00048
00051 bool Listado::modoEdicion() {
00052 _depura("Listado::modoEdicion", 0);
00053 _depura("END Listado::modoEdicion", 0);
00054 return m_modo == EditMode;
00055 }
00056
00057
00059
00062 bool Listado::modoConsulta() {
00063 _depura("Listado::modoConsulta", 0);
00064 _depura("END Listado::modoConsulta", 0);
00065 return m_modo == SelectMode;
00066 }
00067
00068
00070
00075 Listado::Listado(QWidget *parent, Qt::WFlags f, edmode modo) : BLWidget(parent, f) {
00076 _depura("Listado::Listado", 0);
00077 m_modo = modo;
00078 _depura("END Listado::Listado", 0);
00079 }
00080
00081
00083
00089 Listado::Listado(EmpresaBase *emp, QWidget *parent, Qt::WFlags f, edmode modo) : BLWidget(emp, parent, f) {
00090 _depura("Listado::Listado", 0);
00091 m_modo = modo;
00092 _depura("END Listado::Listado", 0);
00093 }
00094
00095
00097
00099 Listado::~Listado() {
00100 _depura("Listado::~Listado", 0, this->windowTitle());
00101 sacaWindow();
00102 _depura("END Listado::~Listado", 0);
00103 }
00104
00105
00107
00110 int Listado::sacaWindow() {
00111 _depura("Listado::sacaWindow", 0);
00112 empresaBase()->sacaWindow(this);
00113 _depura("END Listado::sacaWindow", 0);
00114 return 0;
00115 }
00116
00117
00119
00123 int Listado::meteWindow(QString title) {
00124 _depura("Listado::meteWindow", 0);
00125 empresaBase()->meteWindow(title, this);
00126 _depura("END Listado::meteWindow", 0);
00127 return 0;
00128 }
00129
00130
00137 void Listado::on_mui_list_cellDoubleClicked(int a, int) {
00138 _depura("ArticuloList::on_mui_list_cellDoubleClicked", 0);
00139 editar(a);
00140 _depura("END ArticuloList::on_mui_list_cellDoubleClicked", 0);
00141 }
00142
00143
00145
00147 void Listado::editar(int) {
00148 _depura("metodo para ser reimplementado en clases hijas", 2);
00149 }
00150
00151
00153
00155 void Listado::crear() {
00156 _depura("metodo para ser reimplementado en clases hijas", 2);
00157 }
00158
00159
00161
00163 void Listado::borrar() {
00164 _depura("metodo para ser reimplementado en clases hijas", 2);
00165 }
00166
00167
00169
00171 void Listado::imprimir() {
00172 _depura("Listado::imprimir", 0);
00173 m_listado->imprimirPDF("");
00174 _depura("END Listado::imprimir", 0);
00175 }
00176
00179
00181 void Listado::presentar() {
00182 _depura("Listado::presentar", 0);
00183 QString query = "SELECT * FROM " + m_listado->tableName();
00184 m_listado->cargar(query);
00185 _depura("END Listado::presentar", 0);
00186 }
00187
00188
00190
00193 void Listado::setSubForm(SubForm3 *list) {
00194 _depura("Listado::setSubForm", 0);
00195 m_listado = list;
00196 _depura("END Listado::setSubForm", 0);
00197 }
00198
00199
00201
00204 void Listado::on_m_filtro_textChanged(const QString &text) {
00205 _depura("Listado::on_m_filtro_textChanged", 0);
00206
00207 if (text.size() >= 3) {
00208 on_mui_actualizar_clicked();
00209 }
00210 _depura("END Listado::on_m_filtro_textChanged", 0);
00211 }
00212
00213
00215
00217 void Listado::on_m_filtro_editingFinished() {
00218 _depura("Listado::on_m_filtro_editFinished", 0);
00219 static QString valant = "";
00220 QLineEdit *line = findChild<QLineEdit *>("m_filtro");
00221 if (line->text() != valant) {
00222 valant = line->text();
00223 on_mui_actualizar_clicked();
00224 }
00225 _depura("END Listado::on_m_filtro_editFinished", 0);
00226 }
00227
00228
00230
00232 void Listado::on_mui_actualizar_clicked() {
00233 _depura("Listado::on_mui_actualizar_clicked", 0);
00234 presentar();
00235 _depura("END Listado::on_mui_actualizar_clicked", 0);
00236 }
00237
00238
00240
00242 void Listado::on_mui_imprimir_clicked() {
00243 _depura("Listado::on_mui_imprimir_clicked", 0);
00244 imprimir();
00245 _depura("END Listado::on_mui_imprimir_clicked", 0);
00246 }
00247
00248
00250
00252 void Listado::on_mui_crear_clicked() {
00253 _depura("Listado::on_mui_crear_clicked", 0);
00254 crear();
00255 _depura("END Listado::on_mui_crear_clicked", 0);
00256 }
00257
00258
00260
00262 void Listado::on_mui_borrar_clicked() {
00263 _depura("Listado::on_mui_borrar_clicked", 0);
00264 borrar();
00265 _depura("END Listado::on_mui_borrar_clicked", 0);
00266 }
00267
00268
00275 void Listado::on_mui_editar_clicked() {
00276 _depura("ArticuloList::INIT_s_editArticle", 0);
00277 int a = m_listado->currentRow();
00278 if (a < 0) {
00279 mensajeInfo(tr("Tiene que seleccionar un elemento"));
00280 return;
00281 }
00282 editar(a);
00283 _depura("ArticuloList::END_s_editArticle", 0);
00284 }
00285
00286
00288
00291 void Listado::on_mui_configurar_toggled(bool checked) {
00292 _depura("Listado::on_mui_configurar_toggled", 0);
00293 if (checked) {
00294 m_listado->showConfig();
00295 } else {
00296 m_listado->hideConfig();
00297 }
00298 _depura("END Listado::on_mui_configurar_toggled", 0);
00299 }
00300
00301
00308 void Listado::on_mui_list_customContextMenuRequested(const QPoint &p) {
00309 _depura("Listado::on_mui_list_customContextMenuRequested", 0);
00310 submenu(p);
00311 _depura("END Listado::on_mui_list_customContextMenuRequested", 0);
00312 }
00313
00314
00321 void Listado::submenu(const QPoint &) {
00322 _depura("ArticuloList::on_mui_list_customContextMenuRequested", 0);
00323 int a = m_listado->currentRow();
00324 if (a < 0)
00325 return;
00326 QMenu *popup = new QMenu(this);
00327 QAction *edit = popup->addAction(tr("Editar"));
00328 QAction *del = popup->addAction(tr("Borrar"));
00329 QAction *opcion = popup->exec(QCursor::pos());
00330 if (opcion == del)
00331 on_mui_borrar_clicked();
00332 if (opcion == edit)
00333 on_mui_editar_clicked();
00334 delete popup;
00335 }
00336
00337
00339
00342 void Listado::on_mui_list_toogledConfig(bool check) {
00343 _depura("Listado::on_mui_list_toogledConfig", 0);
00344
00345 QToolButton *botonconfigurar = findChild<QToolButton *>("mui_configurar");
00346 if (botonconfigurar)
00347 botonconfigurar->setChecked(check);
00348 _depura("END Listado::on_mui_list_toogledConfig", 0);
00349 }
00350
00351
00353
00355 void Listado::hideBotonera() {
00356 _depura("Listado::hideBotonera", 0);
00357 QWidget *botonera = findChild<QWidget *>("m_botonera");
00358 if (botonera)
00359 botonera->hide();
00360 _depura("END Listado::hideBotonera", 0);
00361 }
00362
00363
00365
00367 void Listado::showBotonera() {
00368 _depura("Listado::showBotonera", 0);
00369 QWidget *botonera = findChild<QWidget *>("m_botonera");
00370 if (botonera)
00371 botonera->show();
00372 _depura("END Listado::showBotonera", 0);
00373 }
00374
00375
00377
00379 void Listado::hideBusqueda() {
00380 _depura("Listado::hideBusqueda", 0);
00381 QWidget *busqueda = findChild<QWidget *>("m_busqueda");
00382 if (busqueda)
00383 busqueda->hide();
00384 _depura("END Listado::hideBusqueda", 0);
00385 }
00386
00387
00389
00391 void Listado::showBusqueda() {
00392 _depura("Listado::showBusqueda", 0);
00393 QWidget *busqueda = findChild<QWidget *>("m_busqueda");
00394 if (busqueda)
00395 busqueda->show();
00396 _depura("END Listado::showBusqueda", 0);
00397 }
00398
00400
00403 void Listado::trataPermisos(QString nomtabla) {
00404 _depura("Listado::trataPermisos", 0);
00405
00406 if (!empresaBase()->has_table_privilege(nomtabla, "INSERT")) {
00408 QToolButton *b = findChild<QToolButton *>("mui_crear");
00409 if (b) b->setDisabled(TRUE);
00410 QToolButton *c = findChild<QToolButton *>("mui_importar");
00411 if (c) c->setDisabled(TRUE);
00412 QToolButton *d = findChild<QToolButton *>("mui_exportar");
00413 if (d) d->setDisabled(TRUE);
00414 }
00415
00416
00417
00418 if (!empresaBase()->has_table_privilege(nomtabla, "UPDATE")) {
00420 QToolButton *b = findChild<QToolButton *>("mui_editar");
00421 if (b) b->setDisabled(TRUE);
00422 QToolButton *c = findChild<QToolButton *>("mui_borrar");
00423 if (c) c->setDisabled(TRUE);
00424 QToolButton *e = findChild<QToolButton *>("mui_importar");
00425 if (e) e->setDisabled(TRUE);
00426 QToolButton *d = findChild<QToolButton *>("mui_exportar");
00427 if (d) d->setDisabled(TRUE);
00428 }
00429
00430
00431 _depura("END Listado::trataPermisos", 0);
00432 }
00433