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
cb370738
Commit
cb370738
authored
Nov 10, 2014
by
Fabio Bas
Browse files
Oracle: fetch release date and set type
and save them in cards.xml
parent
a320af70
Changes
4
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
cb370738
...
...
@@ -22,13 +22,15 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set)
xml
.
writeStartElement
(
"set"
);
xml
.
writeTextElement
(
"name"
,
set
->
getShortName
());
xml
.
writeTextElement
(
"longname"
,
set
->
getLongName
());
xml
.
writeTextElement
(
"settype"
,
set
->
getSetType
());
xml
.
writeTextElement
(
"releasedate"
,
set
->
getReleaseDate
().
toString
(
Qt
::
ISODate
));
xml
.
writeEndElement
();
return
xml
;
}
CardSet
::
CardSet
(
const
QString
&
_shortName
,
const
QString
&
_longName
)
:
shortName
(
_shortName
),
longName
(
_longName
)
CardSet
::
CardSet
(
const
QString
&
_shortName
,
const
QString
&
_longName
,
const
QString
&
_setType
,
const
QDate
&
_releaseDate
)
:
shortName
(
_shortName
),
longName
(
_longName
)
,
setType
(
_setType
),
releaseDate
(
_releaseDate
)
{
updateSortKey
();
}
...
...
@@ -703,7 +705,8 @@ void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
if
(
xml
.
readNext
()
==
QXmlStreamReader
::
EndElement
)
break
;
if
(
xml
.
name
()
==
"set"
)
{
QString
shortName
,
longName
;
QString
shortName
,
longName
,
setType
;
QDate
releaseDate
;
while
(
!
xml
.
atEnd
())
{
if
(
xml
.
readNext
()
==
QXmlStreamReader
::
EndElement
)
break
;
...
...
@@ -711,8 +714,12 @@ void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
shortName
=
xml
.
readElementText
();
else
if
(
xml
.
name
()
==
"longname"
)
longName
=
xml
.
readElementText
();
else
if
(
xml
.
name
()
==
"settype"
)
setType
=
xml
.
readElementText
();
else
if
(
xml
.
name
()
==
"releasedate"
)
releaseDate
=
QDate
::
fromString
(
xml
.
readElementText
(),
Qt
::
ISODate
);
}
sets
.
insert
(
shortName
,
new
CardSet
(
shortName
,
longName
));
sets
.
insert
(
shortName
,
new
CardSet
(
shortName
,
longName
,
setType
,
releaseDate
));
}
}
}
...
...
cockatrice/src/carddatabase.h
View file @
cb370738
...
...
@@ -4,6 +4,7 @@
#include
<QHash>
#include
<QPixmap>
#include
<QMap>
#include
<QDate>
#include
<QDataStream>
#include
<QList>
#include
<QXmlStreamReader>
...
...
@@ -27,11 +28,15 @@ class CardSet : public QList<CardInfo *> {
private:
QString
shortName
,
longName
;
unsigned
int
sortKey
;
QDate
releaseDate
;
QString
setType
;
public:
CardSet
(
const
QString
&
_shortName
=
QString
(),
const
QString
&
_longName
=
QString
());
CardSet
(
const
QString
&
_shortName
=
QString
(),
const
QString
&
_longName
=
QString
()
,
const
QString
&
_setType
=
QString
(),
const
QDate
&
_releaseDate
=
QDate
()
);
QString
getCorrectedShortName
()
const
;
QString
getShortName
()
const
{
return
shortName
;
}
QString
getLongName
()
const
{
return
longName
;
}
QString
getSetType
()
const
{
return
setType
;
}
QDate
getReleaseDate
()
const
{
return
releaseDate
;
}
int
getSortKey
()
const
{
return
sortKey
;
}
void
setSortKey
(
unsigned
int
_sortKey
);
void
updateSortKey
();
...
...
oracle/src/oracleimporter.cpp
View file @
cb370738
...
...
@@ -30,6 +30,8 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
QString
edition
;
QString
editionLong
;
QVariant
editionCards
;
QString
setType
;
QDate
releaseDate
;
bool
import
;
while
(
it
.
hasNext
())
{
...
...
@@ -37,12 +39,14 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
edition
=
map
.
value
(
"code"
).
toString
();
editionLong
=
map
.
value
(
"name"
).
toString
();
editionCards
=
map
.
value
(
"cards"
);
setType
=
map
.
value
(
"type"
).
toString
();
releaseDate
=
map
.
value
(
"releaseDate"
).
toDate
();
// core and expansion sets are marked to be imported by default
import
=
(
0
==
QString
::
compare
(
map
.
value
(
"type"
).
toString
()
,
QString
(
"core"
),
Qt
::
CaseInsensitive
)
||
0
==
QString
::
compare
(
map
.
value
(
"type"
).
toString
()
,
QString
(
"expansion"
),
Qt
::
CaseInsensitive
));
import
=
(
0
==
QString
::
compare
(
setType
,
QString
(
"core"
),
Qt
::
CaseInsensitive
)
||
0
==
QString
::
compare
(
setType
,
QString
(
"expansion"
),
Qt
::
CaseInsensitive
));
newSetList
.
append
(
SetToDownload
(
edition
,
editionLong
,
editionCards
,
import
));
newSetList
.
append
(
SetToDownload
(
edition
,
editionLong
,
editionCards
,
import
,
setType
,
releaseDate
));
}
qSort
(
newSetList
);
...
...
@@ -237,7 +241,7 @@ int OracleImporter::startImport()
if
(
!
curSet
->
getImport
())
continue
;
CardSet
*
set
=
new
CardSet
(
curSet
->
getShortName
(),
curSet
->
getLongName
());
CardSet
*
set
=
new
CardSet
(
curSet
->
getShortName
(),
curSet
->
getLongName
()
,
curSet
->
getSetType
(),
curSet
->
getReleaseDate
()
);
if
(
!
sets
.
contains
(
set
->
getShortName
()))
sets
.
insert
(
set
->
getShortName
(),
set
);
...
...
oracle/src/oracleimporter.h
View file @
cb370738
...
...
@@ -10,14 +10,18 @@ private:
QString
shortName
,
longName
;
bool
import
;
QVariant
cards
;
QDate
releaseDate
;
QString
setType
;
public:
const
QString
&
getShortName
()
const
{
return
shortName
;
}
const
QString
&
getLongName
()
const
{
return
longName
;
}
const
QVariant
&
getCards
()
const
{
return
cards
;
}
const
QString
&
getSetType
()
const
{
return
setType
;
}
const
QDate
&
getReleaseDate
()
const
{
return
releaseDate
;
}
bool
getImport
()
const
{
return
import
;
}
void
setImport
(
bool
_import
)
{
import
=
_import
;
}
SetToDownload
(
const
QString
&
_shortName
,
const
QString
&
_longName
,
const
QVariant
&
_cards
,
bool
_import
)
:
shortName
(
_shortName
),
longName
(
_longName
),
import
(
_import
),
cards
(
_cards
)
{
}
SetToDownload
(
const
QString
&
_shortName
,
const
QString
&
_longName
,
const
QVariant
&
_cards
,
bool
_import
,
const
QString
&
_setType
=
QString
(),
const
QDate
&
_releaseDate
=
QDate
()
)
:
shortName
(
_shortName
),
longName
(
_longName
),
import
(
_import
),
cards
(
_cards
)
,
setType
(
_setType
),
releaseDate
(
_releaseDate
)
{
}
bool
operator
<
(
const
SetToDownload
&
set
)
const
{
return
longName
.
compare
(
set
.
longName
,
Qt
::
CaseInsensitive
)
<
0
;
}
};
...
...
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