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()
|
||||
{
|
||||
qSort(begin(), end(), CompareFunctor());
|
||||
}
|
||||
|
||||
void SetList::sortByName() {
|
||||
qSort(begin(), end(), CompareName());
|
||||
}
|
||||
|
||||
PictureToLoad::PictureToLoad(CardInfo *_card, bool _stripped, bool _hq)
|
||||
: card(_card), stripped(_stripped), setIndex(0), hq(_hq)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,8 +36,10 @@ public:
|
|||
class SetList : public QList<CardSet *> {
|
||||
private:
|
||||
class CompareFunctor;
|
||||
class CompareName;
|
||||
public:
|
||||
void sortByKey();
|
||||
void sortByName();
|
||||
};
|
||||
|
||||
class PictureToLoad {
|
||||
|
|
|
|||
|
|
@ -144,6 +144,19 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
|||
if (!cardTypes.contains(info->getMainCardType()))
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public:
|
|||
enum FilterBool { ShowTrue, ShowFalse, ShowAll };
|
||||
private:
|
||||
FilterBool isToken;
|
||||
QString cardNameBeginning, cardName, cardText;
|
||||
QString cardNameBeginning, cardName, cardText, cardSet;
|
||||
QSet<QString> cardNameSet, cardTypes, cardColors;
|
||||
public:
|
||||
CardDatabaseDisplayModel(QObject *parent = 0);
|
||||
|
|
@ -43,6 +43,7 @@ public:
|
|||
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
||||
void setCardNameSet(const QSet<QString> &_cardNameSet) { cardNameSet = _cardNameSet; 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 setCardColors(const QSet<QString> &_cardColors) { cardColors = _cardColors; invalidate(); }
|
||||
void clearSearch();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
|
@ -18,6 +19,17 @@ DlgCardSearch::DlgCardSearch(QWidget *parent)
|
|||
QLabel *cardTextLabel = new QLabel(tr("Card text:"));
|
||||
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):"));
|
||||
const QStringList &cardTypes = db->getAllMainCardTypes();
|
||||
QVBoxLayout *cardTypesLayout = new QVBoxLayout;
|
||||
|
|
@ -54,10 +66,12 @@ DlgCardSearch::DlgCardSearch(QWidget *parent)
|
|||
optionsLayout->addWidget(cardNameEdit, 0, 1);
|
||||
optionsLayout->addWidget(cardTextLabel, 1, 0);
|
||||
optionsLayout->addWidget(cardTextEdit, 1, 1);
|
||||
optionsLayout->addWidget(cardTypesLabel, 2, 0);
|
||||
optionsLayout->addLayout(cardTypesLayout, 2, 1);
|
||||
optionsLayout->addWidget(cardColorsLabel, 3, 0);
|
||||
optionsLayout->addLayout(cardColorsLayout, 3, 1);
|
||||
optionsLayout->addWidget(cardSetsLabel, 2, 0);
|
||||
optionsLayout->addWidget(cboSetList, 2, 1);
|
||||
optionsLayout->addWidget(cardTypesLabel, 3, 0);
|
||||
optionsLayout->addLayout(cardTypesLayout, 3, 1);
|
||||
optionsLayout->addWidget(cardColorsLabel, 4, 0);
|
||||
optionsLayout->addLayout(cardColorsLayout, 4, 1);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(optionsLayout);
|
||||
|
|
@ -76,6 +90,10 @@ QString DlgCardSearch::getCardText() const
|
|||
return cardTextEdit->text();
|
||||
}
|
||||
|
||||
QString DlgCardSearch::getCardSet() const {
|
||||
return cboSetList->itemData(cboSetList->currentIndex()).toString();
|
||||
}
|
||||
|
||||
QSet<QString> DlgCardSearch::getCardTypes() const
|
||||
{
|
||||
QStringList result;
|
||||
|
|
|
|||
|
|
@ -7,16 +7,19 @@
|
|||
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
|
||||
class DlgCardSearch : public QDialog {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QLineEdit *cardNameEdit, *cardTextEdit;
|
||||
QList<QCheckBox *> cardTypeCheckBoxes, cardColorCheckBoxes;
|
||||
QComboBox *cboSetList;
|
||||
public:
|
||||
DlgCardSearch(QWidget *parent = 0);
|
||||
QString getCardName() const;
|
||||
QString getCardText() const;
|
||||
QString getCardSet() const;
|
||||
QSet<QString> getCardTypes() const;
|
||||
QSet<QString> getCardColors() const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -504,7 +504,8 @@ void TabDeckEditor::actSearch()
|
|||
databaseDisplayModel->setCardName(dlgCardSearch->getCardName());
|
||||
databaseDisplayModel->setCardText(dlgCardSearch->getCardText());
|
||||
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