┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphindetailsview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2010-05-13 22:06:10 +0000
committerPeter Penz <[email protected]>2010-05-13 22:06:10 +0000
commitcb9669d71cf10e73305c6a60fe0d832f4eb0ac7a (patch)
treea1dbc83e15fa3dc9c36a41e03f1b999cc04a5e02 /src/dolphindetailsview.cpp
parentd64bbc333c5014fad116efc98b77cf3268fc07e0 (diff)
If an information entry will be added to KFileItemDelegate (like done recently), adjusting the corresponding code in Dolphin is a real pain, as the new information will be shown in Dolphin the following way:
- As additional columns in the details view - As additional lines in the icons view - As menu entries in the "Sort By" and "Additional Information" groups - As popup menu entries in the details view header popup - As checkable entries in the View Properties dialog To prevent similar painful transitions in future, the class AdditionalInfoManager has been introduced. All parts in Dolphin that access/show/store additional information, use the AdditionalInfoManager now. If a new information entry will be added in KFileItemDelegate in future, only a small adjustment in AdditionalInfoManager will be required. Still open currently: - AdditionalInfoDialog does not use AdditionalInfoManager yet - DolphinView::Sorting should be replaced by KFileItemDelegate::Information, so that the sorting can also be done in a generic way. - The data for KFileItemDelegate::PathOrUrl is not determined The open issues will get fixed during the next days. Kudos to the brave warriors Sebastian and Frank, that tried to add a new information ;-) CCMAIL: [email protected] CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=1126410
Diffstat (limited to 'src/dolphindetailsview.cpp')
-rw-r--r--src/dolphindetailsview.cpp38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index 5545a6ede..130c9e9b3 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -20,6 +20,7 @@
#include "dolphindetailsview.h"
+#include "additionalinfomanager.h"
#include "dolphinmodel.h"
#include "dolphinviewcontroller.h"
#include "dolphinfileitemdelegate.h"
@@ -607,11 +608,13 @@ void DolphinDetailsView::configureSettings(const QPoint& pos)
for (int i = 0; i < columns; ++i) {
const int logicalIndex = headerView->logicalIndex(i);
const QString text = model()->headerData(logicalIndex, Qt::Horizontal).toString();
- QAction* action = popup.addAction(text);
- action->setCheckable(true);
- action->setChecked(!headerView->isSectionHidden(logicalIndex));
- action->setData(logicalIndex);
- action->setEnabled(logicalIndex != DolphinModel::Name);
+ if (!text.isEmpty()) {
+ QAction* action = popup.addAction(text);
+ action->setCheckable(true);
+ action->setChecked(!headerView->isSectionHidden(logicalIndex));
+ action->setData(logicalIndex);
+ action->setEnabled(logicalIndex != DolphinModel::Name);
+ }
}
popup.addSeparator();
@@ -989,20 +992,7 @@ void DolphinDetailsView::updateDecorationSize(bool showPreview)
KFileItemDelegate::Information DolphinDetailsView::infoForColumn(int columnIndex) const
{
- KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
-
- switch (columnIndex) {
- case DolphinModel::Size: info = KFileItemDelegate::Size; break;
- case DolphinModel::ModifiedTime: info = KFileItemDelegate::ModificationTime; break;
- case DolphinModel::Permissions: info = KFileItemDelegate::Permissions; break;
- 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;
- }
-
- return info;
+ return AdditionalInfoManager::instance().keyForColumn(columnIndex);
}
void DolphinDetailsView::resizeColumns()
@@ -1017,14 +1007,12 @@ void DolphinDetailsView::resizeColumns()
QFontMetrics fontMetrics(viewport()->font());
int columnWidth[DolphinModel::ExtraColumnCount];
+ const int defaultWidth = fontMetrics.width("xxxxxxxxxx");
+ for (int i = 0; i < DolphinModel::ExtraColumnCount; ++i) {
+ columnWidth[i] = defaultWidth;
+ }
columnWidth[DolphinModel::Size] = fontMetrics.width("00000 Items");
columnWidth[DolphinModel::ModifiedTime] = fontMetrics.width("0000-00-00 00:00");
- columnWidth[DolphinModel::Permissions] = fontMetrics.width("xxxxxxxxxx");
- columnWidth[DolphinModel::Owner] = fontMetrics.width("xxxxxxxxxx");
- 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) {