Compare commits
No commits in common. "3ec2143f28ebb489b7172b253c09fa744899866f" and "69dd1afba53b0159e6b8efb84d1e74d2176d66ac" have entirely different histories.
3ec2143f28
...
69dd1afba5
5 changed files with 8 additions and 23 deletions
|
@ -111,7 +111,6 @@ void BasketModel::finishSale()
|
||||||
emit beginRemoveRows(QModelIndex(), 0, marketplace_->getBasket().size() - 1);
|
emit beginRemoveRows(QModelIndex(), 0, marketplace_->getBasket().size() - 1);
|
||||||
marketplace_->finishCurrentSale();
|
marketplace_->finishCurrentSale();
|
||||||
emit endRemoveRows();
|
emit endRemoveRows();
|
||||||
emit basketDataChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasketModel::cancelSale()
|
void BasketModel::cancelSale()
|
||||||
|
|
|
@ -23,9 +23,6 @@ class BasketModel : public QAbstractTableModel
|
||||||
void cancelSale();
|
void cancelSale();
|
||||||
virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
||||||
|
|
||||||
signals:
|
|
||||||
void basketDataChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Marketplace* marketplace_;
|
Marketplace* marketplace_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#include "basketmodel.h"
|
#include "basketmodel.h"
|
||||||
#include "pricedialog.h"
|
#include "pricedialog.h"
|
||||||
#include "salemodel.h"
|
|
||||||
#include "sellerdialog.h"
|
#include "sellerdialog.h"
|
||||||
|
#include "salemodel.h"
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
@ -40,9 +40,6 @@ MainWindow::MainWindow()
|
||||||
&MainWindow::onCancelArticleButtonClicked);
|
&MainWindow::onCancelArticleButtonClicked);
|
||||||
connect(ui_.cancelAllArticlesButton, &QPushButton::clicked, this,
|
connect(ui_.cancelAllArticlesButton, &QPushButton::clicked, this,
|
||||||
&MainWindow::onCancelAllArticlesButtonClicked);
|
&MainWindow::onCancelAllArticlesButtonClicked);
|
||||||
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
|
||||||
static_cast<SaleModel*>(ui_.salesView->model()),
|
|
||||||
&SaleModel::onBasketDataChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionEditSeller_triggered()
|
void MainWindow::on_actionEditSeller_triggered()
|
||||||
|
@ -68,7 +65,6 @@ void MainWindow::on_paidButton_triggered()
|
||||||
dynamic_cast<BasketModel*>(ui_.basketView->model())->finishSale();
|
dynamic_cast<BasketModel*>(ui_.basketView->model())->finishSale();
|
||||||
ui_.lastPriceLabel1->setText(lastPrice);
|
ui_.lastPriceLabel1->setText(lastPrice);
|
||||||
ui_.lastPriceLabel2->setText(lastPrice);
|
ui_.lastPriceLabel2->setText(lastPrice);
|
||||||
// static_cast<SaleModel*>(ui_.salesView->model())->onDataChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,14 @@ QModelIndex SaleModel::parent(const QModelIndex& index) const
|
||||||
if (sale == rootItem.get())
|
if (sale == rootItem.get())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
else {
|
else {
|
||||||
|
/* auto iter =
|
||||||
|
std::find_if(marketplace_->getSales().begin(), marketplace_->getSales().end(),
|
||||||
|
[&sale](const auto& s) { return s.get() == sale; });
|
||||||
|
auto pos = std::distance(marketplace_->getSales().begin(), iter); */
|
||||||
return createIndex(-1, 0, rootItem.get());
|
return createIndex(-1, 0, rootItem.get());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// article = static_cast<Article*>(index.internalPointer());
|
||||||
article = dynamic_cast<Article*>(ent);
|
article = dynamic_cast<Article*>(ent);
|
||||||
|
|
||||||
if (!article) {
|
if (!article) {
|
||||||
|
@ -85,6 +90,7 @@ QVariant SaleModel::data(const QModelIndex& index, int role) const
|
||||||
case 1:
|
case 1:
|
||||||
myFont.setFamily("monospace");
|
myFont.setFamily("monospace");
|
||||||
return myFont;
|
return myFont;
|
||||||
|
return myFont;
|
||||||
default:
|
default:
|
||||||
return myFont;
|
return myFont;
|
||||||
}
|
}
|
||||||
|
@ -156,13 +162,3 @@ QVariant SaleModel::headerData(int section, Qt::Orientation orientation, int rol
|
||||||
} else
|
} else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaleModel::onBasketDataChanged()
|
|
||||||
{
|
|
||||||
emit beginResetModel();
|
|
||||||
auto& sales = marketplace_->getSales();
|
|
||||||
std::sort(sales.begin(), sales.end(), [](const auto& lhs, const auto& rhs) {
|
|
||||||
return lhs->getTimestamp() > rhs->getTimestamp();
|
|
||||||
});
|
|
||||||
emit endResetModel();
|
|
||||||
}
|
|
|
@ -14,14 +14,11 @@ class SaleModel : public QAbstractItemModel
|
||||||
QModelIndex index(int row, int column,
|
QModelIndex index(int row, int column,
|
||||||
const QModelIndex& parent = QModelIndex()) const override;
|
const QModelIndex& parent = QModelIndex()) const override;
|
||||||
QModelIndex parent(const QModelIndex& index) const override;
|
QModelIndex parent(const QModelIndex& index) const override;
|
||||||
QVariant data(const QModelIndex& index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
int rowCount(const QModelIndex& parent) const override;
|
int rowCount(const QModelIndex& parent) const override;
|
||||||
int columnCount(const QModelIndex& parent) const override;
|
int columnCount(const QModelIndex& parent) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
|
|
||||||
public slots:
|
|
||||||
void onBasketDataChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Marketplace* marketplace_;
|
Marketplace* marketplace_;
|
||||||
std::unique_ptr<Sale> rootItem{new Sale()};
|
std::unique_ptr<Sale> rootItem{new Sale()};
|
||||||
|
|
Loading…
Reference in a new issue