-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TvShow] Introduce SeasonNumber type
- Loading branch information
Showing
54 changed files
with
453 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "SeasonNumber.h" | ||
|
||
#include <QRegExp> | ||
#include <QString> | ||
|
||
SeasonNumber::SeasonNumber(int seasonNumber) : | ||
// Any number lower than 0 is regarded invalid => no episode number | ||
m_seasonNumber(seasonNumber > -1 ? seasonNumber : SeasonNumber::NoSeason.toInt()) | ||
{ | ||
} | ||
|
||
const SeasonNumber SeasonNumber::NoSeason = SeasonNumber(-1); | ||
const SeasonNumber SeasonNumber::SpecialsSeason = SeasonNumber(0); | ||
|
||
bool SeasonNumber::operator==(const SeasonNumber &other) const | ||
{ | ||
// Only valid IMDb id's are comparable | ||
return m_seasonNumber == other.m_seasonNumber; | ||
} | ||
|
||
bool SeasonNumber::operator!=(const SeasonNumber &other) const | ||
{ | ||
return !(*this == other); | ||
} | ||
|
||
bool SeasonNumber::operator>(const SeasonNumber &other) const | ||
{ | ||
return m_seasonNumber > other.m_seasonNumber; | ||
} | ||
|
||
bool SeasonNumber::operator<(const SeasonNumber &other) const | ||
{ | ||
return m_seasonNumber < other.m_seasonNumber; | ||
} | ||
|
||
int SeasonNumber::toInt() const | ||
{ | ||
return m_seasonNumber; | ||
} | ||
|
||
QString SeasonNumber::toPaddedString() const | ||
{ | ||
if (m_seasonNumber == SeasonNumber::NoSeason.toInt()) { | ||
return QStringLiteral("xx"); | ||
} | ||
return QString::number(m_seasonNumber).prepend((m_seasonNumber < 10) ? "0" : ""); | ||
} | ||
|
||
QString SeasonNumber::toString() const | ||
{ | ||
return QString::number(m_seasonNumber); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef DATA_SEASON_NUMBER | ||
#define DATA_SEASON_NUMBER | ||
|
||
#include <QString> | ||
|
||
class SeasonNumber | ||
{ | ||
public: | ||
SeasonNumber() = default; | ||
explicit SeasonNumber(int seasonNumber); | ||
|
||
bool operator==(const SeasonNumber &other) const; | ||
bool operator!=(const SeasonNumber &other) const; | ||
bool operator>(const SeasonNumber &other) const; | ||
bool operator<(const SeasonNumber &other) const; | ||
|
||
int toInt() const; | ||
QString toPaddedString() const; | ||
QString toString() const; | ||
|
||
static const SeasonNumber NoSeason; | ||
static const SeasonNumber SpecialsSeason; | ||
|
||
private: | ||
int m_seasonNumber; | ||
}; | ||
|
||
#endif // DATA_SEASON_NUMBER |
Oops, something went wrong.