mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-11 04:43:56 -07:00
Merge 27b8cc5526 into 44e83e91c6
This commit is contained in:
commit
fa80c4f919
7 changed files with 55 additions and 6 deletions
|
|
@ -58,11 +58,22 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SetList::CompareName {
|
||||||
|
public:
|
||||||
|
inline bool operator()(CardSet *a, CardSet *b) const {
|
||||||
|
return a->getLongName() < b->getLongName();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void SetList::sortByKey()
|
void SetList::sortByKey()
|
||||||
{
|
{
|
||||||
qSort(begin(), end(), CompareFunctor());
|
qSort(begin(), end(), CompareFunctor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetList::sortByName() {
|
||||||
|
qSort(begin(), end(), CompareName());
|
||||||
|
}
|
||||||
|
|
||||||
PictureToLoad::PictureToLoad(CardInfo *_card, bool _stripped, bool _hq)
|
PictureToLoad::PictureToLoad(CardInfo *_card, bool _stripped, bool _hq)
|
||||||
: card(_card), stripped(_stripped), setIndex(0), hq(_hq)
|
: card(_card), stripped(_stripped), setIndex(0), hq(_hq)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,10 @@ public:
|
||||||
class SetList : public QList<CardSet *> {
|
class SetList : public QList<CardSet *> {
|
||||||
private:
|
private:
|
||||||
class CompareFunctor;
|
class CompareFunctor;
|
||||||
|
class CompareName;
|
||||||
public:
|
public:
|
||||||
void sortByKey();
|
void sortByKey();
|
||||||
|
void sortByName();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PictureToLoad {
|
class PictureToLoad {
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,19 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
||||||
if (!cardTypes.contains(info->getMainCardType()))
|
if (!cardTypes.contains(info->getMainCardType()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!cardSet.isEmpty()) {
|
||||||
|
bool blnGood = false;
|
||||||
|
for(int intLoop = 0; intLoop < info->getSets().count(); intLoop++) {
|
||||||
|
if (info->getSets().at(intLoop)->getShortName() == cardSet) {
|
||||||
|
blnGood = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!blnGood) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public:
|
||||||
enum FilterBool { ShowTrue, ShowFalse, ShowAll };
|
enum FilterBool { ShowTrue, ShowFalse, ShowAll };
|
||||||
private:
|
private:
|
||||||
FilterBool isToken;
|
FilterBool isToken;
|
||||||
QString cardNameBeginning, cardName, cardText;
|
QString cardNameBeginning, cardName, cardText, cardSet;
|
||||||
QSet<QString> cardNameSet, cardTypes, cardColors;
|
QSet<QString> cardNameSet, cardTypes, cardColors;
|
||||||
public:
|
public:
|
||||||
CardDatabaseDisplayModel(QObject *parent = 0);
|
CardDatabaseDisplayModel(QObject *parent = 0);
|
||||||
|
|
@ -43,6 +43,7 @@ public:
|
||||||
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
||||||
void setCardNameSet(const QSet<QString> &_cardNameSet) { cardNameSet = _cardNameSet; invalidate(); }
|
void setCardNameSet(const QSet<QString> &_cardNameSet) { cardNameSet = _cardNameSet; invalidate(); }
|
||||||
void setCardText(const QString &_cardText) { cardText = _cardText; invalidate(); }
|
void setCardText(const QString &_cardText) { cardText = _cardText; invalidate(); }
|
||||||
|
void setCardSet(const QString &_cardSet) { cardSet = _cardSet; invalidate(); }
|
||||||
void setCardTypes(const QSet<QString> &_cardTypes) { cardTypes = _cardTypes; invalidate(); }
|
void setCardTypes(const QSet<QString> &_cardTypes) { cardTypes = _cardTypes; invalidate(); }
|
||||||
void setCardColors(const QSet<QString> &_cardColors) { cardColors = _cardColors; invalidate(); }
|
void setCardColors(const QSet<QString> &_cardColors) { cardColors = _cardColors; invalidate(); }
|
||||||
void clearSearch();
|
void clearSearch();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
@ -17,6 +18,17 @@ DlgCardSearch::DlgCardSearch(QWidget *parent)
|
||||||
|
|
||||||
QLabel *cardTextLabel = new QLabel(tr("Card text:"));
|
QLabel *cardTextLabel = new QLabel(tr("Card text:"));
|
||||||
cardTextEdit = new QLineEdit;
|
cardTextEdit = new QLineEdit;
|
||||||
|
|
||||||
|
//Adding Set Selector
|
||||||
|
QLabel *cardSetsLabel = new QLabel(tr("Card Set (AND):"));
|
||||||
|
cboSetList = new QComboBox();
|
||||||
|
cboSetList->addItem("");
|
||||||
|
SetList setList = db->getSetList();
|
||||||
|
setList.sortByName();
|
||||||
|
for (int intLoop = 0; intLoop < setList.size(); ++intLoop) {
|
||||||
|
//Adding Translated Set Name, Just In Case
|
||||||
|
cboSetList->addItem(tr("%1").arg(setList.at(intLoop)->getLongName()), setList.at(intLoop)->getShortName());
|
||||||
|
}
|
||||||
|
|
||||||
QLabel *cardTypesLabel = new QLabel(tr("Card type (OR):"));
|
QLabel *cardTypesLabel = new QLabel(tr("Card type (OR):"));
|
||||||
const QStringList &cardTypes = db->getAllMainCardTypes();
|
const QStringList &cardTypes = db->getAllMainCardTypes();
|
||||||
|
|
@ -54,10 +66,12 @@ DlgCardSearch::DlgCardSearch(QWidget *parent)
|
||||||
optionsLayout->addWidget(cardNameEdit, 0, 1);
|
optionsLayout->addWidget(cardNameEdit, 0, 1);
|
||||||
optionsLayout->addWidget(cardTextLabel, 1, 0);
|
optionsLayout->addWidget(cardTextLabel, 1, 0);
|
||||||
optionsLayout->addWidget(cardTextEdit, 1, 1);
|
optionsLayout->addWidget(cardTextEdit, 1, 1);
|
||||||
optionsLayout->addWidget(cardTypesLabel, 2, 0);
|
optionsLayout->addWidget(cardSetsLabel, 2, 0);
|
||||||
optionsLayout->addLayout(cardTypesLayout, 2, 1);
|
optionsLayout->addWidget(cboSetList, 2, 1);
|
||||||
optionsLayout->addWidget(cardColorsLabel, 3, 0);
|
optionsLayout->addWidget(cardTypesLabel, 3, 0);
|
||||||
optionsLayout->addLayout(cardColorsLayout, 3, 1);
|
optionsLayout->addLayout(cardTypesLayout, 3, 1);
|
||||||
|
optionsLayout->addWidget(cardColorsLabel, 4, 0);
|
||||||
|
optionsLayout->addLayout(cardColorsLayout, 4, 1);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(optionsLayout);
|
mainLayout->addLayout(optionsLayout);
|
||||||
|
|
@ -76,6 +90,10 @@ QString DlgCardSearch::getCardText() const
|
||||||
return cardTextEdit->text();
|
return cardTextEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DlgCardSearch::getCardSet() const {
|
||||||
|
return cboSetList->itemData(cboSetList->currentIndex()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
QSet<QString> DlgCardSearch::getCardTypes() const
|
QSet<QString> DlgCardSearch::getCardTypes() const
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,19 @@
|
||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QComboBox;
|
||||||
|
|
||||||
class DlgCardSearch : public QDialog {
|
class DlgCardSearch : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QLineEdit *cardNameEdit, *cardTextEdit;
|
QLineEdit *cardNameEdit, *cardTextEdit;
|
||||||
QList<QCheckBox *> cardTypeCheckBoxes, cardColorCheckBoxes;
|
QList<QCheckBox *> cardTypeCheckBoxes, cardColorCheckBoxes;
|
||||||
|
QComboBox *cboSetList;
|
||||||
public:
|
public:
|
||||||
DlgCardSearch(QWidget *parent = 0);
|
DlgCardSearch(QWidget *parent = 0);
|
||||||
QString getCardName() const;
|
QString getCardName() const;
|
||||||
QString getCardText() const;
|
QString getCardText() const;
|
||||||
|
QString getCardSet() const;
|
||||||
QSet<QString> getCardTypes() const;
|
QSet<QString> getCardTypes() const;
|
||||||
QSet<QString> getCardColors() const;
|
QSet<QString> getCardColors() const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -504,7 +504,8 @@ void TabDeckEditor::actSearch()
|
||||||
databaseDisplayModel->setCardName(dlgCardSearch->getCardName());
|
databaseDisplayModel->setCardName(dlgCardSearch->getCardName());
|
||||||
databaseDisplayModel->setCardText(dlgCardSearch->getCardText());
|
databaseDisplayModel->setCardText(dlgCardSearch->getCardText());
|
||||||
databaseDisplayModel->setCardTypes(dlgCardSearch->getCardTypes());
|
databaseDisplayModel->setCardTypes(dlgCardSearch->getCardTypes());
|
||||||
databaseDisplayModel->setCardColors(dlgCardSearch->getCardColors());
|
databaseDisplayModel->setCardColors(dlgCardSearch->getCardColors());
|
||||||
|
databaseDisplayModel->setCardSet(dlgCardSearch->getCardSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue