#include "numberseriesservice.h" #include "seasonservice.h" QSharedPointer NumberSeriesService::forPluginAndSeason(const QString& pluginId, const QSharedPointer& season) { QList > series = all(QString("pluginId = '%1' AND season = %2").arg(pluginId, QString::number(season->id()))); if (!series.isEmpty()) { load(series[0]); return series[0]; } return {}; } QSharedPointer NumberSeriesService::forPlugin(const QString& pluginId) { SeasonService sesSrv; QSharedPointer currentSeason = sesSrv.active(); if (!currentSeason.isNull()) { return forPluginAndSeason(pluginId, currentSeason); } return {}; } QSharedPointer NumberSeriesService::nextForPlugin(const QString& pluginId, qx::QxSession* pSession/* = nullptr*/) { QSharedPointer numSer = forPlugin(pluginId); if (numSer.isNull()) { return {}; } numSer->setLastNumber(numSer->lastNumber() + 1); update(numSer, pSession); return numSer; } QList > NumberSeriesService::allForSeason(const QSharedPointer& season) { return all(QString("season = %1").arg(QString::number(season->id()))); } QString NumberSeriesService::nextStrForPlugin(const QString& pluginId, qx::QxSession* pSession) { NumberSeriesPtr numSer = nextForPlugin(pluginId, pSession); return QString("%1%2").arg(numSer->prefix()).arg(numSer->lastNumber(), 5, 10, QLatin1Char('0')); }