#include "numberseriesservice.h" #include "seasonservice.h" #include "core-odb.hxx" NumberSeriesService::NumberSeriesService() { } QSharedPointer NumberSeriesService::forPluginAndSeason(QString pluginId, QSharedPointer season) { QList > series = all(QString("pluginId = '%1' AND season = %2").arg(pluginId, QString::number(season->id()))); if (!series.isEmpty()) { return series[0]; } return QSharedPointer(); } QSharedPointer NumberSeriesService::forPlugin(QString pluginId) { SeasonService sesSrv; QSharedPointer currentSeason = sesSrv.active(); if (!currentSeason.isNull()) { return forPluginAndSeason(pluginId, currentSeason); } return QSharedPointer(); } QSharedPointer NumberSeriesService::nextForPlugin(QString pluginId) { QSharedPointer numSer = forPlugin(pluginId); if (numSer.isNull()) { return QSharedPointer(); } numSer->setLastNumber(numSer->lastNumber() + 1); update(numSer); return numSer; } QList > NumberSeriesService::allForSeason(QSharedPointer season) { return all(QString("season = %1").arg(QString::number(season->id()))); } QString NumberSeriesService::nextStrForPlugin(QString pluginId) { NumberSeriesPtr numSer = nextForPlugin(pluginId); QString numSerStr; numSerStr.sprintf("%s%05d", numSer->prefix().toStdString().c_str(), numSer->lastNumber()); return numSerStr; }