make sure filtertree stuff translates
The logic types and attribute names were not previously being translated by the tr(...) function.
This commit is contained in:
parent
2b7ea0c983
commit
610f0b6f6f
4 changed files with 20 additions and 11 deletions
|
@ -18,12 +18,16 @@ FilterBuilder::FilterBuilder(QWidget *parent)
|
||||||
filterCombo = new QComboBox;
|
filterCombo = new QComboBox;
|
||||||
for (i = 0; i < CardFilter::AttrEnd; i++)
|
for (i = 0; i < CardFilter::AttrEnd; i++)
|
||||||
filterCombo->addItem(
|
filterCombo->addItem(
|
||||||
CardFilter::attrName(static_cast<CardFilter::Attr>(i)), QVariant(i));
|
tr(CardFilter::attrName(static_cast<CardFilter::Attr>(i))),
|
||||||
|
QVariant(i)
|
||||||
|
);
|
||||||
|
|
||||||
typeCombo = new QComboBox;
|
typeCombo = new QComboBox;
|
||||||
for (i = 0; i < CardFilter::TypeEnd; i++)
|
for (i = 0; i < CardFilter::TypeEnd; i++)
|
||||||
typeCombo->addItem(
|
typeCombo->addItem(
|
||||||
CardFilter::typeName(static_cast<CardFilter::Type>(i)), QVariant(i));
|
tr(CardFilter::typeName(static_cast<CardFilter::Type>(i))),
|
||||||
|
QVariant(i)
|
||||||
|
);
|
||||||
|
|
||||||
QPushButton *ok = new QPushButton("+");
|
QPushButton *ok = new QPushButton("+");
|
||||||
ok->setMaximumSize(20, 20);
|
ok->setMaximumSize(20, 20);
|
||||||
|
|
|
@ -23,9 +23,9 @@ public:
|
||||||
virtual int childCount() const { return 0; }
|
virtual int childCount() const { return 0; }
|
||||||
virtual int childIndex(const FilterTreeNode *node) const { return -1; }
|
virtual int childIndex(const FilterTreeNode *node) const { return -1; }
|
||||||
virtual int index() const { return (parent() != NULL)? parent()->childIndex(this) : -1; }
|
virtual int index() const { return (parent() != NULL)? parent()->childIndex(this) : -1; }
|
||||||
virtual QString text() const { return ""; }
|
virtual QString text() const { return QString(textCStr()); }
|
||||||
virtual bool isLeaf() const { return false; }
|
virtual bool isLeaf() const { return false; }
|
||||||
virtual const char *textCStr() const { return text().toStdString().c_str(); }
|
virtual const char *textCStr() const { return ""; }
|
||||||
virtual void nodeChanged() const {
|
virtual void nodeChanged() const {
|
||||||
if (parent() != NULL) parent()->nodeChanged();
|
if (parent() != NULL) parent()->nodeChanged();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
const FilterItemList *findTypeList(CardFilter::Type type) const;
|
const FilterItemList *findTypeList(CardFilter::Type type) const;
|
||||||
FilterItemList *typeList(CardFilter::Type type);
|
FilterItemList *typeList(CardFilter::Type type);
|
||||||
FilterTreeNode *parent() const;
|
FilterTreeNode *parent() const;
|
||||||
QString text() const { return QString(CardFilter::attrName(attr)); }
|
const char* textCStr() const { return CardFilter::attrName(attr); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class FilterItem;
|
class FilterItem;
|
||||||
|
@ -86,7 +86,7 @@ public:
|
||||||
FilterTreeNode *parent() const { return p; }
|
FilterTreeNode *parent() const { return p; }
|
||||||
int termIndex(const QString &term) const;
|
int termIndex(const QString &term) const;
|
||||||
FilterTreeNode *termNode(const QString &term);
|
FilterTreeNode *termNode(const QString &term);
|
||||||
QString text() const { return QString(CardFilter::typeName(type)); }
|
const char *textCStr() const { return CardFilter::typeName(type); }
|
||||||
|
|
||||||
bool testTypeAnd(const CardInfo *info, CardFilter::Attr attr) const;
|
bool testTypeAnd(const CardInfo *info, CardFilter::Attr attr) const;
|
||||||
bool testTypeAndNot(const CardInfo *info, CardFilter::Attr attr) const;
|
bool testTypeAndNot(const CardInfo *info, CardFilter::Attr attr) const;
|
||||||
|
@ -107,6 +107,7 @@ public:
|
||||||
CardFilter::Type type() const { return p->type; }
|
CardFilter::Type type() const { return p->type; }
|
||||||
FilterTreeNode *parent() const { return p; }
|
FilterTreeNode *parent() const { return p; }
|
||||||
QString text() const { return term; }
|
QString text() const { return term; }
|
||||||
|
const char *textCStr() const { return term.toStdString().c_str(); }
|
||||||
bool isLeaf() const { return true; }
|
bool isLeaf() const { return true; }
|
||||||
|
|
||||||
bool acceptName(const CardInfo *info) const;
|
bool acceptName(const CardInfo *info) const;
|
||||||
|
@ -152,7 +153,7 @@ public:
|
||||||
FilterTreeNode *termNode(const CardFilter *f);
|
FilterTreeNode *termNode(const CardFilter *f);
|
||||||
FilterTreeNode *attrTypeNode(CardFilter::Attr attr,
|
FilterTreeNode *attrTypeNode(CardFilter::Attr attr,
|
||||||
CardFilter::Type type);
|
CardFilter::Type type);
|
||||||
QString text() const { return QString("root"); }
|
const char *textCStr() { return "root"; }
|
||||||
int index() const { return 0; }
|
int index() const { return 0; }
|
||||||
|
|
||||||
bool acceptsCard(const CardInfo *info) const;
|
bool acceptsCard(const CardInfo *info) const;
|
||||||
|
|
|
@ -133,7 +133,10 @@ QVariant FilterTreeModel::data(const QModelIndex &index, int role) const
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
case Qt::StatusTipRole:
|
case Qt::StatusTipRole:
|
||||||
case Qt::WhatsThisRole:
|
case Qt::WhatsThisRole:
|
||||||
return node->text();
|
if(!node->isLeaf())
|
||||||
|
return tr(node->textCStr());
|
||||||
|
else
|
||||||
|
return node->text();
|
||||||
case Qt::CheckStateRole:
|
case Qt::CheckStateRole:
|
||||||
if (node->isEnabled())
|
if (node->isEnabled())
|
||||||
return Qt::Checked;
|
return Qt::Checked;
|
||||||
|
|
|
@ -285,7 +285,7 @@ TabDeckEditor::~TabDeckEditor()
|
||||||
|
|
||||||
void TabDeckEditor::retranslateUi()
|
void TabDeckEditor::retranslateUi()
|
||||||
{
|
{
|
||||||
aCardTextOnly->setText(tr("&Show card text only"));
|
aCardTextOnly->setText(tr("Show card text only"));
|
||||||
aClearSearch->setText(tr("&Clear search"));
|
aClearSearch->setText(tr("&Clear search"));
|
||||||
searchLabel->setText(tr("&Search for:"));
|
searchLabel->setText(tr("&Search for:"));
|
||||||
|
|
||||||
|
@ -591,11 +591,12 @@ void TabDeckEditor::offsetCountAtIndex(const QModelIndex &idx, int offset)
|
||||||
|
|
||||||
const QModelIndex numberIndex = idx.sibling(idx.row(), 0);
|
const QModelIndex numberIndex = idx.sibling(idx.row(), 0);
|
||||||
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
const int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
|
||||||
|
const int new_count = count + offset;
|
||||||
deckView->setCurrentIndex(numberIndex);
|
deckView->setCurrentIndex(numberIndex);
|
||||||
if ((count + offset) <= 0)
|
if (new_count <= 0)
|
||||||
deckModel->removeRow(idx.row(), idx.parent());
|
deckModel->removeRow(idx.row(), idx.parent());
|
||||||
else
|
else
|
||||||
deckModel->setData(numberIndex, count + offset, Qt::EditRole);
|
deckModel->setData(numberIndex, new_count, Qt::EditRole);
|
||||||
setModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue