.
This commit is contained in:
+6
-26
@@ -281,20 +281,10 @@ void cDistributorWindow::writeXLSX(const QString& szFileName)
|
||||
|
||||
writeXLSXLine(xlsx, 1, tr("Name"), tr("Phone"), tr("Fax"), tr("Email"), tr("address"), tr("postal"), tr("city"), tr("country"), tr("link"), tr("description"));
|
||||
|
||||
for(int x = 0;x < m_lpDistributorListModel->rowCount();x++)
|
||||
for(int x = 0;x < m_lpDistributorList->count();x++)
|
||||
{
|
||||
QStandardItem* lpNameItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 0));
|
||||
QStandardItem* lpPhoneItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 1));
|
||||
QStandardItem* lpFaxItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 2));
|
||||
QStandardItem* lpEmailItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 3));
|
||||
QStandardItem* lpAddressItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 4));
|
||||
QStandardItem* lpPostalItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 5));
|
||||
QStandardItem* lpCityItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 6));
|
||||
QStandardItem* lpCountryItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 7));
|
||||
QStandardItem* lpLinkItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 8));
|
||||
QStandardItem* lpDescriptionItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 9));
|
||||
|
||||
writeXLSXLine(xlsx, x+2, lpNameItem->text(), lpPhoneItem->text(), lpFaxItem->text(), lpEmailItem->text(), lpAddressItem->text(), lpPostalItem->text(), lpCityItem->text(), lpCountryItem->text(), lpLinkItem->text(), lpDescriptionItem->text());
|
||||
cDistributor* lpDistributor = m_lpDistributorList->at(x);
|
||||
writeXLSXLine(xlsx, x+2, lpDistributor->name(), lpDistributor->phone(), lpDistributor->fax(), lpDistributor->eMail(), lpDistributor->address(), QString::number(lpDistributor->postalCode()), lpDistributor->city(), lpDistributor->country(), lpDistributor->link(), lpDistributor->description());
|
||||
}
|
||||
|
||||
xlsx.saveAs(szFileName);
|
||||
@@ -330,20 +320,10 @@ void cDistributorWindow::writeText(const QString& szFileName)
|
||||
|
||||
out << "\"" << tr("Name") << "\";\"" << tr("Phone") << "\";\"" << tr("Fax") << "\";\"" << tr("Email") << "\";\"" << tr("address") << "\";\"" << tr("postal") << "\";\"" << tr("city") << "\";\"" << tr("country") << "\";\"" << tr("link") << "\";\"" << tr("description") << "\"\n";
|
||||
|
||||
for(int x = 0;x < m_lpDistributorListModel->rowCount();x++)
|
||||
for(int x = 0;x < m_lpDistributorList->count();x++)
|
||||
{
|
||||
QStandardItem* lpNameItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 0));
|
||||
QStandardItem* lpPhoneItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 1));
|
||||
QStandardItem* lpFaxItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 2));
|
||||
QStandardItem* lpEmailItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 3));
|
||||
QStandardItem* lpAddressItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 4));
|
||||
QStandardItem* lpPostalItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 5));
|
||||
QStandardItem* lpCityItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 6));
|
||||
QStandardItem* lpCountryItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 7));
|
||||
QStandardItem* lpLinkItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 8));
|
||||
QStandardItem* lpDescriptionItem = m_lpDistributorListModel->itemFromIndex(m_lpDistributorListModel->index(x, 9));
|
||||
|
||||
out << "\"" << lpNameItem->text() << "\";\"" << lpPhoneItem->text() << "\";\"" << lpFaxItem->text() << "\";\"" << lpEmailItem->text() << "\";\"" << lpAddressItem->text() << "\";\"" << lpPostalItem->text() << "\";\"" << lpCityItem->text() << "\";\"" << lpCountryItem->text() << "\";\"" << lpLinkItem->text() << "\";\"" << lpDescriptionItem->text() << "\"\n";
|
||||
cDistributor* lpDistributor = m_lpDistributorList->at(x);
|
||||
out << "\"" << lpDistributor->name() << "\";\"" << lpDistributor->phone() << "\";\"" << lpDistributor->fax() << "\";\"" << lpDistributor->eMail() << "\";\"" << lpDistributor->address() << "\";\"" << lpDistributor->postalCode() << "\";\"" << lpDistributor->city() << "\";\"" << lpDistributor->country() << "\";\"" << lpDistributor->link() << "\";\"" << lpDistributor->description() << "\"\n";
|
||||
}
|
||||
|
||||
file.flush();
|
||||
|
||||
+229
-1
@@ -4,6 +4,8 @@
|
||||
#include "cpartlistwindow.h"
|
||||
#include "cinputlistdialog.h"
|
||||
|
||||
#include "cpartlistselectdialog.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
@@ -19,8 +21,12 @@
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include <QMap>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "xlsxdocument.h"
|
||||
|
||||
|
||||
cMainWindow::cMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
@@ -388,7 +394,199 @@ void cMainWindow::onMenuFileCloseProject()
|
||||
|
||||
void cMainWindow::onMenuFileExport()
|
||||
{
|
||||
QMessageBox::information(this, "bla", "Export Project");
|
||||
cPartlistSelectDialog* lpDialog = new cPartlistSelectDialog(this);
|
||||
|
||||
if(lpDialog->exec() == QDialog::Rejected)
|
||||
{
|
||||
delete lpDialog;
|
||||
return;
|
||||
}
|
||||
|
||||
QString szFileName = lpDialog->fileName();
|
||||
QMap<qint32, qint32> list = lpDialog->partLists();
|
||||
delete lpDialog;
|
||||
|
||||
if(!list.count())
|
||||
return;
|
||||
|
||||
bool bXLSX = false;
|
||||
bool bTXT = false;
|
||||
bool bXML = false;
|
||||
bool bPDF = false;
|
||||
|
||||
QXlsx::Format format;
|
||||
QXlsx::Format formatBig;
|
||||
QXlsx::Format formatMerged;
|
||||
QXlsx::Format formatCurrency;
|
||||
QXlsx::Format formatWrap;
|
||||
|
||||
QString szNumberFormat("_-\"€\"\\ * #,##0.00_-;\\-\"€\"\\ * #,##0.00_-;_-\"€\"\\ * \"-\"??_-;_-@_-");
|
||||
|
||||
format.setFontBold(true);
|
||||
|
||||
formatBig.setFontBold(true);
|
||||
formatBig.setFontSize(16);
|
||||
|
||||
formatMerged.setHorizontalAlignment(QXlsx::Format::AlignLeft);
|
||||
formatMerged.setVerticalAlignment(QXlsx::Format::AlignTop);
|
||||
|
||||
formatCurrency.setNumberFormat(szNumberFormat);
|
||||
|
||||
formatWrap.setTextWarp(true);
|
||||
|
||||
QFileInfo fileInfo(szFileName);
|
||||
QString szType = fileInfo.suffix();
|
||||
|
||||
if(!szType.compare("xlsx", Qt::CaseInsensitive))
|
||||
bXLSX = true;
|
||||
else if(!szType.compare("csv", Qt::CaseInsensitive))
|
||||
bTXT = true;
|
||||
else if(!szType.compare("txt", Qt::CaseInsensitive))
|
||||
bTXT = true;
|
||||
else if(!szType.compare("xml", Qt::CaseInsensitive))
|
||||
bXML = true;
|
||||
else if(!szType.compare("pdf", Qt::CaseInsensitive))
|
||||
bPDF = true;
|
||||
|
||||
QStringList szIDList;
|
||||
QMap<int, int>::const_iterator i;
|
||||
QXlsx::Document xlsx;
|
||||
|
||||
qint32 iLine = 1;
|
||||
|
||||
if(bXLSX)
|
||||
{
|
||||
xlsx.write(iLine, 1, tr("count"), format);
|
||||
xlsx.write(iLine, 2, tr("group"), format);
|
||||
xlsx.write(iLine, 3, tr("part"), format);
|
||||
xlsx.write(iLine, 4, tr("description"), format);
|
||||
xlsx.write(iLine, 5, tr("distributor"), format);
|
||||
xlsx.write(iLine, 6, tr("SKU"), format);
|
||||
xlsx.write(iLine, 7, tr("state"), format);
|
||||
xlsx.write(iLine, 8, tr("price"), format);
|
||||
xlsx.write(iLine, 9, tr("project"), format);
|
||||
}
|
||||
|
||||
iLine++;
|
||||
|
||||
i = list.constBegin();
|
||||
while(i != list.constEnd())
|
||||
{
|
||||
szIDList.append(QString::number(i.key()));
|
||||
i++;
|
||||
}
|
||||
|
||||
QSqlQuery query;
|
||||
QString szQuery = QString("SELECT partlist.id partlistID, "
|
||||
" partlist.name partlistName, "
|
||||
" partlist.description partlistDescription, "
|
||||
" partlistitem.id partlistitemID, "
|
||||
" partlistitem.partID partID, "
|
||||
" partlistitem.distributorID distributorID, "
|
||||
" partlistitem.reference partlistitemReference, "
|
||||
" partlistitem.description partlistitemDescription, "
|
||||
" partlistitem.state partlistitemState, "
|
||||
" partlistitem.price partlistitemPrice, "
|
||||
" partgroup.id partgroupID, "
|
||||
" partgroup.name partgroupName, "
|
||||
" part.name partName, "
|
||||
" part.description partDescription, "
|
||||
" distributor.name distributorName, "
|
||||
" part_distributor.id partdistributorID, "
|
||||
" part_distributor.name partdistributorName, "
|
||||
" part_distributor.description partdistributorDescription, "
|
||||
" part_distributor.link partdistributorLink, "
|
||||
" part_distributor.price partdistributorPrice "
|
||||
"FROM partlist "
|
||||
"JOIN partlistitem ON (partlist.id = partlistitem.partlistID) "
|
||||
"JOIN part ON (partlistitem.partID = part.id) "
|
||||
"JOIN partgroup ON (part.partgroupID = partgroup.id) "
|
||||
"LEFT JOIN distributor ON (partlistitem.distributorID = distributor.id) "
|
||||
"LEFT JOIN part_distributor ON (part_distributor.partID = part.id AND part_distributor.distributorID = partlistitem.distributorID) "
|
||||
"WHERE partlist.id IN (%1) "
|
||||
"ORDER BY LOWER(partgroup.name), "
|
||||
" LOWER(part.name), "
|
||||
" LOWER(distributor.name), "
|
||||
" LOWER(partlist.name);").arg(szIDList.join(", "));
|
||||
query.prepare(szQuery);
|
||||
|
||||
QString szOldGroup;
|
||||
QString szOldPart;
|
||||
QString szOldDistributor;
|
||||
QString szOldState;
|
||||
QStringList szPartlist;
|
||||
QString szDescription;
|
||||
QString szPartDistributorName;
|
||||
qint32 iCount;
|
||||
qreal dPrice;
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
if(szOldGroup != query.value("partgroupName").toString() ||
|
||||
szOldPart != query.value("partName").toString() ||
|
||||
szOldDistributor != query.value("distributorName").toString() ||
|
||||
szOldState != cPartlistItem::stateString((cPartlistItem::STATE)query.value("partlistitemState").toInt()))
|
||||
{
|
||||
if(!szOldGroup.isEmpty())
|
||||
{
|
||||
if(bXLSX)
|
||||
{
|
||||
xlsx.write(iLine, 1, iCount);
|
||||
xlsx.write(iLine, 2, szOldGroup);
|
||||
xlsx.write(iLine, 3, szOldPart);
|
||||
xlsx.write(iLine, 4, szDescription);
|
||||
xlsx.write(iLine, 5, szOldDistributor);
|
||||
xlsx.write(iLine, 6, szPartDistributorName);
|
||||
xlsx.write(iLine, 7, szOldState);
|
||||
xlsx.write(iLine, 8, dPrice, formatCurrency);
|
||||
xlsx.write(iLine, 9, szPartlist.join("\n"), formatWrap);
|
||||
iLine++;
|
||||
}
|
||||
}
|
||||
szPartlist.clear();
|
||||
|
||||
szOldGroup = query.value("partgroupName").toString();
|
||||
szOldPart = query.value("partName").toString();
|
||||
szOldDistributor = query.value("distributorName").toString();
|
||||
szOldState = cPartlistItem::stateString((cPartlistItem::STATE)query.value("partlistitemState").toInt());
|
||||
szPartlist.append(query.value("partlistName").toString());
|
||||
iCount = query.value("partlistitemReference").toString().split(", ").count() * list.find(query.value("partlistID").toInt()).value();
|
||||
dPrice = query.value("partdistributorPrice").toDouble();
|
||||
szDescription = query.value("partDescription").toString();
|
||||
szPartDistributorName = query.value("partdistributorName").toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!szPartlist.contains(query.value("partlistName").toString()))
|
||||
szPartlist.append(query.value("partlistName").toString());
|
||||
iCount += query.value("partlistitemReference").toString().split(", ").count();
|
||||
}
|
||||
}
|
||||
|
||||
if(!szOldGroup.isEmpty())
|
||||
{
|
||||
if(bXLSX)
|
||||
{
|
||||
xlsx.write(iLine, 1, iCount);
|
||||
xlsx.write(iLine, 2, szOldGroup);
|
||||
xlsx.write(iLine, 3, szOldPart);
|
||||
xlsx.write(iLine, 4, szDescription);
|
||||
xlsx.write(iLine, 5, szOldDistributor);
|
||||
xlsx.write(iLine, 6, szPartDistributorName);
|
||||
xlsx.write(iLine, 7, szOldState);
|
||||
xlsx.write(iLine, 8, dPrice, formatCurrency);
|
||||
xlsx.write(iLine, 9, szPartlist.join("\n"), formatWrap);
|
||||
}
|
||||
}
|
||||
|
||||
if(bXLSX)
|
||||
xlsx.saveAs(szFileName);
|
||||
}
|
||||
|
||||
void cMainWindow::onMenuFileClose()
|
||||
@@ -492,6 +690,20 @@ void cMainWindow::onMenuPartsDelete()
|
||||
|
||||
void cMainWindow::onMenuPartsExport()
|
||||
{
|
||||
if(!m_lpPartWindow)
|
||||
return;
|
||||
|
||||
QSettings settings;
|
||||
QString szPath = settings.value("lastPath", QVariant::fromValue(QDir::homePath())).toString();
|
||||
QString szFileName = QFileDialog::getSaveFileName(this, tr("Export"), szPath, tr("Excel 2007+ (*.xlsx);;Text files (*.txt *.csv);;XML files (*.xml);;PDF (*.pdf)"));
|
||||
|
||||
if(szFileName.isEmpty())
|
||||
return;
|
||||
|
||||
QFileInfo fileInfo(szFileName);
|
||||
settings.setValue("lastPath", fileInfo.absolutePath());
|
||||
|
||||
m_lpPartWindow->exportList(szFileName);
|
||||
}
|
||||
|
||||
void cMainWindow::updateMenu()
|
||||
@@ -833,6 +1045,22 @@ void cMainWindow::onMenuPartlistPartDelete()
|
||||
|
||||
void cMainWindow::onMenuPartlistExport()
|
||||
{
|
||||
cPartlistWindow* lpPartlistWindow = qobject_cast<cPartlistWindow*>(ui->m_lpMainTab->widget(ui->m_lpMainTab->currentIndex()));
|
||||
|
||||
if(!lpPartlistWindow)
|
||||
return;
|
||||
|
||||
QSettings settings;
|
||||
QString szPath = settings.value("lastPath", QVariant::fromValue(QDir::homePath())).toString();
|
||||
QString szFileName = QFileDialog::getSaveFileName(this, tr("Export"), szPath, tr("Excel 2007+ (*.xlsx);;Text files (*.txt *.csv);;XML files (*.xml);;PDF (*.pdf)"));
|
||||
|
||||
if(szFileName.isEmpty())
|
||||
return;
|
||||
|
||||
QFileInfo fileInfo(szFileName);
|
||||
settings.setValue("lastPath", fileInfo.absolutePath());
|
||||
|
||||
lpPartlistWindow->exportList(szFileName);
|
||||
}
|
||||
|
||||
void cMainWindow::partlistChanged(QWidget* /*lpWidget*/)
|
||||
|
||||
@@ -82,3 +82,13 @@ cPart* cPartList::find(qint32 id)
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
cPart* cPartList::find(const QString& szGroup, const QString& szPart)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->partGroup()->name() == szGroup && at(x)->name() == szPart)
|
||||
return(at(x));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class cPartList : public QList<cPart*>
|
||||
public:
|
||||
cPart* add(qint32 id);
|
||||
cPart* find(qint32 id);
|
||||
cPart* find(const QString& szGroup, const QString& szPart);
|
||||
};
|
||||
|
||||
#endif // CPART_H
|
||||
|
||||
@@ -60,3 +60,13 @@ cPartGroup* cPartGroupList::find(qint32 id)
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
cPartGroup* cPartGroupList::find(const QString& szGroup)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->name() == szGroup)
|
||||
return(at(x));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class cPartGroupList : public QList<cPartGroup*>
|
||||
public:
|
||||
cPartGroup* add(qint32 id);
|
||||
cPartGroup* find(qint32 id);
|
||||
cPartGroup* find(const QString& szGroup);
|
||||
};
|
||||
|
||||
#endif // CPARTGROUP_H
|
||||
|
||||
@@ -19,8 +19,6 @@ public:
|
||||
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
signals:
|
||||
// void ipRangeChanged(cIPRange* lpIPRange, QStandardItem* lpItem) const;
|
||||
// void locationChanged(cIPRange* lpIPRange, QStandardItem* lpItem) const;
|
||||
};
|
||||
|
||||
#endif // CPARTLISTITEMDELEGATE_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "cpartlistitemeditdialog.h"
|
||||
#include "ui_cpartlistitemeditdialog.h"
|
||||
|
||||
|
||||
cPartlistItemEditDialog::cPartlistItemEditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::cPartlistItemEditDialog),
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include "cpartlistlistdelegate.h"
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QRect>
|
||||
|
||||
|
||||
cPartlistListDelegate::cPartlistListDelegate(QObject *parent) :
|
||||
QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
cPartlistListDelegate::~cPartlistListDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* cPartlistListDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case 0: // count
|
||||
{
|
||||
QSpinBox* lpSpinBox = new QSpinBox(parent);
|
||||
lpSpinBox->setMinimum(0);
|
||||
lpSpinBox->setMaximum(999999);
|
||||
return(lpSpinBox);
|
||||
}
|
||||
default:
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void cPartlistListDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
default:
|
||||
editor->setGeometry(option.rect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void cPartlistListDelegate::setEditorData ( QWidget *editor, const QModelIndex &index ) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
default:
|
||||
QStyledItemDelegate::setEditorData(editor, index);
|
||||
}
|
||||
}
|
||||
|
||||
void cPartlistListDelegate::setModelData ( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
|
||||
{
|
||||
QSpinBox* lpSpinBox = qobject_cast<QSpinBox*>(editor);
|
||||
|
||||
switch(index.column())
|
||||
{
|
||||
case 0: // count
|
||||
if(lpSpinBox)
|
||||
{
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)index.model();
|
||||
QStandardItem* lpItem = lpModel->itemFromIndex(index);
|
||||
lpItem->setText(QString::number(lpSpinBox->value()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef CPARTLISTLISTDELEGATE_H
|
||||
#define CPARTLISTLISTDELEGATE_H
|
||||
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QStandardItem>
|
||||
|
||||
|
||||
class cPartlistListDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
cPartlistListDelegate(QObject* parent = 0);
|
||||
~cPartlistListDelegate();
|
||||
|
||||
virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
signals:
|
||||
};
|
||||
|
||||
#endif // CPARTLISTLISTDELEGATE_H
|
||||
@@ -0,0 +1,112 @@
|
||||
#include "cpartlistselectdialog.h"
|
||||
#include "ui_cpartlistselectdialog.h"
|
||||
|
||||
#include "cpartlistlistdelegate.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cPartlistSelectDialog::cPartlistSelectDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::cPartlistSelectDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
m_lpPartlistModel = new QStandardItemModel(0, 2);
|
||||
ui->m_lpPartlistList->setModel(m_lpPartlistModel);
|
||||
ui->m_lpPartlistList->setItemDelegate(new cPartlistListDelegate());
|
||||
|
||||
QStringList header;
|
||||
header << tr("count") << tr("name") << tr("description");
|
||||
m_lpPartlistModel->setHorizontalHeaderLabels(header);
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT id, name, description FROM partlist ORDER BY LOWER(name);");
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
QList<QStandardItem*> list;
|
||||
|
||||
list.append(new QStandardItem);
|
||||
list.append(new QStandardItem);
|
||||
list.append(new QStandardItem);
|
||||
|
||||
list.at(0)->setText("0");
|
||||
list.at(0)->setTextAlignment(Qt::AlignRight);
|
||||
list.at(0)->setData(QVariant::fromValue(query.value("id").toInt()));
|
||||
list.at(1)->setText(query.value("name").toString());
|
||||
list.at(2)->setText(query.value("description").toString());
|
||||
|
||||
m_lpPartlistModel->appendRow(list);
|
||||
}
|
||||
|
||||
ui->m_lpPartlistList->resizeColumnToContents(0);
|
||||
ui->m_lpPartlistList->resizeColumnToContents(1);
|
||||
ui->m_lpPartlistList->resizeColumnToContents(2);
|
||||
}
|
||||
|
||||
cPartlistSelectDialog::~cPartlistSelectDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString cPartlistSelectDialog::fileName()
|
||||
{
|
||||
return(ui->m_lpFileName->text());
|
||||
}
|
||||
|
||||
QMap<qint32,qint32> cPartlistSelectDialog::partLists()
|
||||
{
|
||||
QMap<qint32,qint32> partList;
|
||||
|
||||
for(int x = 0;x < m_lpPartlistModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpCountItem = m_lpPartlistModel->itemFromIndex(m_lpPartlistModel->index(x, 0));
|
||||
qint32 count = lpCountItem->text().toInt();
|
||||
qint32 id = qvariant_cast<qint32>(lpCountItem->data());
|
||||
|
||||
if(count)
|
||||
partList.insert(id, count);
|
||||
}
|
||||
return(partList);
|
||||
}
|
||||
|
||||
void cPartlistSelectDialog::on_m_lpFileNameSelect_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
QString szPath = settings.value("lastPath", QVariant::fromValue(QDir::homePath())).toString();
|
||||
QString szFileName = QFileDialog::getSaveFileName(this, tr("Export"), szPath, tr("Excel 2007+ (*.xlsx);;Text files (*.txt *.csv);;XML files (*.xml);;PDF (*.pdf)"));
|
||||
|
||||
if(szFileName.isEmpty())
|
||||
return;
|
||||
|
||||
QFileInfo fileInfo(szFileName);
|
||||
settings.setValue("lastPath", fileInfo.absolutePath());
|
||||
|
||||
ui->m_lpFileName->setText(szFileName);
|
||||
}
|
||||
|
||||
void cPartlistSelectDialog::on_m_lpFileName_textChanged(const QString &arg1)
|
||||
{
|
||||
if(arg1.isEmpty())
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
else
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef CPARTLISTSELECTDIALOG_H
|
||||
#define CPARTLISTSELECTDIALOG_H
|
||||
|
||||
|
||||
#include <QDialog>
|
||||
#include <QStandardItemModel>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cPartlistSelectDialog;
|
||||
}
|
||||
|
||||
class cPartlistSelectDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cPartlistSelectDialog(QWidget *parent = 0);
|
||||
~cPartlistSelectDialog();
|
||||
|
||||
QString fileName();
|
||||
QMap<qint32,qint32> partLists();
|
||||
private slots:
|
||||
void on_m_lpFileNameSelect_clicked();
|
||||
|
||||
void on_m_lpFileName_textChanged(const QString &arg1);
|
||||
|
||||
private:
|
||||
Ui::cPartlistSelectDialog* ui;
|
||||
QStandardItemModel* m_lpPartlistModel;
|
||||
};
|
||||
|
||||
#endif // CPARTLISTSELECTDIALOG_H
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cPartlistSelectDialog</class>
|
||||
<widget class="QDialog" name="cPartlistSelectDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>350</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Filename:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpFileName"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_lpFileNameSelect">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTreeView" name="m_lpPartlistList">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QDialogButtonBox" name="m_lpButtonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_lpFileName</tabstop>
|
||||
<tabstop>m_lpFileNameSelect</tabstop>
|
||||
<tabstop>m_lpPartlistList</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>m_lpButtonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cPartlistSelectDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_lpButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cPartlistSelectDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -11,6 +11,10 @@
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
@@ -616,3 +620,171 @@ bool cPartlistWindow::canClose()
|
||||
{
|
||||
return(close());
|
||||
}
|
||||
|
||||
cPartlistItemList cPartlistWindow::itemList(bool bMerge)
|
||||
{
|
||||
cPartlistItemList list;
|
||||
|
||||
for(int x = 0;x < m_lpPartListModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpReferenceItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 0));
|
||||
//QStandardItem* lpCountItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 1));
|
||||
QStandardItem* lpGroupItem = m_lpPartListModel->itemFromIndex(m_lpPartListModel->index(x, 2));
|
||||
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));
|
||||
|
||||
QString szReference = lpReferenceItem->text();
|
||||
cPart* lpPart = m_lpPartList->find(lpGroupItem->text(), lpPartItem->text());
|
||||
cDistributor* lpDistributor = m_lpDistributorList->find(lpDistributorItem->text());
|
||||
QString szState = lpStateItem->text();
|
||||
qreal dPrice = lpPriceItem->text().toDouble();
|
||||
QString szDescription = lpDescriptionItem->text();
|
||||
|
||||
if(bMerge)
|
||||
{
|
||||
cPartlistItem* lpPartlistItem = 0;
|
||||
for(int y = 0;y < list.count();y++)
|
||||
{
|
||||
if(list.at(y)->partID() == lpPart->id())
|
||||
{
|
||||
if(lpDistributor)
|
||||
{
|
||||
if(list.at(y)->distributorID() == lpDistributor->id())
|
||||
lpPartlistItem = list.at(y);
|
||||
}
|
||||
}
|
||||
if(lpPartlistItem)
|
||||
lpPartlistItem->setReference(QString("%1, %2").arg(lpPartlistItem->reference()).arg(szReference));
|
||||
}
|
||||
|
||||
if(!lpPartlistItem)
|
||||
{
|
||||
lpPartlistItem = list.add(x);
|
||||
lpPartlistItem->setReference(szReference);
|
||||
lpPartlistItem->setPartID(lpPart->id());
|
||||
if(lpDistributor)
|
||||
lpPartlistItem->setDistributorID(lpDistributor->id());
|
||||
lpPartlistItem->setState(cPartlistItem::state(szState));
|
||||
lpPartlistItem->setPrice(dPrice);
|
||||
lpPartlistItem->setDescription(szDescription);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cPartlistItem* lpPartlistItem = list.add(x);
|
||||
lpPartlistItem->setReference(szReference);
|
||||
lpPartlistItem->setPartID(lpPart->id());
|
||||
if(lpDistributor)
|
||||
lpPartlistItem->setDistributorID(lpDistributor->id());
|
||||
lpPartlistItem->setState(cPartlistItem::state(szState));
|
||||
lpPartlistItem->setPrice(dPrice);
|
||||
lpPartlistItem->setDescription(szDescription);
|
||||
}
|
||||
}
|
||||
|
||||
return(list);
|
||||
}
|
||||
|
||||
void cPartlistWindow::exportList(const QString& szFileName)
|
||||
{
|
||||
QFileInfo fileInfo(szFileName);
|
||||
QString szType = fileInfo.suffix();
|
||||
|
||||
if(!szType.compare("xlsx", Qt::CaseInsensitive))
|
||||
writeXLSX(szFileName);
|
||||
else if(!szType.compare("csv", Qt::CaseInsensitive))
|
||||
writeText(szFileName);
|
||||
else if(!szType.compare("txt", Qt::CaseInsensitive))
|
||||
writeText(szFileName);
|
||||
else if(!szType.compare("xml", Qt::CaseInsensitive))
|
||||
writeXML(szFileName);
|
||||
else if(!szType.compare("pdf", Qt::CaseInsensitive))
|
||||
writePDF(szFileName);
|
||||
}
|
||||
|
||||
void cPartlistWindow::writeXLSX(const QString& szFileName)
|
||||
{
|
||||
QXlsx::Document xlsx;
|
||||
QXlsx::Format format;
|
||||
QXlsx::Format formatBig;
|
||||
QXlsx::Format formatMerged;
|
||||
QXlsx::Format formatCurrency;
|
||||
QString szNumberFormat("_-\"€\"\\ * #,##0.00_-;\\-\"€\"\\ * #,##0.00_-;_-\"€\"\\ * \"-\"??_-;_-@_-");
|
||||
|
||||
format.setFontBold(true);
|
||||
|
||||
formatBig.setFontBold(true);
|
||||
formatBig.setFontSize(16);
|
||||
|
||||
formatMerged.setHorizontalAlignment(QXlsx::Format::AlignLeft);
|
||||
formatMerged.setVerticalAlignment(QXlsx::Format::AlignTop);
|
||||
|
||||
formatCurrency.setNumberFormat(szNumberFormat);
|
||||
|
||||
xlsx.write(1, 1, ui->m_lpName->text(), formatBig);
|
||||
xlsx.write(2, 1, ui->m_lpDescription->toPlainText());
|
||||
|
||||
xlsx.write(4, 1, tr("reference"), format);
|
||||
xlsx.write(4, 2, tr("count"), format);
|
||||
xlsx.write(4, 3, tr("group"), format);
|
||||
xlsx.write(4, 4, tr("part"), format);
|
||||
xlsx.write(4, 5, tr("distributor"), format);
|
||||
xlsx.write(4, 6, tr("state"), format);
|
||||
xlsx.write(4, 7, tr("price"), format);
|
||||
xlsx.write(4, 8, tr("description"), format);
|
||||
|
||||
cPartlistItemList list = itemList(true);
|
||||
|
||||
for(int x = 0;x < list.count();x++)
|
||||
{
|
||||
cPartlistItem* lpItem = list.at(x);
|
||||
cPart* lpPart = m_lpPartList->find(lpItem->partID());
|
||||
cDistributor* lpDistributor = m_lpDistributorList->find(lpItem->distributorID());
|
||||
|
||||
xlsx.write(x+5, 1, lpItem->reference());
|
||||
xlsx.write(x+5, 2, lpItem->reference().split(", ").count());
|
||||
xlsx.write(x+5, 3, lpPart->partGroup()->name());
|
||||
xlsx.write(x+5, 4, lpPart->name());
|
||||
if(lpDistributor)
|
||||
xlsx.write(x+5, 5, lpDistributor->name());
|
||||
xlsx.write(x+5, 6, lpItem->stateString());
|
||||
xlsx.write(x+5, 7, lpItem->price(), formatCurrency);
|
||||
xlsx.write(x+5, 8, lpItem->description());
|
||||
}
|
||||
|
||||
xlsx.saveAs(szFileName);
|
||||
}
|
||||
|
||||
void cPartlistWindow::writeText(const QString& szFileName)
|
||||
{
|
||||
/*
|
||||
QFile file(szFileName);
|
||||
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text))
|
||||
return;
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
out << "\"" << tr("Group") << "\";\"" << tr("Name") << "\";\"" << tr("Description") << "\";\"" << tr("Link") << "\"\n";
|
||||
|
||||
for(int x = 0;x < m_lpPartList->count();x++)
|
||||
{
|
||||
cPart* lpPart = m_lpPartList->at(x);
|
||||
out << "\"" << lpPart->partGroup()->name() << "\";\"" << lpPart->name() << "\";\"" << lpPart->description() << "\";\"" << lpPart->link() << "\";\"" << "\"\n";
|
||||
}
|
||||
|
||||
file.flush();
|
||||
file.close();
|
||||
*/
|
||||
}
|
||||
|
||||
void cPartlistWindow::writeXML(const QString& szFileName)
|
||||
{
|
||||
}
|
||||
|
||||
void cPartlistWindow::writePDF(const QString& szFileName)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "cpartlistitem.h"
|
||||
|
||||
#include "xlsxdocument.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTabWidget>
|
||||
#include <QStandardItemModel>
|
||||
@@ -46,6 +48,10 @@ public:
|
||||
void partDelete();
|
||||
|
||||
bool canClose();
|
||||
|
||||
cPartlistItemList itemList(bool bMerge = false);
|
||||
|
||||
void exportList(const QString& szFileName);
|
||||
private slots:
|
||||
void on_m_lpName_textChanged(const QString &arg1);
|
||||
// void on_m_lpPartList_doubleClicked(const QModelIndex &index);
|
||||
@@ -82,6 +88,11 @@ private:
|
||||
QStandardItem* findItem(qint32 itemID);
|
||||
|
||||
bool save(qint32 id);
|
||||
|
||||
void writeXLSX(const QString& szFileName);
|
||||
void writeText(const QString& szFileName);
|
||||
void writeXML(const QString& szFileName);
|
||||
void writePDF(const QString& szFileName);
|
||||
};
|
||||
|
||||
#endif // CPARTLISTWINDOW_H
|
||||
|
||||
+112
@@ -11,6 +11,10 @@
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
@@ -285,3 +289,111 @@ bool cPartWindow::canClose()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
void cPartWindow::exportList(const QString& szFileName)
|
||||
{
|
||||
QFileInfo fileInfo(szFileName);
|
||||
QString szType = fileInfo.suffix();
|
||||
|
||||
if(!szType.compare("xlsx", Qt::CaseInsensitive))
|
||||
writeXLSX(szFileName);
|
||||
else if(!szType.compare("csv", Qt::CaseInsensitive))
|
||||
writeText(szFileName);
|
||||
else if(!szType.compare("txt", Qt::CaseInsensitive))
|
||||
writeText(szFileName);
|
||||
else if(!szType.compare("xml", Qt::CaseInsensitive))
|
||||
writeXML(szFileName);
|
||||
else if(!szType.compare("pdf", Qt::CaseInsensitive))
|
||||
writePDF(szFileName);
|
||||
}
|
||||
|
||||
void cPartWindow::writeXLSX(const QString& szFileName)
|
||||
{
|
||||
QXlsx::Document xlsx;
|
||||
qint32 iLine = 1;
|
||||
QXlsx::Format format;
|
||||
QXlsx::Format formatMerged;
|
||||
QXlsx::Format formatCurrency;
|
||||
QString szNumberFormat("_-\"€\"\\ * #,##0.00_-;\\-\"€\"\\ * #,##0.00_-;_-\"€\"\\ * \"-\"??_-;_-@_-");
|
||||
|
||||
format.setFontBold(true);
|
||||
|
||||
formatMerged.setHorizontalAlignment(QXlsx::Format::AlignLeft);
|
||||
formatMerged.setVerticalAlignment(QXlsx::Format::AlignTop);
|
||||
|
||||
formatCurrency.setNumberFormat(szNumberFormat);
|
||||
|
||||
xlsx.write(iLine, 1, tr("Group"), format);
|
||||
xlsx.write(iLine, 2, tr("Name"), format);
|
||||
xlsx.write(iLine, 3, tr("Description"), format);
|
||||
xlsx.write(iLine, 4, tr("Link"), format);
|
||||
xlsx.write(iLine, 5, tr("Distributor"), format);
|
||||
xlsx.write(iLine, 6, tr("Part Name"), format);
|
||||
xlsx.write(iLine, 7, tr("Price"), format);
|
||||
iLine++;
|
||||
|
||||
for(int x = 0;x < m_lpPartList->count();x++)
|
||||
{
|
||||
cPart* lpPart = m_lpPartList->at(x);
|
||||
|
||||
xlsx.write(iLine, 1, lpPart->partGroup()->name());
|
||||
xlsx.write(iLine, 2, lpPart->name());
|
||||
xlsx.write(iLine, 3, lpPart->description());
|
||||
xlsx.write(iLine, 4, lpPart->link());
|
||||
|
||||
qint32 iLineTemp = 0;
|
||||
for(int y = 0;y < m_lpPartDistributorList->count();y++)
|
||||
{
|
||||
cPartDistributor* lpPartDistributor = m_lpPartDistributorList->at(y);
|
||||
|
||||
if(lpPartDistributor->part() == lpPart)
|
||||
{
|
||||
xlsx.write(iLine+iLineTemp, 5, lpPartDistributor->distributor()->name());
|
||||
xlsx.write(iLine+iLineTemp, 6, lpPartDistributor->name());
|
||||
xlsx.write(iLine+iLineTemp, 7, lpPartDistributor->price(), formatCurrency);
|
||||
iLineTemp++;
|
||||
}
|
||||
}
|
||||
if(iLineTemp)
|
||||
{
|
||||
xlsx.mergeCells(QString("A%1:A%2").arg(iLine).arg(iLine+iLineTemp-1), formatMerged);
|
||||
xlsx.mergeCells(QString("B%1:B%2").arg(iLine).arg(iLine+iLineTemp-1), formatMerged);
|
||||
xlsx.mergeCells(QString("C%1:C%2").arg(iLine).arg(iLine+iLineTemp-1), formatMerged);
|
||||
xlsx.mergeCells(QString("D%1:D%2").arg(iLine).arg(iLine+iLineTemp-1), formatMerged);
|
||||
iLine += iLineTemp;
|
||||
}
|
||||
else
|
||||
iLine++;
|
||||
}
|
||||
|
||||
xlsx.saveAs(szFileName);
|
||||
}
|
||||
|
||||
void cPartWindow::writeText(const QString& szFileName)
|
||||
{
|
||||
QFile file(szFileName);
|
||||
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text))
|
||||
return;
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
out << "\"" << tr("Group") << "\";\"" << tr("Name") << "\";\"" << tr("Description") << "\";\"" << tr("Link") << "\"\n";
|
||||
|
||||
for(int x = 0;x < m_lpPartList->count();x++)
|
||||
{
|
||||
cPart* lpPart = m_lpPartList->at(x);
|
||||
out << "\"" << lpPart->partGroup()->name() << "\";\"" << lpPart->name() << "\";\"" << lpPart->description() << "\";\"" << lpPart->link() << "\";\"" << "\"\n";
|
||||
}
|
||||
|
||||
file.flush();
|
||||
file.close();
|
||||
}
|
||||
|
||||
void cPartWindow::writeXML(const QString& szFileName)
|
||||
{
|
||||
}
|
||||
|
||||
void cPartWindow::writePDF(const QString& szFileName)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "cdistributor.h"
|
||||
#include "cpartdistributor.h"
|
||||
|
||||
#include "xlsxdocument.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
@@ -32,6 +34,8 @@ public:
|
||||
void deletePart();
|
||||
|
||||
bool canClose();
|
||||
|
||||
void exportList(const QString& szFileName);
|
||||
private slots:
|
||||
void on_m_lpPartList_clicked(const QModelIndex &index);
|
||||
void on_m_lpPartList_customContextMenuRequested(const QPoint &pos);
|
||||
@@ -55,6 +59,11 @@ private:
|
||||
cPartDistributorList* m_lpPartDistributorList;
|
||||
|
||||
void showPartList(qint32 id = -1);
|
||||
|
||||
void writeXLSX(const QString& szFileName);
|
||||
void writeText(const QString& szFileName);
|
||||
void writeXML(const QString& szFileName);
|
||||
void writePDF(const QString& szFileName);
|
||||
};
|
||||
|
||||
#endif // CPARTWINDOW_H
|
||||
|
||||
+6
-1
@@ -45,6 +45,8 @@ SOURCES += \
|
||||
cpartlistitemdelegate.cpp \
|
||||
cpartlistitemeditdialog.cpp \
|
||||
cinputlistdialog.cpp \
|
||||
cpartlistselectdialog.cpp \
|
||||
cpartlistlistdelegate.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
@@ -64,6 +66,8 @@ HEADERS += \
|
||||
cpartlistitemdelegate.h \
|
||||
cpartlistitemeditdialog.h \
|
||||
cinputlistdialog.h \
|
||||
cpartlistselectdialog.h \
|
||||
cpartlistlistdelegate.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui \
|
||||
@@ -74,7 +78,8 @@ FORMS += \
|
||||
cparteditdialog.ui \
|
||||
cpartdistributoreditdialog.ui \
|
||||
cpartlistitemeditdialog.ui \
|
||||
cinputlistdialog.ui
|
||||
cinputlistdialog.ui \
|
||||
cpartlistselectdialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
qtpartlist.qrc
|
||||
|
||||
Reference in New Issue
Block a user