use C++ features to show price
This commit is contained in:
parent
96d0a03ba8
commit
fa7938ca20
3 changed files with 37 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
#include "basketmodel.h"
|
||||
|
||||
#include <QFont>
|
||||
|
||||
BasketModel::BasketModel(Marketplace* market, QObject* parent)
|
||||
: QAbstractTableModel(parent), marketplace_(market)
|
||||
{
|
||||
|
@ -14,6 +16,22 @@ int BasketModel::columnCount([[maybe_unused]] const QModelIndex& parent) const {
|
|||
|
||||
QVariant BasketModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role == Qt::FontRole) {
|
||||
QFont myFont;
|
||||
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
[[fallthrough]];
|
||||
case 1:
|
||||
[[fallthrough]];
|
||||
case 2:
|
||||
return myFont;
|
||||
case 3:
|
||||
myFont.setFamily("monospace");
|
||||
return myFont;
|
||||
}
|
||||
}
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
|
@ -30,7 +48,7 @@ QVariant BasketModel::data(const QModelIndex& index, int role) const
|
|||
case 2:
|
||||
return article->getSeller()->getSellerNo();
|
||||
case 3:
|
||||
//return article->getPrice();
|
||||
// return article->getPrice();
|
||||
return article->getPriceAsString().c_str();
|
||||
default:
|
||||
return "???";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue