diff --git a/src/dolphin_directoryviewpropertysettings.kcfg b/src/dolphin_directoryviewpropertysettings.kcfg
index e1ab73b64..bd8cf6c16 100644
--- a/src/dolphin_directoryviewpropertysettings.kcfg
+++ b/src/dolphin_directoryviewpropertysettings.kcfg
@@ -3,6 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ kfileitemdelegate.h
@@ -43,6 +44,11 @@
Qt::Descending
+
+
+ KFileItemDelegate::NoInformation
+
+
The last time these properties were changed by the user.
diff --git a/src/dolphin_iconsmodesettings.kcfg b/src/dolphin_iconsmodesettings.kcfg
index edd75d0a7..a9c43726f 100644
--- a/src/dolphin_iconsmodesettings.kcfg
+++ b/src/dolphin_iconsmodesettings.kcfg
@@ -2,7 +2,6 @@
- kfileitemdelegate.h
kglobalsettings.h
kiconloader.h
QListView
@@ -46,9 +45,5 @@
K3Icon::SizeLarge
-
-
- KFileItemDelegate::FriendlyMimeType
-
\ No newline at end of file
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index c019f8eb0..123cfe3b3 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -77,9 +77,6 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
m_viewOptions = QTreeView::viewOptions();
m_viewOptions.font = QFont(settings->fontFamily(), settings->fontSize());
updateDecorationSize();
-
- KFileItemDelegate* delegate = new KFileItemDelegate(parent);
- setItemDelegate(delegate);
}
DolphinDetailsView::~DolphinDetailsView()
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index 1871bb6d9..c771e0180 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -69,12 +69,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
setFlow(QListView::TopToBottom);
m_viewOptions.decorationPosition = QStyleOptionViewItem::Left;
}
-
- KFileItemDelegate* delegate = new KFileItemDelegate(parent);
- const KFileItemDelegate::AdditionalInformation info =
- static_cast(settings->additionalInfo());
- delegate->setAdditionalInformation(info);
- setItemDelegate(delegate);
}
DolphinIconsView::~DolphinIconsView()
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index e0a0a5633..508f010ce 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -303,6 +303,31 @@ void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
descending->setChecked(sortDescending);
}
+void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info)
+{
+ QAction* action = 0;
+ switch (info) {
+ case KFileItemDelegate::FriendlyMimeType:
+ action = actionCollection()->action("show_mime_info");
+ break;
+ case KFileItemDelegate::Size:
+ action = actionCollection()->action("show_size_info");
+ break;
+ case KFileItemDelegate::ModificationTime:
+ action = actionCollection()->action("show_date_info");
+ break;
+ case KFileItemDelegate::NoInformation:
+ default:
+ action = actionCollection()->action("clear_info");
+ break;
+ }
+
+ if (action != 0) {
+ KToggleAction* toggleAction = static_cast(action);
+ toggleAction->setChecked(true);
+ }
+}
+
void DolphinMainWindow::slotSelectionChanged()
{
updateEditActions();
@@ -704,6 +729,29 @@ void DolphinMainWindow::toggleSortOrder()
m_activeView->setSortOrder(order);
}
+void DolphinMainWindow::clearInfo()
+{
+ m_activeView->setAdditionalInfo(KFileItemDelegate::NoInformation);
+}
+
+void DolphinMainWindow::showMimeInfo()
+{
+ clearStatusBar();
+ m_activeView->setAdditionalInfo(KFileItemDelegate::FriendlyMimeType);
+}
+
+void DolphinMainWindow::showSizeInfo()
+{
+ clearStatusBar();
+ m_activeView->setAdditionalInfo(KFileItemDelegate::Size);
+}
+
+void DolphinMainWindow::showDateInfo()
+{
+ clearStatusBar();
+ m_activeView->setAdditionalInfo(KFileItemDelegate::ModificationTime);
+}
+
void DolphinMainWindow::toggleSplitView()
{
if (m_view[SecondaryIdx] == 0) {
@@ -1127,6 +1175,28 @@ void DolphinMainWindow::setupActions()
sortDescending->setText(i18n("Descending"));
connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
+ KToggleAction* clearInfo = actionCollection()->add("clear_info");
+ clearInfo->setText(i18n("No Information"));
+ connect(clearInfo, SIGNAL(triggered()), this, SLOT(clearInfo()));
+
+ KToggleAction* showMimeInfo = actionCollection()->add("show_mime_info");
+ showMimeInfo->setText(i18n("MIME Type"));
+ connect(showMimeInfo, SIGNAL(triggered()), this, SLOT(showMimeInfo()));
+
+ KToggleAction* showSizeInfo = actionCollection()->add("show_size_info");
+ showSizeInfo->setText(i18n("Size"));
+ connect(showSizeInfo, SIGNAL(triggered()), this, SLOT(showSizeInfo()));
+
+ KToggleAction* showDateInfo = actionCollection()->add("show_date_info");
+ showDateInfo->setText(i18n("Date"));
+ connect(showDateInfo, SIGNAL(triggered()), this, SLOT(showDateInfo()));
+
+ QActionGroup* infoGroup = new QActionGroup(this);
+ infoGroup->addAction(clearInfo);
+ infoGroup->addAction(showMimeInfo);
+ infoGroup->addAction(showSizeInfo);
+ infoGroup->addAction(showDateInfo);
+
KToggleAction* showPreview = actionCollection()->add("show_preview");
showPreview->setText(i18n("Preview"));
showPreview->setIcon(KIcon("thumbnail-show"));
@@ -1331,6 +1401,7 @@ void DolphinMainWindow::updateViewActions()
slotSortingChanged(m_activeView->sorting());
slotSortOrderChanged(m_activeView->sortOrder());
+ slotAdditionalInfoChanged(m_activeView->additionalInfo());
KToggleAction* showFilterBarAction =
static_cast(actionCollection()->action("show_filter_bar"));
@@ -1395,6 +1466,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex)
this, SLOT(slotSortingChanged(DolphinView::Sorting)));
connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
+ connect(view, SIGNAL(additionalInfoChanged(KFileItemDelegate::AdditionalInformation)),
+ this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation)));
connect(view, SIGNAL(selectionChanged()),
this, SLOT(slotSelectionChanged()));
connect(view, SIGNAL(showFilterBarChanged(bool)),
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 137fdfc9e..ff9fbf6a9 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -241,6 +241,21 @@ private slots:
/** Switches between an ascending and descending sorting order. */
void toggleSortOrder();
+ /**
+ * Clears any additional information for an item except for the
+ * name and the icon.
+ */
+ void clearInfo();
+
+ /** Shows the MIME type as additional information for the item. */
+ void showMimeInfo();
+
+ /** Shows the size as additional information for the item. */
+ void showSizeInfo();
+
+ /** Shows the date as additional information for the item. */
+ void showDateInfo();
+
/**
* Switches between one and two views:
* If one view is visible, it will get split into two views.
@@ -331,6 +346,9 @@ private slots:
/** Updates the state of the 'Sort Ascending/Descending' action. */
void slotSortOrderChanged(Qt::SortOrder order);
+ /** Updates the state of the 'Additional Information' actions. */
+ void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info);
+
/** Updates the state of the 'Edit' menu actions. */
void slotSelectionChanged();
diff --git a/src/dolphinui.rc b/src/dolphinui.rc
index 5f822bf64..06f94826c 100644
--- a/src/dolphinui.rc
+++ b/src/dolphinui.rc
@@ -32,6 +32,13 @@
+
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 3a6a2e757..60e929eba 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -71,6 +71,7 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow,
m_controller(0),
m_iconsView(0),
m_detailsView(0),
+ m_fileItemDelegate(0),
m_filterBar(0),
m_statusBar(0),
m_dirModel(0),
@@ -425,6 +426,22 @@ Qt::SortOrder DolphinView::sortOrder() const
return m_proxyModel->sortOrder();
}
+void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation info)
+{
+ ViewProperties props(m_urlNavigator->url());
+ props.setAdditionalInfo(info);
+
+ m_fileItemDelegate->setAdditionalInformation(info);
+
+ emit additionalInfoChanged(info);
+ reload();
+}
+
+KFileItemDelegate::AdditionalInformation DolphinView::additionalInfo() const
+{
+ return m_fileItemDelegate->additionalInformation();
+}
+
void DolphinView::goBack()
{
m_urlNavigator->goBack();
@@ -613,6 +630,13 @@ void DolphinView::loadDirectory(const KUrl& url)
emit sortOrderChanged(sortOrder);
}
+ KFileItemDelegate::AdditionalInformation info = props.additionalInfo();
+ if (info != m_fileItemDelegate->additionalInformation()) {
+ m_fileItemDelegate->setAdditionalInformation(info);
+
+ emit additionalInfoChanged(info);
+ }
+
const bool showPreview = props.showPreview();
if (showPreview != m_controller->showPreview()) {
m_controller->setShowPreview(showPreview);
@@ -1045,6 +1069,7 @@ void DolphinView::createView()
view->deleteLater();
m_iconsView = 0;
m_detailsView = 0;
+ m_fileItemDelegate = 0;
}
assert(m_iconsView == 0);
@@ -1063,6 +1088,10 @@ void DolphinView::createView()
break;
}
+
+ m_fileItemDelegate = new KFileItemDelegate(view);
+ view->setItemDelegate(m_fileItemDelegate);
+
view->setModel(m_proxyModel);
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 8ca4a1ac3..8a7637656 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -24,6 +24,7 @@
#include
#include
+#include
#include
#include
@@ -38,6 +39,7 @@
class DolphinController;
class FilterBar;
+class KFileItemDelegate;
class KUrl;
class KDirModel;
class UrlNavigator;
@@ -301,6 +303,12 @@ public:
/** Returns the current used sort order (Qt::Ascending or Qt::Descending). */
Qt::SortOrder sortOrder() const;
+ /** Sets the additional information which should be shown for the items. */
+ void setAdditionalInfo(KFileItemDelegate::AdditionalInformation info);
+
+ /** Returns the additional information which should be shown for the items. */
+ KFileItemDelegate::AdditionalInformation additionalInfo() const;
+
/** Refreshs the view settings by reading out the stored settings. */
void refreshSettings();
@@ -371,6 +379,9 @@ signals:
/** Is emitted if the sort order (ascending or descending) has been changed. */
void sortOrderChanged(Qt::SortOrder order);
+ /** Is emitted if the addtional information for an item has been changed. */
+ void additionalInfoChanged(KFileItemDelegate::AdditionalInformation info);
+
/**
* Is emitted if information of an item is requested to be shown e. g. in the sidebar.
* It the URL is empty, no item information request is pending.
@@ -546,6 +557,7 @@ private:
DolphinController* m_controller;
DolphinIconsView* m_iconsView;
DolphinDetailsView* m_detailsView;
+ KFileItemDelegate* m_fileItemDelegate;
FilterBar* m_filterBar;
DolphinStatusBar* m_statusBar;
diff --git a/src/iconsviewsettingspage.cpp b/src/iconsviewsettingspage.cpp
index 3f0ffb23f..8c02ba0b5 100644
--- a/src/iconsviewsettingspage.cpp
+++ b/src/iconsviewsettingspage.cpp
@@ -55,7 +55,6 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
m_fontFamilyBox(0),
m_fontSizeBox(0),
m_textlinesCountBox(0),
- m_additionalInfo(0),
m_arrangementBox(0),
m_gridSpacingBox(0)
{
@@ -101,15 +100,6 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
m_textWidthBox->addItem(i18n("Medium"));
m_textWidthBox->addItem(i18n("Large"));
- new QLabel(i18n("Additional information:"), textGroup);
- m_additionalInfo = new QComboBox(textGroup);
- m_additionalInfo->addItem(i18n("No Information"), KFileItemDelegate::NoInformation);
- m_additionalInfo->addItem(i18n("MIME Type"), KFileItemDelegate::FriendlyMimeType);
- m_additionalInfo->addItem(i18n("Size"), KFileItemDelegate::Size);
- m_additionalInfo->addItem(i18n("Date"), KFileItemDelegate::ModificationTime);
- const int index = m_additionalInfo->findData(settings->additionalInfo());
- m_additionalInfo->setCurrentIndex(index);
-
Q3GroupBox* gridGroup = new Q3GroupBox(2, Qt::Horizontal, i18n("Grid"), this);
gridGroup->setSizePolicy(sizePolicy);
gridGroup->setMargin(margin);
@@ -176,8 +166,6 @@ void IconsViewSettingsPage::applySettings()
settings->setFontFamily(m_fontFamilyBox->currentFont().family());
settings->setFontSize(fontSize);
settings->setNumberOfTextlines(m_textlinesCountBox->value());
- const int index = m_additionalInfo->currentIndex();
- settings->setAdditionalInfo(m_additionalInfo->itemData(index).toInt());
settings->setGridSpacing(GRID_SPACING_BASE +
m_gridSpacingBox->currentIndex() * GRID_SPACING_INC);
diff --git a/src/iconsviewsettingspage.h b/src/iconsviewsettingspage.h
index c9f5b8a74..675225718 100644
--- a/src/iconsviewsettingspage.h
+++ b/src/iconsviewsettingspage.h
@@ -82,7 +82,6 @@ private:
QFontComboBox* m_fontFamilyBox;
QSpinBox* m_fontSizeBox;
QSpinBox* m_textlinesCountBox;
- QComboBox* m_additionalInfo;
QComboBox* m_arrangementBox;
QComboBox* m_gridSpacingBox;
diff --git a/src/viewproperties.cpp b/src/viewproperties.cpp
index cf675f30a..d3fe72246 100644
--- a/src/viewproperties.cpp
+++ b/src/viewproperties.cpp
@@ -163,6 +163,20 @@ Qt::SortOrder ViewProperties::sortOrder() const
return static_cast(m_node->sortOrder());
}
+void ViewProperties::setAdditionalInfo(KFileItemDelegate::AdditionalInformation info)
+{
+ if (m_node->additionalInfo() != info) {
+ m_node->setAdditionalInfo(info);
+ updateTimeStamp();
+ }
+}
+
+KFileItemDelegate::AdditionalInformation ViewProperties::additionalInfo() const
+{
+ return static_cast(m_node->additionalInfo());
+}
+
+
void ViewProperties::setDirProperties(const ViewProperties& props)
{
setViewMode(props.viewMode());
@@ -170,6 +184,7 @@ void ViewProperties::setDirProperties(const ViewProperties& props)
setShowHiddenFiles(props.showHiddenFiles());
setSorting(props.sorting());
setSortOrder(props.sortOrder());
+ setAdditionalInfo(props.additionalInfo());
}
void ViewProperties::setAutoSaveEnabled(bool autoSave)
diff --git a/src/viewproperties.h b/src/viewproperties.h
index 6683a6d0c..0eb575407 100644
--- a/src/viewproperties.h
+++ b/src/viewproperties.h
@@ -22,6 +22,7 @@
#define VIEWPROPERTIES_H
#include
+#include
#include
#include
@@ -71,6 +72,9 @@ public:
void setSortOrder(Qt::SortOrder sortOrder);
Qt::SortOrder sortOrder() const;
+ void setAdditionalInfo(KFileItemDelegate::AdditionalInformation info);
+ KFileItemDelegate::AdditionalInformation additionalInfo() const;
+
/**
* Sets the directory properties view mode, show preview,
* show hidden files, sorting and sort order like
diff --git a/src/viewpropertiesdialog.cpp b/src/viewpropertiesdialog.cpp
index 81a1f7413..76a45061e 100644
--- a/src/viewpropertiesdialog.cpp
+++ b/src/viewpropertiesdialog.cpp
@@ -53,6 +53,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
m_viewMode(0),
m_sorting(0),
m_sortOrder(0),
+ m_additionalInfo(0),
m_showPreview(0),
m_showHiddenFiles(0),
m_applyToCurrentFolder(0),
@@ -102,6 +103,15 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
const int sortOrderIdx = (m_viewProps->sortOrder() == Qt::Ascending) ? 0 : 1;
m_sortOrder->setCurrentIndex(sortOrderIdx);
+ QLabel* additionalInfoLabel = new QLabel(i18n("Additional information:"), propsBox);
+ m_additionalInfo = new QComboBox(propsBox);
+ m_additionalInfo->addItem(i18n("No Information"), KFileItemDelegate::NoInformation);
+ m_additionalInfo->addItem(i18n("MIME Type"), KFileItemDelegate::FriendlyMimeType);
+ m_additionalInfo->addItem(i18n("Size"), KFileItemDelegate::Size);
+ m_additionalInfo->addItem(i18n("Date"), KFileItemDelegate::ModificationTime);
+ const int addInfoIndex = m_additionalInfo->findData(m_viewProps->additionalInfo());
+ m_additionalInfo->setCurrentIndex(addInfoIndex);
+
m_showPreview = new QCheckBox(i18n("Show preview"), propsBox);
m_showPreview->setChecked(m_viewProps->showPreview());
@@ -116,8 +126,10 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
propsBoxLayout->addWidget(m_sorting, 1, 1);
propsBoxLayout->addWidget(sortOrderLabel, 2, 0);
propsBoxLayout->addWidget(m_sortOrder, 2, 1);
- propsBoxLayout->addWidget(m_showPreview, 3, 0);
- propsBoxLayout->addWidget(m_showHiddenFiles, 4, 0);
+ propsBoxLayout->addWidget(additionalInfoLabel, 3, 0);
+ propsBoxLayout->addWidget(m_additionalInfo, 3, 1);
+ propsBoxLayout->addWidget(m_showPreview, 4, 0);
+ propsBoxLayout->addWidget(m_showHiddenFiles, 5, 0);
topLayout->addWidget(propsBox);
@@ -127,6 +139,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
this, SLOT(slotSortingChanged(int)));
connect(m_sortOrder, SIGNAL(activated(int)),
this, SLOT(slotSortOrderChanged(int)));
+ connect(m_additionalInfo, SIGNAL(activated(int)),
+ this, SLOT(slotAdditionalInfoChanged(int)));
connect(m_showPreview, SIGNAL(clicked()),
this, SLOT(slotShowPreviewChanged()));
connect(m_showHiddenFiles, SIGNAL(clicked()),
@@ -214,6 +228,19 @@ void ViewPropertiesDialog::slotSortOrderChanged(int index)
m_isDirty = true;
}
+void ViewPropertiesDialog::slotAdditionalInfoChanged(int index)
+{
+ KFileItemDelegate::AdditionalInformation info = KFileItemDelegate::NoInformation;
+ switch (index) {
+ case 1: info = KFileItemDelegate::FriendlyMimeType; break;
+ case 2: info = KFileItemDelegate::Size; break;
+ case 3: info = KFileItemDelegate::ModificationTime; break;
+ default: break;
+ }
+ m_viewProps->setAdditionalInfo(info);
+ m_isDirty = true;
+}
+
void ViewPropertiesDialog::slotShowPreviewChanged()
{
const bool show = m_showPreview->isChecked();
diff --git a/src/viewpropertiesdialog.h b/src/viewpropertiesdialog.h
index 9c5dd4cc7..2454137bb 100644
--- a/src/viewpropertiesdialog.h
+++ b/src/viewpropertiesdialog.h
@@ -50,6 +50,7 @@ private slots:
void slotViewModeChanged(int index);
void slotSortingChanged(int index);
void slotSortOrderChanged(int index);
+ void slotAdditionalInfoChanged(int index);
void slotShowPreviewChanged();
void slotShowHiddenFilesChanged();
void markAsDirty();
@@ -62,6 +63,7 @@ private:
QComboBox* m_viewMode;
QComboBox* m_sorting;
QComboBox* m_sortOrder;
+ QComboBox* m_additionalInfo;
QCheckBox* m_showPreview;
QCheckBox* m_showHiddenFiles;
QRadioButton* m_applyToCurrentFolder;