Quote Originally Posted by anda_skoa View Post
A lot of code duplication, this could be written much more compact.

1) no need for "this->"
2) everything up to the last "->" is equal to all cases. can be done outside the switch
3) call cases have return. no need to break
4) no case has local variables. no need to block braces.


Can still be read only, the model only needs to signal its changes to the view(s).

Cheers,
_
How do I signal changeds to the view, i.e., I have now following method:
Qt Code:
  1. void UeOrdersModel::ueAddOrder(const QString& userName,
  2. const QString& placeName,
  3. const QImage& productImage,
  4. const QString& productId,
  5. const QString& productName,
  6. const QString& productPriceSell,
  7. const quint64& productQuantity,
  8. const QString& productVAT)
  9. {
  10. QPair<QString, QString> key=QPair<QString, QString>(userName, placeName);
  11. if(this->ueOrders()->contains(key))
  12. {
  13. double priceSell=productPriceSell.toDouble();
  14. double priceVAT=productVAT.toDouble();
  15. double amountWithoutVAT=productQuantity*priceSell;
  16. double amountWithVAT=productQuantity*(priceSell+(priceSell*priceVAT));
  17. this->ueOrders()->value(key)->append(new UeOrderRecord(this,
  18. userName,
  19. placeName,
  20. productImage,
  21. productId,
  22. productName,
  23. productPriceSell,
  24. productQuantity,
  25. QString::number(amountWithoutVAT),
  26. productVAT,
  27. QString::number(amountWithVAT)));
  28. } // if
  29. } // ueAddOrder
To copy to clipboard, switch view to plain text mode 
How do I now send dataChanged() signal from this method to update QML ListView?