mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Convert ScraperMode and ScraperStatus into enum class
This commit is contained in:
parent
89d7d76080
commit
9d7a554ab3
@ -130,12 +130,12 @@ void ComicVineDialog::goNext()
|
|||||||
if (content->currentWidget() == seriesQuestionWidget) {
|
if (content->currentWidget() == seriesQuestionWidget) {
|
||||||
if (seriesQuestionWidget->getYes()) {
|
if (seriesQuestionWidget->getYes()) {
|
||||||
QString volumeSearchString = comics[0].getParentFolderName();
|
QString volumeSearchString = comics[0].getParentFolderName();
|
||||||
mode = Volume;
|
mode = ScraperMode::Volume;
|
||||||
|
|
||||||
showSearchVolume(volumeSearchString);
|
showSearchVolume(volumeSearchString);
|
||||||
} else {
|
} else {
|
||||||
status = AutoSearching;
|
status = ScraperStatus::AutoSearching;
|
||||||
mode = SingleComicInList;
|
mode = ScraperMode::SingleComicInList;
|
||||||
ComicDB comic = comics[currentIndex];
|
ComicDB comic = comics[currentIndex];
|
||||||
QString title = comic.getTitleOrFileName();
|
QString title = comic.getTitleOrFileName();
|
||||||
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex + 1).arg(comics.length()).arg(title));
|
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex + 1).arg(comics.length()).arg(title));
|
||||||
@ -179,27 +179,27 @@ void ComicVineDialog::goBack()
|
|||||||
clearState();
|
clearState();
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case SelectingSeries:
|
case ScraperStatus::SelectingSeries:
|
||||||
if (mode == Volume)
|
if (mode == ScraperMode::Volume)
|
||||||
showSearchVolume();
|
showSearchVolume();
|
||||||
else
|
else
|
||||||
showSearchSingleComic();
|
showSearchSingleComic();
|
||||||
break;
|
break;
|
||||||
case SortingComics:
|
case ScraperStatus::SortingComics:
|
||||||
showSelectVolume();
|
showSelectVolume();
|
||||||
break;
|
break;
|
||||||
case SelectingComic:
|
case ScraperStatus::SelectingComic:
|
||||||
if (mode == SingleComic)
|
if (mode == ScraperMode::SingleComic)
|
||||||
showSelectVolume();
|
showSelectVolume();
|
||||||
break;
|
break;
|
||||||
case AutoSearching:
|
case ScraperStatus::AutoSearching:
|
||||||
if (mode == Volume)
|
if (mode == ScraperMode::Volume)
|
||||||
showSearchVolume();
|
showSearchVolume();
|
||||||
else
|
else
|
||||||
showSearchSingleComic();
|
showSearchSingleComic();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (mode == Volume)
|
if (mode == ScraperMode::Volume)
|
||||||
showSearchVolume();
|
showSearchVolume();
|
||||||
else
|
else
|
||||||
showSearchSingleComic();
|
showSearchSingleComic();
|
||||||
@ -248,8 +248,8 @@ void ComicVineDialog::show()
|
|||||||
searchVolumeWidget->clean();
|
searchVolumeWidget->clean();
|
||||||
|
|
||||||
if (comics.length() == 1) {
|
if (comics.length() == 1) {
|
||||||
status = AutoSearching;
|
status = ScraperStatus::AutoSearching;
|
||||||
mode = SingleComic;
|
mode = ScraperMode::SingleComic;
|
||||||
|
|
||||||
ComicDB singleComic = comics[0];
|
ComicDB singleComic = comics[0];
|
||||||
QString title = singleComic.getTitleOrFileName();
|
QString title = singleComic.getTitleOrFileName();
|
||||||
@ -296,16 +296,16 @@ void ComicVineDialog::debugClientResults(const QString &string)
|
|||||||
goBack();
|
goBack();
|
||||||
} else {
|
} else {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case SingleComic:
|
case ScraperMode::SingleComic:
|
||||||
case SingleComicInList:
|
case ScraperMode::SingleComicInList:
|
||||||
if (p.getNumResults() == 0)
|
if (p.getNumResults() == 0)
|
||||||
showSearchSingleComic();
|
showSearchSingleComic();
|
||||||
else if (status == SearchingVolume)
|
else if (status == ScraperStatus::SearchingVolume)
|
||||||
showSelectVolume(string);
|
showSelectVolume(string);
|
||||||
else
|
else
|
||||||
showSelectComic(string);
|
showSelectComic(string);
|
||||||
break;
|
break;
|
||||||
case Volume:
|
case ScraperMode::Volume:
|
||||||
if (p.getNumResults() == 0)
|
if (p.getNumResults() == 0)
|
||||||
showSearchVolume();
|
showSearchVolume();
|
||||||
else
|
else
|
||||||
@ -317,7 +317,7 @@ void ComicVineDialog::debugClientResults(const QString &string)
|
|||||||
|
|
||||||
void ComicVineDialog::showSeriesQuestion()
|
void ComicVineDialog::showSeriesQuestion()
|
||||||
{
|
{
|
||||||
status = AskingForInfo;
|
status = ScraperStatus::AskingForInfo;
|
||||||
content->setCurrentWidget(seriesQuestionWidget);
|
content->setCurrentWidget(seriesQuestionWidget);
|
||||||
backButton->setHidden(true);
|
backButton->setHidden(true);
|
||||||
skipButton->setHidden(true);
|
skipButton->setHidden(true);
|
||||||
@ -332,7 +332,7 @@ void ComicVineDialog::showSeriesQuestion()
|
|||||||
|
|
||||||
void ComicVineDialog::showSearchSingleComic()
|
void ComicVineDialog::showSearchSingleComic()
|
||||||
{
|
{
|
||||||
status = AskingForInfo;
|
status = ScraperStatus::AskingForInfo;
|
||||||
content->setCurrentWidget(searchSingleComicWidget);
|
content->setCurrentWidget(searchSingleComicWidget);
|
||||||
backButton->setHidden(true);
|
backButton->setHidden(true);
|
||||||
skipButton->setHidden(true);
|
skipButton->setHidden(true);
|
||||||
@ -349,7 +349,7 @@ void ComicVineDialog::showSearchVolume(const QString &volume)
|
|||||||
{
|
{
|
||||||
searchVolumeWidget->setVolumeInfo(volume);
|
searchVolumeWidget->setVolumeInfo(volume);
|
||||||
|
|
||||||
status = AskingForInfo;
|
status = ScraperStatus::AskingForInfo;
|
||||||
content->setCurrentWidget(searchVolumeWidget);
|
content->setCurrentWidget(searchVolumeWidget);
|
||||||
backButton->setHidden(true);
|
backButton->setHidden(true);
|
||||||
nextButton->setHidden(true);
|
nextButton->setHidden(true);
|
||||||
@ -369,7 +369,7 @@ void ComicVineDialog::showSelectVolume(const QString &json)
|
|||||||
|
|
||||||
void ComicVineDialog::showSelectVolume()
|
void ComicVineDialog::showSelectVolume()
|
||||||
{
|
{
|
||||||
status = SelectingSeries;
|
status = ScraperStatus::SelectingSeries;
|
||||||
|
|
||||||
content->setCurrentWidget(selectVolumeWidget);
|
content->setCurrentWidget(selectVolumeWidget);
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ void ComicVineDialog::showSelectVolume()
|
|||||||
|
|
||||||
void ComicVineDialog::showSelectComic(const QString &json)
|
void ComicVineDialog::showSelectComic(const QString &json)
|
||||||
{
|
{
|
||||||
status = SelectingComic;
|
status = ScraperStatus::SelectingComic;
|
||||||
|
|
||||||
content->setCurrentWidget(selectComicWidget);
|
content->setCurrentWidget(selectComicWidget);
|
||||||
selectComicWidget->load(json, currentVolumeId);
|
selectComicWidget->load(json, currentVolumeId);
|
||||||
@ -402,7 +402,7 @@ void ComicVineDialog::showSelectComic(const QString &json)
|
|||||||
|
|
||||||
void ComicVineDialog::showSortVolumeComics(const QString &json)
|
void ComicVineDialog::showSortVolumeComics(const QString &json)
|
||||||
{
|
{
|
||||||
status = SortingComics;
|
status = ScraperStatus::SortingComics;
|
||||||
|
|
||||||
content->setCurrentWidget(sortVolumeComicsWidget);
|
content->setCurrentWidget(sortVolumeComicsWidget);
|
||||||
|
|
||||||
@ -423,22 +423,22 @@ void ComicVineDialog::queryTimeOut()
|
|||||||
QMessageBox::warning(this, "Comic Vine error", "Time out connecting to Comic Vine");
|
QMessageBox::warning(this, "Comic Vine error", "Time out connecting to Comic Vine");
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case AutoSearching:
|
case ScraperStatus::AutoSearching:
|
||||||
if (mode == Volume)
|
if (mode == ScraperMode::Volume)
|
||||||
showSearchVolume();
|
showSearchVolume();
|
||||||
else
|
else
|
||||||
showSearchSingleComic();
|
showSearchSingleComic();
|
||||||
break;
|
break;
|
||||||
case SearchingVolume:
|
case ScraperStatus::SearchingVolume:
|
||||||
if (mode == Volume)
|
if (mode == ScraperMode::Volume)
|
||||||
showSearchVolume();
|
showSearchVolume();
|
||||||
else
|
else
|
||||||
showSearchSingleComic();
|
showSearchSingleComic();
|
||||||
break;
|
break;
|
||||||
case SearchingSingleComic:
|
case ScraperStatus::SearchingSingleComic:
|
||||||
showSearchSingleComic();
|
showSearchSingleComic();
|
||||||
break;
|
break;
|
||||||
case GettingVolumeComics:
|
case ScraperStatus::GettingVolumeComics:
|
||||||
showSelectVolume();
|
showSelectVolume();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -481,7 +481,7 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr
|
|||||||
QByteArray result = comicVineClient->getComicDetail(comicId, error, timeout); // TODO check timeOut or Connection error
|
QByteArray result = comicVineClient->getComicDetail(comicId, error, timeout); // TODO check timeOut or Connection error
|
||||||
if (error || timeout) {
|
if (error || timeout) {
|
||||||
// TODO
|
// TODO
|
||||||
if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
|
if (mode == ScraperMode::SingleComic || currentIndex == (comics.count() - 1)) {
|
||||||
emit accepted();
|
emit accepted();
|
||||||
} else {
|
} else {
|
||||||
goToNextComic();
|
goToNextComic();
|
||||||
@ -504,7 +504,7 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr
|
|||||||
}
|
}
|
||||||
QSqlDatabase::removeDatabase(connectionName);
|
QSqlDatabase::removeDatabase(connectionName);
|
||||||
|
|
||||||
if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
|
if (mode == ScraperMode::SingleComic || currentIndex == (comics.count() - 1)) {
|
||||||
emit accepted();
|
emit accepted();
|
||||||
} else {
|
} else {
|
||||||
goToNextComic();
|
goToNextComic();
|
||||||
@ -513,7 +513,7 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr
|
|||||||
|
|
||||||
void ComicVineDialog::toggleSkipButton()
|
void ComicVineDialog::toggleSkipButton()
|
||||||
{
|
{
|
||||||
if (mode == SingleComicInList)
|
if (mode == ScraperMode::SingleComicInList)
|
||||||
skipButton->setVisible(true);
|
skipButton->setVisible(true);
|
||||||
else
|
else
|
||||||
skipButton->setHidden(true);
|
skipButton->setHidden(true);
|
||||||
@ -521,7 +521,7 @@ void ComicVineDialog::toggleSkipButton()
|
|||||||
|
|
||||||
void ComicVineDialog::goToNextComic()
|
void ComicVineDialog::goToNextComic()
|
||||||
{
|
{
|
||||||
if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
|
if (mode == ScraperMode::SingleComic || currentIndex == (comics.count() - 1)) {
|
||||||
emit accepted();
|
emit accepted();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -559,7 +559,7 @@ void ComicVineDialog::setLoadingMessage(const QString &message)
|
|||||||
void ComicVineDialog::search()
|
void ComicVineDialog::search()
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case Volume:
|
case ScraperMode::Volume:
|
||||||
launchSearchVolume();
|
launchSearchVolume();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -580,17 +580,17 @@ void ComicVineDialog::searchVolume(const QString &v, int page)
|
|||||||
connect(comicVineClient, &ComicVineClient::finished, comicVineClient, &QObject::deleteLater);
|
connect(comicVineClient, &ComicVineClient::finished, comicVineClient, &QObject::deleteLater);
|
||||||
comicVineClient->search(v, page);
|
comicVineClient->search(v, page);
|
||||||
|
|
||||||
status = SearchingVolume;
|
status = ScraperStatus::SearchingVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicVineDialog::getVolumeComicsInfo(const QString &vID, int /* page */)
|
void ComicVineDialog::getVolumeComicsInfo(const QString &vID, int /* page */)
|
||||||
{
|
{
|
||||||
showLoading(tr("Retrieving volume info..."));
|
showLoading(tr("Retrieving volume info..."));
|
||||||
|
|
||||||
status = GettingVolumeComics;
|
status = ScraperStatus::GettingVolumeComics;
|
||||||
|
|
||||||
auto comicVineClient = new ComicVineClient;
|
auto comicVineClient = new ComicVineClient;
|
||||||
if (mode == Volume)
|
if (mode == ScraperMode::Volume)
|
||||||
connect(comicVineClient, &ComicVineClient::volumeComicsInfo, this, &ComicVineDialog::showSortVolumeComics);
|
connect(comicVineClient, &ComicVineClient::volumeComicsInfo, this, &ComicVineDialog::showSortVolumeComics);
|
||||||
else
|
else
|
||||||
connect(comicVineClient, &ComicVineClient::volumeComicsInfo, this, &ComicVineDialog::showSelectComic);
|
connect(comicVineClient, &ComicVineClient::volumeComicsInfo, this, &ComicVineDialog::showSelectComic);
|
||||||
|
@ -66,13 +66,13 @@ private:
|
|||||||
|
|
||||||
void toggleSkipButton();
|
void toggleSkipButton();
|
||||||
|
|
||||||
enum ScraperMode {
|
enum class ScraperMode {
|
||||||
SingleComic, // the scraper has been opened for a single comic
|
SingleComic, // the scraper has been opened for a single comic
|
||||||
Volume, // the scraper is trying to get comics info for a whole volume
|
Volume, // the scraper is trying to get comics info for a whole volume
|
||||||
SingleComicInList // the scraper has been opened for a list of unrelated comics
|
SingleComicInList // the scraper has been opened for a list of unrelated comics
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ScraperStatus {
|
enum class ScraperStatus {
|
||||||
AutoSearching,
|
AutoSearching,
|
||||||
AskingForInfo,
|
AskingForInfo,
|
||||||
SelectingComic,
|
SelectingComic,
|
||||||
|
Loading…
Reference in New Issue
Block a user