#include "sqlqueryproductsmodel.h"

#include "../databaseinfo/databaseinfo.h"

SqlQueryProductsModel::SqlQueryProductsModel(QObject *parent)
    : QSqlQueryModel(parent) {}

QVariant SqlQueryProductsModel::data(const QModelIndex &item, int role) const {
  auto data = QSqlQueryModel::data(item, role);
  if (role == Qt::DisplayRole) {
    CREATE_INDEX(barcodeIndex, COLUMN::Products_ProductTypes_Barcode);
    if (item.column() == int(barcodeIndex))
      return data.toString().rightJustified(13, '0');
  }
  return data;
}
