Model col widths off deck editor & disable button if no tokens in deck (#2751)

This commit is contained in:
Zach H 2017-06-04 13:58:34 -04:00 committed by GitHub
parent d970b9e50f
commit f3f83882e0
4 changed files with 23 additions and 13 deletions

View file

@ -75,7 +75,9 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
connect(chooseTokenFromAllRadioButton, SIGNAL(toggled(bool)), this, SLOT(actChooseTokenFromAll(bool)));
chooseTokenFromDeckRadioButton = new QRadioButton(tr("Show tokens from this &deck"));
connect(chooseTokenFromDeckRadioButton, SIGNAL(toggled(bool)), this, SLOT(actChooseTokenFromDeck(bool)));
QTreeView *chooseTokenView = new QTreeView;
QByteArray deckHeaderState = settingsCache->layouts().getDeckEditorDbHeaderState();
chooseTokenView = new QTreeView;
chooseTokenView->setModel(cardDatabaseDisplayModel);
chooseTokenView->setUniformRowHeights(true);
chooseTokenView->setRootIsDecorated(false);
@ -83,19 +85,24 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
chooseTokenView->setSortingEnabled(true);
chooseTokenView->sortByColumn(0, Qt::AscendingOrder);
chooseTokenView->resizeColumnToContents(0);
chooseTokenView->header()->setStretchLastSection(false);
chooseTokenView->header()->hideSection(1);
chooseTokenView->header()->hideSection(2);
chooseTokenView->setWordWrap(true);
chooseTokenView->setColumnWidth(0, 130);
chooseTokenView->setColumnWidth(3, 178);
chooseTokenView->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
if (!deckHeaderState.isNull())
chooseTokenView->header()->restoreState(deckHeaderState);
chooseTokenView->header()->setStretchLastSection(false);
chooseTokenView->header()->hideSection(1); // Sets
chooseTokenView->header()->hideSection(2); // Mana Cost
chooseTokenView->header()->setSectionResizeMode(5, QHeaderView::ResizeToContents); // Color(s)
connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex)));
if (predefinedTokens.isEmpty())
{
chooseTokenFromAllRadioButton->setChecked(true);
else {
chooseTokenFromDeckRadioButton->setDisabled(true); // No tokens in deck = no need for option
}
else
{
chooseTokenFromDeckRadioButton->setChecked(true);
cardDatabaseDisplayModel->setCardNameSet(QSet<QString>::fromList(predefinedTokens));
}
@ -216,4 +223,4 @@ QString DlgCreateToken::getAnnotation() const
bool DlgCreateToken::getDestroy() const
{
return destroyCheckBox->isChecked();
}
}