+void DolphinDetailsView::configureColumns(const QPoint& pos)
+{
+ KMenu popup(this);
+ popup.addTitle(i18nc("@title:menu", "Columns"));
+
+ QHeaderView* headerView = header();
+ for (int i = DolphinModel::ModifiedTime; i <= DolphinModel::Type; ++i) {
+ const int logicalIndex = headerView->logicalIndex(i);
+ const QString text = model()->headerData(i, Qt::Horizontal).toString();
+ QAction* action = popup.addAction(text);
+ action->setCheckable(true);
+ action->setChecked(!headerView->isSectionHidden(logicalIndex));
+ action->setData(i);
+ }
+
+ QAction* activatedAction = popup.exec(header()->mapToGlobal(pos));
+ if (activatedAction != 0) {
+ const bool show = activatedAction->isChecked();
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ Q_ASSERT(settings != 0);
+
+ // remember the changed column visibility in the settings
+ const int columnIndex = activatedAction->data().toInt();
+ switch (columnIndex) {
+ case DolphinModel::ModifiedTime: settings->setShowDate(show); break;
+ case DolphinModel::Permissions: settings->setShowPermissions(show); break;
+ case DolphinModel::Owner: settings->setShowOwner(show); break;
+ case DolphinModel::Group: settings->setShowGroup(show); break;
+ case DolphinModel::Type: settings->setShowType(show); break;
+ default: break;
+ }
+
+ // apply the changed column visibility
+ if (show) {
+ showColumn(columnIndex);
+ } else {
+ hideColumn(columnIndex);
+ }
+ }
+}
+