Create an enum for price sources

Probably settingscache would have been the correct place for the enum,
but keeping it in the same class/file where price sources are defined
sounds cleaner to me
This commit is contained in:
Fabio Bas 2014-07-02 19:13:05 +02:00
parent a9ffbf5d2d
commit 9ca5908de5
3 changed files with 10 additions and 7 deletions

View file

@ -24,6 +24,7 @@
#include "dlg_settings.h" #include "dlg_settings.h"
#include "main.h" #include "main.h"
#include "settingscache.h" #include "settingscache.h"
#include "priceupdater.h"
GeneralSettingsPage::GeneralSettingsPage() GeneralSettingsPage::GeneralSettingsPage()
{ {
@ -538,10 +539,10 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
switch(settingsCache->getPriceTagSource()) switch(settingsCache->getPriceTagSource())
{ {
case 0: case AbstractPriceUpdater::BLPPriceSource:
priceTagSource0->setChecked(true); priceTagSource0->setChecked(true);
break; break;
case 1: case AbstractPriceUpdater::DBPriceSource:
priceTagSource1->setChecked(true); priceTagSource1->setChecked(true);
break; break;
} }
@ -578,11 +579,11 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked)
if(!checked) if(!checked)
return; return;
int source=0; int source=AbstractPriceUpdater::BLPPriceSource;
if(priceTagSource0->isChecked()) if(priceTagSource0->isChecked())
source=0; source=AbstractPriceUpdater::BLPPriceSource;
if(priceTagSource1->isChecked()) if(priceTagSource1->isChecked())
source=1; source=AbstractPriceUpdater::DBPriceSource;
emit priceTagSourceChanged(source); emit priceTagSourceChanged(source);
} }

View file

@ -14,6 +14,8 @@ class QNetworkAccessManager;
class AbstractPriceUpdater : public QWidget class AbstractPriceUpdater : public QWidget
{ {
Q_OBJECT Q_OBJECT
public:
enum PriceSource { BLPPriceSource, DBPriceSource };
protected: protected:
const DeckList *deck; const DeckList *deck;
QNetworkAccessManager *nam; QNetworkAccessManager *nam;

View file

@ -648,10 +648,10 @@ void TabDeckEditor::actUpdatePrices()
switch(settingsCache->getPriceTagSource()) switch(settingsCache->getPriceTagSource())
{ {
case 0: case AbstractPriceUpdater::BLPPriceSource:
up = new BLPPriceUpdater(deckModel->getDeckList()); up = new BLPPriceUpdater(deckModel->getDeckList());
break; break;
case 1: case AbstractPriceUpdater::DBPriceSource:
up = new DBPriceUpdater(deckModel->getDeckList()); up = new DBPriceUpdater(deckModel->getDeckList());
break; break;
} }