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:
sylvanbasilisk 2014-03-24 23:52:30 +00:00
parent 2b7ea0c983
commit 610f0b6f6f
4 changed files with 20 additions and 11 deletions

View file

@ -18,12 +18,16 @@ FilterBuilder::FilterBuilder(QWidget *parent)
filterCombo = new QComboBox;
for (i = 0; i < CardFilter::AttrEnd; i++)
filterCombo->addItem(
CardFilter::attrName(static_cast<CardFilter::Attr>(i)), QVariant(i));
tr(CardFilter::attrName(static_cast<CardFilter::Attr>(i))),
QVariant(i)
);
typeCombo = new QComboBox;
for (i = 0; i < CardFilter::TypeEnd; i++)
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("+");
ok->setMaximumSize(20, 20);

View file

@ -23,9 +23,9 @@ public:
virtual int childCount() const { return 0; }
virtual int childIndex(const FilterTreeNode *node) const { return -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 const char *textCStr() const { return text().toStdString().c_str(); }
virtual const char *textCStr() const { return ""; }
virtual void nodeChanged() const {
if (parent() != NULL) parent()->nodeChanged();
}
@ -70,7 +70,7 @@ public:
const FilterItemList *findTypeList(CardFilter::Type type) const;
FilterItemList *typeList(CardFilter::Type type);
FilterTreeNode *parent() const;
QString text() const { return QString(CardFilter::attrName(attr)); }
const char* textCStr() const { return CardFilter::attrName(attr); }
};
class FilterItem;
@ -86,7 +86,7 @@ public:
FilterTreeNode *parent() const { return p; }
int termIndex(const QString &term) const;
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 testTypeAndNot(const CardInfo *info, CardFilter::Attr attr) const;
@ -107,6 +107,7 @@ public:
CardFilter::Type type() const { return p->type; }
FilterTreeNode *parent() const { return p; }
QString text() const { return term; }
const char *textCStr() const { return term.toStdString().c_str(); }
bool isLeaf() const { return true; }
bool acceptName(const CardInfo *info) const;
@ -152,7 +153,7 @@ public:
FilterTreeNode *termNode(const CardFilter *f);
FilterTreeNode *attrTypeNode(CardFilter::Attr attr,
CardFilter::Type type);
QString text() const { return QString("root"); }
const char *textCStr() { return "root"; }
int index() const { return 0; }
bool acceptsCard(const CardInfo *info) const;

View file

@ -133,7 +133,10 @@ QVariant FilterTreeModel::data(const QModelIndex &index, int role) const
case Qt::ToolTipRole:
case Qt::StatusTipRole:
case Qt::WhatsThisRole:
return node->text();
if(!node->isLeaf())
return tr(node->textCStr());
else
return node->text();
case Qt::CheckStateRole:
if (node->isEnabled())
return Qt::Checked;

View file

@ -285,7 +285,7 @@ TabDeckEditor::~TabDeckEditor()
void TabDeckEditor::retranslateUi()
{
aCardTextOnly->setText(tr("&Show card text only"));
aCardTextOnly->setText(tr("Show card text only"));
aClearSearch->setText(tr("&Clear search"));
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 int count = deckModel->data(numberIndex, Qt::EditRole).toInt();
const int new_count = count + offset;
deckView->setCurrentIndex(numberIndex);
if ((count + offset) <= 0)
if (new_count <= 0)
deckModel->removeRow(idx.row(), idx.parent());
else
deckModel->setData(numberIndex, count + offset, Qt::EditRole);
deckModel->setData(numberIndex, new_count, Qt::EditRole);
setModified(true);
}