Skip to content

Commit

Permalink
renamed to PixelsImageProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Childcity committed Jan 5, 2021
1 parent bae1f02 commit b0fbf8a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions 15PuzzleGame/15PuzzleGame.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ include(src/Utils/StdFutureWatcher/src/StdFutureWatcher.pri)
HEADERS += \
src/Dal/Image/Providers/imageproviderfactory.h \
src/Dal/Image/Providers/imageprovidertype.h \
src/Dal/Image/Providers/phubimageprovider.h \
src/Dal/Image/Providers/pixelsimageprovider.h \
src/Dal/Image/boardimagecontroller.h \
src/Dal/Image/Providers/flickrimageprovider.h \
src/Dal/Image/Providers/irundomimageprovider.h \
Expand All @@ -40,7 +40,7 @@ HEADERS += \

SOURCES += \
src/Dal/Image/Providers/imageproviderfactory.cpp \
src/Dal/Image/Providers/phubimageprovider.cpp \
src/Dal/Image/Providers/pixelsimageprovider.cpp \
src/Dal/Image/boardimagecontroller.cpp \
src/Dal/Image/Providers/flickrimageprovider.cpp \
src/Dal/Image/Providers/irundomimageprovider.cpp \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "phubimageprovider.h"
#include "PixelsImageProvider.h"
#include "main.h"

#include <QJsonObject>
Expand All @@ -7,18 +7,18 @@
namespace Dal::Image {


PHubImageProvider::PHubImageProvider(std::shared_ptr<Net::IDownloader> downloader)
PixelsImageProvider::PixelsImageProvider(std::shared_ptr<Net::IDownloader> downloader)
: downloader_(std::move(downloader))
{
if (! downloader_)
throw std::invalid_argument("downloader mustn't be nullptr");
}

PHubImageProvider::~PHubImageProvider()
PixelsImageProvider::~PixelsImageProvider()
{
DEBUG("~PHubImageProvider");
DEBUG("~PixelsImageProvider");
}
QImage PHubImageProvider::getRundomImage() const
QImage PixelsImageProvider::getRundomImage() const
{
const int rndPage = getFastNotSecureRandomNum(1, 50);
const auto rndPageUrl = QString("%1&page=%2").arg(getImgListUrl_).arg(rndPage);
Expand Down Expand Up @@ -74,7 +74,7 @@ QImage PHubImageProvider::getRundomImage() const
return QImage::fromData(tmpRes);
}

size_t PHubImageProvider::getFastNotSecureRandomNum(size_t min, size_t max) const
size_t PixelsImageProvider::getFastNotSecureRandomNum(size_t min, size_t max) const
{
using namespace std::chrono;
unsigned now = static_cast<unsigned>(system_clock::now().time_since_epoch().count());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
namespace Dal::Image {


class PHubImageProvider : public IRundomImageProvider {
class PixelsImageProvider : public IRundomImageProvider {
public:
explicit PHubImageProvider(std::shared_ptr<Net::IDownloader> downloader);
explicit PixelsImageProvider(std::shared_ptr<Net::IDownloader> downloader);

~PHubImageProvider() override;
~PixelsImageProvider() override;

// IRundomImageProvider interface
public:
Expand Down
4 changes: 2 additions & 2 deletions 15PuzzleGame/src/Dal/Image/boardimagecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "Net/downloader.h"
#include "Dal/Image/Providers/flickrimageprovider.h"
#include "Dal/Image/Providers/phubimageprovider.h"
#include "Dal/Image/Providers/pixelsimageprovider.h"

#include <QPoint>

Expand Down Expand Up @@ -33,7 +33,7 @@ void BoardImageController::getBoardImagesAsync(const QPoint &dimensions)
const auto downloader = std::make_shared<Net::Downloader>(cancelationRequest);
downloader->setTimeout(5s);

const auto imgProvider = std::make_unique<PHubImageProvider>(downloader);
const auto imgProvider = std::make_unique<PixelsImageProvider>(downloader);

const QImage fullImage(imgProvider->getRundomImage());

Expand Down

0 comments on commit b0fbf8a

Please sign in to comment.