Commit df659e58 authored by Daenyth's avatar Daenyth
Browse files

Mask set shortcodes for windows illegal filenames

Ref #122
parent e5d9692d
...@@ -16,12 +16,6 @@ ...@@ -16,12 +16,6 @@
const int CardDatabase::versionNeeded = 3; const int CardDatabase::versionNeeded = 3;
CardSet::CardSet(const QString &_shortName, const QString &_longName)
: shortName(_shortName), longName(_longName)
{
updateSortKey();
}
QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set) QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set)
{ {
xml.writeStartElement("set"); xml.writeStartElement("set");
...@@ -32,6 +26,24 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set) ...@@ -32,6 +26,24 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set)
return xml; return xml;
} }
CardSet::CardSet(const QString &_shortName, const QString &_longName)
: shortName(_shortName), longName(_longName)
{
updateSortKey();
}
QString CardSet::getCorrectedShortName() const
{
// Because windows is horrible.
QSet<QString> invalidFileNames;
invalidFileNames << "CON" << "PRN" << "AUX" << "NUL" << "COM1" << "COM2" <<
"COM3" << "COM4" << "COM5" << "COM6" << "COM7" << "COM8" << "COM9" <<
"LPT1" << "LPT2" << "LPT3" << "LPT4" << "LPT5" << "LPT6" << "LPT7" <<
"LPT8" << "LPT9";
return invalidFileNames.contains(shortName) ? shortName + "_" : shortName;
}
void CardSet::setSortKey(unsigned int _sortKey) void CardSet::setSortKey(unsigned int _sortKey)
{ {
sortKey = _sortKey; sortKey = _sortKey;
......
...@@ -26,6 +26,7 @@ private: ...@@ -26,6 +26,7 @@ private:
unsigned int sortKey; unsigned int sortKey;
public: public:
CardSet(const QString &_shortName = QString(), const QString &_longName = QString()); CardSet(const QString &_shortName = QString(), const QString &_longName = QString());
QString getCorrectedShortName() const;
QString getShortName() const { return shortName; } QString getShortName() const { return shortName; }
QString getLongName() const { return longName; } QString getLongName() const { return longName; }
int getSortKey() const { return sortKey; } int getSortKey() const { return sortKey; }
...@@ -51,7 +52,7 @@ public: ...@@ -51,7 +52,7 @@ public:
PictureToLoad(CardInfo *_card = 0, bool _stripped = false, bool _hq = true); PictureToLoad(CardInfo *_card = 0, bool _stripped = false, bool _hq = true);
CardInfo *getCard() const { return card; } CardInfo *getCard() const { return card; }
bool getStripped() const { return stripped; } bool getStripped() const { return stripped; }
QString getSetName() const { return sortedSets[setIndex]->getShortName(); } QString getSetName() const { return sortedSets[setIndex]->getCorrectedShortName(); }
bool nextSet(); bool nextSet();
bool getHq() const { return hq; } bool getHq() const { return hq; }
void setHq(bool _hq) { hq = _hq; } void setHq(bool _hq) { hq = _hq; }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment