┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphindetailsview.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2010-05-10 12:49:41 +0000
committerFrank Reininghaus <[email protected]>2010-05-10 12:49:41 +0000
commit7e74c6f23beb06b9541508b91914a4f9b3ee3a62 (patch)
treefa66e579562ffd6e99b8328faf4cc99999c41903 /src/dolphindetailsview.cpp
parent717ff023cca4b8fc6c4b2b636004a810af3a4ae8 (diff)
Provide the destination of a symbolic link as a column in Dolphin's
(and Konqueror's) Details View in KDE SC 4.5. This is based on the changes to KFileItemDelegate from commit 1124981. FEATURE: 211690 svn path=/trunk/KDE/kdebase/apps/; revision=1124982
Diffstat (limited to 'src/dolphindetailsview.cpp')
-rw-r--r--src/dolphindetailsview.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index 8ea5e93e6..5545a6ede 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -645,30 +645,40 @@ void DolphinDetailsView::updateColumnVisibility()
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
const QList<int> columnPositions = settings->columnPositions();
-
+
const KFileItemDelegate::InformationList list = m_dolphinViewController->view()->additionalInfo();
- for (int i = DolphinModel::Name; i <= DolphinModel::Version; ++i) {
+ for (int i = DolphinModel::Name; i < DolphinModel::ExtraColumnCount; ++i) {
const KFileItemDelegate::Information info = infoForColumn(i);
const bool hide = !list.contains(info) && (i != DolphinModel::Name);
if (isColumnHidden(i) != hide) {
setColumnHidden(i, hide);
}
-
- const int from = headerView->visualIndex(i);
- headerView->moveSection(from, columnPositions[i]);
+
+ // If the list columnPositions has been written by an older Dolphin version,
+ // its length might be smaller than DolphinModel::ExtraColumnCount. Therefore,
+ // we have to check if item number i exists before accessing it.
+ if (i < columnPositions.length()) {
+ const int position = columnPositions[i];
+
+ // The position might be outside the correct range if the list columnPositions
+ // has been written by a newer Dolphin version with more columns.
+ if (position < DolphinModel::ExtraColumnCount) {
+ const int from = headerView->visualIndex(i);
+ headerView->moveSection(from, position);
+ }
+ }
}
-
+
resizeColumns();
connect(headerView, SIGNAL(sectionMoved(int, int, int)),
this, SLOT(saveColumnPositions()));
-
}
void DolphinDetailsView::saveColumnPositions()
{
QList<int> columnPositions;
- for (int i = DolphinModel::Name; i <= DolphinModel::Version; ++i) {
+ for (int i = DolphinModel::Name; i < DolphinModel::ExtraColumnCount; ++i) {
columnPositions.append(header()->visualIndex(i));
}
@@ -988,6 +998,7 @@ KFileItemDelegate::Information DolphinDetailsView::infoForColumn(int columnIndex
case DolphinModel::Owner: info = KFileItemDelegate::Owner; break;
case DolphinModel::Group: info = KFileItemDelegate::OwnerAndGroup; break;
case DolphinModel::Type: info = KFileItemDelegate::FriendlyMimeType; break;
+ case DolphinModel::LinkDestination: info = KFileItemDelegate::LinkDest; break;
default: break;
}
@@ -1005,7 +1016,7 @@ void DolphinDetailsView::resizeColumns()
QHeaderView* headerView = header();
QFontMetrics fontMetrics(viewport()->font());
- int columnWidth[DolphinModel::Version + 1];
+ int columnWidth[DolphinModel::ExtraColumnCount];
columnWidth[DolphinModel::Size] = fontMetrics.width("00000 Items");
columnWidth[DolphinModel::ModifiedTime] = fontMetrics.width("0000-00-00 00:00");
columnWidth[DolphinModel::Permissions] = fontMetrics.width("xxxxxxxxxx");
@@ -1013,6 +1024,7 @@ void DolphinDetailsView::resizeColumns()
columnWidth[DolphinModel::Group] = fontMetrics.width("xxxxxxxxxx");
columnWidth[DolphinModel::Type] = fontMetrics.width("XXXX Xxxxxxx");
columnWidth[DolphinModel::Version] = fontMetrics.width("xxxxxxxx");
+ columnWidth[DolphinModel::LinkDestination] = fontMetrics.width("xxxxxxxx");
int requiredWidth = 0;
for (int i = KDirModel::Size; i <= KDirModel::Type; ++i) {