diff options
author | Andy Shaw <andy.shaw@digia.com> | 2012-02-03 23:45:33 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-07 21:21:19 (GMT) |
commit | 2e220e4603d6a0c21efee3a884be76e9f2d7ebb7 (patch) | |
tree | f9a4d4316ad26b35b34bb25a95ebb00062d5312d /src/gui | |
parent | 68241a1d889b94156a63159fb7cdcffc10b9d397 (diff) | |
download | Qt-2e220e4603d6a0c21efee3a884be76e9f2d7ebb7.zip Qt-2e220e4603d6a0c21efee3a884be76e9f2d7ebb7.tar.gz Qt-2e220e4603d6a0c21efee3a884be76e9f2d7ebb7.tar.bz2 |
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>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/dialogs/qfiledialog.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 239c1b8..74a7dfb 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -479,9 +479,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; } |