<entry name="AdditionalInfo" type="Int">
<label context="@label">Additional information</label>
- <default code="true">KFileItemDelegate::NoInformation</default>
+ <default>0</default>
</entry>
<entry name="Timestamp" type="DateTime" >
DolphinController::DolphinController(QObject* parent) :
QObject(parent),
m_showPreview(false),
- m_showAdditionalInfo(false),
m_zoomInPossible(false),
- m_zoomOutPossible(false)
+ m_zoomOutPossible(false),
+ m_additionalInfoCount(0),
+ m_url()
{
}
}
}
-void DolphinController::setShowAdditionalInfo(bool show)
+void DolphinController::setAdditionalInfoCount(int count)
{
- if (m_showAdditionalInfo != show) {
- m_showAdditionalInfo = show;
- emit showAdditionalInfoChanged(show);
+ if (m_additionalInfoCount != count) {
+ m_additionalInfoCount = count;
+ emit additionalInfoCountChanged(count);
}
}
void setShowPreview(bool show);
bool showPreview() const;
- void setShowAdditionalInfo(bool show);
- bool showAdditionalInfo() const;
+ void setAdditionalInfoCount(int count);
+ bool additionalInfoCount() const;
void triggerZoomIn();
void setZoomInPossible(bool possible);
void showPreviewChanged(bool show);
/**
- * Is emitted if the state for showing additional info has been
- * changed to \a show.
+ * Is emitted if the number of additional informations has been
+ * changed to \a count.
*/
- void showAdditionalInfoChanged(bool show);
+ void additionalInfoCountChanged(int count);
/**
* Is emitted if the item with the index \a index should be triggered.
private:
bool m_showPreview;
- bool m_showAdditionalInfo;
bool m_zoomInPossible;
bool m_zoomOutPossible;
+ int m_additionalInfoCount;
KUrl m_url;
};
return m_showPreview;
}
-inline bool DolphinController::showAdditionalInfo() const
+inline bool DolphinController::additionalInfoCount() const
{
- return m_showAdditionalInfo;
+ return m_additionalInfoCount;
}
inline void DolphinController::setZoomInPossible(bool possible)
controller, SLOT(emitViewportEntered()));
connect(controller, SIGNAL(showPreviewChanged(bool)),
this, SLOT(slotShowPreviewChanged(bool)));
- connect(controller, SIGNAL(showAdditionalInfoChanged(bool)),
- this, SLOT(slotShowAdditionalInfoChanged(bool)));
+ connect(controller, SIGNAL(additionalInfoCountChanged(int)),
+ this, SLOT(slotAdditionalInfoCountChanged(int)));
connect(controller, SIGNAL(zoomIn()),
this, SLOT(zoomIn()));
connect(controller, SIGNAL(zoomOut()),
m_viewOptions.font = font;
setWordWrap(settings->numberOfTextlines() > 1);
- updateGridSize(controller->showPreview(), controller->showAdditionalInfo());
+ updateGridSize(controller->showPreview(), controller->additionalInfoCount());
if (settings->arrangement() == QListView::TopToBottom) {
setFlow(QListView::LeftToRight);
void DolphinIconsView::slotShowPreviewChanged(bool showPreview)
{
- updateGridSize(showPreview, m_controller->showAdditionalInfo());
+ updateGridSize(showPreview, m_controller->additionalInfoCount());
}
-void DolphinIconsView::slotShowAdditionalInfoChanged(bool showAdditionalInfo)
+void DolphinIconsView::slotAdditionalInfoCountChanged(int count)
{
- updateGridSize(m_controller->showPreview(), showAdditionalInfo);
+ updateGridSize(m_controller->showPreview(), count);
}
void DolphinIconsView::zoomIn()
settings->setItemWidth(settings->itemWidth() + diff);
settings->setItemHeight(settings->itemHeight() + diff);
- updateGridSize(showPreview, m_controller->showAdditionalInfo());
+ updateGridSize(showPreview, m_controller->additionalInfoCount());
}
}
settings->setItemWidth(settings->itemWidth() - diff);
settings->setItemHeight(settings->itemHeight() - diff);
- updateGridSize(showPreview, m_controller->showAdditionalInfo());
+ updateGridSize(showPreview, m_controller->additionalInfoCount());
}
}
return decSize;
}
-void DolphinIconsView::updateGridSize(bool showPreview, bool showAdditionalInfo)
+void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
{
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
Q_ASSERT(settings != 0);
size = previewSize;
}
- if (showAdditionalInfo) {
- itemHeight += m_viewOptions.font.pointSize() * 2;
- }
+ Q_ASSERT(additionalInfoCount >= 0);
+ itemHeight += additionalInfoCount * m_viewOptions.font.pointSize() * 2;
if (settings->arrangement() == QListView::TopToBottom) {
// The decoration width indirectly defines the maximum
private slots:
void slotShowPreviewChanged(bool show);
- void slotShowAdditionalInfoChanged(bool show);
+ void slotAdditionalInfoCountChanged(int count);
void zoomIn();
void zoomOut();
/**
* Updates the size of the grid depending on the state
- * of \a showPreview and \a showAdditionalInfo.
+ * of \a showPreview and \a additionalInfoCount.
*/
- void updateGridSize(bool showPreview, bool showAdditionalInfo);
+ void updateGridSize(bool showPreview, int additionalInfoCount);
private:
DolphinController* m_controller;
void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::InformationList list)
{
- QAction* action = 0;
- KFileItemDelegate::Information info = list.isEmpty() ? KFileItemDelegate::NoInformation : list.first();
+ QAction* showMimeInfo = actionCollection()->action("show_mime_info");
+ QAction* showSizeInfo = actionCollection()->action("show_size_info");
+ QAction* showDateInfo = actionCollection()->action("show_date_info");
- 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;
- }
+ showMimeInfo->setChecked(false);
+ showSizeInfo->setChecked(false);
+ showDateInfo->setChecked(false);
- if (action != 0) {
- KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
- toggleAction->setChecked(true);
-
- QActionGroup* group = toggleAction->actionGroup();
- Q_ASSERT(group != 0);
- const DolphinView* view = m_activeViewContainer->view();
- group->setEnabled(view->mode() == DolphinView::IconsView);
+ const DolphinView* view = m_activeViewContainer->view();
+ // currently only the icons view supports additional information
+ const bool enable = (view->mode() == DolphinView::IconsView);
+ showMimeInfo->setEnabled(enable);
+ showSizeInfo->setEnabled(enable);
+ showDateInfo->setEnabled(enable);
+
+ foreach (KFileItemDelegate::Information info, list) {
+ switch (info) {
+ case KFileItemDelegate::FriendlyMimeType:
+ showMimeInfo->setChecked(true);
+ break;
+ case KFileItemDelegate::Size:
+ showSizeInfo->setChecked(true);
+ break;
+ case KFileItemDelegate::ModificationTime:
+ showDateInfo->setChecked(true);
+ break;
+ default:
+ break;
+ }
}
}
view->setCategorizedSorting(!categorizedSorting);
}
-void DolphinMainWindow::clearInfo()
-{
- m_activeViewContainer->view()->setAdditionalInfo(KFileItemDelegate::NoInformation);
-}
-
-void DolphinMainWindow::showMimeInfo()
+void DolphinMainWindow::toggleMimeInfo()
{
- clearStatusBar();
- m_activeViewContainer->view()->setAdditionalInfo(KFileItemDelegate::FriendlyMimeType);
+ toggleAdditionalInfo("show_mime_info", KFileItemDelegate::FriendlyMimeType);
}
-void DolphinMainWindow::showSizeInfo()
+void DolphinMainWindow::toggleSizeInfo()
{
- clearStatusBar();
- m_activeViewContainer->view()->setAdditionalInfo(KFileItemDelegate::Size);
+ toggleAdditionalInfo("show_size_info", KFileItemDelegate::Size);
}
-void DolphinMainWindow::showDateInfo()
+void DolphinMainWindow::toggleDateInfo()
{
- clearStatusBar();
- m_activeViewContainer->view()->setAdditionalInfo(KFileItemDelegate::ModificationTime);
+ toggleAdditionalInfo("show_date_info", KFileItemDelegate::ModificationTime);
}
void DolphinMainWindow::toggleSplitView()
showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
connect(showInGroups, SIGNAL(triggered()), this, SLOT(toggleSortCategorization()));
- KToggleAction* clearInfo = actionCollection()->add<KToggleAction>("clear_info");
- clearInfo->setText(i18nc("@action:inmenu Additional information", "No Information"));
- connect(clearInfo, SIGNAL(triggered()), this, SLOT(clearInfo()));
-
KToggleAction* showMimeInfo = actionCollection()->add<KToggleAction>("show_mime_info");
showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type"));
- connect(showMimeInfo, SIGNAL(triggered()), this, SLOT(showMimeInfo()));
+ connect(showMimeInfo, SIGNAL(triggered()), this, SLOT(toggleMimeInfo()));
KToggleAction* showSizeInfo = actionCollection()->add<KToggleAction>("show_size_info");
showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size"));
- connect(showSizeInfo, SIGNAL(triggered()), this, SLOT(showSizeInfo()));
+ connect(showSizeInfo, SIGNAL(triggered()), this, SLOT(toggleSizeInfo()));
KToggleAction* showDateInfo = actionCollection()->add<KToggleAction>("show_date_info");
showDateInfo->setText(i18nc("@action:inmenu Additional information", "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);
+ connect(showDateInfo, SIGNAL(triggered()), this, SLOT(toggleDateInfo()));
KToggleAction* showPreview = actionCollection()->add<KToggleAction>("show_preview");
showPreview->setText(i18nc("@action:intoolbar", "Preview"));
}
}
+void DolphinMainWindow::toggleAdditionalInfo(const char* actionName,
+ KFileItemDelegate::Information info)
+{
+ clearStatusBar();
+
+ DolphinView* view = m_activeViewContainer->view();
+ KFileItemDelegate::InformationList list = view->additionalInfo();
+
+ const bool show = actionCollection()->action(actionName)->isChecked();
+
+ const int index = list.indexOf(info);
+ const bool containsInfo = (index >= 0);
+ if (show && !containsInfo) {
+ list.append(info);
+ view->setAdditionalInfo(list);
+ } else if (!show && containsInfo) {
+ list.removeAt(index);
+ view->setAdditionalInfo(list);
+ Q_ASSERT(list.indexOf(info) < 0);
+ }
+}
+
DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :
KonqUndoManager::UiInterface(mainWin),
m_mainWin(mainWin)
#include <config-nepomuk.h>
-#include <kxmlguiwindow.h>
-#include <ksortablelist.h>
+#include <kfileitemdelegate.h>
#include <konq_undo.h>
+#include <ksortablelist.h>
+#include <kxmlguiwindow.h>
#include <QtCore/QList>
/** Switches between sorting by categories or not. */
void toggleSortCategorization();
- /**
- * 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();
+ /** Switches between showing the MIME type as additional information for the item or not. */
+ void toggleMimeInfo();
- /** Shows the size as additional information for the item. */
- void showSizeInfo();
+ /** Switches between showing the size as additional information for the item or not. */
+ void toggleSizeInfo();
- /** Shows the date as additional information for the item. */
- void showDateInfo();
+ /** Switchtes between showing the date as additional information for the item or not. */
+ void toggleDateInfo();
/**
* Switches between one and two views:
*/
void updateSplitAction();
+ /**
+ * Helper method for the slots toggleDateInfo(), toggleSizeInfo()
+ * and toggleMimeInfo(). Applies \a info dependent from the current
+ * checked state of the action \a actionName to the file item delegate.
+ */
+ void toggleAdditionalInfo(const char* actionName,
+ KFileItemDelegate::Information info);
+
private:
/**
* DolphinMainWindow supports up to two views beside each other.
</Menu>
<Menu name="additional_info">
<text context="@title:menu">Additional Information</text>
- <Action name="clear_info" />
<Action name="show_mime_info" />
<Action name="show_size_info" />
<Action name="show_date_info" />
ViewProperties props(viewPropsUrl);
props.setAdditionalInfo(info);
- m_controller->setShowAdditionalInfo(!info.isEmpty());
+ m_controller->setAdditionalInfoCount(info.count());
m_fileItemDelegate->setShowInformation(info);
emit additionalInfoChanged(info);
startDirLister(viewPropsUrl, true);
}
-void DolphinView::setAdditionalInfo(KFileItemDelegate::Information info)
-{
- KFileItemDelegate::InformationList list;
- if (info != KFileItemDelegate::NoInformation)
- list << info;
-
- setAdditionalInfo(list);
-}
-
KFileItemDelegate::InformationList DolphinView::additionalInfo() const
{
return m_fileItemDelegate->showInformation();
KFileItemDelegate::InformationList info = props.additionalInfo();
if (info != m_fileItemDelegate->showInformation()) {
- m_controller->setShowAdditionalInfo(!info.isEmpty());
+ m_controller->setAdditionalInfoCount(info.count());
m_fileItemDelegate->setShowInformation(info);
emit additionalInfoChanged(info);
}
void DolphinView::createView()
{
+ KFileItemDelegate::InformationList infoList;
+ if (m_fileItemDelegate != 0) {
+ infoList = m_fileItemDelegate->showInformation();
+ }
+
// delete current view
QAbstractItemView* view = itemView();
if (view != 0) {
Q_ASSERT(view != 0);
m_fileItemDelegate = new KFileItemDelegate(view);
+ m_fileItemDelegate->setShowInformation(infoList);
view->setItemDelegate(m_fileItemDelegate);
view->setModel(m_proxyModel);
/** Sets the additional information which should be shown for the items. */
void setAdditionalInfo(KFileItemDelegate::InformationList info);
- /** Sets the additional information which should be shown for the items. */
- void setAdditionalInfo(KFileItemDelegate::Information info);
-
/** Returns the additional information which should be shown for the items. */
KFileItemDelegate::InformationList additionalInfo() const;
void ViewProperties::setAdditionalInfo(KFileItemDelegate::InformationList list)
{
- KFileItemDelegate::Information info = list.isEmpty() ?
- KFileItemDelegate::NoInformation : list.first();
+ int info = NoInfo;
+ foreach (KFileItemDelegate::Information currentInfo, list) {
+ switch (currentInfo) {
+ case KFileItemDelegate::FriendlyMimeType:
+ info = info | TypeInfo;
+ break;
+ case KFileItemDelegate::Size:
+ info = info | SizeInfo;
+ break;
+ case KFileItemDelegate::ModificationTime:
+ info = info | DateInfo;
+ break;
+ default:
+ break;
+ }
+ }
if (m_node->additionalInfo() != info) {
m_node->setAdditionalInfo(info);
KFileItemDelegate::InformationList ViewProperties::additionalInfo() const
{
- KFileItemDelegate::Information info = static_cast<KFileItemDelegate::Information>(m_node->additionalInfo());
+ const int info = m_node->additionalInfo();
+
+ KFileItemDelegate::InformationList list;
+ if (info & TypeInfo) {
+ list.append(KFileItemDelegate::FriendlyMimeType);
+ }
+ if (info & SizeInfo) {
+ list.append(KFileItemDelegate::Size);
+ }
+ if (info & DateInfo) {
+ list.append(KFileItemDelegate::ModificationTime);
+ }
- if (info != KFileItemDelegate::NoInformation)
- return KFileItemDelegate::InformationList() << info;
- else
- return KFileItemDelegate::InformationList();
+ return list;
}
Q_DISABLE_COPY(ViewProperties)
private:
+ enum AdditionalInfoValues
+ {
+ NoInfo = 0,
+ TypeInfo = 1,
+ SizeInfo = 2,
+ DateInfo = 4
+ };
+
bool m_changedProps;
bool m_autoSave;
QString m_filepath;