Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
a44b7367
Commit
a44b7367
authored
Dec 05, 2014
by
Zach H
Browse files
removing blp pricing
parent
ef8bd60a
Changes
4
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/dlg_settings.cpp
View file @
a44b7367
...
@@ -567,29 +567,10 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
...
@@ -567,29 +567,10 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
priceTagsCheckBox
->
setChecked
(
settingsCache
->
getPriceTagFeature
());
priceTagsCheckBox
->
setChecked
(
settingsCache
->
getPriceTagFeature
());
connect
(
priceTagsCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
settingsCache
,
SLOT
(
setPriceTagFeature
(
int
)));
connect
(
priceTagsCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
settingsCache
,
SLOT
(
setPriceTagFeature
(
int
)));
priceTagSource0
=
new
QRadioButton
;
priceTagSource1
=
new
QRadioButton
;
switch
(
settingsCache
->
getPriceTagSource
())
{
case
AbstractPriceUpdater
::
DBPriceSource
:
priceTagSource1
->
setChecked
(
true
);
break
;
case
AbstractPriceUpdater
::
BLPPriceSource
:
default:
priceTagSource0
->
setChecked
(
true
);
break
;
}
connect
(
priceTagSource0
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
radioPriceTagSourceClicked
(
bool
)));
connect
(
priceTagSource1
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
radioPriceTagSourceClicked
(
bool
)));
connect
(
this
,
SIGNAL
(
priceTagSourceChanged
(
int
)),
settingsCache
,
SLOT
(
setPriceTagSource
(
int
)));
connect
(
this
,
SIGNAL
(
priceTagSourceChanged
(
int
)),
settingsCache
,
SLOT
(
setPriceTagSource
(
int
)));
QGridLayout
*
generalGrid
=
new
QGridLayout
;
QGridLayout
*
generalGrid
=
new
QGridLayout
;
generalGrid
->
addWidget
(
priceTagsCheckBox
,
0
,
0
);
generalGrid
->
addWidget
(
priceTagsCheckBox
,
0
,
0
);
generalGrid
->
addWidget
(
priceTagSource0
,
1
,
0
);
generalGrid
->
addWidget
(
priceTagSource1
,
2
,
0
);
generalGroupBox
=
new
QGroupBox
;
generalGroupBox
=
new
QGroupBox
;
generalGroupBox
->
setLayout
(
generalGrid
);
generalGroupBox
->
setLayout
(
generalGrid
);
...
@@ -602,9 +583,7 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
...
@@ -602,9 +583,7 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
void
DeckEditorSettingsPage
::
retranslateUi
()
void
DeckEditorSettingsPage
::
retranslateUi
()
{
{
priceTagsCheckBox
->
setText
(
tr
(
"Enable &price tag feature"
));
priceTagsCheckBox
->
setText
(
tr
(
"Enable &price tag feature from deckbrew.com"
));
priceTagSource0
->
setText
(
tr
(
"using data from blacklotusproject.com"
));
priceTagSource1
->
setText
(
tr
(
"using data from deckbrew.com"
));
generalGroupBox
->
setTitle
(
tr
(
"General"
));
generalGroupBox
->
setTitle
(
tr
(
"General"
));
}
}
...
@@ -613,12 +592,7 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked)
...
@@ -613,12 +592,7 @@ void DeckEditorSettingsPage::radioPriceTagSourceClicked(bool checked)
if
(
!
checked
)
if
(
!
checked
)
return
;
return
;
int
source
=
AbstractPriceUpdater
::
BLPPriceSource
;
int
source
=
AbstractPriceUpdater
::
DBPriceSource
;
if
(
priceTagSource0
->
isChecked
())
source
=
AbstractPriceUpdater
::
BLPPriceSource
;
if
(
priceTagSource1
->
isChecked
())
source
=
AbstractPriceUpdater
::
DBPriceSource
;
emit
priceTagSourceChanged
(
source
);
emit
priceTagSourceChanged
(
source
);
}
}
...
...
cockatrice/src/priceupdater.cpp
View file @
a44b7367
...
@@ -28,82 +28,6 @@ AbstractPriceUpdater::AbstractPriceUpdater(const DeckList *_deck)
...
@@ -28,82 +28,6 @@ AbstractPriceUpdater::AbstractPriceUpdater(const DeckList *_deck)
deck
=
_deck
;
deck
=
_deck
;
}
}
// blacklotusproject.com
/**
* Constructor.
*
* @param _deck deck.
*/
BLPPriceUpdater
::
BLPPriceUpdater
(
const
DeckList
*
_deck
)
:
AbstractPriceUpdater
(
_deck
)
{
}
/**
* Update the prices of the cards in deckList.
*/
void
BLPPriceUpdater
::
updatePrices
()
{
QString
q
=
"http://blacklotusproject.com/json/?cards="
;
QStringList
cards
=
deck
->
getCardList
();
for
(
int
i
=
0
;
i
<
cards
.
size
();
++
i
)
{
q
+=
cards
[
i
].
toLower
()
+
"|"
;
}
QUrl
url
(
q
.
replace
(
' '
,
'+'
));
QNetworkReply
*
reply
=
nam
->
get
(
QNetworkRequest
(
url
));
connect
(
reply
,
SIGNAL
(
finished
()),
this
,
SLOT
(
downloadFinished
()));
}
/**
* Called when the download of the json file with the prices is finished.
*/
void
BLPPriceUpdater
::
downloadFinished
()
{
QNetworkReply
*
reply
=
static_cast
<
QNetworkReply
*>
(
sender
());
bool
ok
;
QVariantMap
resultMap
=
QtJson
::
Json
::
parse
(
QString
(
reply
->
readAll
()),
ok
).
toMap
();
if
(
!
ok
)
{
reply
->
deleteLater
();
deleteLater
();
return
;
}
QMap
<
QString
,
float
>
cardsPrice
;
QListIterator
<
QVariant
>
it
(
resultMap
.
value
(
"cards"
).
toList
());
while
(
it
.
hasNext
())
{
QVariantMap
map
=
it
.
next
().
toMap
();
QString
name
=
map
.
value
(
"name"
).
toString
().
toLower
();
float
price
=
map
.
value
(
"price"
).
toString
().
toFloat
();
QString
set
=
map
.
value
(
"set_code"
).
toString
();
/**
* Make sure Masters Edition (MED) isn't the set, as it doesn't
* physically exist. Also check the price to see that the cheapest set
* ends up as the final price.
*/
if
(
set
!=
"MED"
&&
(
!
cardsPrice
.
contains
(
name
)
||
cardsPrice
.
value
(
name
)
>
price
))
cardsPrice
.
insert
(
name
,
price
);
}
InnerDecklistNode
*
listRoot
=
deck
->
getRoot
();
for
(
int
i
=
0
;
i
<
listRoot
->
size
();
i
++
)
{
InnerDecklistNode
*
currentZone
=
dynamic_cast
<
InnerDecklistNode
*>
(
listRoot
->
at
(
i
));
for
(
int
j
=
0
;
j
<
currentZone
->
size
();
j
++
)
{
DecklistCardNode
*
currentCard
=
dynamic_cast
<
DecklistCardNode
*>
(
currentZone
->
at
(
j
));
if
(
!
currentCard
)
continue
;
currentCard
->
setPrice
(
cardsPrice
[
currentCard
->
getName
().
toLower
()]);
}
}
reply
->
deleteLater
();
deleteLater
();
emit
finishedUpdate
();
}
// deckbrew.com
// deckbrew.com
/**
/**
...
...
cockatrice/src/priceupdater.h
View file @
a44b7367
...
@@ -18,7 +18,7 @@ class AbstractPriceUpdater : public QWidget
...
@@ -18,7 +18,7 @@ class AbstractPriceUpdater : public QWidget
{
{
Q_OBJECT
Q_OBJECT
public:
public:
enum
PriceSource
{
BLPPriceSource
,
DBPriceSource
};
enum
PriceSource
{
DBPriceSource
};
protected:
protected:
const
DeckList
*
deck
;
const
DeckList
*
deck
;
QNetworkAccessManager
*
nam
;
QNetworkAccessManager
*
nam
;
...
@@ -31,16 +31,6 @@ public:
...
@@ -31,16 +31,6 @@ public:
virtual
void
updatePrices
()
=
0
;
virtual
void
updatePrices
()
=
0
;
};
};
class
BLPPriceUpdater
:
public
AbstractPriceUpdater
{
Q_OBJECT
protected:
virtual
void
downloadFinished
();
public:
BLPPriceUpdater
(
const
DeckList
*
deck
);
virtual
void
updatePrices
();
};
class
DBPriceUpdater
:
public
AbstractPriceUpdater
class
DBPriceUpdater
:
public
AbstractPriceUpdater
{
{
Q_OBJECT
Q_OBJECT
...
...
cockatrice/src/tab_deck_editor.cpp
View file @
a44b7367
...
@@ -680,11 +680,8 @@ void TabDeckEditor::actUpdatePrices()
...
@@ -680,11 +680,8 @@ void TabDeckEditor::actUpdatePrices()
switch
(
settingsCache
->
getPriceTagSource
())
switch
(
settingsCache
->
getPriceTagSource
())
{
{
case
AbstractPriceUpdater
::
DBPriceSource
:
case
AbstractPriceUpdater
::
DBPriceSource
:
up
=
new
DBPriceUpdater
(
deckModel
->
getDeckList
());
break
;
case
AbstractPriceUpdater
::
BLPPriceSource
:
default:
default:
up
=
new
B
LP
PriceUpdater
(
deckModel
->
getDeckList
());
up
=
new
D
BPriceUpdater
(
deckModel
->
getDeckList
());
break
;
break
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment