.
This commit is contained in:
+24
-5
@@ -9,6 +9,7 @@ cDistributor::cDistributor() :
|
||||
m_szCity(""),
|
||||
m_szCountry(""),
|
||||
m_szPhone(""),
|
||||
m_szFax(""),
|
||||
m_szEMail(""),
|
||||
m_szLink(""),
|
||||
m_szDescription("")
|
||||
@@ -85,6 +86,16 @@ QString cDistributor::phone()
|
||||
return(m_szPhone);
|
||||
}
|
||||
|
||||
void cDistributor::setFax(const QString& szFax)
|
||||
{
|
||||
m_szFax = szFax;
|
||||
}
|
||||
|
||||
QString cDistributor::fax()
|
||||
{
|
||||
return(m_szFax);
|
||||
}
|
||||
|
||||
void cDistributor::setEMail(const QString& szEMail)
|
||||
{
|
||||
m_szEMail = szEMail;
|
||||
@@ -116,15 +127,23 @@ QString cDistributor::description()
|
||||
}
|
||||
|
||||
cDistributor* cDistributorList::add(qint32 id)
|
||||
{
|
||||
cDistributor* lpDistributor = find(id);
|
||||
if(lpDistributor)
|
||||
return(lpDistributor);
|
||||
|
||||
lpDistributor = new cDistributor;
|
||||
lpDistributor->setID(id);
|
||||
append(lpDistributor);
|
||||
return(lpDistributor);
|
||||
}
|
||||
|
||||
cDistributor* cDistributorList::find(qint32 id)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->id() == id)
|
||||
return(at(x));
|
||||
}
|
||||
|
||||
cDistributor* lpDistributor = new cDistributor;
|
||||
lpDistributor->setID(id);
|
||||
append(lpDistributor);
|
||||
return(lpDistributor);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ public:
|
||||
void setPhone(const QString& szPhone);
|
||||
QString phone();
|
||||
|
||||
void setFax(const QString& szFax);
|
||||
QString fax();
|
||||
|
||||
void setEMail(const QString& szEMail);
|
||||
QString eMail();
|
||||
|
||||
@@ -48,6 +51,7 @@ private:
|
||||
QString m_szCity;
|
||||
QString m_szCountry;
|
||||
QString m_szPhone;
|
||||
QString m_szFax;
|
||||
QString m_szEMail;
|
||||
QString m_szLink;
|
||||
QString m_szDescription;
|
||||
@@ -59,6 +63,7 @@ class cDistributorList : public QList<cDistributor*>
|
||||
{
|
||||
public:
|
||||
cDistributor* add(qint32 id);
|
||||
cDistributor* find(qint32 id);
|
||||
};
|
||||
|
||||
#endif // CDISTRIBUTOR_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "cdistributoreditdialog.h"
|
||||
#include "ui_cdistributoreditdialog.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -36,6 +37,7 @@ void cDistributorEditDialog::setValues(cDistributor* lpDistributor)
|
||||
ui->m_lpCity->setText(lpDistributor->city());
|
||||
ui->m_lpCountry->setText(lpDistributor->country());
|
||||
ui->m_lpPhone->setText(lpDistributor->phone());
|
||||
ui->m_lpFax->setText(lpDistributor->fax());
|
||||
ui->m_lpEMail->setText(lpDistributor->eMail());
|
||||
ui->m_lpDescription->setText(lpDistributor->description());
|
||||
|
||||
@@ -72,7 +74,7 @@ bool cDistributorEditDialog::save()
|
||||
szQuery = QString("SELECT name FROM distributor WHERE name='%1' AND id <> %2;").arg(ui->m_lpName->text()).arg(m_id);
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -82,7 +84,7 @@ bool cDistributorEditDialog::save()
|
||||
return(false);
|
||||
}
|
||||
|
||||
szQuery = QString("UPDATE distributor SET name=:name, link=:link, address=:address, postal_code=:postal_code, city=:city, country=:country, phone=:phone, email=:email, description=:description WHERE id=:id;");
|
||||
szQuery = QString("UPDATE distributor SET name=:name, link=:link, address=:address, postal_code=:postal_code, city=:city, country=:country, phone=:phone, fax=:fax, email=:email, description=:description WHERE id=:id;");
|
||||
query.prepare(szQuery);
|
||||
query.bindValue(":name", ui->m_lpName->text());
|
||||
query.bindValue(":link", ui->m_lpLink->text());
|
||||
@@ -91,13 +93,14 @@ bool cDistributorEditDialog::save()
|
||||
query.bindValue(":city", ui->m_lpCity->text());
|
||||
query.bindValue(":country", ui->m_lpCountry->text());
|
||||
query.bindValue(":phone", ui->m_lpPhone->text());
|
||||
query.bindValue(":fax", ui->m_lpFax->text());
|
||||
query.bindValue(":email", ui->m_lpEMail->text());
|
||||
query.bindValue(":description", ui->m_lpDescription->document()->toPlainText());
|
||||
query.bindValue(":id", m_id);
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -112,7 +115,7 @@ bool cDistributorEditDialog::add()
|
||||
szQuery = QString("SELECT name FROM distributor WHERE name='%1';").arg(ui->m_lpName->text());
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -122,7 +125,7 @@ bool cDistributorEditDialog::add()
|
||||
return(false);
|
||||
}
|
||||
|
||||
szQuery = QString("INSERT INTO distributor (name, link, address, postal_code, city, country, phone, email, description) VALUES (:name, :link, :address, :postal_code, :city, :country, :phone, :email, :description);");
|
||||
szQuery = QString("INSERT INTO distributor (name, link, address, postal_code, city, country, phone, fax, email, description) VALUES (:name, :link, :address, :postal_code, :city, :country, :phone, :fax, :email, :description);");
|
||||
query.prepare(szQuery);
|
||||
query.bindValue(":name", ui->m_lpName->text());
|
||||
query.bindValue(":link", ui->m_lpLink->text());
|
||||
@@ -131,25 +134,26 @@ bool cDistributorEditDialog::add()
|
||||
query.bindValue(":city", ui->m_lpCity->text());
|
||||
query.bindValue(":country", ui->m_lpCountry->text());
|
||||
query.bindValue(":phone", ui->m_lpPhone->text());
|
||||
query.bindValue(":fax", ui->m_lpFax->text());
|
||||
query.bindValue(":email", ui->m_lpEMail->text());
|
||||
query.bindValue(":description", ui->m_lpDescription->document()->toPlainText());
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
szQuery = QString("SELECT id FROM distributor WHERE name='%1';").arg(ui->m_lpName->text());
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!query.next())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
+128
-96
@@ -17,117 +17,137 @@
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpAddress"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Postal:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpPostalCode"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>City:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpCity"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Country:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpCountry"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Phone:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpPhone"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>EMail:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpEMail"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Web:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpLink"/>
|
||||
<item row="3" column="4">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>EMail:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLineEdit" name="m_lpCity"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>City:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<widget class="QLineEdit" name="m_lpEMail"/>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Country:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Address:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Postal:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="m_lpPostalCode"/>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<widget class="QLineEdit" name="m_lpCountry"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Phone:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="m_lpPhone"/>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLineEdit" name="m_lpFax"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Fax:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="5" column="1" colspan="5">
|
||||
<widget class="QTextEdit" name="m_lpDescription"/>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="5">
|
||||
<widget class="QLineEdit" name="m_lpLink"/>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="5">
|
||||
<widget class="QLineEdit" name="m_lpAddress"/>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="5">
|
||||
<widget class="QLineEdit" name="m_lpName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -144,6 +164,18 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_lpName</tabstop>
|
||||
<tabstop>m_lpAddress</tabstop>
|
||||
<tabstop>m_lpPostalCode</tabstop>
|
||||
<tabstop>m_lpCity</tabstop>
|
||||
<tabstop>m_lpCountry</tabstop>
|
||||
<tabstop>m_lpPhone</tabstop>
|
||||
<tabstop>m_lpFax</tabstop>
|
||||
<tabstop>m_lpEMail</tabstop>
|
||||
<tabstop>m_lpLink</tabstop>
|
||||
<tabstop>m_lpDescription</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
||||
+18
-10
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "cdistributoreditdialog.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
@@ -40,7 +42,7 @@ void cDistributorWindow::showDistributorList()
|
||||
m_lpDistributorListModel->clear();
|
||||
|
||||
QStringList header;
|
||||
header << tr("Name") << tr("Phone") << tr("Email") << tr("address") << tr("postal") << tr("city") << tr("country") << tr("link") << tr("description");
|
||||
header << tr("Name") << tr("Phone") << tr("Fax") << tr("Email") << tr("address") << tr("postal") << tr("city") << tr("country") << tr("link") << tr("description");
|
||||
m_lpDistributorListModel->setHorizontalHeaderLabels(header);
|
||||
|
||||
for(int x = 0;x < m_lpDistributorList->count();x++)
|
||||
@@ -53,13 +55,14 @@ void cDistributorWindow::showDistributorList()
|
||||
|
||||
lpItems.at(0)->setText(lpDistributor->name());
|
||||
lpItems.at(1)->setText(lpDistributor->phone());
|
||||
lpItems.at(2)->setText(lpDistributor->eMail());
|
||||
lpItems.at(3)->setText(lpDistributor->address());
|
||||
lpItems.at(4)->setText(QString("%1").arg(lpDistributor->postalCode()));
|
||||
lpItems.at(5)->setText(lpDistributor->city());
|
||||
lpItems.at(6)->setText(lpDistributor->country());
|
||||
lpItems.at(7)->setText(lpDistributor->link());
|
||||
lpItems.at(8)->setText(lpDistributor->description());
|
||||
lpItems.at(2)->setText(lpDistributor->fax());
|
||||
lpItems.at(3)->setText(lpDistributor->eMail());
|
||||
lpItems.at(4)->setText(lpDistributor->address());
|
||||
lpItems.at(5)->setText(QString("%1").arg(lpDistributor->postalCode()));
|
||||
lpItems.at(6)->setText(lpDistributor->city());
|
||||
lpItems.at(7)->setText(lpDistributor->country());
|
||||
lpItems.at(8)->setText(lpDistributor->link());
|
||||
lpItems.at(9)->setText(lpDistributor->description());
|
||||
|
||||
for(int z = 0;z < header.count();z++)
|
||||
lpItems.at(z)->setData(QVariant::fromValue(lpDistributor), Qt::UserRole);
|
||||
@@ -215,7 +218,7 @@ void cDistributorWindow::onDelete()
|
||||
szQuery = QString("SELECT * FROM partlistitem WHERE distributorID = %1;").arg(lpDistributor->id());
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -231,7 +234,7 @@ void cDistributorWindow::onDelete()
|
||||
szQuery = QString("DELETE FROM distributor WHERE id=%1;").arg(lpDistributor->id());
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -239,3 +242,8 @@ void cDistributorWindow::onDelete()
|
||||
distributorChanged(0);
|
||||
showDistributorList();
|
||||
}
|
||||
|
||||
void cDistributorWindow::on_m_lpDistributorList_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
onEdit();
|
||||
}
|
||||
|
||||
@@ -28,11 +28,13 @@ public:
|
||||
void deleteDistributor();
|
||||
private slots:
|
||||
void on_m_lpDistributorList_clicked(const QModelIndex &index);
|
||||
void on_m_lpDistributorList_doubleClicked(const QModelIndex &index);
|
||||
void on_m_lpDistributorList_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
void onAdd();
|
||||
void onEdit();
|
||||
void onDelete();
|
||||
|
||||
signals:
|
||||
void selectionChanged(const QModelIndex& index) const;
|
||||
void distributorChanged(cDistributor* lpDistributor) const;
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
+47
-11
@@ -42,6 +42,7 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
loadDistributorList();
|
||||
loadPartGroupList();
|
||||
loadPartList();
|
||||
loadPartDistributorList();
|
||||
|
||||
updateMenu();
|
||||
}
|
||||
@@ -113,6 +114,7 @@ void cMainWindow::initDB()
|
||||
" city STRING,"
|
||||
" country STRING,"
|
||||
" phone STRING,"
|
||||
" fax STRING,"
|
||||
" email STRING,"
|
||||
" description TEXT);");
|
||||
}
|
||||
@@ -176,11 +178,11 @@ void cMainWindow::loadDistributorList()
|
||||
QSqlQuery query;
|
||||
QString szQuery;
|
||||
|
||||
szQuery = "SELECT id, name, link, address, postal_code, city, country, phone, email, link, description FROM distributor ORDER BY name;";
|
||||
szQuery = "SELECT id, name, link, address, postal_code, city, country, phone, fax, email, link, description FROM distributor ORDER BY name;";
|
||||
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -196,6 +198,7 @@ void cMainWindow::loadDistributorList()
|
||||
lpDistributor->setCity(query.value("city").toString());
|
||||
lpDistributor->setCountry(query.value("country").toString());
|
||||
lpDistributor->setPhone(query.value("phone").toString());
|
||||
lpDistributor->setFax(query.value("fax").toString());
|
||||
lpDistributor->setEMail(query.value("email").toString());
|
||||
lpDistributor->setLink(query.value("link").toString());
|
||||
lpDistributor->setDescription(query.value("description").toString());
|
||||
@@ -213,7 +216,7 @@ void cMainWindow::loadPartGroupList()
|
||||
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -239,24 +242,57 @@ void cMainWindow::loadPartList()
|
||||
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cPartGroup* lpPartGroup = m_partGroupList.find(query.value("part.partgroupID").toInt());
|
||||
cPartGroup* lpPartGroup = m_partGroupList.find(query.value("partgroupID").toInt());
|
||||
if(!lpPartGroup)
|
||||
return;
|
||||
|
||||
cPart* lpPart = m_partList.add(query.value("part.id").toInt());
|
||||
cPart* lpPart = m_partList.add(query.value("id").toInt());
|
||||
if(!lpPart)
|
||||
return;
|
||||
|
||||
lpPart->setName(query.value("part.name").toString());
|
||||
lpPart->setDescription(query.value("part.description").toString());
|
||||
lpPart->setName(query.value("name").toString());
|
||||
lpPart->setDescription(query.value("description").toString());
|
||||
lpPart->setPartGroup(lpPartGroup);
|
||||
lpPart->setLink(query.value("part.link").toString());
|
||||
lpPart->setLink(query.value("link").toString());
|
||||
}
|
||||
}
|
||||
|
||||
void cMainWindow::loadPartDistributorList()
|
||||
{
|
||||
m_partDistributorList.clear();
|
||||
|
||||
QSqlQuery query;
|
||||
QString szQuery;
|
||||
|
||||
szQuery = "SELECT id, name, description, partID, distributorID, price, link FROM part_distributor ORDER BY name;";
|
||||
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cPart* lpPart = m_partList.find(query.value("partID").toInt());
|
||||
cDistributor* lpDistributor = m_distributorList.find(query.value("distributorID").toInt());
|
||||
|
||||
cPartDistributor* lpPartDistributor = m_partDistributorList.add(query.value("id").toInt());
|
||||
if(!lpPartDistributor)
|
||||
return;
|
||||
|
||||
lpPartDistributor->setName(query.value("name").toString());
|
||||
lpPartDistributor->setDescription(query.value("description").toString());
|
||||
lpPartDistributor->setPart(lpPart);
|
||||
lpPartDistributor->setDistributor(lpDistributor);
|
||||
lpPartDistributor->setPrice(query.value("price").toReal());
|
||||
lpPartDistributor->setLink(query.value("link").toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +365,7 @@ void cMainWindow::on_m_lpMenuPartsShow_triggered()
|
||||
{
|
||||
m_lpPartWindow = new cPartWindow(this);
|
||||
ui->m_lpMainTab->addTab(m_lpPartWindow, tr("Parts"));
|
||||
m_lpPartWindow->setList(&m_partGroupList, &m_partList);
|
||||
m_lpPartWindow->setList(&m_partGroupList, &m_partList, &m_distributorList, &m_partDistributorList);
|
||||
|
||||
connect(m_lpPartWindow, SIGNAL(selectionChanged(QModelIndex)), this, SLOT(partSelectionChanged(QModelIndex)));
|
||||
connect(m_lpPartWindow, SIGNAL(partChanged(cPart*)), this, SLOT(partChanged(cPart*)));
|
||||
@@ -549,7 +585,7 @@ void cMainWindow::on_m_lpMenuPartlistOpen_triggered()
|
||||
|
||||
if(!query.exec("SELECT id, name, description FROM partlist ORDER BY name;"))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
QMessageBox::critical(this, "Error", "No projects found.");
|
||||
return;
|
||||
}
|
||||
|
||||
+41
-38
@@ -9,6 +9,7 @@
|
||||
#include "cdistributor.h"
|
||||
#include "cpartgroup.h"
|
||||
#include "cpart.h"
|
||||
#include "cpartdistributor.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QCloseEvent>
|
||||
@@ -29,55 +30,57 @@ public:
|
||||
~cMainWindow();
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui;
|
||||
QSqlDatabase m_db;
|
||||
cDistributorList m_distributorList;
|
||||
cPartGroupList m_partGroupList;
|
||||
cPartList m_partList;
|
||||
Ui::cMainWindow* ui;
|
||||
QSqlDatabase m_db;
|
||||
cDistributorList m_distributorList;
|
||||
cPartGroupList m_partGroupList;
|
||||
cPartList m_partList;
|
||||
cPartDistributorList m_partDistributorList;
|
||||
|
||||
cDistributorWindow* m_lpDistributorWindow;
|
||||
cPartWindow* m_lpPartWindow;
|
||||
cDistributorWindow* m_lpDistributorWindow;
|
||||
cPartWindow* m_lpPartWindow;
|
||||
|
||||
void initDB();
|
||||
void loadDistributorList();
|
||||
void loadPartGroupList();
|
||||
void loadPartList();
|
||||
void initDB();
|
||||
void loadDistributorList();
|
||||
void loadPartGroupList();
|
||||
void loadPartList();
|
||||
void loadPartDistributorList();
|
||||
|
||||
void updateMenu();
|
||||
void updateMenu();
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
private slots:
|
||||
void on_m_lpMenuFileNewProject_triggered();
|
||||
void on_m_lpMenuFileOpenProject_triggered();
|
||||
void on_m_lpMenuFileCloseProject_triggered();
|
||||
void on_m_lpMenuFileExport_triggered();
|
||||
void on_m_lpMenuFileClose_triggered();
|
||||
void on_m_lpMenuFileNewProject_triggered();
|
||||
void on_m_lpMenuFileOpenProject_triggered();
|
||||
void on_m_lpMenuFileCloseProject_triggered();
|
||||
void on_m_lpMenuFileExport_triggered();
|
||||
void on_m_lpMenuFileClose_triggered();
|
||||
|
||||
void on_m_lpMenuDistributorShow_triggered();
|
||||
void on_m_lpMenuDistributorAdd_triggered();
|
||||
void on_m_lpMenuDistributorEdit_triggered();
|
||||
void on_m_lpMenuDistributorDelete_triggered();
|
||||
void on_m_lpMenuDistributorShow_triggered();
|
||||
void on_m_lpMenuDistributorAdd_triggered();
|
||||
void on_m_lpMenuDistributorEdit_triggered();
|
||||
void on_m_lpMenuDistributorDelete_triggered();
|
||||
|
||||
void on_m_lpMenuPartsShow_triggered();
|
||||
void on_m_lpMenuPartsAdd_triggered();
|
||||
void on_m_lpMenuPartsEdit_triggered();
|
||||
void on_m_lpMenuPartsDelete_triggered();
|
||||
void on_m_lpMainTab_currentChanged(int);
|
||||
void on_m_lpMenuPartsShow_triggered();
|
||||
void on_m_lpMenuPartsAdd_triggered();
|
||||
void on_m_lpMenuPartsEdit_triggered();
|
||||
void on_m_lpMenuPartsDelete_triggered();
|
||||
void on_m_lpMainTab_currentChanged(int);
|
||||
|
||||
void distributorSelectionChanged(const QModelIndex& index);
|
||||
void distributorChanged(cDistributor* lpDistributor);
|
||||
void distributorSelectionChanged(const QModelIndex& index);
|
||||
void distributorChanged(cDistributor* lpDistributor);
|
||||
|
||||
void partSelectionChanged(const QModelIndex& index);
|
||||
void partGroupChanged(cPartGroup* lpPartGroup);
|
||||
void partChanged(cPart* lpPart);
|
||||
void partSelectionChanged(const QModelIndex& index);
|
||||
void partGroupChanged(cPartGroup* lpPartGroup);
|
||||
void partChanged(cPart* lpPart);
|
||||
|
||||
void partlistChanged(QWidget* lpWidget);
|
||||
void partlistChanged(QWidget* lpWidget);
|
||||
|
||||
void on_m_lpMenuPartlistNew_triggered();
|
||||
void on_m_lpMenuPartlistOpen_triggered();
|
||||
void on_m_lpMenuPartlistClose_triggered();
|
||||
void on_m_lpMenuPartlistSave_triggered();
|
||||
void on_m_lpMenuPartlistSaveAs_triggered();
|
||||
void on_m_lpMenuPartlistNew_triggered();
|
||||
void on_m_lpMenuPartlistOpen_triggered();
|
||||
void on_m_lpMenuPartlistClose_triggered();
|
||||
void on_m_lpMenuPartlistSave_triggered();
|
||||
void on_m_lpMenuPartlistSaveAs_triggered();
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
|
||||
@@ -62,15 +62,23 @@ cPartGroup* cPart::partGroup()
|
||||
}
|
||||
|
||||
cPart* cPartList::add(qint32 id)
|
||||
{
|
||||
cPart* lpPart = find(id);
|
||||
if(lpPart)
|
||||
return(lpPart);
|
||||
|
||||
lpPart = new cPart;
|
||||
lpPart->setID(id);
|
||||
append(lpPart);
|
||||
return(lpPart);
|
||||
}
|
||||
|
||||
cPart* cPartList::find(qint32 id)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->id() == id)
|
||||
return(at(x));
|
||||
}
|
||||
|
||||
cPart* lpPart = new cPart;
|
||||
lpPart->setID(id);
|
||||
append(lpPart);
|
||||
return(lpPart);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class cPartList : public QList<cPart*>
|
||||
{
|
||||
public:
|
||||
cPart* add(qint32 id);
|
||||
cPart* find(qint32 id);
|
||||
};
|
||||
|
||||
#endif // CPART_H
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
#include "cpartdistributor.h"
|
||||
|
||||
|
||||
cPartDistributor::cPartDistributor() :
|
||||
m_id(-1),
|
||||
m_szName(""),
|
||||
m_szDescription(""),
|
||||
m_lpPart(0),
|
||||
m_lpDistributor(0),
|
||||
m_dPrice(0.0),
|
||||
m_szLink("")
|
||||
{
|
||||
}
|
||||
|
||||
void cPartDistributor::setID(const qint32& id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
qint32 cPartDistributor::id()
|
||||
{
|
||||
return(m_id);
|
||||
}
|
||||
|
||||
void cPartDistributor::setName(const QString& szName)
|
||||
{
|
||||
m_szName = szName;
|
||||
}
|
||||
|
||||
QString cPartDistributor::name()
|
||||
{
|
||||
return(m_szName);
|
||||
}
|
||||
|
||||
void cPartDistributor::setDescription(const QString& szDescription)
|
||||
{
|
||||
m_szDescription = szDescription;
|
||||
}
|
||||
|
||||
QString cPartDistributor::description()
|
||||
{
|
||||
return(m_szDescription);
|
||||
}
|
||||
|
||||
void cPartDistributor::setPart(cPart* lpPart)
|
||||
{
|
||||
m_lpPart = lpPart;
|
||||
}
|
||||
|
||||
cPart* cPartDistributor::part()
|
||||
{
|
||||
return(m_lpPart);
|
||||
}
|
||||
|
||||
void cPartDistributor::setDistributor(cDistributor *lpDistributor)
|
||||
{
|
||||
m_lpDistributor = lpDistributor;
|
||||
}
|
||||
|
||||
cDistributor* cPartDistributor::distributor()
|
||||
{
|
||||
return(m_lpDistributor);
|
||||
}
|
||||
|
||||
void cPartDistributor::setPrice(const qreal& dPrice)
|
||||
{
|
||||
m_dPrice = dPrice;
|
||||
}
|
||||
|
||||
qreal cPartDistributor::price()
|
||||
{
|
||||
return(m_dPrice);
|
||||
}
|
||||
|
||||
void cPartDistributor::setLink(const QString& szLink)
|
||||
{
|
||||
m_szLink = szLink;
|
||||
}
|
||||
|
||||
QString cPartDistributor::link()
|
||||
{
|
||||
return(m_szLink);
|
||||
}
|
||||
|
||||
cPartDistributor* cPartDistributorList::add(qint32 id)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->id() == id)
|
||||
return(at(x));
|
||||
}
|
||||
|
||||
cPartDistributor* lpPartDistributor = new cPartDistributor;
|
||||
lpPartDistributor->setID(id);
|
||||
append(lpPartDistributor);
|
||||
return(lpPartDistributor);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef CPARTDISTRIBUTOR_H
|
||||
#define CPARTDISTRIBUTOR_H
|
||||
|
||||
|
||||
#include "cpart.h"
|
||||
#include "cdistributor.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
|
||||
|
||||
class cPartDistributor
|
||||
{
|
||||
public:
|
||||
cPartDistributor();
|
||||
|
||||
void setID(const qint32& id);
|
||||
qint32 id();
|
||||
|
||||
void setName(const QString& szName);
|
||||
QString name();
|
||||
|
||||
void setDescription(const QString& szDescription);
|
||||
QString description();
|
||||
|
||||
void setPart(cPart* lpPart);
|
||||
cPart* part();
|
||||
|
||||
void setDistributor(cDistributor* lpDistributor);
|
||||
cDistributor* distributor();
|
||||
|
||||
void setPrice(const qreal& dPrice);
|
||||
qreal price();
|
||||
|
||||
void setLink(const QString& szLink);
|
||||
QString link();
|
||||
private:
|
||||
qint32 m_id;
|
||||
QString m_szName;
|
||||
QString m_szDescription;
|
||||
cPart* m_lpPart;
|
||||
cDistributor* m_lpDistributor;
|
||||
qreal m_dPrice;
|
||||
QString m_szLink;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cPartDistributor*)
|
||||
|
||||
class cPartDistributorList : public QList<cPartDistributor*>
|
||||
{
|
||||
public:
|
||||
cPartDistributor* add(qint32 id);
|
||||
};
|
||||
|
||||
#endif // CPARTDISTRIBUTOR_H
|
||||
+66
-17
@@ -1,6 +1,7 @@
|
||||
#include "cparteditdialog.h"
|
||||
#include "ui_cparteditdialog.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -22,6 +23,9 @@ cPartEditDialog::cPartEditDialog(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
m_lpPartDistributorListModel = new QStandardItemModel(0, 2);
|
||||
ui->m_lpPartDistributorList->setModel(m_lpPartDistributorListModel);
|
||||
}
|
||||
|
||||
cPartEditDialog::~cPartEditDialog()
|
||||
@@ -29,10 +33,12 @@ cPartEditDialog::~cPartEditDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cPartEditDialog::setValues(cPart* lpPart, cPartGroupList* lpPartGroupList)
|
||||
void cPartEditDialog::setValues(cPart* lpPart, cPartGroupList* lpPartGroupList, cDistributorList *lpDistributorList, cPartDistributorList *lpPartDistributorList)
|
||||
{
|
||||
m_lpPart = lpPart;
|
||||
m_lpPartGroupList = lpPartGroupList;
|
||||
m_lpPart = lpPart;
|
||||
m_lpPartGroupList = lpPartGroupList;
|
||||
m_lpDistributorList = lpDistributorList;
|
||||
m_lpPartDistributorList = lpPartDistributorList;
|
||||
|
||||
for(int x = 0;x < m_lpPartGroupList->count();x++)
|
||||
ui->m_lpGroup->addItem(m_lpPartGroupList->at(x)->name(), QVariant::fromValue(m_lpPartGroupList->at(x)));
|
||||
@@ -46,9 +52,49 @@ void cPartEditDialog::setValues(cPart* lpPart, cPartGroupList* lpPartGroupList)
|
||||
ui->m_lpGroup->setCurrentText(lpPart->partGroup()->name());
|
||||
|
||||
m_id = lpPart->id();
|
||||
|
||||
showPartDistributorList();
|
||||
}
|
||||
}
|
||||
|
||||
void cPartEditDialog::showPartDistributorList()
|
||||
{
|
||||
m_lpPartDistributorListModel->clear();
|
||||
|
||||
QStringList header;
|
||||
header << tr("Name") << tr("Distributor") << tr("Price") << tr("Description") << tr("link");
|
||||
|
||||
m_lpPartDistributorListModel->setHorizontalHeaderLabels(header);
|
||||
|
||||
for(int x = 0;x < m_lpPartDistributorList->count();x++)
|
||||
{
|
||||
cPartDistributor* lpPartDistributor = m_lpPartDistributorList->at(x);
|
||||
|
||||
if(lpPartDistributor->part() == m_lpPart)
|
||||
{
|
||||
QList<QStandardItem*> lpItems;
|
||||
cDistributor* lpDistributor = lpPartDistributor->distributor();
|
||||
|
||||
for(int z = 0;z < header.count();z++)
|
||||
lpItems.append(new QStandardItem);
|
||||
|
||||
lpItems.at(0)->setText(lpPartDistributor->name());
|
||||
lpItems.at(1)->setText(lpDistributor->name());
|
||||
lpItems.at(2)->setText(QString::number(lpPartDistributor->price(), 'f', 2));
|
||||
lpItems.at(3)->setText(lpPartDistributor->description());
|
||||
lpItems.at(4)->setText(lpPartDistributor->link());
|
||||
|
||||
for(int z = 0;z < header.count();z++)
|
||||
lpItems.at(z)->setData(QVariant::fromValue(lpPartDistributor), Qt::UserRole);
|
||||
|
||||
m_lpPartDistributorListModel->appendRow(lpItems);
|
||||
}
|
||||
}
|
||||
|
||||
for(int z = 0;z < header.count();z++)
|
||||
ui->m_lpPartDistributorList->resizeColumnToContents(z);
|
||||
}
|
||||
|
||||
void cPartEditDialog::on_m_lpName_textChanged(const QString &arg1)
|
||||
{
|
||||
if(arg1.isEmpty())
|
||||
@@ -84,7 +130,7 @@ bool cPartEditDialog::save()
|
||||
query.bindValue(":partgroupID", qvariant_cast<cPartGroup*>(ui->m_lpGroup->currentData(Qt::UserRole))->id());
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -104,7 +150,7 @@ bool cPartEditDialog::save()
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
@@ -121,7 +167,7 @@ bool cPartEditDialog::add()
|
||||
query.bindValue(":partgroupID", qvariant_cast<cPartGroup*>(ui->m_lpGroup->currentData(Qt::UserRole))->id());
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -140,23 +186,23 @@ bool cPartEditDialog::add()
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
szQuery = QString("SELECT name FROM part WHERE name=:name AND partgroupID = :partgroupID;");
|
||||
szQuery = QString("SELECT id, name FROM part WHERE name=:name AND partgroupID = :partgroupID;");
|
||||
query.prepare(szQuery);
|
||||
query.bindValue(":name", ui->m_lpName->text());
|
||||
query.bindValue(":partgroupID", qvariant_cast<cPartGroup*>(ui->m_lpGroup->currentData(Qt::UserRole))->id());
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!query.next())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -182,7 +228,7 @@ void cPartEditDialog::on_m_lpGroupAdd_clicked()
|
||||
query.prepare("SELECT id FROM partgroup WHERE name=:name;");
|
||||
query.bindValue(":name", szGroup);
|
||||
if(!query.exec())
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
else
|
||||
{
|
||||
if(query.next())
|
||||
@@ -192,21 +238,24 @@ void cPartEditDialog::on_m_lpGroupAdd_clicked()
|
||||
query.prepare("INSERT INTO partgroup (name) VALUES(:name);");
|
||||
query.bindValue(":name", szGroup);
|
||||
if(!query.exec())
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
else
|
||||
{
|
||||
query.prepare("SELECT id FROM partgroup WHERE name=:name;");
|
||||
query.bindValue(":name", szGroup);
|
||||
if(!query.exec())
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
else
|
||||
{
|
||||
cPartGroup* lpGroup = m_lpPartGroupList->add(query.value("id").toInt());
|
||||
lpGroup->setName(szGroup);
|
||||
if(query.next())
|
||||
{
|
||||
cPartGroup* lpGroup = m_lpPartGroupList->add(query.value("id").toInt());
|
||||
lpGroup->setName(szGroup);
|
||||
|
||||
setValues(m_lpPart, m_lpPartGroupList);
|
||||
setValues(m_lpPart, m_lpPartGroupList, m_lpDistributorList, m_lpPartDistributorList);
|
||||
|
||||
ui->m_lpGroup->setCurrentText(szGroup);
|
||||
ui->m_lpGroup->setCurrentText(szGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -3,9 +3,13 @@
|
||||
|
||||
|
||||
#include "cpart.h"
|
||||
#include "cdistributor.h"
|
||||
#include "cpartdistributor.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cPartEditDialog;
|
||||
@@ -20,16 +24,21 @@ public:
|
||||
~cPartEditDialog();
|
||||
|
||||
qint32 id();
|
||||
void setValues(cPart* lpPart, cPartGroupList* lpPartGroupList);
|
||||
void setValues(cPart* lpPart, cPartGroupList* lpPartGroupList, cDistributorList* lpDistributorList, cPartDistributorList* lpPartDistributorList);
|
||||
private slots:
|
||||
void on_m_lpName_textChanged(const QString &arg1);
|
||||
void on_m_lpGroupAdd_clicked();
|
||||
|
||||
private:
|
||||
Ui::cPartEditDialog* ui;
|
||||
QStandardItemModel* m_lpPartDistributorListModel;
|
||||
qint32 m_id;
|
||||
cPart* m_lpPart;
|
||||
cPartGroupList* m_lpPartGroupList;
|
||||
cDistributorList* m_lpDistributorList;
|
||||
cPartDistributorList* m_lpPartDistributorList;
|
||||
|
||||
void showPartDistributorList();
|
||||
|
||||
bool save();
|
||||
bool add();
|
||||
|
||||
+30
-13
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>300</height>
|
||||
<height>585</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -66,18 +66,35 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="m_lpDescription"/>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="m_lpDescription"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Distributor</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="m_lpPartDistributorList">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_lpButtonBox">
|
||||
|
||||
+12
-7
@@ -1,6 +1,7 @@
|
||||
#include "cpartlistwindow.h"
|
||||
#include "ui_cpartlistwindow.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
@@ -52,13 +53,13 @@ void cPartlistWindow::setPartlistID(const qint32& id)
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!query.next())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,7 +129,7 @@ bool cPartlistWindow::saveAs()
|
||||
query.bindValue(":name", ui->m_lpName->text());
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -143,7 +144,7 @@ bool cPartlistWindow::saveAs()
|
||||
query.bindValue(":description", ui->m_lpDescription->document()->toPlainText());
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -151,7 +152,7 @@ bool cPartlistWindow::saveAs()
|
||||
query.bindValue(":name", ui->m_lpName->text());
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -171,7 +172,7 @@ bool cPartlistWindow::save(qint32 id)
|
||||
query.bindValue(":partlistID", id);
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -181,7 +182,7 @@ bool cPartlistWindow::save(qint32 id)
|
||||
query.bindValue(":id", id);
|
||||
if(!query.exec())
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -192,3 +193,7 @@ bool cPartlistWindow::somethingChanged()
|
||||
{
|
||||
return(m_bSomethingChanged);
|
||||
}
|
||||
|
||||
void cPartlistWindow::on_m_lpPartList_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
bool somethingChanged();
|
||||
private slots:
|
||||
void on_m_lpName_textChanged(const QString &arg1);
|
||||
void on_m_lpPartList_doubleClicked(const QModelIndex &index);
|
||||
|
||||
signals:
|
||||
void partlistChanged(QWidget* lpWidget) const;
|
||||
|
||||
+21
-8
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "cparteditdialog.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
@@ -15,7 +17,11 @@
|
||||
|
||||
cPartWindow::cPartWindow(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cPartWindow)
|
||||
ui(new Ui::cPartWindow),
|
||||
m_lpPartGroupList(0),
|
||||
m_lpPartList(0),
|
||||
m_lpDistributorList(0),
|
||||
m_lpPartDistributorList(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -28,10 +34,12 @@ cPartWindow::~cPartWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cPartWindow::setList(cPartGroupList* lpPartGroupList, cPartList* lpPartList)
|
||||
void cPartWindow::setList(cPartGroupList* lpPartGroupList, cPartList* lpPartList, cDistributorList *lpDistributorList, cPartDistributorList *lpPartDistributorList)
|
||||
{
|
||||
m_lpPartGroupList = lpPartGroupList;
|
||||
m_lpPartList = lpPartList;
|
||||
m_lpPartGroupList = lpPartGroupList;
|
||||
m_lpPartList = lpPartList;
|
||||
m_lpDistributorList = lpDistributorList;
|
||||
m_lpPartDistributorList = lpPartDistributorList;
|
||||
|
||||
showPartList();
|
||||
}
|
||||
@@ -142,7 +150,7 @@ void cPartWindow::deletePart()
|
||||
void cPartWindow::onAdd()
|
||||
{
|
||||
cPartEditDialog* lpDialog = new cPartEditDialog(this);
|
||||
lpDialog->setValues(0, m_lpPartGroupList);
|
||||
lpDialog->setValues(0, m_lpPartGroupList, m_lpDistributorList, m_lpPartDistributorList);
|
||||
|
||||
if(lpDialog->exec() == QDialog::Rejected)
|
||||
{
|
||||
@@ -190,7 +198,7 @@ void cPartWindow::onEdit()
|
||||
return;
|
||||
|
||||
cPartEditDialog* lpDialog = new cPartEditDialog(this);
|
||||
lpDialog->setValues(lpPart, m_lpPartGroupList);
|
||||
lpDialog->setValues(lpPart, m_lpPartGroupList, m_lpDistributorList, m_lpPartDistributorList);
|
||||
|
||||
if(lpDialog->exec() == QDialog::Rejected)
|
||||
{
|
||||
@@ -245,7 +253,7 @@ void cPartWindow::onDelete()
|
||||
szQuery = QString("SELECT * FROM partlistitem WHERE partID = %1;").arg(lpPart->id());
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -261,7 +269,7 @@ void cPartWindow::onDelete()
|
||||
szQuery = QString("DELETE FROM part WHERE id=%1;").arg(lpPart->id());
|
||||
if(!query.exec(szQuery))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
myDebug << query.lastError().text();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -269,3 +277,8 @@ void cPartWindow::onDelete()
|
||||
partChanged(0);
|
||||
showPartList();
|
||||
}
|
||||
|
||||
void cPartWindow::on_m_lpPartList_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
onEdit();
|
||||
}
|
||||
|
||||
+24
-19
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "cpart.h"
|
||||
#include "cpartgroup.h"
|
||||
#include "cdistributor.h"
|
||||
#include "cpartdistributor.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
@@ -21,33 +23,36 @@ public:
|
||||
explicit cPartWindow(QWidget *parent = 0);
|
||||
~cPartWindow();
|
||||
|
||||
void setList(cPartGroupList* lpPartGroupList, cPartList* lpPartList);
|
||||
bool somethingSelected();
|
||||
bool groupSelected();
|
||||
void setList(cPartGroupList* lpPartGroupList, cPartList* lpPartList, cDistributorList* lpDistributorList, cPartDistributorList* lpPartDistributorList);
|
||||
bool somethingSelected();
|
||||
bool groupSelected();
|
||||
|
||||
void addPart();
|
||||
void editPart();
|
||||
void deletePart();
|
||||
void addPart();
|
||||
void editPart();
|
||||
void deletePart();
|
||||
private slots:
|
||||
void on_m_lpPartList_clicked(const QModelIndex &index);
|
||||
void on_m_lpPartList_customContextMenuRequested(const QPoint &pos);
|
||||
void on_m_lpPartList_clicked(const QModelIndex &index);
|
||||
void on_m_lpPartList_customContextMenuRequested(const QPoint &pos);
|
||||
void on_m_lpPartList_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void onAdd();
|
||||
void onEdit();
|
||||
void onDelete();
|
||||
void onAdd();
|
||||
void onEdit();
|
||||
void onDelete();
|
||||
|
||||
signals:
|
||||
void selectionChanged(const QModelIndex& index) const;
|
||||
void partGroupChanged(cPartGroup* lpPartGroup) const;
|
||||
void partChanged(cPart* lpPart) const;
|
||||
void selectionChanged(const QModelIndex& index) const;
|
||||
void partGroupChanged(cPartGroup* lpPartGroup) const;
|
||||
void partChanged(cPart* lpPart) const;
|
||||
|
||||
private:
|
||||
Ui::cPartWindow* ui;
|
||||
QStandardItemModel* m_lpPartListModel;
|
||||
cPartGroupList* m_lpPartGroupList;
|
||||
cPartList* m_lpPartList;
|
||||
Ui::cPartWindow* ui;
|
||||
QStandardItemModel* m_lpPartListModel;
|
||||
cPartGroupList* m_lpPartGroupList;
|
||||
cPartList* m_lpPartList;
|
||||
cDistributorList* m_lpDistributorList;
|
||||
cPartDistributorList* m_lpPartDistributorList;
|
||||
|
||||
void showPartList();
|
||||
void showPartList();
|
||||
};
|
||||
|
||||
#endif // CPARTWINDOW_H
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
+4
-2
@@ -34,7 +34,8 @@ SOURCES += \
|
||||
cdistributoreditdialog.cpp \
|
||||
cpartgroup.cpp \
|
||||
cpart.cpp \
|
||||
cparteditdialog.cpp
|
||||
cparteditdialog.cpp \
|
||||
cpartdistributor.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
@@ -46,7 +47,8 @@ HEADERS += \
|
||||
cdistributoreditdialog.h \
|
||||
cpartgroup.h \
|
||||
cpart.h \
|
||||
cparteditdialog.h
|
||||
cparteditdialog.h \
|
||||
cpartdistributor.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui \
|
||||
|
||||
+10
-10
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.5.0, 2018-01-05T10:47:46. -->
|
||||
<!-- Written by QtCreator 4.4.1, 2018-01-08T15:45:10. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{bfe59401-82ec-419b-b187-ace4a5aa00ed}</value>
|
||||
<value type="QByteArray">{ae4c64ac-803d-420c-9f8a-6a863607cc06}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
@@ -59,14 +59,14 @@
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.10.0 MinGW 32bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.10.0 MinGW 32bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5100.win32_mingw53_kit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.9.3 MinGW 32bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.9.3 MinGW 32bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.593.win32_mingw53_kit</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/birkeh/Documents/GitHub/build-qtPartlist-Desktop_Qt_5_10_0_MinGW_32bit-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/vet0572/Documents/github/build-qtPartlist-Desktop_Qt_5_9_3_MinGW_32bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -120,7 +120,7 @@
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/birkeh/Documents/GitHub/build-qtPartlist-Desktop_Qt_5_10_0_MinGW_32bit-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/vet0572/Documents/github/build-qtPartlist-Desktop_Qt_5_9_3_MinGW_32bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -174,7 +174,7 @@
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/birkeh/Documents/GitHub/build-qtPartlist-Desktop_Qt_5_10_0_MinGW_32bit-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/vet0572/Documents/github/build-qtPartlist-Desktop_Qt_5_9_3_MinGW_32bit-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -286,13 +286,13 @@
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qtPartlist</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/birkeh/Documents/GitHub/qtPartlist/qtPartlist.pro</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/vet0572/Documents/github/qtPartlist/qtPartlist.pro</value>
|
||||
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">qtPartlist.pro</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">C:/Users/birkeh/Documents/GitHub/build-qtPartlist-Desktop_Qt_5_10_0_MinGW_32bit-Debug</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">C:/Users/vet0572/Documents/github/build-qtPartlist-Desktop_Qt_5_9_3_MinGW_32bit-Debug</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
|
||||
Reference in New Issue
Block a user