.
This commit is contained in:
Vendored
Vendored
Vendored
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
TARGET = QtXlsx
|
||||
|
||||
QMAKE_DOCS = $$PWD/doc/qtxlsx.qdocconf
|
||||
|
||||
load(qt_module)
|
||||
|
||||
CONFIG += build_xlsx_lib
|
||||
include(qtxlsx.pri)
|
||||
|
||||
#Define this macro if you want to run tests, so more AIPs will get exported.
|
||||
#DEFINES += XLSX_TEST
|
||||
|
||||
QMAKE_TARGET_COMPANY = "Debao Zhang"
|
||||
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2013-2014 Debao Zhang <hello@debao.me>"
|
||||
QMAKE_TARGET_DESCRIPTION = ".Xlsx file wirter for Qt5"
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "cdistributoreditdialog.h"
|
||||
|
||||
#include "xlsxdocument.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QString>
|
||||
@@ -248,3 +250,20 @@ void cDistributorWindow::on_m_lpDistributorList_doubleClicked(const QModelIndex
|
||||
{
|
||||
onEdit();
|
||||
}
|
||||
|
||||
bool cDistributorWindow::canClose()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
void cDistributorWindow::exportList(const QString& szFileName)
|
||||
{
|
||||
// QXlsx::Document xlsx;
|
||||
// xlsx.write("A1", "Hello Qt!");
|
||||
// xlsx.saveAs("c:\\temp\\Test.xlsx");
|
||||
|
||||
QXlsx::Document xlsx;
|
||||
xlsx.write("A1", "Hello Qt!");
|
||||
xlsx.write("B1", "DaWig woa do!");
|
||||
xlsx.saveAs(szFileName);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ public:
|
||||
void addDistributor();
|
||||
void editDistributor();
|
||||
void deleteDistributor();
|
||||
|
||||
bool canClose();
|
||||
|
||||
void exportList(const QString& szFileName);
|
||||
private slots:
|
||||
void on_m_lpDistributorList_clicked(const QModelIndex &index);
|
||||
void on_m_lpDistributorList_doubleClicked(const QModelIndex &index);
|
||||
|
||||
+86
-1
@@ -67,7 +67,7 @@ void cMainWindow::createActions()
|
||||
createAction(m_lpMenuFile, m_lpToolBarFile, &m_lpActionFileOpenProject, ":/icons/normal/Open file.png", ":/icons/hot/Open file.png", ":/icons/disabled/Open file.png", tr("&Open Project..."), QKeySequence::Open, tr("Open a project"), &cMainWindow::onMenuFileOpenProject);
|
||||
createAction(m_lpMenuFile, 0, &m_lpActionFileCloseProject, "", "", "", tr("&Close Project..."), QKeySequence::Close, tr("Close project"), &cMainWindow::onMenuFileCloseProject);
|
||||
createSeparator(m_lpMenuFile, m_lpToolBarFile);
|
||||
createAction(m_lpMenuFile, m_lpToolBarFile, &m_lpActionFileExport, ":/icons/normal/Save file.png",":/icons/hot/Save file.png", ":/icons/disabled/Save file", tr("&Export..."), QKeySequence::UnknownKey, tr("Export project"), &cMainWindow::onMenuFileExport);
|
||||
createAction(m_lpMenuFile, m_lpToolBarFile, &m_lpActionFileExport, ":/icons/normal/Export.png",":/icons/hot/Export.png", ":/icons/disabled/Export.png", tr("&Export..."), QKeySequence::UnknownKey, tr("Export project"), &cMainWindow::onMenuFileExport);
|
||||
createSeparator(m_lpMenuFile, m_lpToolBarFile);
|
||||
createAction(m_lpMenuFile, 0, &m_lpActionFileClose, "", "", "", tr("&Close"), QKeySequence::Quit, tr("Close application"), &cMainWindow::onMenuFileClose);
|
||||
|
||||
@@ -78,6 +78,8 @@ void cMainWindow::createActions()
|
||||
createAction(m_lpMenuDistributor, m_lpToolBarDistributor, &m_lpActionDistributorAdd, ":/icons/normal/Add.png", ":/icons/hot/Add.png", ":/icons/disabled/Add.png", tr("&add distributor..."), QKeySequence::UnknownKey, tr("Add distributor"), &cMainWindow::onMenuDistributorAdd);
|
||||
createAction(m_lpMenuDistributor, m_lpToolBarDistributor, &m_lpActionDistributorEdit, ":/icons/normal/Edit.png", ":/icons/hot/Edit.png", ":/icons/disabled/Edit.png", tr("&edit distributor..."), QKeySequence::UnknownKey, tr("Edit distributor"), &cMainWindow::onMenuDistributorEdit);
|
||||
createAction(m_lpMenuDistributor, m_lpToolBarDistributor, &m_lpActionDistributorDelete, ":/icons/normal/Delete.png", ":/icons/hot/Delete.png", ":/icons/disabled/Delete.png", tr("&delete distributor..."), QKeySequence::UnknownKey, tr("Delete distributor"), &cMainWindow::onMenuDistributorDelete);
|
||||
createSeparator(m_lpMenuDistributor, m_lpToolBarDistributor);
|
||||
createAction(m_lpMenuDistributor, m_lpToolBarDistributor, &m_lpActionDistributorExport, ":/icons/normal/Export.png",":/icons/hot/Export.png", ":/icons/disabled/Export.png", tr("&Export..."), QKeySequence::UnknownKey, tr("Export distributor list"), &cMainWindow::onMenuDistributorExport);
|
||||
|
||||
m_lpMenuParts = menuBar()->addMenu(tr("&Part"));
|
||||
m_lpToolBarParts = addToolBar(tr("Part"));
|
||||
@@ -86,6 +88,8 @@ void cMainWindow::createActions()
|
||||
createAction(m_lpMenuParts, m_lpToolBarParts, &m_lpActionPartsAdd, ":/icons/normal/Add.png", ":/icons/hot/Add.png", ":/icons/disabled/Add.png", tr("&add part..."), QKeySequence::UnknownKey, tr("Add part"), &cMainWindow::onMenuPartsAdd);
|
||||
createAction(m_lpMenuParts, m_lpToolBarParts, &m_lpActionPartsEdit, ":/icons/normal/Edit.png", ":/icons/hot/Edit.png", ":/icons/disabled/Edit.png", tr("&edit part..."), QKeySequence::UnknownKey, tr("Edit part"), &cMainWindow::onMenuPartsEdit);
|
||||
createAction(m_lpMenuParts, m_lpToolBarParts, &m_lpActionPartsDelete, ":/icons/normal/Delete.png", ":/icons/hot/Delete.png", ":/icons/disabled/Delete.png", tr("&delete part..."), QKeySequence::UnknownKey, tr("Delete part"), &cMainWindow::onMenuPartsDelete);
|
||||
createSeparator(m_lpMenuParts, m_lpToolBarParts);
|
||||
createAction(m_lpMenuParts, m_lpToolBarParts, &m_lpActionPartsExport, ":/icons/normal/Export.png",":/icons/hot/Export.png", ":/icons/disabled/Export.png", tr("&Export..."), QKeySequence::UnknownKey, tr("Export parts"), &cMainWindow::onMenuPartsExport);
|
||||
|
||||
m_lpMenuPartlist = menuBar()->addMenu(tr("Part&list"));
|
||||
m_lpToolBarPartlist = addToolBar(tr("Partlist"));
|
||||
@@ -101,6 +105,8 @@ void cMainWindow::createActions()
|
||||
createAction(m_lpMenuPartlist, m_lpToolBarPartlist, &m_lpActionPartlistPartAdd, ":/icons/normal/Add.png", ":/icons/hot/Add.png", ":/icons/disabled/Add.png", tr("&add part..."), QKeySequence::UnknownKey, tr("Add part"), &cMainWindow::onMenuPartlistPartAdd);
|
||||
createAction(m_lpMenuPartlist, m_lpToolBarPartlist, &m_lpActionPartlistPartEdit, ":/icons/normal/Edit.png", ":/icons/hot/Edit.png", ":/icons/disabled/Edit.png", tr("&edit part..."), QKeySequence::UnknownKey, tr("Edit part"), &cMainWindow::onMenuPartlistPartEdit);
|
||||
createAction(m_lpMenuPartlist, m_lpToolBarPartlist, &m_lpActionPartlistPartDelete, ":/icons/normal/Delete.png", ":/icons/hot/Delete.png", ":/icons/disabled/Delete.png", tr("&delete part..."), QKeySequence::UnknownKey, tr("Delete part"), &cMainWindow::onMenuPartlistPartDelete);
|
||||
createSeparator(m_lpMenuPartlist, m_lpToolBarPartlist);
|
||||
createAction(m_lpMenuPartlist, m_lpToolBarPartlist, &m_lpActionPartlistExport, ":/icons/normal/Export.png",":/icons/hot/Export.png", ":/icons/disabled/Export.png", tr("&Export..."), QKeySequence::UnknownKey, tr("Export part list"), &cMainWindow::onMenuPartlistExport);
|
||||
}
|
||||
|
||||
cMainWindow::~cMainWindow()
|
||||
@@ -425,6 +431,12 @@ void cMainWindow::onMenuDistributorDelete()
|
||||
m_lpDistributorWindow->deleteDistributor();
|
||||
}
|
||||
|
||||
void cMainWindow::onMenuDistributorExport()
|
||||
{
|
||||
if(m_lpDistributorWindow)
|
||||
m_lpDistributorWindow->exportList("c:\\temp\\test99.xlsx");
|
||||
}
|
||||
|
||||
void cMainWindow::onMenuPartsShow()
|
||||
{
|
||||
if(!m_lpPartWindow)
|
||||
@@ -463,6 +475,10 @@ void cMainWindow::onMenuPartsDelete()
|
||||
m_lpPartWindow->deletePart();
|
||||
}
|
||||
|
||||
void cMainWindow::onMenuPartsExport()
|
||||
{
|
||||
}
|
||||
|
||||
void cMainWindow::updateMenu()
|
||||
{
|
||||
QWidget* lpWidget = ui->m_lpMainTab->currentWidget();
|
||||
@@ -472,11 +488,13 @@ void cMainWindow::updateMenu()
|
||||
m_lpActionDistributorAdd->setEnabled(false);
|
||||
m_lpActionDistributorEdit->setEnabled(false);
|
||||
m_lpActionDistributorDelete->setEnabled(false);
|
||||
m_lpActionDistributorExport->setEnabled(false);
|
||||
|
||||
m_lpActionPartsShow->setEnabled(true);
|
||||
m_lpActionPartsAdd->setEnabled(false);
|
||||
m_lpActionPartsEdit->setEnabled(false);
|
||||
m_lpActionPartsDelete->setEnabled(false);
|
||||
m_lpActionPartsExport->setEnabled(false);
|
||||
|
||||
m_lpActionPartlistNew->setEnabled(true);
|
||||
m_lpActionPartlistOpen->setEnabled(true);
|
||||
@@ -486,6 +504,7 @@ void cMainWindow::updateMenu()
|
||||
m_lpActionPartlistPartAdd->setEnabled(false);
|
||||
m_lpActionPartlistPartEdit->setEnabled(false);
|
||||
m_lpActionPartlistPartDelete->setEnabled(false);
|
||||
m_lpActionPartlistExport->setEnabled(false);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -498,6 +517,7 @@ void cMainWindow::updateMenu()
|
||||
{
|
||||
m_lpActionDistributorShow->setEnabled(false);
|
||||
m_lpActionDistributorAdd->setEnabled(true);
|
||||
m_lpActionDistributorExport->setEnabled(true);
|
||||
if(lpDistributorWindow->somethingSelected())
|
||||
{
|
||||
m_lpActionDistributorEdit->setEnabled(true);
|
||||
@@ -513,6 +533,7 @@ void cMainWindow::updateMenu()
|
||||
m_lpActionPartsAdd->setEnabled(false);
|
||||
m_lpActionPartsEdit->setEnabled(false);
|
||||
m_lpActionPartsDelete->setEnabled(false);
|
||||
m_lpActionPartsExport->setEnabled(false);
|
||||
|
||||
m_lpActionPartlistNew->setEnabled(true);
|
||||
m_lpActionPartlistOpen->setEnabled(true);
|
||||
@@ -522,6 +543,7 @@ void cMainWindow::updateMenu()
|
||||
m_lpActionPartlistPartAdd->setEnabled(false);
|
||||
m_lpActionPartlistPartEdit->setEnabled(false);
|
||||
m_lpActionPartlistPartDelete->setEnabled(false);
|
||||
m_lpActionPartlistExport->setEnabled(false);
|
||||
}
|
||||
else if(lpPartWindow)
|
||||
{
|
||||
@@ -537,11 +559,13 @@ void cMainWindow::updateMenu()
|
||||
m_lpActionPartsEdit->setEnabled(false);
|
||||
m_lpActionPartsDelete->setEnabled(false);
|
||||
}
|
||||
m_lpActionPartsExport->setEnabled(true);
|
||||
|
||||
m_lpActionDistributorShow->setEnabled(true);
|
||||
m_lpActionDistributorAdd->setEnabled(false);
|
||||
m_lpActionDistributorEdit->setEnabled(false);
|
||||
m_lpActionDistributorDelete->setEnabled(false);
|
||||
m_lpActionDistributorExport->setEnabled(false);
|
||||
|
||||
m_lpActionPartlistNew->setEnabled(true);
|
||||
m_lpActionPartlistOpen->setEnabled(true);
|
||||
@@ -551,6 +575,7 @@ void cMainWindow::updateMenu()
|
||||
m_lpActionPartlistPartAdd->setEnabled(false);
|
||||
m_lpActionPartlistPartEdit->setEnabled(false);
|
||||
m_lpActionPartlistPartDelete->setEnabled(false);
|
||||
m_lpActionPartlistExport->setEnabled(false);
|
||||
}
|
||||
else if(lpPartlistWindow)
|
||||
{
|
||||
@@ -559,16 +584,19 @@ void cMainWindow::updateMenu()
|
||||
m_lpActionPartlistClose->setEnabled(true);
|
||||
m_lpActionPartlistSave->setEnabled(lpPartlistWindow->somethingChanged());
|
||||
m_lpActionPartlistSaveAs->setEnabled(true);
|
||||
m_lpActionPartlistExport->setEnabled(true);
|
||||
|
||||
m_lpActionDistributorShow->setEnabled(true);
|
||||
m_lpActionDistributorAdd->setEnabled(false);
|
||||
m_lpActionDistributorEdit->setEnabled(false);
|
||||
m_lpActionDistributorDelete->setEnabled(false);
|
||||
m_lpActionDistributorExport->setEnabled(false);
|
||||
|
||||
m_lpActionPartsShow->setEnabled(true);
|
||||
m_lpActionPartsAdd->setEnabled(false);
|
||||
m_lpActionPartsEdit->setEnabled(false);
|
||||
m_lpActionPartsDelete->setEnabled(false);
|
||||
m_lpActionPartsExport->setEnabled(false);
|
||||
|
||||
m_lpActionPartlistPartAdd->setEnabled(true);
|
||||
if(lpPartlistWindow->somethingSelected())
|
||||
@@ -760,20 +788,77 @@ void cMainWindow::onMenuPartlistSaveAs()
|
||||
|
||||
void cMainWindow::onMenuPartlistPartAdd()
|
||||
{
|
||||
cPartlistWindow* lpPartlistWindow = qobject_cast<cPartlistWindow*>(ui->m_lpMainTab->widget(ui->m_lpMainTab->currentIndex()));
|
||||
|
||||
if(!lpPartlistWindow)
|
||||
return;
|
||||
|
||||
lpPartlistWindow->partAdd();
|
||||
}
|
||||
|
||||
void cMainWindow::onMenuPartlistPartEdit()
|
||||
{
|
||||
cPartlistWindow* lpPartlistWindow = qobject_cast<cPartlistWindow*>(ui->m_lpMainTab->widget(ui->m_lpMainTab->currentIndex()));
|
||||
|
||||
if(!lpPartlistWindow)
|
||||
return;
|
||||
|
||||
lpPartlistWindow->partEdit();
|
||||
}
|
||||
|
||||
void cMainWindow::onMenuPartlistPartDelete()
|
||||
{
|
||||
cPartlistWindow* lpPartlistWindow = qobject_cast<cPartlistWindow*>(ui->m_lpMainTab->widget(ui->m_lpMainTab->currentIndex()));
|
||||
|
||||
if(!lpPartlistWindow)
|
||||
return;
|
||||
|
||||
lpPartlistWindow->partDelete();
|
||||
}
|
||||
|
||||
void cMainWindow::onMenuPartlistExport()
|
||||
{
|
||||
}
|
||||
|
||||
void cMainWindow::partlistChanged(QWidget* /*lpWidget*/)
|
||||
{
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
void cMainWindow::on_m_lpMainTab_tabCloseRequested(int index)
|
||||
{
|
||||
QWidget* lpWidget = ui->m_lpMainTab->widget(index);
|
||||
if(!lpWidget)
|
||||
return;
|
||||
|
||||
cDistributorWindow* lpDistributorWindow = qobject_cast<cDistributorWindow*>(lpWidget);
|
||||
cPartWindow* lpPartWindow = qobject_cast<cPartWindow*>(lpWidget);
|
||||
cPartlistWindow* lpPartlistWindow = qobject_cast<cPartlistWindow*>(lpWidget);
|
||||
|
||||
if(lpDistributorWindow)
|
||||
{
|
||||
if(lpDistributorWindow->canClose())
|
||||
{
|
||||
delete lpDistributorWindow;
|
||||
m_lpDistributorWindow = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(lpPartWindow)
|
||||
{
|
||||
if(lpPartWindow->canClose())
|
||||
{
|
||||
delete lpPartWindow;
|
||||
m_lpPartWindow = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(lpPartlistWindow)
|
||||
{
|
||||
if(lpPartlistWindow->canClose())
|
||||
delete lpPartlistWindow;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ private:
|
||||
QAction* m_lpActionDistributorAdd;
|
||||
QAction* m_lpActionDistributorEdit;
|
||||
QAction* m_lpActionDistributorDelete;
|
||||
QAction* m_lpActionDistributorExport;
|
||||
|
||||
QMenu* m_lpMenuParts;
|
||||
QToolBar* m_lpToolBarParts;
|
||||
@@ -61,6 +62,7 @@ private:
|
||||
QAction* m_lpActionPartsAdd;
|
||||
QAction* m_lpActionPartsEdit;
|
||||
QAction* m_lpActionPartsDelete;
|
||||
QAction* m_lpActionPartsExport;
|
||||
|
||||
QMenu* m_lpMenuPartlist;
|
||||
QToolBar* m_lpToolBarPartlist;
|
||||
@@ -72,6 +74,7 @@ private:
|
||||
QAction* m_lpActionPartlistPartAdd;
|
||||
QAction* m_lpActionPartlistPartEdit;
|
||||
QAction* m_lpActionPartlistPartDelete;
|
||||
QAction* m_lpActionPartlistExport;
|
||||
|
||||
QSqlDatabase m_db;
|
||||
cDistributorList m_distributorList;
|
||||
@@ -139,11 +142,13 @@ private slots:
|
||||
void onMenuDistributorAdd();
|
||||
void onMenuDistributorEdit();
|
||||
void onMenuDistributorDelete();
|
||||
void onMenuDistributorExport();
|
||||
|
||||
void onMenuPartsShow();
|
||||
void onMenuPartsAdd();
|
||||
void onMenuPartsEdit();
|
||||
void onMenuPartsDelete();
|
||||
void onMenuPartsExport();
|
||||
|
||||
void onMenuPartlistNew();
|
||||
void onMenuPartlistOpen();
|
||||
@@ -153,6 +158,7 @@ private slots:
|
||||
void onMenuPartlistPartAdd();
|
||||
void onMenuPartlistPartEdit();
|
||||
void onMenuPartlistPartDelete();
|
||||
void onMenuPartlistExport();
|
||||
|
||||
void on_m_lpMainTab_currentChanged(int);
|
||||
|
||||
@@ -165,6 +171,7 @@ private slots:
|
||||
|
||||
void partlistChanged(QWidget* lpWidget);
|
||||
void partlistSelectionChanged(const QModelIndex& index);
|
||||
void on_m_lpMainTab_tabCloseRequested(int index);
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
||||
+14
-10
@@ -30,7 +30,7 @@ QWidget* cPartListItemDelegate::createEditor( QWidget *parent, const QStyleOptio
|
||||
QTextEdit* lpEdit = new QTextEdit(parent);
|
||||
return(lpEdit);
|
||||
}
|
||||
case 3: // distributor
|
||||
case 4: // distributor
|
||||
{
|
||||
cPartDistributorList* lpList = qvariant_cast<cPartDistributorList*>(index.data(Qt::UserRole+2));
|
||||
QComboBox* lpComboBox = new QComboBox(parent);
|
||||
@@ -48,7 +48,7 @@ QWidget* cPartListItemDelegate::createEditor( QWidget *parent, const QStyleOptio
|
||||
}
|
||||
return(lpComboBox);
|
||||
}
|
||||
case 4: // state
|
||||
case 5: // state
|
||||
{
|
||||
QComboBox* lpComboBox = new QComboBox(parent);
|
||||
|
||||
@@ -60,7 +60,7 @@ QWidget* cPartListItemDelegate::createEditor( QWidget *parent, const QStyleOptio
|
||||
|
||||
return(lpComboBox);
|
||||
}
|
||||
case 5: // price
|
||||
case 6: // price
|
||||
{
|
||||
QDoubleSpinBox* lpSpinBox = new QDoubleSpinBox(parent);
|
||||
lpSpinBox->setMinimum(0);
|
||||
@@ -68,7 +68,7 @@ QWidget* cPartListItemDelegate::createEditor( QWidget *parent, const QStyleOptio
|
||||
lpSpinBox->setDecimals(2);
|
||||
return(lpSpinBox);
|
||||
}
|
||||
case 6: // description
|
||||
case 7: // description
|
||||
return(QStyledItemDelegate::createEditor(parent, option, index));
|
||||
default:
|
||||
return(0);
|
||||
@@ -108,10 +108,10 @@ void cPartListItemDelegate::setEditorData ( QWidget *editor, const QModelIndex &
|
||||
lpTextEdit->setText(list.join("\n"));
|
||||
}
|
||||
break;
|
||||
case 3: // distributor
|
||||
case 4: // distributor
|
||||
lpComboBox->setCurrentText(index.data(Qt::EditRole).toString());
|
||||
break;
|
||||
case 4: // state
|
||||
case 5: // state
|
||||
lpComboBox->setCurrentText(index.data(Qt::EditRole).toString());
|
||||
break;
|
||||
default:
|
||||
@@ -138,23 +138,27 @@ void cPartListItemDelegate::setModelData ( QWidget *editor, QAbstractItemModel *
|
||||
list1.append(list.at(x));
|
||||
}
|
||||
model->setData(index, list1.join(", "), Qt::EditRole);
|
||||
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)index.model();
|
||||
QStandardItem* lpItem = lpModel->itemFromIndex(lpModel->index(index.row(), 1));
|
||||
lpItem->setText(QString::number(list1.count()));
|
||||
}
|
||||
break;
|
||||
case 3: // distributor
|
||||
case 4: // distributor
|
||||
{
|
||||
cPartDistributor* lpPartDistributor = qvariant_cast<cPartDistributor*>(lpComboBox->currentData());
|
||||
|
||||
model->setData(index, lpComboBox->currentText(), Qt::EditRole);
|
||||
// model->setData(index, QVariant::fromValue(lpPartDistributor), Qt::UserRole+1);
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)index.model();
|
||||
QStandardItem* lpItem = lpModel->itemFromIndex(lpModel->index(index.row(), 5));
|
||||
QStandardItem* lpItem = lpModel->itemFromIndex(lpModel->index(index.row(), 6));
|
||||
lpItem->setText(QString::number(lpPartDistributor->price(), 'f', 2));
|
||||
}
|
||||
break;
|
||||
case 4: // state
|
||||
case 5: // state
|
||||
model->setData(index, lpComboBox->currentText(), Qt::EditRole);
|
||||
break;
|
||||
case 5: // price
|
||||
case 6: // price
|
||||
if(lpSpinBox)
|
||||
{
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)index.model();
|
||||
|
||||
+109
-43
@@ -18,6 +18,7 @@
|
||||
cPartlistWindow::cPartlistWindow(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cPartlistWindow),
|
||||
m_bPartlistLoading(false),
|
||||
m_lpMainTab(0),
|
||||
m_id(-1),
|
||||
m_bSomethingChanged(false),
|
||||
@@ -31,6 +32,8 @@ cPartlistWindow::cPartlistWindow(QWidget *parent) :
|
||||
m_lpPartListModel = new QStandardItemModel(0, 3);
|
||||
ui->m_lpPartList->setModel(m_lpPartListModel);
|
||||
ui->m_lpPartList->setItemDelegate(new cPartListItemDelegate());
|
||||
|
||||
connect(m_lpPartListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(onPartlistItemChanged(QStandardItem*)));
|
||||
}
|
||||
|
||||
cPartlistWindow::~cPartlistWindow()
|
||||
@@ -47,7 +50,8 @@ void cPartlistWindow::setPartlistName(const QString& szPartlistName)
|
||||
{
|
||||
setWindowTitle(szPartlistName);
|
||||
ui->m_lpName->setText(szPartlistName);
|
||||
m_bSomethingChanged = true;
|
||||
if(!m_bPartlistLoading)
|
||||
m_bSomethingChanged = true;
|
||||
}
|
||||
|
||||
QString cPartlistWindow::partlistName()
|
||||
@@ -57,7 +61,8 @@ QString cPartlistWindow::partlistName()
|
||||
|
||||
void cPartlistWindow::setPartlistID(const qint32& id)
|
||||
{
|
||||
m_id = id;
|
||||
m_bPartlistLoading = true;
|
||||
m_id = id;
|
||||
|
||||
QSqlQuery query;
|
||||
|
||||
@@ -67,12 +72,14 @@ void cPartlistWindow::setPartlistID(const qint32& id)
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
m_bPartlistLoading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!query.next())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
m_bPartlistLoading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,6 +115,8 @@ void cPartlistWindow::setPartlistID(const qint32& id)
|
||||
}
|
||||
|
||||
showPartList();
|
||||
|
||||
m_bPartlistLoading = false;
|
||||
}
|
||||
|
||||
void cPartlistWindow::setList(cDistributorList* lpDistributorList, cPartGroupList* lpPartGroupList, cPartList* lpPartList, cPartDistributorList* lpPartDistributorList)
|
||||
@@ -120,6 +129,9 @@ void cPartlistWindow::setList(cDistributorList* lpDistributorList, cPartGroupLis
|
||||
|
||||
void cPartlistWindow::on_m_lpName_textChanged(const QString &arg1)
|
||||
{
|
||||
if(m_bPartlistLoading)
|
||||
return;
|
||||
|
||||
if(m_lpMainTab)
|
||||
{
|
||||
m_bSomethingChanged = true;
|
||||
@@ -214,7 +226,7 @@ void cPartlistWindow::showPartList()
|
||||
m_lpPartListModel->clear();
|
||||
|
||||
QStringList header;
|
||||
header << tr("reference") << ("group") << tr("part") << tr("distributor") << tr("state") << tr("price") << tr("description");
|
||||
header << tr("reference") << tr("count") << tr("group") << tr("part") << tr("distributor") << tr("state") << tr("price") << tr("description");
|
||||
m_lpPartListModel->setHorizontalHeaderLabels(header);
|
||||
ui->m_lpPartList->header()->setMinimumSectionSize(50);
|
||||
|
||||
@@ -259,6 +271,7 @@ QStandardItem* cPartlistWindow::findItem(qint32 itemID)
|
||||
if(lpPartlistItem->id() == itemID)
|
||||
return(lpItem);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
void cPartlistWindow::addItem(cPartlistItem* lpPartlistItem, QStandardItem *lpRoot)
|
||||
@@ -269,18 +282,20 @@ void cPartlistWindow::addItem(cPartlistItem* lpPartlistItem, QStandardItem *lpRo
|
||||
lpItems.append(new QStandardItem);
|
||||
|
||||
lpItems.at(0)->setText(lpPartlistItem->reference());
|
||||
lpItems.at(1)->setText(m_lpPartList->find(lpPartlistItem->partID())->partGroup()->name());
|
||||
lpItems.at(2)->setText(m_lpPartList->find(lpPartlistItem->partID())->name());
|
||||
lpItems.at(2)->setData(lpPartlistItem->partID(), Qt::UserRole);
|
||||
lpItems.at(1)->setText(QString::number(lpPartlistItem->reference().split(", ").count()));
|
||||
lpItems.at(1)->setTextAlignment(Qt::AlignRight);
|
||||
lpItems.at(2)->setText(m_lpPartList->find(lpPartlistItem->partID())->partGroup()->name());
|
||||
lpItems.at(3)->setText(m_lpPartList->find(lpPartlistItem->partID())->name());
|
||||
lpItems.at(3)->setData(lpPartlistItem->partID(), Qt::UserRole);
|
||||
if(lpPartlistItem->distributorID())
|
||||
{
|
||||
lpItems.at(3)->setText(m_lpDistributorList->find(lpPartlistItem->distributorID())->name());
|
||||
lpItems.at(3)->setData(QVariant::fromValue(lpPartlistItem->distributorID()), Qt::UserRole);
|
||||
lpItems.at(4)->setText(m_lpDistributorList->find(lpPartlistItem->distributorID())->name());
|
||||
lpItems.at(4)->setData(QVariant::fromValue(lpPartlistItem->distributorID()), Qt::UserRole);
|
||||
}
|
||||
lpItems.at(4)->setText(lpPartlistItem->stateString());
|
||||
lpItems.at(5)->setText(QString::number(lpPartlistItem->price(), 'f', 2));
|
||||
lpItems.at(5)->setTextAlignment(Qt::AlignRight);
|
||||
lpItems.at(6)->setText(lpPartlistItem->description());
|
||||
lpItems.at(5)->setText(lpPartlistItem->stateString());
|
||||
lpItems.at(6)->setText(QString::number(lpPartlistItem->price(), 'f', 2));
|
||||
lpItems.at(6)->setTextAlignment(Qt::AlignRight);
|
||||
lpItems.at(7)->setText(lpPartlistItem->description());
|
||||
|
||||
for(int z = 0;z < m_lpPartListModel->columnCount();z++)
|
||||
{
|
||||
@@ -293,6 +308,8 @@ void cPartlistWindow::addItem(cPartlistItem* lpPartlistItem, QStandardItem *lpRo
|
||||
lpRoot->appendRow(lpItems);
|
||||
else
|
||||
m_lpPartListModel->appendRow(lpItems);
|
||||
if(!m_bPartlistLoading)
|
||||
m_bSomethingChanged = true;
|
||||
}
|
||||
|
||||
bool cPartlistWindow::save(qint32 id)
|
||||
@@ -320,11 +337,11 @@ bool cPartlistWindow::save(qint32 id)
|
||||
for(int x = 0;x < m_lpPartListModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpReferenceItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 0));
|
||||
QStandardItem* lpPartItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 2));
|
||||
QStandardItem* lpDistributorItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 3));
|
||||
QStandardItem* lpStateItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 4));
|
||||
QStandardItem* lpPriceItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 5));
|
||||
QStandardItem* lpDescriptionItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 6));
|
||||
QStandardItem* lpPartItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 3));
|
||||
QStandardItem* lpDistributorItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 4));
|
||||
QStandardItem* lpStateItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 5));
|
||||
QStandardItem* lpPriceItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 6));
|
||||
QStandardItem* lpDescriptionItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 7));
|
||||
|
||||
QSqlQuery query;
|
||||
cDistributor* lpDistributor = m_lpDistributorList->find(lpDistributorItem->text());
|
||||
@@ -350,6 +367,10 @@ bool cPartlistWindow::save(qint32 id)
|
||||
}
|
||||
}
|
||||
|
||||
m_bSomethingChanged = false;
|
||||
|
||||
partlistChanged(this);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -370,6 +391,21 @@ bool cPartlistWindow::somethingSelected()
|
||||
// onPartEdit();
|
||||
//}
|
||||
|
||||
void cPartlistWindow::partAdd()
|
||||
{
|
||||
onPartAdd();
|
||||
}
|
||||
|
||||
void cPartlistWindow::partEdit()
|
||||
{
|
||||
onPartEdit();
|
||||
}
|
||||
|
||||
void cPartlistWindow::partDelete()
|
||||
{
|
||||
onPartDelete();
|
||||
}
|
||||
|
||||
void cPartlistWindow::on_m_lpPartList_clicked(const QModelIndex &index)
|
||||
{
|
||||
selectionChanged(index);
|
||||
@@ -414,18 +450,20 @@ void cPartlistWindow::onPartAdd()
|
||||
lpItems.append(new QStandardItem);
|
||||
|
||||
lpItems.at(0)->setText(szReference.split("\n").join(", "));
|
||||
lpItems.at(1)->setText(QString::number(szReference.split("\n").join(", ").split(", ").count()));
|
||||
lpItems.at(1)->setTextAlignment(Qt::AlignRight);
|
||||
if(lpPart)
|
||||
{
|
||||
lpItems.at(1)->setText(lpPart->partGroup()->name());
|
||||
lpItems.at(2)->setText(lpPart->name());
|
||||
lpItems.at(2)->setData(lpPart->id(), Qt::UserRole);
|
||||
lpItems.at(2)->setText(lpPart->partGroup()->name());
|
||||
lpItems.at(3)->setText(lpPart->name());
|
||||
lpItems.at(3)->setData(lpPart->id(), Qt::UserRole);
|
||||
}
|
||||
if(lpDistributor)
|
||||
lpItems.at(3)->setText(lpDistributor->name());
|
||||
lpItems.at(4)->setText(szState);
|
||||
lpItems.at(5)->setText(QString::number(dPrice, 'f', 2));
|
||||
lpItems.at(5)->setTextAlignment(Qt::AlignRight);
|
||||
lpItems.at(6)->setText(szDescription);
|
||||
lpItems.at(4)->setText(lpDistributor->name());
|
||||
lpItems.at(5)->setText(szState);
|
||||
lpItems.at(6)->setText(QString::number(dPrice, 'f', 2));
|
||||
lpItems.at(6)->setTextAlignment(Qt::AlignRight);
|
||||
lpItems.at(7)->setText(szDescription);
|
||||
|
||||
for(int z = 0;z < m_lpPartListModel->columnCount();z++)
|
||||
{
|
||||
@@ -437,6 +475,9 @@ void cPartlistWindow::onPartAdd()
|
||||
|
||||
delete lpDialog;
|
||||
|
||||
if(!m_bPartlistLoading)
|
||||
m_bSomethingChanged = true;
|
||||
|
||||
partlistChanged(this);
|
||||
}
|
||||
|
||||
@@ -449,6 +490,7 @@ void cPartlistWindow::onPartEdit()
|
||||
QStandardItem* lpItem = m_lpPartListModel->itemFromIndex(index);
|
||||
|
||||
QStandardItem* lpReferenceItem;
|
||||
QStandardItem* lpCountItem;
|
||||
QStandardItem* lpPartGroupItem;
|
||||
QStandardItem* lpPartItem;
|
||||
QStandardItem* lpDistributorItem;
|
||||
@@ -460,22 +502,24 @@ void cPartlistWindow::onPartEdit()
|
||||
{
|
||||
QStandardItem* lpParent = lpItem->parent();
|
||||
lpReferenceItem = lpParent->child(index.row(), 0);
|
||||
lpPartGroupItem = lpParent->child(index.row(), 1);
|
||||
lpPartItem = lpParent->child(index.row(), 2);
|
||||
lpDistributorItem = lpParent->child(index.row(), 3);
|
||||
lpStateItem = lpParent->child(index.row(), 4);
|
||||
lpPriceItem = lpParent->child(index.row(), 5);
|
||||
lpDescriptionItem = lpParent->child(index.row(), 6);
|
||||
lpCountItem = lpParent->child(index.row(), 1);
|
||||
lpPartGroupItem = lpParent->child(index.row(), 2);
|
||||
lpPartItem = lpParent->child(index.row(), 3);
|
||||
lpDistributorItem = lpParent->child(index.row(), 4);
|
||||
lpStateItem = lpParent->child(index.row(), 5);
|
||||
lpPriceItem = lpParent->child(index.row(), 6);
|
||||
lpDescriptionItem = lpParent->child(index.row(), 7);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpReferenceItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 0));
|
||||
lpPartGroupItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 1));
|
||||
lpPartItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 2));
|
||||
lpDistributorItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 3));
|
||||
lpStateItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 4));
|
||||
lpPriceItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 5));
|
||||
lpDescriptionItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 6));
|
||||
lpCountItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 1));
|
||||
lpPartGroupItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 2));
|
||||
lpPartItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 3));
|
||||
lpDistributorItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 4));
|
||||
lpStateItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 5));
|
||||
lpPriceItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 6));
|
||||
lpDescriptionItem = m_lpPartListModel->itemFromIndex(index.model()->index(index.row(), 7));
|
||||
}
|
||||
|
||||
lpDialog->setValues(lpReferenceItem->text(), lpPartGroupItem->text(), lpPartItem->text(), lpDistributorItem->text(), lpStateItem->text(), lpPriceItem->text().toDouble(), lpDescriptionItem->text());
|
||||
@@ -485,12 +529,13 @@ void cPartlistWindow::onPartEdit()
|
||||
for(int x = 0;x < lpItem->rowCount();x++)
|
||||
{
|
||||
lpReferenceItem = lpItem->child(x, 0);
|
||||
lpPartGroupItem = lpItem->child(x, 1);
|
||||
lpPartItem = lpItem->child(x, 2);
|
||||
lpDistributorItem = lpItem->child(x, 3);
|
||||
lpStateItem = lpItem->child(x, 4);
|
||||
lpPriceItem = lpItem->child(x, 5);
|
||||
lpDescriptionItem = lpItem->child(x, 6);
|
||||
lpCountItem = lpItem->child(x, 1);
|
||||
lpPartGroupItem = lpItem->child(x, 2);
|
||||
lpPartItem = lpItem->child(x, 3);
|
||||
lpDistributorItem = lpItem->child(x, 4);
|
||||
lpStateItem = lpItem->child(x, 5);
|
||||
lpPriceItem = lpItem->child(x, 6);
|
||||
lpDescriptionItem = lpItem->child(x, 7);
|
||||
lpDialog->addReplace(lpReferenceItem->text(), lpPartGroupItem->text(), lpPartItem->text(), lpDistributorItem->text(), lpStateItem->text(), lpPriceItem->text().toDouble(), lpDescriptionItem->text());
|
||||
}
|
||||
}
|
||||
@@ -509,6 +554,7 @@ void cPartlistWindow::onPartEdit()
|
||||
QString szDescription = lpDialog->description();
|
||||
|
||||
lpReferenceItem->setText(szReference.split("\n").join(", "));
|
||||
lpCountItem->setText(QString::number(szReference.split("\n").join(", ").split(", ").count()));
|
||||
if(lpPart)
|
||||
{
|
||||
lpPartGroupItem->setText(lpPart->partGroup()->name());
|
||||
@@ -529,6 +575,9 @@ void cPartlistWindow::onPartEdit()
|
||||
|
||||
delete lpDialog;
|
||||
|
||||
if(!m_bPartlistLoading)
|
||||
m_bSomethingChanged = true;
|
||||
|
||||
partlistChanged(this);
|
||||
}
|
||||
|
||||
@@ -543,5 +592,22 @@ void cPartlistWindow::onPartDelete()
|
||||
|
||||
m_lpPartListModel->removeRow(lpItem->row());
|
||||
|
||||
if(!m_bPartlistLoading)
|
||||
m_bSomethingChanged = true;
|
||||
|
||||
partlistChanged(this);
|
||||
}
|
||||
|
||||
void cPartlistWindow::onPartlistItemChanged(QStandardItem*)
|
||||
{
|
||||
if(m_bPartlistLoading)
|
||||
return;
|
||||
|
||||
m_bSomethingChanged = true;
|
||||
partlistChanged(this);
|
||||
}
|
||||
|
||||
bool cPartlistWindow::canClose()
|
||||
{
|
||||
return(close());
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ public:
|
||||
|
||||
bool somethingChanged();
|
||||
bool somethingSelected();
|
||||
|
||||
void partAdd();
|
||||
void partEdit();
|
||||
void partDelete();
|
||||
|
||||
bool canClose();
|
||||
private slots:
|
||||
void on_m_lpName_textChanged(const QString &arg1);
|
||||
// void on_m_lpPartList_doubleClicked(const QModelIndex &index);
|
||||
@@ -50,12 +56,15 @@ private slots:
|
||||
void onPartEdit();
|
||||
void onPartDelete();
|
||||
|
||||
void onPartlistItemChanged(QStandardItem*);
|
||||
|
||||
signals:
|
||||
void partlistChanged(QWidget* lpWidget) const;
|
||||
void selectionChanged(const QModelIndex& index) const;
|
||||
|
||||
private:
|
||||
Ui::cPartlistWindow* ui;
|
||||
bool m_bPartlistLoading;
|
||||
QTabWidget* m_lpMainTab;
|
||||
QStandardItemModel* m_lpPartListModel;
|
||||
qint32 m_id;
|
||||
|
||||
@@ -280,3 +280,8 @@ void cPartWindow::on_m_lpPartList_doubleClicked(const QModelIndex &/*index*/)
|
||||
{
|
||||
onEdit();
|
||||
}
|
||||
|
||||
bool cPartWindow::canClose()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public:
|
||||
void addPart();
|
||||
void editPart();
|
||||
void deletePart();
|
||||
|
||||
bool canClose();
|
||||
private slots:
|
||||
void on_m_lpPartList_clicked(const QModelIndex &index);
|
||||
void on_m_lpPartList_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 637 B |
+4
-2
@@ -8,6 +8,8 @@ QT += core gui sql
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
include(3rdparty/qtxlsx/src/xlsx/qtxlsx.pri)
|
||||
|
||||
TARGET = qtPartlist
|
||||
TEMPLATE = app
|
||||
|
||||
@@ -42,7 +44,7 @@ SOURCES += \
|
||||
cpartlistitem.cpp \
|
||||
cpartlistitemdelegate.cpp \
|
||||
cpartlistitemeditdialog.cpp \
|
||||
cinputlistdialog.cpp
|
||||
cinputlistdialog.cpp \
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
@@ -61,7 +63,7 @@ HEADERS += \
|
||||
cpartlistitem.h \
|
||||
cpartlistitemdelegate.h \
|
||||
cpartlistitemeditdialog.h \
|
||||
cinputlistdialog.h
|
||||
cinputlistdialog.h \
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui \
|
||||
|
||||
@@ -717,5 +717,8 @@
|
||||
<file>icons/normal/Zoom in.png</file>
|
||||
<file>icons/normal/Zoom out.png</file>
|
||||
<file>icons/normal/Zoom.png</file>
|
||||
<file>icons/disabled/Export.png</file>
|
||||
<file>icons/hot/Export.png</file>
|
||||
<file>icons/normal/Export.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user