mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 00:04:48 -07:00
Run formatter on all our files (#6942)
This commit is contained in:
parent
b3c89167c5
commit
1d5d3f2d38
19 changed files with 153 additions and 81 deletions
|
|
@ -61,24 +61,30 @@ inline QString expandPattern(const QString &pattern,
|
|||
QString result = pattern;
|
||||
|
||||
auto replaceIfPresent = [&](const QString &token, const QString &value) -> bool {
|
||||
if (!result.contains(token))
|
||||
if (!result.contains(token)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value.isEmpty())
|
||||
if (value.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
result.replace(token, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!replaceIfPresent("{name}", name))
|
||||
if (!replaceIfPresent("{name}", name)) {
|
||||
return {};
|
||||
if (!replaceIfPresent("{set}", set))
|
||||
}
|
||||
if (!replaceIfPresent("{set}", set)) {
|
||||
return {};
|
||||
if (!replaceIfPresent("{collector}", collector))
|
||||
}
|
||||
if (!replaceIfPresent("{collector}", collector)) {
|
||||
return {};
|
||||
if (!replaceIfPresent("{providerId}", providerId))
|
||||
}
|
||||
if (!replaceIfPresent("{providerId}", providerId)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -96,8 +102,9 @@ generateImportVariants(const QString &name, const QString &set, const QString &c
|
|||
pattern.replace("_", sep);
|
||||
|
||||
QString v = expandPattern(pattern, name, set, collector, providerId);
|
||||
if (!v.isEmpty())
|
||||
if (!v.isEmpty()) {
|
||||
variants << v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ CardPictureLoaderWorker::CardPictureLoaderWorker()
|
|||
static_cast<qint64>(SettingsCache::instance().getNetworkCacheSizeInMB()));
|
||||
|
||||
connect(&SettingsCache::instance(), &SettingsCache::networkCacheSizeChanged, cache, [this](int newSizeInMB) {
|
||||
if (cache)
|
||||
if (cache) {
|
||||
cache->setMaximumCacheSize(1024L * 1024L * static_cast<qint64>(newSizeInMB));
|
||||
}
|
||||
});
|
||||
|
||||
networkManager->setCache(cache);
|
||||
|
|
|
|||
|
|
@ -70,8 +70,9 @@ bool FlowLayout::hasHeightForWidth() const
|
|||
*/
|
||||
int FlowLayout::heightForWidth(const int width) const
|
||||
{
|
||||
if (flowDirection != Qt::Horizontal)
|
||||
if (flowDirection != Qt::Horizontal) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int totalHeight = 0;
|
||||
int rowUsedWidth = 0;
|
||||
|
|
@ -181,8 +182,9 @@ int FlowLayout::layoutAllRows(const int originX, const int originY, const int av
|
|||
*/
|
||||
void FlowLayout::layoutSingleRow(const QVector<QLayoutItem *> &rowItems, int x, const int y, const int availableWidth)
|
||||
{
|
||||
if (rowItems.isEmpty())
|
||||
if (rowItems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ── Pass 1: measure fixed width and count expanding items ────────────────
|
||||
int fixedWidth = 0;
|
||||
|
|
@ -211,12 +213,14 @@ void FlowLayout::layoutSingleRow(const QVector<QLayoutItem *> &rowItems, int x,
|
|||
|
||||
// ── Pass 2: place items ──────────────────────────────────────────────────
|
||||
for (QLayoutItem *item : rowItems) {
|
||||
if (!item || item->isEmpty())
|
||||
if (!item || item->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QWidget *widget = item->widget();
|
||||
if (!widget)
|
||||
if (!widget) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const QSizePolicy::Policy hPolicy = widget->sizePolicy().horizontalPolicy();
|
||||
const QSize maxSize = widget->maximumSize();
|
||||
|
|
|
|||
|
|
@ -108,8 +108,9 @@ void FlowWidget::clearLayout()
|
|||
if (flowLayout) {
|
||||
QLayoutItem *item;
|
||||
while ((item = flowLayout->takeAt(0))) {
|
||||
if (item->widget())
|
||||
if (item->widget()) {
|
||||
item->widget()->deleteLater();
|
||||
}
|
||||
delete item;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public:
|
|||
QJsonObject getOracleCard() const
|
||||
{
|
||||
return oracleCard;
|
||||
};
|
||||
}
|
||||
|
||||
QString getCollectorNumber() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
ArchidektApiResponseCard getCard() const
|
||||
{
|
||||
return card;
|
||||
};
|
||||
}
|
||||
|
||||
QList<Category> getCategories() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public:
|
|||
QVector<ArchidektApiResponseCardEntry> getCards() const
|
||||
{
|
||||
return cards;
|
||||
};
|
||||
}
|
||||
|
||||
QVector<ArchidektApiResponseDeckCategory> getCategories() const
|
||||
{
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
QString getDeckName() const
|
||||
{
|
||||
return name;
|
||||
};
|
||||
}
|
||||
|
||||
int getDeckFormat() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -174,7 +174,8 @@ void VisualDatabaseDisplayFilterToolbarWidget::updateCompactMode(int availableWi
|
|||
};
|
||||
|
||||
for (auto *btn : filterButtons) {
|
||||
if (btn->isCompact() != compact) // only act on transitions
|
||||
if (btn->isCompact() != compact) { // only act on transitions
|
||||
btn->setCompact(compact);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -251,20 +251,27 @@ static void setupParserRules()
|
|||
const auto arg = std::any_cast<int>(sv[1]);
|
||||
const auto op = std::any_cast<QString>(sv[0]);
|
||||
|
||||
if (op == ">")
|
||||
if (op == ">") {
|
||||
return [=](const int s) { return s > arg; };
|
||||
if (op == ">=")
|
||||
}
|
||||
if (op == ">=") {
|
||||
return [=](const int s) { return s >= arg; };
|
||||
if (op == "<")
|
||||
}
|
||||
if (op == "<") {
|
||||
return [=](const int s) { return s < arg; };
|
||||
if (op == "<=")
|
||||
}
|
||||
if (op == "<=") {
|
||||
return [=](const int s) { return s <= arg; };
|
||||
if (op == "=")
|
||||
}
|
||||
if (op == "=") {
|
||||
return [=](const int s) { return s == arg; };
|
||||
if (op == ":")
|
||||
}
|
||||
if (op == ":") {
|
||||
return [=](const int s) { return s == arg; };
|
||||
if (op == "!=")
|
||||
}
|
||||
if (op == "!=") {
|
||||
return [=](const int s) { return s != arg; };
|
||||
}
|
||||
return [](int) { return false; };
|
||||
};
|
||||
|
||||
|
|
@ -315,8 +322,9 @@ static void setupParserRules()
|
|||
return true;
|
||||
}
|
||||
|
||||
if (parts.contains("c") && match.length() == 0)
|
||||
if (parts.contains("c") && match.length() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto containsColor = [&parts](const QString &s) { return parts.contains(s); };
|
||||
return std::any_of(match.begin(), match.end(), containsColor);
|
||||
|
|
|
|||
|
|
@ -205,8 +205,9 @@ bool FilterItem::acceptColor(const CardInfoPtr info) const
|
|||
*/
|
||||
int match_count = 0;
|
||||
for (auto &it : converted_term) {
|
||||
if (info->getColors().contains(it, Qt::CaseInsensitive))
|
||||
if (info->getColors().contains(it, Qt::CaseInsensitive)) {
|
||||
match_count++;
|
||||
}
|
||||
}
|
||||
|
||||
return match_count == converted_term.length();
|
||||
|
|
@ -542,12 +543,14 @@ void FilterTree::removeFilter(const CardFilter *toRemove)
|
|||
{
|
||||
for (int i = childNodes.size() - 1; i >= 0; --i) {
|
||||
auto *logicMap = dynamic_cast<LogicMap *>(childNodes.at(i));
|
||||
if (!logicMap || logicMap->attr != toRemove->attr())
|
||||
if (!logicMap || logicMap->attr != toRemove->attr()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FilterItemList *typeList = logicMap->typeList(toRemove->type());
|
||||
if (!typeList)
|
||||
if (!typeList) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int termIdx = typeList->termIndex(toRemove->term());
|
||||
if (termIdx != -1) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
class ICardSetPriorityController
|
||||
{
|
||||
public:
|
||||
struct SetSaveData {
|
||||
struct SetSaveData
|
||||
{
|
||||
QString shortName;
|
||||
unsigned int sortKey;
|
||||
bool enabled;
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void saveSets(const QVector<SetSaveData> & /* data */) override {
|
||||
};
|
||||
void saveSets(const QVector<SetSaveData> & /* data */) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_NOOP_CARD_SET_PRIORITY_CONTROLLER_H
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ int CardSearchModel::rowCount(const QModelIndex &parent) const
|
|||
|
||||
QVariant CardSearchModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() >= searchResults.size())
|
||||
if (!index.isValid() || index.row() >= searchResults.size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
return searchResults.at(index.row()).card->getName();
|
||||
|
|
@ -34,8 +35,9 @@ void CardSearchModel::updateSearchResults(const QString &query)
|
|||
beginResetModel();
|
||||
searchResults.clear();
|
||||
|
||||
if (query.isEmpty() || !sourceModel)
|
||||
if (query.isEmpty() || !sourceModel) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the filter for the display model
|
||||
sourceModel->setCardName(query);
|
||||
|
|
@ -46,13 +48,15 @@ void CardSearchModel::updateSearchResults(const QString &query)
|
|||
QModelIndex sourceIndex = sourceModel->mapToSource(modelIndex);
|
||||
CardDatabaseModel *sourceDbModel = qobject_cast<CardDatabaseModel *>(sourceModel->sourceModel());
|
||||
|
||||
if (!sourceDbModel || !sourceIndex.isValid())
|
||||
if (!sourceDbModel || !sourceIndex.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CardInfoPtr card = sourceDbModel->getCard(sourceIndex.row());
|
||||
|
||||
if (!card)
|
||||
if (!card) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int distance = levenshteinDistance(query.toLower(), card->getName().toLower());
|
||||
searchResults.append({card, distance});
|
||||
|
|
@ -63,8 +67,9 @@ void CardSearchModel::updateSearchResults(const QString &query)
|
|||
[](const SearchResult &a, const SearchResult &b) { return a.distance < b.distance; });
|
||||
|
||||
// Keep only the top 5 results
|
||||
if (searchResults.size() > 10)
|
||||
if (searchResults.size() > 10) {
|
||||
searchResults = searchResults.mid(0, 10);
|
||||
}
|
||||
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, 0));
|
||||
emit layoutChanged();
|
||||
|
|
|
|||
|
|
@ -75,12 +75,14 @@ bool CardDatabaseDisplayModel::lessThan(const QModelIndex &left, const QModelInd
|
|||
|
||||
// test for an exact match: isLeftType && leftString.size() == cardName.size()
|
||||
// or an exclusive start match: isLeftType && !isRightType
|
||||
if (isLeftType && (!isRightType || leftString.size() == cardName.size()))
|
||||
if (isLeftType && (!isRightType || leftString.size() == cardName.size())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// same checks for the right string
|
||||
if (isRightType && (!isLeftType || rightString.size() == cardName.size()))
|
||||
if (isRightType && (!isLeftType || rightString.size() == cardName.size())) {
|
||||
return false;
|
||||
}
|
||||
} else if (right.column() == CardDatabaseModel::PTColumn && left.column() == CardDatabaseModel::PTColumn) {
|
||||
QStringList leftList = leftString.split("/");
|
||||
QStringList rightList = rightString.split("/");
|
||||
|
|
@ -172,8 +174,9 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
|||
{
|
||||
CardInfoPtr info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
|
||||
|
||||
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken()))
|
||||
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filterString != nullptr) {
|
||||
if (filterTree != nullptr && !filterTree->acceptsCard(info)) {
|
||||
|
|
@ -187,14 +190,17 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
|||
|
||||
bool CardDatabaseDisplayModel::rowMatchesCardName(CardInfoPtr info) const
|
||||
{
|
||||
if (!cardName.isEmpty() && !info->getName().contains(cardName, Qt::CaseInsensitive))
|
||||
if (!cardName.isEmpty() && !info->getName().contains(cardName, Qt::CaseInsensitive)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!cardNameSet.isEmpty() && !cardNameSet.contains(info->getName()))
|
||||
if (!cardNameSet.isEmpty() && !cardNameSet.contains(info->getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filterTree != nullptr)
|
||||
if (filterTree != nullptr) {
|
||||
return filterTree->acceptsCard(info);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -208,8 +214,9 @@ void CardDatabaseDisplayModel::clearFilterAll()
|
|||
cardText.clear();
|
||||
cardTypes.clear();
|
||||
cardColors.clear();
|
||||
if (filterTree != nullptr)
|
||||
if (filterTree != nullptr) {
|
||||
filterTree->clear();
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 10, 0))
|
||||
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
||||
#else
|
||||
|
|
@ -219,8 +226,9 @@ void CardDatabaseDisplayModel::clearFilterAll()
|
|||
|
||||
void CardDatabaseDisplayModel::setFilterTree(FilterTree *_filterTree)
|
||||
{
|
||||
if (this->filterTree != nullptr)
|
||||
if (this->filterTree != nullptr) {
|
||||
disconnect(this->filterTree, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
this->filterTree = _filterTree;
|
||||
connect(this->filterTree, &FilterTree::changed, this, &CardDatabaseDisplayModel::filterTreeChanged);
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@ int CardDatabaseModel::columnCount(const QModelIndex & /*parent*/) const
|
|||
QVariant CardDatabaseModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() >= cardList.size() || index.column() >= CARDDBMODEL_COLUMNS ||
|
||||
(role != Qt::DisplayRole && role != SortRole))
|
||||
(role != Qt::DisplayRole && role != SortRole)) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
CardInfoPtr card = cardList.at(index.row());
|
||||
switch (index.column()) {
|
||||
|
|
@ -56,10 +57,12 @@ QVariant CardDatabaseModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
QVariant CardDatabaseModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
if (role != Qt::DisplayRole) {
|
||||
return QVariant();
|
||||
if (orientation != Qt::Horizontal)
|
||||
}
|
||||
if (orientation != Qt::Horizontal) {
|
||||
return QVariant();
|
||||
}
|
||||
switch (section) {
|
||||
case NameColumn:
|
||||
return QString(tr("Name"));
|
||||
|
|
@ -81,21 +84,24 @@ QVariant CardDatabaseModel::headerData(int section, Qt::Orientation orientation,
|
|||
void CardDatabaseModel::cardInfoChanged(CardInfoPtr card)
|
||||
{
|
||||
const int row = cardList.indexOf(card);
|
||||
if (row == -1)
|
||||
if (row == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit dataChanged(index(row, 0), index(row, CARDDBMODEL_COLUMNS - 1));
|
||||
}
|
||||
|
||||
bool CardDatabaseModel::checkCardHasAtLeastOneEnabledSet(CardInfoPtr card)
|
||||
{
|
||||
if (!showOnlyCardsFromEnabledSets)
|
||||
if (!showOnlyCardsFromEnabledSets) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &printings : card->getSets()) {
|
||||
for (const auto &printing : printings) {
|
||||
if (printing.getSet()->getEnabled())
|
||||
if (printing.getSet()->getEnabled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ SetsModel::SetsModel(CardDatabase *_db, QObject *parent) : QAbstractTableModel(p
|
|||
{
|
||||
sets.sortByKey();
|
||||
for (const CardSetPtr &set : sets) {
|
||||
if (set->getEnabled())
|
||||
if (set->getEnabled()) {
|
||||
enabledSets.insert(set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -15,16 +16,18 @@ SetsModel::~SetsModel() = default;
|
|||
|
||||
int SetsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
if (parent.isValid()) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return sets.size();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant SetsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || (index.column() >= NUM_COLS) || (index.row() >= rowCount()))
|
||||
if (!index.isValid() || (index.column() >= NUM_COLS) || (index.row() >= rowCount())) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
CardSetPtr set = sets[index.row()];
|
||||
|
||||
|
|
@ -40,8 +43,9 @@ QVariant SetsModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
}
|
||||
|
||||
if (role != Qt::DisplayRole && role != SortRole)
|
||||
if (role != Qt::DisplayRole && role != SortRole) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column()) {
|
||||
case SortKeyCol:
|
||||
|
|
@ -72,8 +76,9 @@ bool SetsModel::setData(const QModelIndex &index, const QVariant &value, int rol
|
|||
|
||||
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();
|
||||
}
|
||||
switch (section) {
|
||||
case SortKeyCol:
|
||||
return QString("Key"); /* no tr() for translations needed, column just used for sorting --> hidden */
|
||||
|
|
@ -97,13 +102,15 @@ QVariant SetsModel::headerData(int section, Qt::Orientation orientation, int rol
|
|||
|
||||
Qt::ItemFlags SetsModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
return Qt::NoItemFlags;
|
||||
}
|
||||
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
|
||||
if (index.column() == EnabledCol)
|
||||
if (index.column() == EnabledCol) {
|
||||
flags |= Qt::ItemIsUserCheckable;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
|
@ -115,8 +122,9 @@ Qt::DropActions SetsModel::supportedDropActions() const
|
|||
|
||||
QMimeData *SetsModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
if (indexes.isEmpty())
|
||||
if (indexes.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetsMimeData *result = new SetsMimeData(indexes[0].row());
|
||||
return qobject_cast<QMimeData *>(result);
|
||||
|
|
@ -128,16 +136,19 @@ bool SetsModel::dropMimeData(const QMimeData *data,
|
|||
int /*column*/,
|
||||
const QModelIndex &parent)
|
||||
{
|
||||
if (action != Qt::MoveAction)
|
||||
if (action != Qt::MoveAction) {
|
||||
return false;
|
||||
}
|
||||
if (row == -1) {
|
||||
if (!parent.isValid())
|
||||
if (!parent.isValid()) {
|
||||
return false;
|
||||
}
|
||||
row = parent.row();
|
||||
}
|
||||
int oldRow = qobject_cast<const SetsMimeData *>(data)->getOldRow();
|
||||
if (oldRow < row)
|
||||
if (oldRow < row) {
|
||||
row--;
|
||||
}
|
||||
|
||||
swapRows(oldRow, row);
|
||||
|
||||
|
|
@ -148,10 +159,11 @@ void SetsModel::toggleRow(int row, bool enable)
|
|||
{
|
||||
CardSetPtr temp = sets.at(row);
|
||||
|
||||
if (enable)
|
||||
if (enable) {
|
||||
enabledSets.insert(temp);
|
||||
else
|
||||
} else {
|
||||
enabledSets.remove(temp);
|
||||
}
|
||||
|
||||
emit dataChanged(index(row, EnabledCol), index(row, EnabledCol));
|
||||
}
|
||||
|
|
@ -160,13 +172,15 @@ void SetsModel::toggleRow(int row)
|
|||
{
|
||||
CardSetPtr tmp = sets.at(row);
|
||||
|
||||
if (tmp == nullptr)
|
||||
if (tmp == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabledSets.contains(tmp))
|
||||
if (enabledSets.contains(tmp)) {
|
||||
enabledSets.remove(tmp);
|
||||
else
|
||||
} else {
|
||||
enabledSets.insert(tmp);
|
||||
}
|
||||
|
||||
emit dataChanged(index(row, EnabledCol), index(row, EnabledCol));
|
||||
}
|
||||
|
|
@ -175,9 +189,11 @@ void SetsModel::toggleAll(bool enabled)
|
|||
{
|
||||
enabledSets.clear();
|
||||
|
||||
if (enabled)
|
||||
for (CardSetPtr set : sets)
|
||||
if (enabled) {
|
||||
for (CardSetPtr set : sets) {
|
||||
enabledSets.insert(set);
|
||||
}
|
||||
}
|
||||
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
|
|
@ -208,8 +224,9 @@ void SetsModel::sort(int column, Qt::SortOrder order)
|
|||
int numRows = rowCount();
|
||||
int row;
|
||||
|
||||
for (row = 0; row < numRows; ++row)
|
||||
for (row = 0; row < numRows; ++row) {
|
||||
setMap.insert(index(row, column).data(SetsModel::SortRole).toString(), sets.at(row));
|
||||
}
|
||||
|
||||
QList<CardSetPtr> tmp = setMap.values();
|
||||
sets.clear();
|
||||
|
|
@ -253,8 +270,9 @@ void SetsModel::restore(CardDatabase *db)
|
|||
// enabled sets
|
||||
enabledSets.clear();
|
||||
for (const CardSetPtr &set : sets) {
|
||||
if (set->getEnabled())
|
||||
if (set->getEnabled()) {
|
||||
enabledSets.insert(set);
|
||||
}
|
||||
}
|
||||
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
|
|
|
|||
|
|
@ -89,12 +89,15 @@ static inline QString toString(Type t)
|
|||
|
||||
static inline Type fromString(const QString &s)
|
||||
{
|
||||
if (s == "Main Type")
|
||||
if (s == "Main Type") {
|
||||
return MAIN_TYPE;
|
||||
if (s == "Mana Cost")
|
||||
}
|
||||
if (s == "Mana Cost") {
|
||||
return MANA_COST;
|
||||
if (s == "Colors")
|
||||
}
|
||||
if (s == "Colors") {
|
||||
return COLOR;
|
||||
}
|
||||
return MAIN_TYPE; // default
|
||||
}
|
||||
} // namespace DeckListModelGroupCriteria
|
||||
|
|
@ -427,8 +430,9 @@ private:
|
|||
|
||||
template <typename T> T getNode(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
return dynamic_cast<T>(root);
|
||||
}
|
||||
return dynamic_cast<T>(static_cast<AbstractDecklistNode *>(index.internalPointer()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,25 +29,29 @@ bool DeckListSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
|
|||
QString ln = lNode->getName();
|
||||
QString rn = rNode->getName();
|
||||
int cmp = ln.localeAwareCompare(rn);
|
||||
if (cmp != 0)
|
||||
if (cmp != 0) {
|
||||
return cmp < 0;
|
||||
}
|
||||
} else if (crit == "cmc") {
|
||||
int lc = lInfo ? lInfo->getCmc().toInt() : 0;
|
||||
int rc = rInfo ? rInfo->getCmc().toInt() : 0;
|
||||
if (lc != rc)
|
||||
if (lc != rc) {
|
||||
return lc < rc;
|
||||
}
|
||||
} else if (crit == "colors") {
|
||||
QString lr = lInfo ? lInfo->getColors() : QString();
|
||||
QString rr = rInfo ? rInfo->getColors() : QString();
|
||||
int cmp = lr.localeAwareCompare(rr);
|
||||
if (cmp != 0)
|
||||
if (cmp != 0) {
|
||||
return cmp < 0;
|
||||
}
|
||||
} else if (crit == "maintype") {
|
||||
QString lr = lInfo ? lInfo->getMainCardType() : QString();
|
||||
QString rr = rInfo ? rInfo->getMainCardType() : QString();
|
||||
int cmp = lr.localeAwareCompare(rr);
|
||||
if (cmp != 0)
|
||||
if (cmp != 0) {
|
||||
return cmp < 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ protected:
|
|||
inline OracleWizard *wizard()
|
||||
{
|
||||
return (OracleWizard *)QWizardPage::wizard();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class SimpleDownloadFilePage : public OracleWizardPage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue