Save deck editor's database view columns state

This commit is contained in:
Fabio Bas
2016-04-02 09:38:34 +02:00
parent f217551f5f
commit 58f85e7ebd
4 changed files with 29 additions and 6 deletions

View File

@@ -335,14 +335,19 @@ void TabDeckEditor::createCentralFrame()
databaseView->setSortingEnabled(true);
databaseView->sortByColumn(0, Qt::AscendingOrder);
databaseView->setModel(databaseDisplayModel);
databaseView->header()->setStretchLastSection(false);
#if QT_VERSION >= 0x050000
databaseView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
#else
databaseView->header()->setResizeMode(0, QHeaderView::Stretch);
#endif
connect(databaseView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoLeft(const QModelIndex &, const QModelIndex &)));
connect(databaseView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actAddCard()));
QByteArray dbHeaderState = settingsCache->layouts().getDeckEditorDbHeaderState();
if(dbHeaderState.isNull())
{
// first run
databaseView->setColumnWidth(0, 200);
} else {
databaseView->header()->restoreState(dbHeaderState);
}
connect(databaseView->header(), SIGNAL(geometriesChanged()), this, SLOT(saveDbHeaderState()));
searchEdit->setTreeView(databaseView);
aAddCard = new QAction(QString(), this);
@@ -1079,3 +1084,8 @@ void TabDeckEditor::dockTopLevelChanged(bool topLevel)
return;
}
}
void TabDeckEditor::saveDbHeaderState()
{
settingsCache->layouts().setDeckEditorDbHeaderState(databaseView->header()->saveState());
}