diff --git a/CustomerEdit.cpp b/CustomerEdit.cpp index 3a03046..a5052bd 100644 --- a/CustomerEdit.cpp +++ b/CustomerEdit.cpp @@ -18,11 +18,10 @@ #include "CustomerEdit.h" #include "ui_CustomerEdit.h" - +#include "functions.h" #include #include #include -#include "Macros.h" CustomerEdit::~CustomerEdit() { diff --git a/CustomerSearch.cpp b/CustomerSearch.cpp index 985f348..a1dcbcb 100644 --- a/CustomerSearch.cpp +++ b/CustomerSearch.cpp @@ -16,10 +16,11 @@ along with this program. If not, see . **/ #include "CustomerSearch.h" -#include "Macros.h" #include #include +#include +/* #include #include #include @@ -29,6 +30,7 @@ #include #include #include +*/ CustomerSearch::CustomerSearch(QWidget *parent) : QWidget(parent) diff --git a/CustomerSelection.cpp b/CustomerSelection.cpp index 46d280f..5ce665a 100644 --- a/CustomerSelection.cpp +++ b/CustomerSelection.cpp @@ -20,8 +20,6 @@ #include "ui_CustomerSelection.h" #include -#include "Macros.h" - CustomerSelection::CustomerSelection(QWidget *parent) : QDialog(parent), diff --git a/Database.cpp b/Database.cpp index cf2b399..b35c181 100644 --- a/Database.cpp +++ b/Database.cpp @@ -23,7 +23,7 @@ #include #include "User.h" #include "Database.h" -#include "Macros.h" +#include "functions.h" void insert_klient(const QString& skrot, const QString& full, const QString& tytul, const QString& imie, const QString& nazwisko, const QString& adres) { diff --git a/Database.h b/Database.h index 4a78812..1543b26 100644 --- a/Database.h +++ b/Database.h @@ -77,5 +77,4 @@ void insert_klient(const QString &skrot, const QString &full, const QString &tyt void insert_zapisane(const QString& nr_oferty, int id_klienta, const QString& data, int uid, const QString& zapytanie_data, const QString& zapytanie_nr, int dostawa, int termin, int platnosc, int oferta, const QString& uwagi); void insert_combo(const QString& typ, const QString& sh, const QString& lo); -//QStringList getUsersList(); #endif // DATABASE_H diff --git a/LoadDialog.cpp b/LoadDialog.cpp index ef744ac..3c1657e 100644 --- a/LoadDialog.cpp +++ b/LoadDialog.cpp @@ -18,7 +18,6 @@ #include "LoadDialog.h" #include "ui_LoadDialog.h" -#include "Macros.h" #include "OfferSearch.h" #include diff --git a/LoginDialog.cpp b/LoginDialog.cpp index 9f7d402..27070f1 100644 --- a/LoginDialog.cpp +++ b/LoginDialog.cpp @@ -63,7 +63,7 @@ LoginDialog::LoginDialog() : QObject::connect(m_db, &Database::newUsers, this, &LoginDialog::updateUserList); QObject::connect(m_db, &Database::changeStatus, ui->info, &QLabel::setText); connect(this, &LoginDialog::userListRequested, m_db, &Database::getUsersList); -// m_db->setupInitialConnection(); + emit(userListRequested()); } diff --git a/LoginDialog.h b/LoginDialog.h index 5b4bf8b..d71e9cf 100644 --- a/LoginDialog.h +++ b/LoginDialog.h @@ -34,11 +34,11 @@ class LoginDialog : public QDialog Q_OBJECT public: - explicit LoginDialog(); //konstruktor inicjalizujący elementy interface, user** służy do przekazania zwrotnego danych wybranego użytkownika + explicit LoginDialog(); ~LoginDialog(); public slots: - void ok(); //slot obsługujący przycisk ok - sprawdza zgodność skrótu wpisanego hasła ze skrótem zapisanym w klasie user i tworzy połączenie z bazą MySQL (klasa QSqlDatabase) + void ok(); void updateUserList(const QStringList&); signals: diff --git a/Macros.h b/Macros.h deleted file mode 100644 index 683b73e..0000000 --- a/Macros.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MACROS_H -#define MACROS_H - -#include -#include -#include -#include -#include -#include -#include - -#define EXEC_SILENT(s) \ -do{ \ - if(q.exec(s) == false) \ - { \ - qDebug() << "Zapytanie mysql zkończone niepowodzeniem!"; \ - qDebug() << "\tZapytanie mysql: " << s; \ - qDebug() << "\tError text: " << q.lastError().text(); \ - QMessageBox::warning(NULL, "error", "Wystąpił błąd połączenia z bazą danych. Sprawdź połączenie i spróbuj ponownie"); \ - return; \ - } \ -}while(0) - -#endif // MACROS_H diff --git a/MainWindow.cpp b/MainWindow.cpp index 0676eb8..cabcb33 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -37,7 +37,7 @@ #include "LoginDialog.h" #include "LoadDialog.h" #include "User.h" -#include "Macros.h" + #include "AddConditionDialog.h" #include "SettingsDialog.h" diff --git a/MerchandiseListModel.h b/MerchandiseListModel.h index 89ad8c0..cfcd75e 100644 --- a/MerchandiseListModel.h +++ b/MerchandiseListModel.h @@ -49,10 +49,7 @@ class MerchandiseListModel : public QAbstractTableModel public slots: void clear(); - void setKurs(double kurs); - - ///dodawanie towarów do tabeli (wywoływane przez sygnał z dialogu dodajTowar) void changeItemCount(int id, double ile); protected: diff --git a/MerchandiseNew.cpp b/MerchandiseNew.cpp index 43e9252..b3b7a7c 100644 --- a/MerchandiseNew.cpp +++ b/MerchandiseNew.cpp @@ -40,6 +40,11 @@ void MerchandiseNew::acc() { ui->pushButton_ok->setEnabled(false); + /********************** + * TODO + * Przenieść do klasy Database !!! + */ + QSqlQuery q; q.exec(QString("INSERT INTO `merchandise` (`id`, `code`, `description`, `price`, `unit`) VALUES (NULL, '%1', '%2', '%3', '%4')") .arg(ui->kod->text()) diff --git a/MerchandiseSearchModel.cpp b/MerchandiseSearchModel.cpp index 69b322b..7ba30d6 100644 --- a/MerchandiseSearchModel.cpp +++ b/MerchandiseSearchModel.cpp @@ -98,5 +98,4 @@ void MerchandiseSearchModel::setFilter(const QString &filter) QVariant MerchandiseSearchModel::d(const QModelIndex &index, int col) const { return sourceModel()->data(index.sibling(index.row(), col)); - // return sourceModel()->data(sourceModel()->index(index.row(), col, index.parent())); } diff --git a/MerchendiseSelectionDelegate.cpp b/MerchendiseSelectionDelegate.cpp index a74c9e0..21edd94 100644 --- a/MerchendiseSelectionDelegate.cpp +++ b/MerchendiseSelectionDelegate.cpp @@ -37,7 +37,6 @@ void MerchendiseSelectionDelegate::setModelData(QWidget *editor, QAbstractItemMo spinBox->interpretText(); double count = spinBox->value(); model->setData(index, count, Qt::EditRole); - // emit itemCountChanged(model->data(index, Qt::UserRole).toInt(), count); } void MerchendiseSelectionDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const diff --git a/MerchendiseSelectionDelegate.h b/MerchendiseSelectionDelegate.h index 336c0e1..3db7b9a 100644 --- a/MerchendiseSelectionDelegate.h +++ b/MerchendiseSelectionDelegate.h @@ -16,9 +16,6 @@ class MerchendiseSelectionDelegate : public QItemDelegate void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const; - -signals: - // void itemCountChanged(int id, double count) const; }; #endif // MERCHENDISESELECTIONDELEGATE_H diff --git a/User.cpp b/User.cpp index 065ebca..511f12f 100644 --- a/User.cpp +++ b/User.cpp @@ -57,6 +57,10 @@ User::~User() void User::nrOfertyInkrement() { + /******************** + * Też do bazy ? + */ + _nrOferty++; QString s = QString("UPDATE users SET nrOferty=%1 WHERE uid=%2").arg(_nrOferty).arg(_uid); @@ -67,7 +71,6 @@ void User::nrOfertyInkrement() _nrOferty--; qCritical() << "Zapytanie mysql zkonczone niepowodzeniem!"; qDebug() << "\tError text: " << q.lastError().text(); - // throw std::exception("Failed to execute query"); } } diff --git a/User.h b/User.h index 972d5d0..cea8e12 100644 --- a/User.h +++ b/User.h @@ -25,7 +25,7 @@ class QString; class QSqlDatabase; /*! - * \briefklasa przechowująca dane użytkownika + * \brief Klasa przechowująca dane użytkownika */ class User { diff --git a/functions.h b/functions.h index 1867c31..8f5b7ae 100644 --- a/functions.h +++ b/functions.h @@ -6,6 +6,26 @@ class QString; #include #include +#include +#include +#include +#include +#include +#include +#include + +#define EXEC_SILENT(s) \ +do{ \ + if(q.exec(s) == false) \ + { \ + qDebug() << "Zapytanie mysql zkończone niepowodzeniem!"; \ + qDebug() << "\tZapytanie mysql: " << s; \ + qDebug() << "\tError text: " << q.lastError().text(); \ + QMessageBox::warning(NULL, "error", "Wystąpił błąd połączenia z bazą danych. Sprawdź połączenie i spróbuj ponownie"); \ + return; \ + } \ +}while(0) + /*! * \brief filePath wyznacza bezwzględną ścieżka do pliku o nazwie jak plik wykonywalny z rozszerzeniem podanym jako parametr * \param suffix Rozszerzenie pliku (podawać z kropką) diff --git a/kOferta.pro b/kOferta.pro index 34991b3..1ed4780 100644 --- a/kOferta.pro +++ b/kOferta.pro @@ -26,7 +26,7 @@ CONFIG += c++11 TEMPLATE = app -DEFINES += VER=2.44 +DEFINES += VER=2.45 win32 { RC_FILE = res/koferta.rc @@ -40,12 +40,7 @@ win32 { DEFINES += RELEASE DEFINES += WIN32 - # DEFINES += QT_NO_DEBUG_OUTPUT - #LIBS += -L"C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86" -lUser32 -lAdvAPI32 - #LIBS += -L"C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x64" -lUser32 -lAdvAPI32 - #INCLUDEPATH += "C:/Program Files/MySQL/MySQL Connector C 6.1 6.1.2/include" - #LIBS += -L"C:/Program Files/MySQL/MySQL Connector C 6.1 6.1.2/lib" -llibmysql LIBS += -L"C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/lib" -llibmysql } @@ -59,7 +54,6 @@ DEPENDPATH += . res HEADERS += \ Database.h \ LoadDialog.h \ - Macros.h \ MainWindow.h \ User.h \ functions.h \ @@ -138,5 +132,4 @@ TRANSLATIONS = \ OTHER_FILES += \ LICENSE.md \ README.md \ - hosts \ res/koferta.rc