Reorganize project structure and update .pro file
This commit is contained in:
+22
-22
@@ -15,7 +15,7 @@ INCLUDEPATH = \
|
||||
src/gui/forms \
|
||||
src/models
|
||||
|
||||
FORMS = src/gui/mainwindow.ui \
|
||||
FORMS = src/gui/mainwindow/mainwindow.ui \
|
||||
src/gui/forms/formbaselist.ui \
|
||||
src/gui/forms/formbudget.ui \
|
||||
src/gui/forms/formbudgetlist.ui \
|
||||
@@ -30,15 +30,15 @@ FORMS = src/gui/mainwindow.ui \
|
||||
src/gui/forms/formbase.ui
|
||||
|
||||
|
||||
HEADERS = src/gui/mainwindow.h \
|
||||
HEADERS = src/gui/mainwindow/mainwindow.h \
|
||||
src/gui/forms/formbaselist.h \
|
||||
src/gui/forms/formbudgetlist.h \
|
||||
src/models/treemodel.h \
|
||||
itemnumberdelegate.h \
|
||||
qmtreeview.h \
|
||||
itemtextdelegate.h \
|
||||
header.h \
|
||||
mapplication.h \
|
||||
src/gui/widgets/itemnumberdelegate.h \
|
||||
src/gui/widgets/qmtreeview.h \
|
||||
src/gui/widgets/itemtextdelegate.h \
|
||||
src/utils/header.h \
|
||||
src/app/mapplication.h \
|
||||
src/gui/forms/formbudget.h \
|
||||
utils/fiebdc.h \
|
||||
utils/filterlineedit.h \
|
||||
@@ -48,7 +48,7 @@ HEADERS = src/gui/mainwindow.h \
|
||||
widget/avatarwidget.h \
|
||||
src/gui/forms/formproduct.h \
|
||||
data/sqltable.h \
|
||||
itemrichtextdelegate.h \
|
||||
src/gui/widgets/itemrichtextdelegate.h \
|
||||
src/gui/forms/dialogcreateenterprise.h \
|
||||
utils/frameless.h \
|
||||
src/gui/forms/dialogopencompany.h \
|
||||
@@ -56,31 +56,31 @@ HEADERS = src/gui/mainwindow.h \
|
||||
src/gui/forms/formelementlist.h \
|
||||
src/gui/forms/formthirdlist.h \
|
||||
widget/mlineeditbutton.h \
|
||||
itemtextpopupdelegate.h \
|
||||
src/gui/widgets/itemtextpopupdelegate.h \
|
||||
widget/lineedittag.h \
|
||||
widget/treemodelcomposeelement.h \
|
||||
itemcomboboxdelegate.h \
|
||||
src/gui/widgets/itemcomboboxdelegate.h \
|
||||
src/gui/widgets/qlistmodel.h \
|
||||
widget/msqlquerymodel.h \
|
||||
src/gui/forms/forminvoiceinlist.h \
|
||||
src/gui/forms/formbase.h \
|
||||
treeitem.h
|
||||
src/models/treeitem.h
|
||||
|
||||
|
||||
RESOURCES = editabletreemodel.qrc
|
||||
|
||||
|
||||
SOURCES = src/gui/mainwindow.cpp \
|
||||
SOURCES = src/gui/mainwindow/mainwindow.cpp \
|
||||
utils/dbutils.cpp \
|
||||
src/gui/forms/formbaselist.cpp \
|
||||
src/gui/forms/formbudgetlist.cpp \
|
||||
src/models/treemodel.cpp \
|
||||
main.cpp \
|
||||
itemnumberdelegate.cpp \
|
||||
qmtreeview.cpp \
|
||||
itemtextdelegate.cpp \
|
||||
header.cpp \
|
||||
mapplication.cpp \
|
||||
src/main.cpp \
|
||||
src/gui/widgets/itemnumberdelegate.cpp \
|
||||
src/gui/widgets/qmtreeview.cpp \
|
||||
src/gui/widgets/itemtextdelegate.cpp \
|
||||
src/utils/header.cpp \
|
||||
src/app/mapplication.cpp \
|
||||
src/gui/forms/formbudget.cpp \
|
||||
utils/fiebdc.cpp \
|
||||
utils/filterlineedit.cpp \
|
||||
@@ -89,7 +89,7 @@ SOURCES = src/gui/mainwindow.cpp \
|
||||
src/gui/forms/formthird.cpp \
|
||||
widget/avatarwidget.cpp \
|
||||
src/gui/forms/formproduct.cpp \
|
||||
itemrichtextdelegate.cpp \
|
||||
src/gui/widgets/itemrichtextdelegate.cpp \
|
||||
src/gui/forms/dialogcreateenterprise.cpp \
|
||||
utils/frameless.cpp \
|
||||
src/gui/forms/dialogopencompany.cpp \
|
||||
@@ -97,15 +97,15 @@ SOURCES = src/gui/mainwindow.cpp \
|
||||
src/gui/forms/formelementlist.cpp \
|
||||
src/gui/forms/formthirdlist.cpp \
|
||||
widget/mlineeditbutton.cpp \
|
||||
itemtextpopupdelegate.cpp \
|
||||
src/gui/widgets/itemtextpopupdelegate.cpp \
|
||||
widget/lineedittag.cpp \
|
||||
widget/treemodelcomposeelement.cpp \
|
||||
itemcomboboxdelegate.cpp \
|
||||
src/gui/widgets/itemcomboboxdelegate.cpp \
|
||||
src/gui/widgets/qlistmodel.cpp \
|
||||
widget/msqlquerymodel.cpp \
|
||||
src/gui/forms/forminvoiceinlist.cpp \
|
||||
src/gui/forms/formbase.cpp \
|
||||
treeitem.cpp
|
||||
src/models/treeitem.cpp
|
||||
|
||||
|
||||
# install
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
#include "formelementlist.h"
|
||||
#include "qpainter.h"
|
||||
#include "ui_formelementlist.h"
|
||||
#include "formproduct.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mapplication.h"
|
||||
#include "msqlquerymodel.h"
|
||||
#include "utils/filtertableheader.h"
|
||||
#include "gui/formbaselist.h"
|
||||
|
||||
#include <QDrag>
|
||||
|
||||
|
||||
formElementList::formElementList(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::formElementList)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
mModel = new MSqlQueryModel(this);
|
||||
ui->tableView->setModel(mModel);
|
||||
updateList();
|
||||
ui->tableView->setColumnWidth(0, 150);
|
||||
ui->tableView->setColumnWidth(1, 80);
|
||||
ui->tableView->setColumnWidth(2, 120);
|
||||
ui->tableView->setColumnWidth(3, 350);
|
||||
ui->tableView->setColumnWidth(4, 80);
|
||||
ui->tableView->setColumnWidth(5, 80);
|
||||
ui->tableView->setColumnWidth(6, 40);
|
||||
|
||||
// Set up filter row
|
||||
auto *m_tableHeader = new FilterTableHeader(ui->tableView);
|
||||
ui->tableView->setHorizontalHeader(m_tableHeader);
|
||||
m_tableHeader->setFilter(0, "");
|
||||
m_tableHeader->setFocusColumn(0);
|
||||
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(0, Qt::Horizontal, tr("Tipo"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(1, Qt::Horizontal, tr("Clase"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(2, Qt::Horizontal, tr("Código"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(3, Qt::Horizontal, tr("Resumen"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(4, Qt::Horizontal, tr("Coste"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(5, Qt::Horizontal, tr("Venta"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(6, Qt::Horizontal, tr("Activo"));
|
||||
|
||||
ui->tableView->setDragEnabled(true); // Habilita el drag
|
||||
connect(ui->tableView, &QTableView::pressed, this, &formElementList::startDrag);
|
||||
}
|
||||
|
||||
formElementList::~formElementList()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void formElementList::updateList()
|
||||
{
|
||||
dApp->Enterprise().open();
|
||||
mModel->setQuery("SELECT TYPE1, TYPE2, CODE, TITLE, PURCHASE_PRICE, SALE_PRICE, STATE FROM ELEMENT" /*" ORDER BY CODE ASC"*/,
|
||||
dApp->Enterprise());
|
||||
dApp->Enterprise().close();
|
||||
}
|
||||
|
||||
void formElementList::on_buttonNew_released()
|
||||
{
|
||||
formProduct *form = dApp->mainWindow()->createFormProduct(); // sustistuir por Mainwindow::createFormProduct();
|
||||
form->show();
|
||||
}
|
||||
|
||||
void formElementList::on_buttonEdit_released()
|
||||
{
|
||||
openDocument(ui->tableView->currentIndex());
|
||||
}
|
||||
|
||||
void formElementList::on_buttonClone_released()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void formElementList::on_buttonDelete_released()
|
||||
{
|
||||
QModelIndex index = ui->tableView->currentIndex();
|
||||
QAbstractItemModel *model = const_cast<QAbstractItemModel*>(index.model()); // Obtén el modelo asociado
|
||||
if (index.column() != 0)
|
||||
{
|
||||
//index = index.parent().child(index.row(), 0);
|
||||
index = model->index(index.row(), 0, index.parent());
|
||||
}
|
||||
QString ID = index.data().toString();
|
||||
QModelIndex parentIndex = index.parent();
|
||||
QModelIndex childIndex = model->index(index.row(), 2, parentIndex); // Obtén el índice del hijo
|
||||
int type = childIndex.data().toInt(); // Accede al dato
|
||||
//int type = index.parent().child(index.row(), 2).data().toInt();
|
||||
|
||||
dApp->Enterprise().open();
|
||||
QSqlQuery qry = QSqlQuery(dApp->Enterprise());
|
||||
|
||||
/*
|
||||
if (index.parent().child(index.row(), 2).data().toInt() == 0)
|
||||
{
|
||||
// TODO: borrar la composición
|
||||
if(!qry.exec(QString("DELETE FROM ELEMENTCOMPOSITION WHERE CODE = '%1';").arg(ID)))
|
||||
{
|
||||
qDebug() << "Error ejecutando el query: " << qry.lastError().text() << "\n";
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if(!qry.exec(QString("DELETE FROM ELEMENT WHERE CODE = '%1';").arg(ID)))
|
||||
{
|
||||
qDebug() << "Error ejecutando el query: " << qry.lastError().text() << "\n";
|
||||
}
|
||||
updateList();
|
||||
|
||||
error:
|
||||
dApp->Enterprise().close();
|
||||
}
|
||||
|
||||
void formElementList::on_buttonUpdate_released()
|
||||
{
|
||||
updateList();
|
||||
}
|
||||
|
||||
void formElementList::on_tableView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
openDocument(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void formElementList::openDocument(QModelIndex index)
|
||||
{
|
||||
QAbstractItemModel *model = ui->tableView->model();
|
||||
//QModelIndex item = index;
|
||||
formProduct *form = dApp->mainWindow()->createFormProduct();
|
||||
|
||||
//if (index.column() != 2)
|
||||
// item = index.parent().child(index.row(), 2);
|
||||
form->openDocument(model->index(index.row(), 2).data().toString());// item.data().toString());
|
||||
form->show();
|
||||
}
|
||||
|
||||
|
||||
void formElementList::startDrag(const QModelIndex &index) {
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
// Crear datos MIME
|
||||
QMimeData *mimeData = new QMimeData();
|
||||
QString data = mModel->data(index).toString();
|
||||
mimeData->setText(data);
|
||||
|
||||
// Iniciar arrastre
|
||||
QDrag *drag = new QDrag(ui->tableView);
|
||||
drag->setMimeData(mimeData);
|
||||
|
||||
// Crear un ícono para el cursor
|
||||
QPixmap pixmap(100, 30);
|
||||
pixmap.fill(Qt::transparent); // Fondo transparente
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.setBrush(Qt::yellow);
|
||||
painter.drawRoundedRect(0, 0, pixmap.width(), pixmap.height(), 5, 5);
|
||||
|
||||
painter.setPen(Qt::black);
|
||||
painter.drawText(pixmap.rect(), Qt::AlignCenter, data);
|
||||
painter.end();
|
||||
|
||||
drag->setPixmap(pixmap); // Asignar el ícono al cursor
|
||||
//drag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2)); // Centro del ícono como punto caliente
|
||||
|
||||
|
||||
drag->exec(Qt::MoveAction);
|
||||
}
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
#include "formelementlist.h"
|
||||
#include "qpainter.h"
|
||||
#include "ui_formelementlist.h"
|
||||
#include "formproduct.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mapplication.h"
|
||||
#include "msqlquerymodel.h"
|
||||
#include "utils/filtertableheader.h"
|
||||
#include "gui/formbaselist.h"
|
||||
|
||||
#include <QDrag>
|
||||
|
||||
|
||||
formElementList::formElementList(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::formElementList)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
mModel = new MSqlQueryModel(this);
|
||||
ui->tableView->setModel(mModel);
|
||||
updateList();
|
||||
ui->tableView->setColumnWidth(0, 150);
|
||||
ui->tableView->setColumnWidth(1, 80);
|
||||
ui->tableView->setColumnWidth(2, 120);
|
||||
ui->tableView->setColumnWidth(3, 350);
|
||||
ui->tableView->setColumnWidth(4, 80);
|
||||
ui->tableView->setColumnWidth(5, 80);
|
||||
ui->tableView->setColumnWidth(6, 40);
|
||||
|
||||
// Set up filter row
|
||||
auto *m_tableHeader = new FilterTableHeader(ui->tableView);
|
||||
ui->tableView->setHorizontalHeader(m_tableHeader);
|
||||
m_tableHeader->setFilter(0, "");
|
||||
m_tableHeader->setFocusColumn(0);
|
||||
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(0, Qt::Horizontal, tr("Tipo"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(1, Qt::Horizontal, tr("Clase"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(2, Qt::Horizontal, tr("Código"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(3, Qt::Horizontal, tr("Resumen"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(4, Qt::Horizontal, tr("Coste"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(5, Qt::Horizontal, tr("Venta"));
|
||||
ui->tableView->horizontalHeader()->model()->setHeaderData(6, Qt::Horizontal, tr("Activo"));
|
||||
|
||||
ui->tableView->setDragEnabled(true); // Habilita el drag
|
||||
connect(ui->tableView, &QTableView::pressed, this, &formElementList::startDrag);
|
||||
}
|
||||
|
||||
formElementList::~formElementList()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void formElementList::updateList()
|
||||
{
|
||||
dApp->Enterprise().open();
|
||||
mModel->setQuery("SELECT TYPE1, TYPE2, CODE, TITLE, PURCHASE_PRICE, SALE_PRICE, STATE FROM ELEMENT" /*" ORDER BY CODE ASC"*/,
|
||||
dApp->Enterprise());
|
||||
dApp->Enterprise().close();
|
||||
}
|
||||
|
||||
void formElementList::on_buttonNew_released()
|
||||
{
|
||||
formProduct *form = dApp->mainWindow()->createFormProduct(); // sustistuir por Mainwindow::createFormProduct();
|
||||
form->show();
|
||||
}
|
||||
|
||||
void formElementList::on_buttonEdit_released()
|
||||
{
|
||||
openDocument(ui->tableView->currentIndex());
|
||||
}
|
||||
|
||||
void formElementList::on_buttonClone_released()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void formElementList::on_buttonDelete_released()
|
||||
{
|
||||
QModelIndex index = ui->tableView->currentIndex();
|
||||
QAbstractItemModel *model = const_cast<QAbstractItemModel*>(index.model()); // Obtén el modelo asociado
|
||||
if (index.column() != 0)
|
||||
{
|
||||
//index = index.parent().child(index.row(), 0);
|
||||
index = model->index(index.row(), 0, index.parent());
|
||||
}
|
||||
QString ID = index.data().toString();
|
||||
QModelIndex parentIndex = index.parent();
|
||||
QModelIndex childIndex = model->index(index.row(), 2, parentIndex); // Obtén el índice del hijo
|
||||
int type = childIndex.data().toInt(); // Accede al dato
|
||||
//int type = index.parent().child(index.row(), 2).data().toInt();
|
||||
|
||||
dApp->Enterprise().open();
|
||||
QSqlQuery qry = QSqlQuery(dApp->Enterprise());
|
||||
|
||||
/*
|
||||
if (index.parent().child(index.row(), 2).data().toInt() == 0)
|
||||
{
|
||||
// TODO: borrar la composición
|
||||
if(!qry.exec(QString("DELETE FROM ELEMENTCOMPOSITION WHERE CODE = '%1';").arg(ID)))
|
||||
{
|
||||
qDebug() << "Error ejecutando el query: " << qry.lastError().text() << "\n";
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if(!qry.exec(QString("DELETE FROM ELEMENT WHERE CODE = '%1';").arg(ID)))
|
||||
{
|
||||
qDebug() << "Error ejecutando el query: " << qry.lastError().text() << "\n";
|
||||
}
|
||||
updateList();
|
||||
|
||||
error:
|
||||
dApp->Enterprise().close();
|
||||
}
|
||||
|
||||
void formElementList::on_buttonUpdate_released()
|
||||
{
|
||||
updateList();
|
||||
}
|
||||
|
||||
void formElementList::on_tableView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
openDocument(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void formElementList::openDocument(QModelIndex index)
|
||||
{
|
||||
QAbstractItemModel *model = ui->tableView->model();
|
||||
//QModelIndex item = index;
|
||||
formProduct *form = dApp->mainWindow()->createFormProduct();
|
||||
|
||||
//if (index.column() != 2)
|
||||
// item = index.parent().child(index.row(), 2);
|
||||
form->openDocument(model->index(index.row(), 2).data().toString());// item.data().toString());
|
||||
form->show();
|
||||
}
|
||||
|
||||
|
||||
void formElementList::startDrag(const QModelIndex &index) {
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
// Crear datos MIME
|
||||
QMimeData *mimeData = new QMimeData();
|
||||
QString data = mModel->data(index).toString();
|
||||
mimeData->setText(data);
|
||||
|
||||
// Iniciar arrastre
|
||||
QDrag *drag = new QDrag(ui->tableView);
|
||||
drag->setMimeData(mimeData);
|
||||
|
||||
// Crear un ícono para el cursor
|
||||
QPixmap pixmap(100, 30);
|
||||
pixmap.fill(Qt::transparent); // Fondo transparente
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.setBrush(Qt::yellow);
|
||||
painter.drawRoundedRect(0, 0, pixmap.width(), pixmap.height(), 5, 5);
|
||||
|
||||
painter.setPen(Qt::black);
|
||||
painter.drawText(pixmap.rect(), Qt::AlignCenter, data);
|
||||
painter.end();
|
||||
|
||||
drag->setPixmap(pixmap); // Asignar el ícono al cursor
|
||||
//drag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2)); // Centro del ícono como punto caliente
|
||||
|
||||
|
||||
drag->exec(Qt::MoveAction);
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#ifndef FORMPRODUCT_H
|
||||
#define FORMPRODUCT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "formbase.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class formProduct;
|
||||
}
|
||||
|
||||
class formProduct : public formBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//explicit formProduct(QWidget *parent = 0);
|
||||
explicit formProduct(QString aID = "", int aEditMode = 0, QWidget *parent = nullptr);
|
||||
~formProduct();
|
||||
|
||||
void newDocument() override {}
|
||||
void openDocument(QString id) override;
|
||||
void closeDocument() override;
|
||||
void save() override;
|
||||
bool needsave() override { return mNeedSave; }
|
||||
void setEditMode(bool aMode) override {}
|
||||
|
||||
public slots:
|
||||
void on_ModelSetData(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
|
||||
private slots:
|
||||
void on_editPC_valueChanged(double arg1);
|
||||
void on_editMargin_valueChanged(double arg1);
|
||||
void on_editPV_valueChanged(double arg1);
|
||||
void on_comboIVA_currentIndexChanged(const QString &arg1);
|
||||
void on_editPV_editingFinished();
|
||||
void on_buttonSave_released();
|
||||
|
||||
void on_editPVIVA_valueChanged(const QString &arg1);
|
||||
|
||||
void on_comboType2_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::formProduct *ui;
|
||||
bool editMode;
|
||||
|
||||
void CalculatePrice();
|
||||
bool InsertElement(QString ID, QModelIndex index);
|
||||
void setLineType(QString type, QModelIndex index);
|
||||
void setCellText(QString val, QModelIndex index, int col);
|
||||
void setEditMode();
|
||||
void setComposeElement(bool val);
|
||||
};
|
||||
|
||||
#endif // FORMPRODUCT_H
|
||||
Reference in New Issue
Block a user