diff --git a/cockatrice/src/dlg_create_token.cpp b/cockatrice/src/dlg_create_token.cpp index 0a5c16bc..2bc10d9c 100644 --- a/cockatrice/src/dlg_create_token.cpp +++ b/cockatrice/src/dlg_create_token.cpp @@ -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::fromList(predefinedTokens)); } @@ -216,4 +223,4 @@ QString DlgCreateToken::getAnnotation() const bool DlgCreateToken::getDestroy() const { return destroyCheckBox->isChecked(); -} +} \ No newline at end of file diff --git a/cockatrice/src/dlg_create_token.h b/cockatrice/src/dlg_create_token.h index fa5c3159..d7d314e9 100644 --- a/cockatrice/src/dlg_create_token.h +++ b/cockatrice/src/dlg_create_token.h @@ -11,6 +11,7 @@ class QCheckBox; class QPushButton; class QRadioButton; class QCloseEvent; +class QTreeView; class DeckList; class CardDatabaseModel; class TokenDisplayModel; @@ -44,6 +45,7 @@ private: QCheckBox *destroyCheckBox; QRadioButton *chooseTokenFromAllRadioButton, *chooseTokenFromDeckRadioButton; CardInfoPicture *pic; + QTreeView *chooseTokenView; void updateSearchFieldWithoutUpdatingFilter(const QString &newValue) const; }; diff --git a/cockatrice/src/settings/layoutssettings.h b/cockatrice/src/settings/layoutssettings.h index 2e715b13..1617d7c3 100644 --- a/cockatrice/src/settings/layoutssettings.h +++ b/cockatrice/src/settings/layoutssettings.h @@ -8,8 +8,7 @@ class LayoutsSettings : public SettingsManager { Q_OBJECT friend class SettingsCache; -public: - +public: void setDeckEditorLayoutState(const QByteArray &value); void setDeckEditorGeometry(const QByteArray &value); void setDeckEditorCardSize(const QSize &value); diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index 661a5a7a..85692aed 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -345,11 +345,13 @@ void TabDeckEditor::createCentralFrame() connect(databaseView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actAddCard())); QByteArray dbHeaderState = settingsCache->layouts().getDeckEditorDbHeaderState(); - if(dbHeaderState.isNull()) + if (dbHeaderState.isNull()) { // first run databaseView->setColumnWidth(0, 200); - } else { + } + else + { databaseView->header()->restoreState(dbHeaderState); } connect(databaseView->header(), SIGNAL(geometriesChanged()), this, SLOT(saveDbHeaderState()));