Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bricklink/lot.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class Lot
int tierQuantity(int i) const { return m_tier_quantity [qBound(0, i, 2)]; }
void setTierQuantity(int i, int q) { m_tier_quantity [qBound(0, i, 2)] = q; }
double price() const { return m_price; }
double priceKilo() const { return price() > 0 && weight() > 0 ? price() / weight() * 1000 : 0; }
void setPrice(double p) { m_price = p; }
double tierPrice(int i) const { return m_tier_price[qBound(0, i, 2)]; }
void setTierPrice(int i, double p) { m_tier_price[qBound(0, i, 2)] = p; }
Expand Down
2 changes: 2 additions & 0 deletions src/common/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,7 @@ QVector<ColumnData> Document::defaultColumnLayout(bool simpleMode)
DocumentModel::PriceDiff,
DocumentModel::Price,
DocumentModel::Total,
DocumentModel::PriceKilo,
DocumentModel::Cost,
DocumentModel::Bulk,
DocumentModel::Sale,
Expand Down Expand Up @@ -1904,6 +1905,7 @@ QVector<ColumnData> Document::defaultColumnLayout(bool simpleMode)
DocumentModel::DateLastSold,
DocumentModel::PriceOrig,
DocumentModel::PriceDiff,
DocumentModel::PriceKilo,
DocumentModel::QuantityOrig,
DocumentModel::QuantityDiff,
};
Expand Down
10 changes: 10 additions & 0 deletions src/common/documentmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,16 @@ void DocumentModel::initializeColumns()
return doubleCompare(l1->total(), l2->total());
},
});
C(PriceKilo, Column {
.defaultWidth = 15,
.alignment = Qt::AlignRight,
.editable = false,
.title = QT_TR_NOOP("Price / kg"),
.displayFn = [&](const Lot *lot) { return lot->priceKilo(); },
.compareFn = [&](const Lot *l1, const Lot *l2) {
return doubleCompare(l1->priceKilo(), l2->priceKilo());
},
});
C(Sale, Column {
.defaultWidth = 5,
.alignment = Qt::AlignRight,
Expand Down
1 change: 1 addition & 0 deletions src/common/documentmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class DocumentModel : public QAbstractTableModel
PriceDiff,
Price,
Total,
PriceKilo,
Cost,
Bulk,
Sale,
Expand Down
1 change: 1 addition & 0 deletions src/desktop/documentdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,7 @@ QString DocumentDelegate::displayData(const QModelIndex &idx, const QVariant &di
case DocumentModel::PriceDiff:
case DocumentModel::Price:
case DocumentModel::Total:
case DocumentModel::PriceKilo:
case DocumentModel::Cost:
case DocumentModel::TierP1:
case DocumentModel::TierP2:
Expand Down
1 change: 1 addition & 0 deletions src/mobile/View.qml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ Page {
tint: Qt.rgba(1, 1, 0, .1)
}
}
DelegateChoice { roleValue: Document.PriceKilo; delegate: currencyDelegate }
DelegateChoice { roleValue: Document.Cost; delegate: currencyDelegate }
DelegateChoice { roleValue: Document.TierP1
GridCell {
Expand Down