Rework the way sets selection/importing works; fix #539 (rebased)
This commit is contained in:
parent
e69ca60164
commit
881cea27f4
13 changed files with 369 additions and 162 deletions
|
@ -33,7 +33,7 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set)
|
||||||
CardSet::CardSet(const QString &_shortName, const QString &_longName, const QString &_setType, const QDate &_releaseDate)
|
CardSet::CardSet(const QString &_shortName, const QString &_longName, const QString &_setType, const QDate &_releaseDate)
|
||||||
: shortName(_shortName), longName(_longName), releaseDate(_releaseDate), setType(_setType)
|
: shortName(_shortName), longName(_longName), releaseDate(_releaseDate), setType(_setType)
|
||||||
{
|
{
|
||||||
updateSortKey();
|
loadSetOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CardSet::getCorrectedShortName() const
|
QString CardSet::getCorrectedShortName() const
|
||||||
|
@ -58,12 +58,36 @@ void CardSet::setSortKey(unsigned int _sortKey)
|
||||||
settings.setValue("sortkey", sortKey);
|
settings.setValue("sortkey", sortKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardSet::updateSortKey()
|
void CardSet::loadSetOptions()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup("sets");
|
settings.beginGroup("sets");
|
||||||
settings.beginGroup(shortName);
|
settings.beginGroup(shortName);
|
||||||
|
|
||||||
sortKey = settings.value("sortkey", 0).toInt();
|
sortKey = settings.value("sortkey", 0).toInt();
|
||||||
|
enabled = settings.value("enabled", false).toBool();
|
||||||
|
isknown = settings.value("isknown", false).toBool();
|
||||||
|
// qDebug() << "load set" << shortName << "key" << sortKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardSet::setEnabled(bool _enabled)
|
||||||
|
{
|
||||||
|
enabled = _enabled;
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
settings.beginGroup("sets");
|
||||||
|
settings.beginGroup(shortName);
|
||||||
|
settings.setValue("enabled", enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardSet::setIsKnown(bool _isknown)
|
||||||
|
{
|
||||||
|
isknown = _isknown;
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
settings.beginGroup("sets");
|
||||||
|
settings.beginGroup(shortName);
|
||||||
|
settings.setValue("isknown", isknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SetList::CompareFunctor {
|
class SetList::CompareFunctor {
|
||||||
|
@ -79,6 +103,81 @@ void SetList::sortByKey()
|
||||||
qSort(begin(), end(), CompareFunctor());
|
qSort(begin(), end(), CompareFunctor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SetList::getEnabledSetsNum()
|
||||||
|
{
|
||||||
|
int num=0;
|
||||||
|
for (int i = 0; i < size(); ++i)
|
||||||
|
{
|
||||||
|
CardSet *set = at(i);
|
||||||
|
if(set->getEnabled())
|
||||||
|
++num;
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SetList::getUnknownSetsNum()
|
||||||
|
{
|
||||||
|
int num=0;
|
||||||
|
for (int i = 0; i < size(); ++i)
|
||||||
|
{
|
||||||
|
CardSet *set = at(i);
|
||||||
|
if(!set->getIsKnown())
|
||||||
|
++num;
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetList::enableAllUnknown()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < size(); ++i)
|
||||||
|
{
|
||||||
|
CardSet *set = at(i);
|
||||||
|
if(!set->getIsKnown())
|
||||||
|
{
|
||||||
|
set->setIsKnown(true);
|
||||||
|
set->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetList::enableAll()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < size(); ++i)
|
||||||
|
{
|
||||||
|
CardSet *set = at(i);
|
||||||
|
set->setIsKnown(true);
|
||||||
|
set->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetList::markAllAsKnown()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < size(); ++i)
|
||||||
|
{
|
||||||
|
CardSet *set = at(i);
|
||||||
|
if(!set->getIsKnown())
|
||||||
|
{
|
||||||
|
set->setIsKnown(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetList::guessSortKeys()
|
||||||
|
{
|
||||||
|
// sort by release date DESC; invalid dates to the bottom.
|
||||||
|
QDate distantFuture(2050, 1, 1);
|
||||||
|
int aHundredYears = 36500;
|
||||||
|
for (int i = 0; i < size(); ++i)
|
||||||
|
{
|
||||||
|
CardSet *set = at(i);
|
||||||
|
QDate date = set->getReleaseDate();
|
||||||
|
if(date.isNull())
|
||||||
|
set->setSortKey(aHundredYears);
|
||||||
|
else
|
||||||
|
set->setSortKey(date.daysTo(distantFuture));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PictureToLoad::PictureToLoad(CardInfo *_card, bool _hq)
|
PictureToLoad::PictureToLoad(CardInfo *_card, bool _hq)
|
||||||
: card(_card), setIndex(0), hq(_hq)
|
: card(_card), setIndex(0), hq(_hq)
|
||||||
{
|
{
|
||||||
|
@ -512,7 +611,7 @@ void CardInfo::getPixmap(QSize size, QPixmap &pixmap)
|
||||||
|
|
||||||
void CardInfo::clearPixmapCache()
|
void CardInfo::clearPixmapCache()
|
||||||
{
|
{
|
||||||
qDebug() << "Deleting pixmap for" << name;
|
//qDebug() << "Deleting pixmap for" << name;
|
||||||
QPixmapCache::remove(pixmapCacheKey);
|
QPixmapCache::remove(pixmapCacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,7 +835,11 @@ void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
|
||||||
else if (xml.name() == "releasedate")
|
else if (xml.name() == "releasedate")
|
||||||
releaseDate = QDate::fromString(xml.readElementText(), Qt::ISODate);
|
releaseDate = QDate::fromString(xml.readElementText(), Qt::ISODate);
|
||||||
}
|
}
|
||||||
sets.insert(shortName, new CardSet(shortName, longName, setType, releaseDate));
|
|
||||||
|
CardSet * newSet = getSet(shortName);
|
||||||
|
newSet->setLongName(longName);
|
||||||
|
newSet->setSetType(setType);
|
||||||
|
newSet->setReleaseDate(releaseDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -907,6 +1010,11 @@ void CardDatabase::picDownloadHqChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardDatabase::emitCardListChanged()
|
||||||
|
{
|
||||||
|
emit cardListChanged();
|
||||||
|
}
|
||||||
|
|
||||||
LoadStatus CardDatabase::loadCardDatabase(const QString &path, bool tokens)
|
LoadStatus CardDatabase::loadCardDatabase(const QString &path, bool tokens)
|
||||||
{
|
{
|
||||||
LoadStatus tempLoadStatus = NotLoaded;
|
LoadStatus tempLoadStatus = NotLoaded;
|
||||||
|
@ -919,8 +1027,6 @@ LoadStatus CardDatabase::loadCardDatabase(const QString &path, bool tokens)
|
||||||
while (setsIterator.hasNext())
|
while (setsIterator.hasNext())
|
||||||
allSets.append(setsIterator.next().value());
|
allSets.append(setsIterator.next().value());
|
||||||
allSets.sortByKey();
|
allSets.sortByKey();
|
||||||
for (int i = 0; i < allSets.size(); ++i)
|
|
||||||
allSets[i]->setSortKey(i);
|
|
||||||
|
|
||||||
emit cardListChanged();
|
emit cardListChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ private:
|
||||||
unsigned int sortKey;
|
unsigned int sortKey;
|
||||||
QDate releaseDate;
|
QDate releaseDate;
|
||||||
QString setType;
|
QString setType;
|
||||||
|
bool enabled, isknown;
|
||||||
public:
|
public:
|
||||||
CardSet(const QString &_shortName = QString(), const QString &_longName = QString(), const QString &_setType = QString(), const QDate &_releaseDate = QDate());
|
CardSet(const QString &_shortName = QString(), const QString &_longName = QString(), const QString &_setType = QString(), const QDate &_releaseDate = QDate());
|
||||||
QString getCorrectedShortName() const;
|
QString getCorrectedShortName() const;
|
||||||
|
@ -38,9 +39,17 @@ public:
|
||||||
QString getLongName() const { return longName; }
|
QString getLongName() const { return longName; }
|
||||||
QString getSetType() const { return setType; }
|
QString getSetType() const { return setType; }
|
||||||
QDate getReleaseDate() const { return releaseDate; }
|
QDate getReleaseDate() const { return releaseDate; }
|
||||||
|
void setLongName(QString & _longName) { longName = _longName; }
|
||||||
|
void setSetType(QString & _setType) { setType = _setType; }
|
||||||
|
void setReleaseDate(QDate & _releaseDate) { releaseDate = _releaseDate; }
|
||||||
|
|
||||||
|
void loadSetOptions();
|
||||||
int getSortKey() const { return sortKey; }
|
int getSortKey() const { return sortKey; }
|
||||||
void setSortKey(unsigned int _sortKey);
|
void setSortKey(unsigned int _sortKey);
|
||||||
void updateSortKey();
|
bool getEnabled() const { return enabled; }
|
||||||
|
void setEnabled(bool _enabled);
|
||||||
|
bool getIsKnown() const { return isknown; }
|
||||||
|
void setIsKnown(bool _isknown);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SetList : public QList<CardSet *> {
|
class SetList : public QList<CardSet *> {
|
||||||
|
@ -48,6 +57,12 @@ private:
|
||||||
class CompareFunctor;
|
class CompareFunctor;
|
||||||
public:
|
public:
|
||||||
void sortByKey();
|
void sortByKey();
|
||||||
|
void guessSortKeys();
|
||||||
|
void enableAllUnknown();
|
||||||
|
void enableAll();
|
||||||
|
void markAllAsKnown();
|
||||||
|
int getEnabledSetsNum();
|
||||||
|
int getUnknownSetsNum();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PictureToLoad {
|
class PictureToLoad {
|
||||||
|
@ -253,6 +268,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void clearPixmapCache();
|
void clearPixmapCache();
|
||||||
LoadStatus loadCardDatabase(const QString &path, bool tokens = false);
|
LoadStatus loadCardDatabase(const QString &path, bool tokens = false);
|
||||||
|
void emitCardListChanged();
|
||||||
private slots:
|
private slots:
|
||||||
void imageLoaded(CardInfo *card, QImage image);
|
void imageLoaded(CardInfo *card, QImage image);
|
||||||
void picDownloadChanged();
|
void picDownloadChanged();
|
||||||
|
|
|
@ -42,7 +42,10 @@ QVariant CardDatabaseModel::data(const QModelIndex &index, int role) const
|
||||||
QStringList setList;
|
QStringList setList;
|
||||||
const QList<CardSet *> &sets = card->getSets();
|
const QList<CardSet *> &sets = card->getSets();
|
||||||
for (int i = 0; i < sets.size(); i++)
|
for (int i = 0; i < sets.size(); i++)
|
||||||
setList << sets[i]->getShortName();
|
{
|
||||||
|
if(sets[i]->getEnabled())
|
||||||
|
setList << sets[i]->getShortName();
|
||||||
|
}
|
||||||
return setList.join(", ");
|
return setList.join(", ");
|
||||||
}
|
}
|
||||||
case ManaCostColumn: return role == SortRole ?
|
case ManaCostColumn: return role == SortRole ?
|
||||||
|
@ -77,9 +80,26 @@ void CardDatabaseModel::updateCardList()
|
||||||
for (int i = 0; i < cardList.size(); ++i)
|
for (int i = 0; i < cardList.size(); ++i)
|
||||||
disconnect(cardList[i], 0, this, 0);
|
disconnect(cardList[i], 0, this, 0);
|
||||||
|
|
||||||
cardList = db->getCardList();
|
cardList.clear();
|
||||||
for (int i = 0; i < cardList.size(); ++i)
|
|
||||||
connect(cardList[i], SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *)));
|
foreach(CardInfo * card, db->getCardList())
|
||||||
|
{
|
||||||
|
bool hasSet = false;
|
||||||
|
foreach(CardSet * set, card->getSets())
|
||||||
|
{
|
||||||
|
if(set->getEnabled())
|
||||||
|
{
|
||||||
|
hasSet = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasSet)
|
||||||
|
{
|
||||||
|
cardList.append(card);
|
||||||
|
connect(card, SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,11 @@ SetsModel::SetsModel(CardDatabase *_db, QObject *parent)
|
||||||
: QAbstractTableModel(parent), sets(_db->getSetList())
|
: QAbstractTableModel(parent), sets(_db->getSetList())
|
||||||
{
|
{
|
||||||
sets.sortByKey();
|
sets.sortByKey();
|
||||||
|
foreach(CardSet *set, sets)
|
||||||
|
{
|
||||||
|
if(set->getEnabled())
|
||||||
|
enabledSets.insert(set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetsModel::~SetsModel()
|
SetsModel::~SetsModel()
|
||||||
|
@ -20,12 +25,20 @@ int SetsModel::rowCount(const QModelIndex &parent) const
|
||||||
|
|
||||||
QVariant SetsModel::data(const QModelIndex &index, int role) const
|
QVariant SetsModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid() || (index.column() >= NUM_COLS) || (index.row() >= rowCount()) || (role != Qt::DisplayRole))
|
if (!index.isValid() || (index.column() >= NUM_COLS) || (index.row() >= rowCount()))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
CardSet *set = sets[index.row()];
|
CardSet *set = sets[index.row()];
|
||||||
|
|
||||||
|
if ( role == Qt::CheckStateRole && index.column() == EnabledCol )
|
||||||
|
return static_cast< int >( enabledSets.contains(set) ? Qt::Checked : Qt::Unchecked );
|
||||||
|
|
||||||
|
if (role != Qt::DisplayRole)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case SortKeyCol: return QString("%1").arg(set->getSortKey(), 4, 10, QChar('0'));
|
case SortKeyCol: return QString("%1").arg(set->getSortKey(), 8, 10, QChar('0'));
|
||||||
|
case IsKnownCol: return set->getIsKnown();
|
||||||
case SetTypeCol: return set->getSetType();
|
case SetTypeCol: return set->getSetType();
|
||||||
case ShortNameCol: return set->getShortName();
|
case ShortNameCol: return set->getShortName();
|
||||||
case LongNameCol: return set->getLongName();
|
case LongNameCol: return set->getLongName();
|
||||||
|
@ -34,12 +47,24 @@ QVariant SetsModel::data(const QModelIndex &index, int role) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SetsModel::setData(const QModelIndex & index, const QVariant & value, int role)
|
||||||
|
{
|
||||||
|
if (role == Qt::CheckStateRole && index.column () == EnabledCol)
|
||||||
|
{
|
||||||
|
toggleRow(index.row(), value == Qt::Checked);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant SetsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant SetsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if ((role != Qt::DisplayRole) || (orientation != Qt::Horizontal))
|
if ((role != Qt::DisplayRole) || (orientation != Qt::Horizontal))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case SortKeyCol: return tr("Key");
|
case SortKeyCol: return tr("Key");
|
||||||
|
case IsKnownCol: return tr("Is known");
|
||||||
|
case EnabledCol: return tr("Enabled");
|
||||||
case SetTypeCol: return tr("Set type");
|
case SetTypeCol: return tr("Set type");
|
||||||
case ShortNameCol: return tr("Set code");
|
case ShortNameCol: return tr("Set code");
|
||||||
case LongNameCol: return tr("Long name");
|
case LongNameCol: return tr("Long name");
|
||||||
|
@ -50,8 +75,17 @@ QVariant SetsModel::headerData(int section, Qt::Orientation orientation, int rol
|
||||||
|
|
||||||
Qt::ItemFlags SetsModel::flags(const QModelIndex &index) const
|
Qt::ItemFlags SetsModel::flags(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
Qt::ItemFlags result = QAbstractTableModel::flags(index);
|
if (!index.isValid())
|
||||||
return result | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
return 0;
|
||||||
|
|
||||||
|
Qt::ItemFlags flags = QAbstractTableModel::flags(index) |
|
||||||
|
Qt::ItemIsDragEnabled |
|
||||||
|
Qt::ItemIsDropEnabled;
|
||||||
|
|
||||||
|
if ( index.column() == EnabledCol)
|
||||||
|
flags |= Qt::ItemIsUserCheckable;
|
||||||
|
|
||||||
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::DropActions SetsModel::supportedDropActions() const
|
Qt::DropActions SetsModel::supportedDropActions() const
|
||||||
|
@ -86,6 +120,30 @@ bool SetsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetsModel::toggleRow(int row, bool enable)
|
||||||
|
{
|
||||||
|
CardSet *temp = sets.at(row);
|
||||||
|
|
||||||
|
if(enable)
|
||||||
|
enabledSets.insert(temp);
|
||||||
|
else
|
||||||
|
enabledSets.remove(temp);
|
||||||
|
|
||||||
|
emit dataChanged(index(row, EnabledCol), index(row, EnabledCol));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetsModel::toggleAll(bool enable)
|
||||||
|
{
|
||||||
|
enabledSets.clear();
|
||||||
|
if(enable)
|
||||||
|
{
|
||||||
|
foreach(CardSet *set, sets)
|
||||||
|
enabledSets.insert(set);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
void SetsModel::swapRows(int oldRow, int newRow)
|
void SetsModel::swapRows(int oldRow, int newRow)
|
||||||
{
|
{
|
||||||
beginRemoveRows(QModelIndex(), oldRow, oldRow);
|
beginRemoveRows(QModelIndex(), oldRow, oldRow);
|
||||||
|
@ -124,19 +182,35 @@ void SetsModel::sort(int column, Qt::SortOrder order)
|
||||||
emit dataChanged(index(0, 0), index(numRows - 1, columnCount() - 1));
|
emit dataChanged(index(0, 0), index(numRows - 1, columnCount() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetsModel::save()
|
void SetsModel::save(CardDatabase *db)
|
||||||
{
|
{
|
||||||
|
// order
|
||||||
for (int i = 0; i < sets.size(); i++)
|
for (int i = 0; i < sets.size(); i++)
|
||||||
sets[i]->setSortKey(i);
|
sets[i]->setSortKey(i+1);
|
||||||
|
|
||||||
|
// enabled sets
|
||||||
|
foreach(CardSet *set, sets)
|
||||||
|
set->setEnabled(enabledSets.contains(set));
|
||||||
|
|
||||||
sets.sortByKey();
|
sets.sortByKey();
|
||||||
|
|
||||||
|
db->emitCardListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetsModel::restore(CardDatabase *db)
|
void SetsModel::restore(CardDatabase *db)
|
||||||
{
|
{
|
||||||
|
// order
|
||||||
sets = db->getSetList();
|
sets = db->getSetList();
|
||||||
sets.sortByKey();
|
sets.sortByKey();
|
||||||
|
|
||||||
|
// enabled sets
|
||||||
|
enabledSets.clear();
|
||||||
|
foreach(CardSet *set, sets)
|
||||||
|
{
|
||||||
|
if(set->getEnabled())
|
||||||
|
enabledSets.insert(set);
|
||||||
|
}
|
||||||
|
|
||||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QSet>
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
|
|
||||||
class SetsProxyModel;
|
class SetsProxyModel;
|
||||||
|
@ -21,16 +22,18 @@ class SetsModel : public QAbstractTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class SetsProxyModel;
|
friend class SetsProxyModel;
|
||||||
private:
|
private:
|
||||||
static const int NUM_COLS = 5;
|
static const int NUM_COLS = 7;
|
||||||
SetList sets;
|
SetList sets;
|
||||||
|
QSet<CardSet *> enabledSets;
|
||||||
public:
|
public:
|
||||||
enum SetsColumns { SortKeyCol, LongNameCol, ShortNameCol, SetTypeCol, ReleaseDateCol };
|
enum SetsColumns { SortKeyCol, IsKnownCol, EnabledCol, LongNameCol, ShortNameCol, SetTypeCol, ReleaseDateCol };
|
||||||
|
|
||||||
SetsModel(CardDatabase *_db, QObject *parent = 0);
|
SetsModel(CardDatabase *_db, QObject *parent = 0);
|
||||||
~SetsModel();
|
~SetsModel();
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const { Q_UNUSED(parent); return NUM_COLS; }
|
int columnCount(const QModelIndex &parent = QModelIndex()) const { Q_UNUSED(parent); return NUM_COLS; }
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
bool setData(const QModelIndex & index, const QVariant & value, int role);
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
Qt::DropActions supportedDropActions() const;
|
Qt::DropActions supportedDropActions() const;
|
||||||
|
@ -39,8 +42,10 @@ public:
|
||||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
||||||
QStringList mimeTypes() const;
|
QStringList mimeTypes() const;
|
||||||
void swapRows(int oldRow, int newRow);
|
void swapRows(int oldRow, int newRow);
|
||||||
|
void toggleRow(int row, bool enable);
|
||||||
|
void toggleAll(bool enable);
|
||||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||||
void save();
|
void save(CardDatabase *db);
|
||||||
void restore(CardDatabase *db);
|
void restore(CardDatabase *db);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
#include <QTimer>
|
||||||
#include "tab_deck_editor.h"
|
#include "tab_deck_editor.h"
|
||||||
#include "window_sets.h"
|
#include "window_sets.h"
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
|
@ -291,6 +292,9 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
|
||||||
resize(950, 700);
|
resize(950, 700);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(setListChanged()), db, SIGNAL(cardListChanged()));
|
||||||
|
QTimer::singleShot(0, this, SLOT(checkUnknownSets()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TabDeckEditor::~TabDeckEditor()
|
TabDeckEditor::~TabDeckEditor()
|
||||||
|
@ -781,3 +785,40 @@ void TabDeckEditor::filterRemove(QAction *action) {
|
||||||
|
|
||||||
filterModel->removeRow(idx.row(), idx.parent());
|
filterModel->removeRow(idx.row(), idx.parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabDeckEditor::checkUnknownSets()
|
||||||
|
{
|
||||||
|
SetList sets = db->getSetList();
|
||||||
|
|
||||||
|
// no set is enabled. Probably this is the first time running trice
|
||||||
|
if(!sets.getEnabledSetsNum())
|
||||||
|
{
|
||||||
|
sets.guessSortKeys();
|
||||||
|
sets.sortByKey();
|
||||||
|
sets.enableAll();
|
||||||
|
db->emitCardListChanged();
|
||||||
|
|
||||||
|
actEditSets();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int numUnknownSets = sets.getUnknownSetsNum();
|
||||||
|
// no unkown sets.
|
||||||
|
if(!numUnknownSets)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int ret = QMessageBox::question(this, tr("New sets found"), tr("%1 new set(s) have been found in the card database. Do you want to enable them?").arg(numUnknownSets), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
|
||||||
|
|
||||||
|
switch(ret)
|
||||||
|
{
|
||||||
|
case QMessageBox::No:
|
||||||
|
sets.markAllAsKnown();
|
||||||
|
break;
|
||||||
|
case QMessageBox::Yes:
|
||||||
|
sets.enableAllUnknown();
|
||||||
|
db->emitCardListChanged();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
|
@ -111,10 +111,12 @@ public:
|
||||||
void setDeck(DeckLoader *_deckLoader);
|
void setDeck(DeckLoader *_deckLoader);
|
||||||
void setModified(bool _windowModified);
|
void setModified(bool _windowModified);
|
||||||
bool confirmClose();
|
bool confirmClose();
|
||||||
public slots:
|
public slots:
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
void checkUnknownSets();
|
||||||
signals:
|
signals:
|
||||||
void deckEditorClosing(TabDeckEditor *tab);
|
void deckEditorClosing(TabDeckEditor *tab);
|
||||||
|
void setListChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QItemSelection>
|
#include <QItemSelection>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
WndSets::WndSets(QWidget *parent)
|
WndSets::WndSets(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
|
@ -37,12 +40,18 @@ WndSets::WndSets(QWidget *parent)
|
||||||
|
|
||||||
view->sortByColumn(SetsModel::SortKeyCol, Qt::AscendingOrder);
|
view->sortByColumn(SetsModel::SortKeyCol, Qt::AscendingOrder);
|
||||||
view->setColumnHidden(SetsModel::SortKeyCol, true);
|
view->setColumnHidden(SetsModel::SortKeyCol, true);
|
||||||
|
view->setColumnHidden(SetsModel::IsKnownCol, true);
|
||||||
view->setRootIsDecorated(false);
|
view->setRootIsDecorated(false);
|
||||||
|
|
||||||
saveButton = new QPushButton(tr("Save set ordering"));
|
enableButton = new QPushButton(tr("Enable set"));
|
||||||
connect(saveButton, SIGNAL(clicked()), this, SLOT(actSave()));
|
connect(enableButton, SIGNAL(clicked()), this, SLOT(actEnable()));
|
||||||
restoreButton = new QPushButton(tr("Restore saved set ordering"));
|
disableButton = new QPushButton(tr("Disable set"));
|
||||||
connect(restoreButton, SIGNAL(clicked()), this, SLOT(actRestore()));
|
connect(disableButton, SIGNAL(clicked()), this, SLOT(actDisable()));
|
||||||
|
enableAllButton = new QPushButton(tr("Enable all sets"));
|
||||||
|
connect(enableAllButton, SIGNAL(clicked()), this, SLOT(actEnableAll()));
|
||||||
|
disableAllButton = new QPushButton(tr("Disable all sets"));
|
||||||
|
connect(disableAllButton, SIGNAL(clicked()), this, SLOT(actDisableAll()));
|
||||||
|
|
||||||
upButton = new QPushButton(tr("Move selected set up"));
|
upButton = new QPushButton(tr("Move selected set up"));
|
||||||
connect(upButton, SIGNAL(clicked()), this, SLOT(actUp()));
|
connect(upButton, SIGNAL(clicked()), this, SLOT(actUp()));
|
||||||
downButton = new QPushButton(tr("Move selected set down"));
|
downButton = new QPushButton(tr("Move selected set down"));
|
||||||
|
@ -52,6 +61,8 @@ WndSets::WndSets(QWidget *parent)
|
||||||
bottomButton = new QPushButton(tr("Move selected set to bottom"));
|
bottomButton = new QPushButton(tr("Move selected set to bottom"));
|
||||||
connect(bottomButton, SIGNAL(clicked()), this, SLOT(actBottom()));
|
connect(bottomButton, SIGNAL(clicked()), this, SLOT(actBottom()));
|
||||||
|
|
||||||
|
enableButton->setDisabled(true);
|
||||||
|
disableButton->setDisabled(true);
|
||||||
upButton->setDisabled(true);
|
upButton->setDisabled(true);
|
||||||
downButton->setDisabled(true);
|
downButton->setDisabled(true);
|
||||||
topButton->setDisabled(true);
|
topButton->setDisabled(true);
|
||||||
|
@ -60,17 +71,31 @@ WndSets::WndSets(QWidget *parent)
|
||||||
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
|
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
|
||||||
this, SLOT(actToggleButtons(const QItemSelection &, const QItemSelection &)));
|
this, SLOT(actToggleButtons(const QItemSelection &, const QItemSelection &)));
|
||||||
|
|
||||||
|
QGroupBox *toggleFrame = new QGroupBox(tr("Enable sets"));
|
||||||
|
QVBoxLayout *toggleVBox = new QVBoxLayout;
|
||||||
|
toggleVBox->addWidget(enableButton);
|
||||||
|
toggleVBox->addWidget(disableButton);
|
||||||
|
toggleVBox->addWidget(enableAllButton);
|
||||||
|
toggleVBox->addWidget(disableAllButton);
|
||||||
|
toggleFrame->setLayout(toggleVBox);
|
||||||
|
|
||||||
|
QGroupBox *sortFrame = new QGroupBox(tr("Sort sets"));
|
||||||
|
QVBoxLayout *sortVBox = new QVBoxLayout;
|
||||||
|
sortVBox->addWidget(upButton);
|
||||||
|
sortVBox->addWidget(downButton);
|
||||||
|
sortVBox->addWidget(topButton);
|
||||||
|
sortVBox->addWidget(bottomButton);
|
||||||
|
sortFrame->setLayout(sortVBox);
|
||||||
|
|
||||||
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actSave()));
|
||||||
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(actRestore()));
|
||||||
|
|
||||||
QGridLayout *mainLayout = new QGridLayout;
|
QGridLayout *mainLayout = new QGridLayout;
|
||||||
mainLayout->addWidget(view, 0, 0, 1, 2);
|
mainLayout->addWidget(view, 0, 0, 1, 2);
|
||||||
|
mainLayout->addWidget(toggleFrame, 1, 0, 1, 1);
|
||||||
mainLayout->addWidget(upButton, 1, 0, 1, 1);
|
mainLayout->addWidget(sortFrame, 1, 1, 1, 1);
|
||||||
mainLayout->addWidget(downButton, 2, 0, 1, 1);
|
mainLayout->addWidget(buttonBox, 2, 0, 1, 2);
|
||||||
|
|
||||||
mainLayout->addWidget(topButton, 1, 1, 1, 1);
|
|
||||||
mainLayout->addWidget(bottomButton, 2, 1, 1, 1);
|
|
||||||
|
|
||||||
mainLayout->addWidget(saveButton, 3, 0, 1, 1);
|
|
||||||
mainLayout->addWidget(restoreButton, 3, 1, 1, 1);
|
|
||||||
|
|
||||||
QWidget *centralWidget = new QWidget;
|
QWidget *centralWidget = new QWidget;
|
||||||
centralWidget->setLayout(mainLayout);
|
centralWidget->setLayout(mainLayout);
|
||||||
|
@ -86,13 +111,15 @@ WndSets::~WndSets()
|
||||||
|
|
||||||
void WndSets::actSave()
|
void WndSets::actSave()
|
||||||
{
|
{
|
||||||
model->save();
|
model->save(db);
|
||||||
QMessageBox::information(this, tr("Success"), tr("The sets database has been saved successfully."));
|
QMessageBox::information(this, tr("Success"), tr("The sets database has been saved successfully."));
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WndSets::actRestore()
|
void WndSets::actRestore()
|
||||||
{
|
{
|
||||||
model->restore(db);
|
model->restore(db);
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WndSets::actToggleButtons(const QItemSelection & selected, const QItemSelection &)
|
void WndSets::actToggleButtons(const QItemSelection & selected, const QItemSelection &)
|
||||||
|
@ -102,6 +129,8 @@ void WndSets::actToggleButtons(const QItemSelection & selected, const QItemSelec
|
||||||
downButton->setDisabled(disabled);
|
downButton->setDisabled(disabled);
|
||||||
topButton->setDisabled(disabled);
|
topButton->setDisabled(disabled);
|
||||||
bottomButton->setDisabled(disabled);
|
bottomButton->setDisabled(disabled);
|
||||||
|
enableButton->setDisabled(disabled);
|
||||||
|
disableButton->setDisabled(disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WndSets::selectRow(int row)
|
void WndSets::selectRow(int row)
|
||||||
|
@ -111,6 +140,34 @@ void WndSets::selectRow(int row)
|
||||||
view->scrollTo(idx, QAbstractItemView::EnsureVisible);
|
view->scrollTo(idx, QAbstractItemView::EnsureVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WndSets::actEnable()
|
||||||
|
{
|
||||||
|
QModelIndexList rows = view->selectionModel()->selectedRows();
|
||||||
|
if(rows.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
model->toggleRow(rows.first().row(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WndSets::actDisable()
|
||||||
|
{
|
||||||
|
QModelIndexList rows = view->selectionModel()->selectedRows();
|
||||||
|
if(rows.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
model->toggleRow(rows.first().row(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WndSets::actEnableAll()
|
||||||
|
{
|
||||||
|
model->toggleAll(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WndSets::actDisableAll()
|
||||||
|
{
|
||||||
|
model->toggleAll(false);
|
||||||
|
}
|
||||||
|
|
||||||
void WndSets::actUp()
|
void WndSets::actUp()
|
||||||
{
|
{
|
||||||
QModelIndexList rows = view->selectionModel()->selectedRows();
|
QModelIndexList rows = view->selectionModel()->selectedRows();
|
||||||
|
|
|
@ -15,13 +15,18 @@ class WndSets : public QMainWindow {
|
||||||
private:
|
private:
|
||||||
SetsModel *model;
|
SetsModel *model;
|
||||||
QTreeView *view;
|
QTreeView *view;
|
||||||
QPushButton *saveButton, *restoreButton, *upButton, *downButton, *bottomButton, *topButton;
|
QPushButton *enableButton, *disableButton, *enableAllButton, *disableAllButton,
|
||||||
|
*upButton, *downButton, *bottomButton, *topButton;
|
||||||
public:
|
public:
|
||||||
WndSets(QWidget *parent = 0);
|
WndSets(QWidget *parent = 0);
|
||||||
~WndSets();
|
~WndSets();
|
||||||
protected:
|
protected:
|
||||||
void selectRow(int row);
|
void selectRow(int row);
|
||||||
private slots:
|
private slots:
|
||||||
|
void actEnable();
|
||||||
|
void actDisable();
|
||||||
|
void actEnableAll();
|
||||||
|
void actDisableAll();
|
||||||
void actSave();
|
void actSave();
|
||||||
void actRestore();
|
void actRestore();
|
||||||
void actUp();
|
void actUp();
|
||||||
|
|
|
@ -32,7 +32,6 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
|
||||||
QVariant editionCards;
|
QVariant editionCards;
|
||||||
QString setType;
|
QString setType;
|
||||||
QDate releaseDate;
|
QDate releaseDate;
|
||||||
bool import;
|
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
map = it.next().toMap();
|
map = it.next().toMap();
|
||||||
|
@ -45,11 +44,7 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data)
|
||||||
setType[0] = setType[0].toUpper();
|
setType[0] = setType[0].toUpper();
|
||||||
releaseDate = map.value("releaseDate").toDate();
|
releaseDate = map.value("releaseDate").toDate();
|
||||||
|
|
||||||
// core and expansion sets are marked to be imported by default
|
newSetList.append(SetToDownload(edition, editionLong, editionCards, setType, releaseDate));
|
||||||
import = (0 == QString::compare(setType, QString("core"), Qt::CaseInsensitive) ||
|
|
||||||
0 == QString::compare(setType, QString("expansion"), Qt::CaseInsensitive));
|
|
||||||
|
|
||||||
newSetList.append(SetToDownload(edition, editionLong, editionCards, import, setType, releaseDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qSort(newSetList);
|
qSort(newSetList);
|
||||||
|
@ -266,9 +261,6 @@ int OracleImporter::startImport()
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
curSet = & it.next();
|
curSet = & it.next();
|
||||||
if(!curSet->getImport())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName(), curSet->getSetType(), curSet->getReleaseDate());
|
CardSet *set = new CardSet(curSet->getShortName(), curSet->getLongName(), curSet->getSetType(), curSet->getReleaseDate());
|
||||||
if (!sets.contains(set->getShortName()))
|
if (!sets.contains(set->getShortName()))
|
||||||
sets.insert(set->getShortName(), set);
|
sets.insert(set->getShortName(), set);
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
class SetToDownload {
|
class SetToDownload {
|
||||||
private:
|
private:
|
||||||
QString shortName, longName;
|
QString shortName, longName;
|
||||||
bool import;
|
|
||||||
QVariant cards;
|
QVariant cards;
|
||||||
QDate releaseDate;
|
QDate releaseDate;
|
||||||
QString setType;
|
QString setType;
|
||||||
|
@ -18,10 +17,8 @@ public:
|
||||||
const QVariant &getCards() const { return cards; }
|
const QVariant &getCards() const { return cards; }
|
||||||
const QString &getSetType() const { return setType; }
|
const QString &getSetType() const { return setType; }
|
||||||
const QDate &getReleaseDate() const { return releaseDate; }
|
const QDate &getReleaseDate() const { return releaseDate; }
|
||||||
bool getImport() const { return import; }
|
SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, const QString &_setType = QString(), const QDate &_releaseDate = QDate())
|
||||||
void setImport(bool _import) { import = _import; }
|
: shortName(_shortName), longName(_longName), cards(_cards), releaseDate(_releaseDate), setType(_setType) { }
|
||||||
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), releaseDate(_releaseDate), setType(_setType) { }
|
|
||||||
bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; }
|
bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ OracleWizard::OracleWizard(QWidget *parent)
|
||||||
|
|
||||||
addPage(new IntroPage);
|
addPage(new IntroPage);
|
||||||
addPage(new LoadSetsPage);
|
addPage(new LoadSetsPage);
|
||||||
addPage(new ChooseSetsPage);
|
|
||||||
addPage(new SaveSetsPage);
|
addPage(new SaveSetsPage);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
@ -427,94 +426,6 @@ void LoadSetsPage::importFinished()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChooseSetsPage::ChooseSetsPage(QWidget *parent)
|
|
||||||
: OracleWizardPage(parent)
|
|
||||||
{
|
|
||||||
checkBoxLayout = new QVBoxLayout;
|
|
||||||
|
|
||||||
QWidget *checkboxFrame = new QWidget(this);
|
|
||||||
checkboxFrame->setLayout(checkBoxLayout);
|
|
||||||
|
|
||||||
QScrollArea *checkboxArea = new QScrollArea(this);
|
|
||||||
checkboxArea->setWidget(checkboxFrame);
|
|
||||||
checkboxArea->setWidgetResizable(true);
|
|
||||||
|
|
||||||
checkAllButton = new QPushButton(this);
|
|
||||||
connect(checkAllButton, SIGNAL(clicked()), this, SLOT(actCheckAll()));
|
|
||||||
uncheckAllButton = new QPushButton(this);
|
|
||||||
connect(uncheckAllButton, SIGNAL(clicked()), this, SLOT(actUncheckAll()));
|
|
||||||
|
|
||||||
QGridLayout *layout = new QGridLayout(this);
|
|
||||||
layout->addWidget(checkboxArea, 0, 0, 1, 2);
|
|
||||||
layout->addWidget(checkAllButton, 1, 0);
|
|
||||||
layout->addWidget(uncheckAllButton, 1, 1);
|
|
||||||
|
|
||||||
setLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChooseSetsPage::initializePage()
|
|
||||||
{
|
|
||||||
// populate checkbox list
|
|
||||||
for (int i = 0; i < checkBoxList.size(); ++i)
|
|
||||||
delete checkBoxList[i];
|
|
||||||
checkBoxList.clear();
|
|
||||||
|
|
||||||
QList<SetToDownload> &sets = wizard()->importer->getSets();
|
|
||||||
for (int i = 0; i < sets.size(); ++i) {
|
|
||||||
QCheckBox *checkBox = new QCheckBox(sets[i].getLongName());
|
|
||||||
checkBox->setChecked(sets[i].getImport());
|
|
||||||
connect(checkBox, SIGNAL(stateChanged(int)), this, SLOT(checkBoxChanged(int)));
|
|
||||||
checkBoxLayout->addWidget(checkBox);
|
|
||||||
checkBoxList << checkBox;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChooseSetsPage::retranslateUi()
|
|
||||||
{
|
|
||||||
setTitle(tr("Sets selection"));
|
|
||||||
setSubTitle(tr("The following sets has been found in the source file. "
|
|
||||||
"Please mark the sets that will be imported.\n"
|
|
||||||
"All core and expansion sets are selected by default."));
|
|
||||||
|
|
||||||
checkAllButton->setText(tr("&Check all"));
|
|
||||||
uncheckAllButton->setText(tr("&Uncheck all"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChooseSetsPage::checkBoxChanged(int state)
|
|
||||||
{
|
|
||||||
QCheckBox *checkBox = qobject_cast<QCheckBox *>(sender());
|
|
||||||
QList<SetToDownload> &sets = wizard()->importer->getSets();
|
|
||||||
for (int i = 0; i < sets.size(); ++i)
|
|
||||||
if (sets[i].getLongName() == checkBox->text()) {
|
|
||||||
sets[i].setImport(state);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChooseSetsPage::actCheckAll()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < checkBoxList.size(); ++i)
|
|
||||||
checkBoxList[i]->setChecked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChooseSetsPage::actUncheckAll()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < checkBoxList.size(); ++i)
|
|
||||||
checkBoxList[i]->setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChooseSetsPage::validatePage()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < checkBoxList.size(); ++i)
|
|
||||||
{
|
|
||||||
if(checkBoxList[i]->isChecked())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Please mark at least one set."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveSetsPage::SaveSetsPage(QWidget *parent)
|
SaveSetsPage::SaveSetsPage(QWidget *parent)
|
||||||
: OracleWizardPage(parent)
|
: OracleWizardPage(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,25 +98,6 @@ private slots:
|
||||||
void zipDownloadFailed(const QString &message);
|
void zipDownloadFailed(const QString &message);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChooseSetsPage : public OracleWizardPage
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ChooseSetsPage(QWidget *parent = 0);
|
|
||||||
void retranslateUi();
|
|
||||||
protected:
|
|
||||||
void initializePage();
|
|
||||||
bool validatePage();
|
|
||||||
private:
|
|
||||||
QPushButton *checkAllButton, *uncheckAllButton;
|
|
||||||
QVBoxLayout *checkBoxLayout;
|
|
||||||
QList<QCheckBox *> checkBoxList;
|
|
||||||
private slots:
|
|
||||||
void actCheckAll();
|
|
||||||
void actUncheckAll();
|
|
||||||
void checkBoxChanged(int state);
|
|
||||||
};
|
|
||||||
|
|
||||||
class SaveSetsPage : public OracleWizardPage
|
class SaveSetsPage : public OracleWizardPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Reference in a new issue