summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2012-02-04 00:45:33 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-17 05:28:26 +0100
commit9aa51821e446152517aa3022bcf7ebbcc7d3d888 (patch)
treecf6af99c119749f2569e79f78c3e3456190d5e5b /src
parent3ea33062d42f821cf3230de3f1d7d6d4f033a609 (diff)
Ensure the header's context menu is in sync with the visible sections
When the filedialog was reshown the context menu for the header was not in sync with the sections that were actually visible. This ensures that it is in sync after the state of the header is restored. Task-number: QTBUG-23271 Change-Id: Ia1546bf300d43a5822482f63de99eb52b674bf52 Reviewed-by: Zeno Albisser <zeno.albisser@nokia.com> (cherry picked from commit 2e220e4603d6a0c21efee3a884be76e9f2d7ebb7)
Diffstat (limited to 'src')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index ed5264159f..84fdef6702 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -482,9 +482,20 @@ bool QFileDialog::restoreState(const QByteArray &state)
history.pop_front();
setHistory(history);
setDirectory(lastVisitedDir()->isEmpty() ? currentDirectory : *lastVisitedDir());
- if (!d->qFileDialogUi->treeView->header()->restoreState(headerData))
+ QHeaderView *headerView = d->qFileDialogUi->treeView->header();
+ if (!headerView->restoreState(headerData))
return false;
+ QList<QAction*> actions = headerView->actions();
+ QAbstractItemModel *abstractModel = d->model;
+#ifndef QT_NO_PROXYMODEL
+ if (d->proxyModel)
+ abstractModel = d->proxyModel;
+#endif
+ int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1);
+ for (int i = 1; i < total; ++i)
+ actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i));
+
setViewMode(ViewMode(viewMode));
return true;
}