Model.cpp.template 607 B

1234567891011121314151617181920212223242526272829
  1. #include "%1.h"
  2. #include "MessageException.h"
  3. %1::%1(QObject *parent)
  4. : QxModelBase<%2>(parent)
  5. {
  6. }
  7. %1::~%1()
  8. {
  9. }
  10. void %1::fetchByName(const QString &name, int pageIndex)
  11. {
  12. qx::QxSqlQuery query;
  13. if (!name.isEmpty())
  14. query.where("t." + %2::column_NAME()).containsString(name).orderAsc("t." + %2::column_ID());
  15. query.orderAsc("t." + %2::column_ID());
  16. QStringList relations;
  17. relations << "<t>";
  18. this->countWithRelation(query, relations);
  19. this->limit(query, pageIndex);
  20. QSqlError error = this->qxFetchByQuery(query, relations);
  21. if (error.isValid())
  22. throw MessageException(error.text());
  23. }