due to the recent tagging freeze this commit contains several fixes in one:

* the filterbar now also filters directories (works also in the column-view :-))

* The "Additional Information" menu entry now also works for showing/hiding the columns of the details view. This also implies that the columns for the details view can now be adjusted per directory -> we have now a consistent behavior between the icons view and details view. Still open: the view properties dialog must be fixed

* Don't show a "Nepomuk not available" error message when starting Dolphin and Nepomuk is not available.

* Fix issue that the information panel blocked the application because of parsing the full meta data of a huge file.

svn path=/trunk/KDE/kdebase/apps/; revision=729704
This commit is contained in:
Peter Penz 2007-10-26 17:36:16 +00:00
parent 6c1153092e
commit f11c699fa2
23 changed files with 339 additions and 268 deletions

View file

@ -39,10 +39,6 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
QWidget* parent) :
KVBox(parent),
m_mainWindow(mainWindow),
m_dateBox(0),
m_permissionsBox(0),
m_ownerBox(0),
m_groupBox(0),
m_smallIconSize(0),
m_mediumIconSize(0),
m_largeIconSize(0),
@ -55,23 +51,6 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
setSpacing(spacing);
setMargin(margin);
// create "Columns" properties
QGroupBox* columnsBox = new QGroupBox(i18nc("@title:group", "Columns"), this);
columnsBox->setSizePolicy(sizePolicy);
m_dateBox = new QCheckBox(i18nc("@option:check Columns", "Date"), this);
m_permissionsBox = new QCheckBox(i18nc("@option:check Columns", "Permissions"), this);
m_ownerBox = new QCheckBox(i18nc("@option:check Columns", "Owner"), this);
m_groupBox = new QCheckBox(i18nc("@option:check Columns", "Group"), this);
m_typeBox = new QCheckBox(i18nc("@option:check Columns", "Type"), this);
QGridLayout* columnsLayout = new QGridLayout(columnsBox);
columnsLayout->addWidget(m_dateBox, 0, 0);
columnsLayout->addWidget(m_permissionsBox, 1, 0);
columnsLayout->addWidget(m_ownerBox, 2, 0);
columnsLayout->addWidget(m_groupBox, 0, 1);
columnsLayout->addWidget(m_typeBox, 1, 1);
// Create "Icon" properties
QGroupBox* iconSizeBox = new QGroupBox(i18nc("@title:group", "Icon Size"), this);
iconSizeBox->setSizePolicy(sizePolicy);
@ -117,12 +96,6 @@ void DetailsViewSettingsPage::applySettings()
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
settings->setShowDate(m_dateBox->isChecked());
settings->setShowPermissions(m_permissionsBox->isChecked());
settings->setShowOwner(m_ownerBox->isChecked());
settings->setShowGroup(m_groupBox->isChecked());
settings->setShowType(m_typeBox->isChecked());
int iconSize = KIconLoader::SizeSmall;
if (m_mediumIconSize->isChecked()) {
iconSize = KIconLoader::SizeMedium;
@ -149,12 +122,6 @@ void DetailsViewSettingsPage::loadSettings()
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
m_dateBox->setChecked(settings->showDate());
m_permissionsBox->setChecked(settings->showPermissions());
m_ownerBox->setChecked(settings->showOwner());
m_groupBox->setChecked(settings->showGroup());
m_typeBox->setChecked(settings->showType());
switch (settings->iconSize()) {
case KIconLoader::SizeLarge:
m_largeIconSize->setChecked(true);

View file

@ -54,11 +54,6 @@ private:
private:
DolphinMainWindow* m_mainWindow;
QCheckBox* m_dateBox;
QCheckBox* m_permissionsBox;
QCheckBox* m_ownerBox;
QCheckBox* m_groupBox;
QCheckBox* m_typeBox;
QRadioButton* m_smallIconSize;
QRadioButton* m_mediumIconSize;
QRadioButton* m_largeIconSize;

View file

@ -25,29 +25,5 @@
<label context="@label">Icon size</label>
<default code="true">KIconLoader::SizeSmall</default>
</entry>
<entry name="ShowDate" type="Bool">
<label context="@label">Show date</label>
<default>true</default>
</entry>
<entry name="ShowGroup" type="Bool">
<label context="@label">Show group</label>
<default>false</default>
</entry>
<entry name="ShowOwner" type="Bool">
<label context="@label">Show owner</label>
<default>false</default>
</entry>
<entry name="ShowPermissions" type="Bool">
<label context="@label">Show permissions</label>
<default>false</default>
</entry>
<entry name="ShowSize" type="Bool">
<label context="@label">Show size</label>
<default>false</default>
</entry>
<entry name="ShowType" type="Bool">
<label context="@label">Show type</label>
<default>false</default>
</entry>
</group>
</kcfg>

View file

@ -48,7 +48,8 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
m_contentX(0),
m_columns(),
m_emptyViewport(0),
m_animation(0)
m_animation(0),
m_nameFilter()
{
Q_ASSERT(controller != 0);
@ -145,14 +146,17 @@ void DolphinColumnView::setRootUrl(const KUrl& url)
void DolphinColumnView::setNameFilter(const QString& nameFilter)
{
foreach (DolphinColumnWidget* column, m_columns) {
column->setNameFilter(nameFilter);
if (nameFilter != m_nameFilter) {
m_nameFilter = nameFilter;
foreach (DolphinColumnWidget* column, m_columns) {
column->setNameFilter(nameFilter);
}
}
}
QString DolphinColumnView::nameFilter() const
{
return activeColumn()->nameFilter();
return m_nameFilter;
}
KUrl DolphinColumnView::rootUrl() const

View file

@ -172,6 +172,7 @@ private:
QList<DolphinColumnWidget*> m_columns;
QFrame* m_emptyViewport;
QTimeLine* m_animation;
QString m_nameFilter;
friend class DolphinColumnWidget;
};

View file

@ -35,6 +35,7 @@
#include <kfileitem.h>
#include <kio/previewjob.h>
#include <kiconeffect.h>
#include <kmimetyperesolver.h>
#include <konqmimedata.h>
#include <QAbstractProxyModel>
@ -122,6 +123,7 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
m_proxyModel->setSourceModel(m_dolphinModel);
setModel(m_proxyModel);
new KMimeTypeResolver(this, m_dolphinModel);
m_dirLister->openUrl(url, KDirLister::NoFlags);
}
@ -191,22 +193,7 @@ void DolphinColumnWidget::updateBackground()
void DolphinColumnWidget::setNameFilter(const QString& nameFilter)
{
// The name filter of KDirLister does a 'hard' filtering, which
// means that only the items are shown where the names match
// exactly the filter. This is non-transparent for the user, which
// just wants to have a 'soft' filtering: does the name contain
// the filter string?
QString adjustedFilter(nameFilter);
adjustedFilter.insert(0, '*');
adjustedFilter.append('*');
m_dirLister->setNameFilter(adjustedFilter);
m_dirLister->emitChanges();
}
QString DolphinColumnWidget::nameFilter() const
{
return m_dirLister->nameFilter();
m_proxyModel->setFilterRegExp(nameFilter);
}
void DolphinColumnWidget::dragEnterEvent(QDragEnterEvent* event)
@ -242,11 +229,15 @@ void DolphinColumnWidget::dropEvent(QDropEvent* event)
{
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
event->acceptProposedAction();
m_view->m_controller->indicateDroppedUrls(urls,
url(),
indexAt(event->pos()),
event->source());
const QModelIndex index = indexAt(event->pos());
if (index.isValid()) {
const KFileItem item = itemForIndex(index);
m_view->m_controller->indicateDroppedUrls(urls,
url(),
item,
event->source());
event->acceptProposedAction();
}
}
QListView::dropEvent(event);
m_dragging = false;
@ -335,7 +326,7 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const
}
void DolphinColumnWidget::triggerItem(const QModelIndex& index)
{
const KFileItem item = m_dolphinModel->itemForIndex(m_proxyModel->mapToSource(index));
const KFileItem item = itemForIndex(index);
m_view->m_controller->triggerItem(item);
}
@ -449,4 +440,11 @@ bool DolphinColumnWidget::isCutItem(const KFileItem& item) const
return false;
}
KFileItem DolphinColumnWidget::itemForIndex(const QModelIndex& index) const
{
const QModelIndex dirIndex = m_proxyModel->mapToSource(index);
return m_dolphinModel->itemForIndex(dirIndex);
}
#include "dolphincolumnwidget.moc"

View file

@ -90,13 +90,6 @@ public:
*/
void setNameFilter(const QString& nameFilter);
/**
* Returns the currently used name filter. All items
* which contain the name filter will be shown.
*/
QString nameFilter() const;
protected:
virtual QStyleOptionViewItem viewOptions() const;
virtual void dragEnterEvent(QDragEnterEvent* event);
@ -145,6 +138,8 @@ private:
*/
bool isCutItem(const KFileItem& item) const;
KFileItem itemForIndex(const QModelIndex& index) const;
private:
bool m_active;
bool m_showPreview;

View file

@ -21,14 +21,15 @@
#include <QPainter>
DolphinController::DolphinController(QObject* parent) :
QObject(parent),
DolphinController::DolphinController(DolphinView* dolphinView) :
QObject(dolphinView),
m_showHiddenFiles(false),
m_showPreview(false),
m_zoomInPossible(false),
m_zoomOutPossible(false),
m_additionalInfoCount(0),
m_url()
//m_additionalInfoCount(0),
m_url(),
m_dolphinView(dolphinView)
{
}
@ -64,10 +65,10 @@ void DolphinController::requestActivation()
void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
const KUrl& destPath,
const QModelIndex& destIndex,
const KFileItem& destItem,
QWidget* source)
{
emit urlsDropped(urls, destPath, destIndex, source);
emit urlsDropped(urls, destPath, destItem, source);
}
@ -81,6 +82,11 @@ void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
emit sortOrderChanged(order);
}
void DolphinController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info)
{
emit additionalInfoChanged(info);
}
void DolphinController::setShowHiddenFiles(bool show)
{
if (m_showHiddenFiles != show) {
@ -97,13 +103,13 @@ void DolphinController::setShowPreview(bool show)
}
}
void DolphinController::setAdditionalInfoCount(int count)
/*void DolphinController::setAdditionalInfoCount(int count)
{
if (m_additionalInfoCount != count) {
m_additionalInfoCount = count;
emit additionalInfoCountChanged(count);
}
}
}*/
void DolphinController::indicateActivationChange(bool active)
{

View file

@ -25,13 +25,16 @@
#include <QtCore/QObject>
#include <libdolphin_export.h>
class DolphinView;
class KUrl;
class QBrush;
class QModelIndex;
class QPoint;
class QRect;
class QWidget;
// TODO: get rid of all the state duplications in the controller and allow read access
// to the Dolphin view for all view implementations
/**
* @brief Acts as mediator between the abstract Dolphin view and the view
* implementations.
@ -42,7 +45,7 @@ class QWidget;
* by passing it in the constructor:
*
* \code
* DolphinController* controller = new DolphinController(parent);
* DolphinController* controller = new DolphinController(dolphinView);
* QAbstractItemView* view = new DolphinIconsView(parent, controller);
* \endcode
*
@ -73,9 +76,15 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
Q_OBJECT
public:
explicit DolphinController(QObject* parent);
explicit DolphinController(DolphinView* dolphinView);
virtual ~DolphinController();
/**
* Allows read access for the the view implementation to the abstract
* Dolphin view.
*/
const DolphinView* dolphinView() const;
/**
* Sets the URL to \a url and emits the signal urlChanged() if
* \a url is different for the current URL. This method should
@ -119,12 +128,12 @@ public:
* will start the corresponding action (copy, move, link).
* @param urls URLs that are dropped above a destination.
* @param destPath Path of the destination.
* @param destIndex Model index of the destination item.
* @param destItem Destination item (can be null, see KFileItem::isNull()).
* @param source Pointer to the view implementation which invoked this method.
*/
void indicateDroppedUrls(const KUrl::List& urls,
const KUrl& destPath,
const QModelIndex& destIndex,
const KFileItem& destItem,
QWidget* source);
/**
@ -143,6 +152,14 @@ public:
*/
void indicateSortOrderChange(Qt::SortOrder order);
/**
* Informs the abstract Dolphin view about an additional information change
* done inside the view implementation. This method should be invoked by the
* view implementation (e. g. the details view uses this method in combination
* with the details header).
*/
void indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info);
/**
* Informs the view implementation about a change of the show hidden files
* state and is invoked by the abstract Dolphin view.
@ -164,8 +181,8 @@ public:
* additional informations and is invoked by the abstract Dolphin view.
* The signal additionalInfoCountChanged() is emitted.
*/
void setAdditionalInfoCount(int count);
bool additionalInfoCount() const;
//void setAdditionalInfoCount(int count);
//bool additionalInfoCount() const;
/**
* Informs the view implementation about a change of the activation
@ -258,12 +275,13 @@ signals:
/**
* Is emitted if the URLs \a urls have been dropped to the destination
* path \a destPath. If the URLs have been dropped above an item of
* the destination path, the item is indicated by \a destIndex.
* \a source indicates the widget where the dragging has been started from.
* the destination path, the item is indicated by \a destItem
* (can be null, see KFileItem::isNull()). \a source indicates
* the widget where the dragging has been started from.
*/
void urlsDropped(const KUrl::List& urls,
const KUrl& destPath,
const QModelIndex& destIndex,
const KFileItem& destItem,
QWidget* source);
/**
@ -282,6 +300,13 @@ signals:
*/
void sortOrderChanged(Qt::SortOrder order);
/**
* Is emitted if the additional info has been changed to \a info
* by the view implementation. The abstract Dolphin view connects
* to this signal to update its menu actions.
*/
void additionalInfoChanged(const KFileItemDelegate::InformationList& info);
/**
* Is emitted if the state for showing hidden files has been
* changed to \a show by the abstract Dolphin view. The view
@ -304,7 +329,7 @@ signals:
* The view implementation might connect to this signal if custom
* updates are required in this case.
*/
void additionalInfoCountChanged(int count);
//void additionalInfoCountChanged(int count);
/**
* Is emitted if the activation state has been changed to \a active
@ -353,10 +378,16 @@ private:
bool m_showPreview;
bool m_zoomInPossible;
bool m_zoomOutPossible;
int m_additionalInfoCount;
//int m_additionalInfoCount;
KUrl m_url;
DolphinView* m_dolphinView;
};
inline const DolphinView* DolphinController::dolphinView() const
{
return m_dolphinView;
}
inline const KUrl& DolphinController::url() const
{
return m_url;
@ -372,10 +403,10 @@ inline bool DolphinController::showPreview() const
return m_showPreview;
}
inline bool DolphinController::additionalInfoCount() const
/*inline bool DolphinController::additionalInfoCount() const
{
return m_additionalInfoCount;
}
}*/
inline void DolphinController::setZoomInPossible(bool possible)
{

View file

@ -97,6 +97,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
this, SLOT(zoomIn()));
connect(controller, SIGNAL(zoomOut()),
this, SLOT(zoomOut()));
connect(controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
this, SLOT(updateColumnVisibility()));
// apply the details mode settings to the widget
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
@ -140,28 +142,7 @@ bool DolphinDetailsView::event(QEvent* event)
headerView->setResizeMode(0, QHeaderView::Stretch);
headerView->setMovable(false);
// hide columns if this is indicated by the settings
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
Q_ASSERT(settings != 0);
if (!settings->showDate()) {
hideColumn(DolphinModel::ModifiedTime);
}
if (!settings->showPermissions()) {
hideColumn(DolphinModel::Permissions);
}
if (!settings->showOwner()) {
hideColumn(DolphinModel::Owner);
}
if (!settings->showGroup()) {
hideColumn(DolphinModel::Group);
}
if (!settings->showType()) {
hideColumn(DolphinModel::Type);
}
updateColumnVisibility();
hideColumn(DolphinModel::Rating);
hideColumn(DolphinModel::Tags);
@ -278,10 +259,14 @@ void DolphinDetailsView::dropEvent(QDropEvent* event)
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
event->acceptProposedAction();
m_controller->indicateDroppedUrls(urls,
m_controller->url(),
indexAt(event->pos()),
event->source());
const QModelIndex index = indexAt(event->pos());
if (index.isValid() && (index.column() == DolphinModel::Name)) {
const KFileItem item = itemForIndex(index);
m_controller->indicateDroppedUrls(urls,
m_controller->url(),
item,
event->source());
}
}
QTreeView::dropEvent(event);
m_dragging = false;
@ -453,7 +438,7 @@ void DolphinDetailsView::configureColumns(const QPoint& pos)
popup.addTitle(i18nc("@title:menu", "Columns"));
QHeaderView* headerView = header();
for (int i = DolphinModel::ModifiedTime; i <= DolphinModel::Type; ++i) {
for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) {
const int logicalIndex = headerView->logicalIndex(i);
const QString text = model()->headerData(i, Qt::Horizontal).toString();
QAction* action = popup.addAction(text);
@ -465,29 +450,52 @@ void DolphinDetailsView::configureColumns(const QPoint& pos)
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();
KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
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;
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;
default: break;
}
// apply the changed column visibility
if (show) {
showColumn(columnIndex);
Q_ASSERT(!list.contains(info));
list.append(info);
} else {
hideColumn(columnIndex);
Q_ASSERT(list.contains(info));
const int index = list.indexOf(info);
list.removeAt(index);
}
m_controller->indicateAdditionalInfoChange(list);
setColumnHidden(columnIndex, !show);
}
}
void DolphinDetailsView::updateColumnVisibility()
{
KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
if (list.isEmpty() || list.contains(KFileItemDelegate::NoInformation)) {
list.clear();
list.append(KFileItemDelegate::Size);
list.append(KFileItemDelegate::ModificationTime);
m_controller->indicateAdditionalInfoChange(list);
}
setColumnHidden(DolphinModel::Size, !list.contains(KFileItemDelegate::Size));
setColumnHidden(DolphinModel::ModifiedTime, !list.contains(KFileItemDelegate::ModificationTime));
setColumnHidden(DolphinModel::Permissions, !list.contains(KFileItemDelegate::Permissions));
setColumnHidden(DolphinModel::Owner, !list.contains(KFileItemDelegate::Owner));
setColumnHidden(DolphinModel::Group, !list.contains(KFileItemDelegate::OwnerAndGroup));
setColumnHidden(DolphinModel::Type, !list.contains(KFileItemDelegate::FriendlyMimeType));
}
bool DolphinDetailsView::isZoomInPossible() const
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();

View file

@ -116,6 +116,8 @@ private slots:
*/
void configureColumns(const QPoint& pos);
void updateColumnVisibility();
private:
bool isZoomInPossible() const;
bool isZoomOutPossible() const;

View file

@ -63,8 +63,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
controller, SLOT(emitViewportEntered()));
connect(controller, SIGNAL(showPreviewChanged(bool)),
this, SLOT(slotShowPreviewChanged(bool)));
connect(controller, SIGNAL(additionalInfoCountChanged(int)),
this, SLOT(slotAdditionalInfoCountChanged(int)));
connect(controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
this, SLOT(slotAdditionalInfoChanged(const KFileItemDelegate::InformationList&)));
connect(controller, SIGNAL(zoomIn()),
this, SLOT(zoomIn()));
connect(controller, SIGNAL(zoomOut()),
@ -86,7 +86,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
m_viewOptions.font = font;
setWordWrap(settings->numberOfTextlines() > 1);
updateGridSize(controller->showPreview(), controller->additionalInfoCount());
updateGridSize(controller->showPreview(), 0);
if (settings->arrangement() == QListView::TopToBottom) {
setFlow(QListView::LeftToRight);
@ -195,11 +195,15 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
if (!selectionModel()->isSelected(indexAt(event->pos()))) {
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
m_controller->indicateDroppedUrls(urls,
m_controller->url(),
indexAt(event->pos()),
event->source());
event->acceptProposedAction();
const QModelIndex index = indexAt(event->pos());
if (index.isValid()) {
const KFileItem item = itemForIndex(index);
m_controller->indicateDroppedUrls(urls,
m_controller->url(),
item,
event->source());
event->acceptProposedAction();
}
}
}
@ -244,12 +248,13 @@ void DolphinIconsView::slotEntered(const QModelIndex& index)
void DolphinIconsView::slotShowPreviewChanged(bool showPreview)
{
updateGridSize(showPreview, m_controller->additionalInfoCount());
const int infoCount = m_controller->dolphinView()->additionalInfo().count();
updateGridSize(showPreview, infoCount);
}
void DolphinIconsView::slotAdditionalInfoCountChanged(int count)
void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info)
{
updateGridSize(m_controller->showPreview(), count);
updateGridSize(m_controller->showPreview(), info.count());
}
void DolphinIconsView::zoomIn()
@ -278,7 +283,8 @@ void DolphinIconsView::zoomIn()
settings->setItemWidth(settings->itemWidth() + diff);
settings->setItemHeight(settings->itemHeight() + diff);
updateGridSize(showPreview, m_controller->additionalInfoCount());
const int infoCount = m_controller->dolphinView()->additionalInfo().count();
updateGridSize(showPreview, infoCount);
}
}
@ -309,7 +315,8 @@ void DolphinIconsView::zoomOut()
settings->setItemWidth(settings->itemWidth() - diff);
settings->setItemHeight(settings->itemHeight() - diff);
updateGridSize(showPreview, m_controller->additionalInfoCount());
const int infoCount = m_controller->dolphinView()->additionalInfo().count();
updateGridSize(showPreview, infoCount);
}
}

View file

@ -23,6 +23,7 @@
#include <kcategorizedview.h>
#include <kfileitem.h>
#include <kfileitemdelegate.h>
#include <QSize>
#include <QStyleOption>
@ -64,7 +65,7 @@ private slots:
void triggerItem(const QModelIndex& index);
void slotEntered(const QModelIndex& index);
void slotShowPreviewChanged(bool show);
void slotAdditionalInfoCountChanged(int count);
void slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info);
void zoomIn();
void zoomOut();

View file

@ -326,32 +326,51 @@ void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::InformationList list)
{
QAction* showMimeInfo = actionCollection()->action("show_mime_info");
QAction* showSizeInfo = actionCollection()->action("show_size_info");
QAction* showDateInfo = actionCollection()->action("show_date_info");
QAction* showPermissionsInfo = actionCollection()->action("show_permissions_info");
QAction* showOwnerInfo = actionCollection()->action("show_owner_info");
QAction* showGroupInfo = actionCollection()->action("show_group_info");
QAction* showMimeInfo = actionCollection()->action("show_mime_info");
showMimeInfo->setChecked(false);
showSizeInfo->setChecked(false);
showDateInfo->setChecked(false);
showPermissionsInfo->setChecked(false);
showOwnerInfo->setChecked(false);
showGroupInfo->setChecked(false);
showMimeInfo->setChecked(false);
const DolphinView* view = m_activeViewContainer->view();
// currently only the icons view supports additional information
const bool enable = (view->mode() == DolphinView::IconsView);
showMimeInfo->setEnabled(enable);
// currently the column view does not support additional information
const bool enable = (view->mode() != DolphinView::ColumnView);
showSizeInfo->setEnabled(enable);
showDateInfo->setEnabled(enable);
showPermissionsInfo->setEnabled(enable);
showOwnerInfo->setEnabled(enable);
showGroupInfo->setEnabled(enable);
showMimeInfo->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;
case KFileItemDelegate::Permissions:
showPermissionsInfo->setChecked(true);
break;
case KFileItemDelegate::Owner:
showOwnerInfo->setChecked(true);
break;
case KFileItemDelegate::OwnerAndGroup:
showGroupInfo->setChecked(true);
break;
case KFileItemDelegate::FriendlyMimeType:
showMimeInfo->setChecked(true);
break;
default:
break;
}
@ -770,11 +789,6 @@ void DolphinMainWindow::toggleSortCategorization()
view->setCategorizedSorting(!categorizedSorting);
}
void DolphinMainWindow::toggleMimeInfo()
{
toggleAdditionalInfo("show_mime_info", KFileItemDelegate::FriendlyMimeType);
}
void DolphinMainWindow::toggleSizeInfo()
{
toggleAdditionalInfo("show_size_info", KFileItemDelegate::Size);
@ -785,6 +799,26 @@ void DolphinMainWindow::toggleDateInfo()
toggleAdditionalInfo("show_date_info", KFileItemDelegate::ModificationTime);
}
void DolphinMainWindow::togglePermissionsInfo()
{
toggleAdditionalInfo("show_permissions_info", KFileItemDelegate::Permissions);
}
void DolphinMainWindow::toggleOwnerInfo()
{
toggleAdditionalInfo("show_owner_info", KFileItemDelegate::Owner);
}
void DolphinMainWindow::toggleGroupInfo()
{
toggleAdditionalInfo("show_group_info", KFileItemDelegate::OwnerAndGroup);
}
void DolphinMainWindow::toggleMimeInfo()
{
toggleAdditionalInfo("show_mime_info", KFileItemDelegate::FriendlyMimeType);
}
void DolphinMainWindow::toggleSplitView()
{
if (m_viewContainer[SecondaryView] == 0) {
@ -1037,14 +1071,6 @@ void DolphinMainWindow::init()
// assure a proper default size if Dolphin runs the first time
resize(700, 500);
}
#ifdef HAVE_NEPOMUK
if (!MetaDataWidget::metaDataAvailable()) {
DolphinStatusBar* statusBar = activeViewContainer()->statusBar();
statusBar->setMessage(i18nc("@info:status",
"Failed to contact Nepomuk service, annotation and tagging are disabled."),
DolphinStatusBar::Error);
}
#endif
emit urlChanged(homeUrl);
}
@ -1219,10 +1245,6 @@ void DolphinMainWindow::setupActions()
showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
connect(showInGroups, SIGNAL(triggered()), this, SLOT(toggleSortCategorization()));
KToggleAction* showMimeInfo = actionCollection()->add<KToggleAction>("show_mime_info");
showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type"));
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(toggleSizeInfo()));
@ -1231,6 +1253,22 @@ void DolphinMainWindow::setupActions()
showDateInfo->setText(i18nc("@action:inmenu Additional information", "Date"));
connect(showDateInfo, SIGNAL(triggered()), this, SLOT(toggleDateInfo()));
KToggleAction* showPermissionsInfo = actionCollection()->add<KToggleAction>("show_permissions_info");
showPermissionsInfo->setText(i18nc("@action:inmenu Additional information", "Permissions"));
connect(showPermissionsInfo, SIGNAL(triggered()), this, SLOT(togglePermissionsInfo()));
KToggleAction* showOwnerInfo = actionCollection()->add<KToggleAction>("show_owner_info");
showOwnerInfo->setText(i18nc("@action:inmenu Additional information", "Owner"));
connect(showOwnerInfo, SIGNAL(triggered()), this, SLOT(toggleOwnerInfo()));
KToggleAction* showGroupInfo = actionCollection()->add<KToggleAction>("show_group_info");
showGroupInfo->setText(i18nc("@action:inmenu Additional information", "Group"));
connect(showGroupInfo, SIGNAL(triggered()), this, SLOT(toggleGroupInfo()));
KToggleAction* showMimeInfo = actionCollection()->add<KToggleAction>("show_mime_info");
showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type"));
connect(showMimeInfo, SIGNAL(triggered()), this, SLOT(toggleMimeInfo()));
KToggleAction* showPreview = actionCollection()->add<KToggleAction>("show_preview");
showPreview->setText(i18nc("@action:intoolbar", "Preview"));
showPreview->setIcon(KIcon("fileview-preview"));

View file

@ -287,15 +287,24 @@ private slots:
/** Switches between sorting by categories or not. */
void toggleSortCategorization();
/** Switches between showing the MIME type as additional information for the item or not. */
void toggleMimeInfo();
/** Switches between showing the size as additional information for the item or not. */
void toggleSizeInfo();
/** Switchtes between showing the date as additional information for the item or not. */
void toggleDateInfo();
/** Switchtes between showing the permissions as additional information for the item or not. */
void togglePermissionsInfo();
/** Switchtes between showing the owner as additional information for the item or not. */
void toggleOwnerInfo();
/** Switchtes between showing the group as additional information for the item or not. */
void toggleGroupInfo();
/** Switches between showing the MIME type as additional information for the item or not. */
void toggleMimeInfo();
/**
* Switches between one and two views:
* If one view is visible, it will get split into two views.

View file

@ -22,9 +22,12 @@
</Menu>
<Menu name="additional_info">
<text context="@title:menu">Additional Information</text>
<Action name="show_mime_info" />
<Action name="show_size_info" />
<Action name="show_date_info" />
<Action name="show_permissions_info" />
<Action name="show_owner_info" />
<Action name="show_group_info" />
<Action name="show_mime_info" />
</Menu>
<Action name="show_preview" />
<Action name="show_in_groups" />

View file

@ -37,10 +37,13 @@
<Action name="descending" />
</Menu>
<Menu name="additional_info">
<text context="@title:menu">Additional Information</text>
<Action name="show_mime_info" />
<Action name="show_size_info" />
<Action name="show_date_info" />
<text context="@title:menu">Additional Information</text>
<Action name="show_size_info" />
<Action name="show_date_info" />
<Action name="show_permissions_info" />
<Action name="show_owner_info" />
<Action name="show_group_info" />
<Action name="show_mime_info" />
</Menu>
<Action name="show_preview" />
<Action name="show_in_groups" />

View file

@ -102,12 +102,14 @@ DolphinView::DolphinView(QWidget* parent,
connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
this, SLOT(openContextMenu(const QPoint&)));
connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const QModelIndex&, QWidget*)),
this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const QModelIndex&, QWidget*)));
connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)),
this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)));
connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(updateSorting(DolphinView::Sorting)));
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
this, SLOT(updateSortOrder(Qt::SortOrder)));
connect(m_controller, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList&)));
connect(m_controller, SIGNAL(itemTriggered(const KFileItem&)),
this, SLOT(triggerItem(const KFileItem&)));
connect(m_controller, SIGNAL(activated()),
@ -197,6 +199,12 @@ void DolphinView::setMode(Mode mode)
createView();
// the file item delegate has been recreated, apply the current
// additional information manually
const KFileItemDelegate::InformationList infoList = props.additionalInfo();
m_fileItemDelegate->setShowInformation(infoList);
emit additionalInfoChanged(infoList);
// Not all view modes support categorized sorting. Adjust the sorting model
// if changing the view mode results in a change of the categorized sorting
// capabilities.
@ -437,12 +445,15 @@ void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info)
const KUrl viewPropsUrl = viewPropertiesUrl();
ViewProperties props(viewPropsUrl);
props.setAdditionalInfo(info);
m_controller->setAdditionalInfoCount(info.count());
m_fileItemDelegate->setShowInformation(info);
emit additionalInfoChanged(info);
loadDirectory(viewPropsUrl, true);
if (itemView() != m_detailsView) {
// the details view requires no reloading of the directory, as it maps
// the file item delegate info to its columns internally
loadDirectory(viewPropsUrl, true);
}
}
KFileItemDelegate::InformationList DolphinView::additionalInfo() const
@ -493,17 +504,7 @@ void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
void DolphinView::setNameFilter(const QString& nameFilter)
{
// The name filter of KDirLister does a 'hard' filtering, which
// means that only the items are shown where the names match
// exactly the filter. This is non-transparent for the user, which
// just wants to have a 'soft' filtering: does the name contain
// the filter string?
QString adjustedFilter(nameFilter);
adjustedFilter.insert(0, '*');
adjustedFilter.append('*');
m_dirLister->setNameFilter(adjustedFilter);
m_dirLister->emitChanges();
m_proxyModel->setFilterRegExp(nameFilter);
if (isColumnViewActive()) {
// adjusting the directory lister is not enough in the case of the
@ -679,7 +680,6 @@ void DolphinView::applyViewProperties(const KUrl& url)
KFileItemDelegate::InformationList info = props.additionalInfo();
if (info != m_fileItemDelegate->showInformation()) {
m_controller->setAdditionalInfoCount(info.count());
m_fileItemDelegate->setShowInformation(info);
emit additionalInfoChanged(info);
}
@ -717,7 +717,7 @@ void DolphinView::openContextMenu(const QPoint& pos)
KFileItem item;
const QModelIndex index = itemView()->indexAt(pos);
if (isValidNameIndex(index)) {
if (index.isValid() && (index.column() == DolphinModel::Name)) {
item = fileItem(index);
}
@ -726,27 +726,23 @@ void DolphinView::openContextMenu(const QPoint& pos)
void DolphinView::dropUrls(const KUrl::List& urls,
const KUrl& destPath,
const QModelIndex& destIndex,
const KFileItem& destItem,
QWidget* source)
{
KFileItem directory;
if (isValidNameIndex(destIndex)) {
KFileItem item = fileItem(destIndex);
Q_ASSERT(!item.isNull());
if (item.isDir()) {
// the URLs are dropped above a directory
directory = item;
bool dropAboveDir = false;
if (!destItem.isNull()) {
dropAboveDir = destItem.isDir();
if (!dropAboveDir) {
// the dropping is done above a file
return;
}
}
if ((directory.isNull()) && (source == itemView())) {
// The dropping is done into the same viewport where
// the dragging has been started. Just ignore this...
} else if (source == itemView()) {
// the dropping is done into the same viewport where the dragging
// has been started
return;
}
const KUrl& destination = (directory.isNull()) ?
destPath : directory.url();
const KUrl& destination = dropAboveDir ? destItem.url() : destPath;
dropUrls(urls, destination);
}
@ -776,6 +772,17 @@ void DolphinView::updateSortOrder(Qt::SortOrder order)
emit sortOrderChanged(order);
}
void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& info)
{
ViewProperties props(viewPropertiesUrl());
props.setAdditionalInfo(info);
m_fileItemDelegate->setShowInformation(info);
emit additionalInfoChanged(info);
}
void DolphinView::emitContentsMoved()
{
// only emit the contents moved signal if:
@ -825,11 +832,6 @@ void DolphinView::clearHoverInformation()
void DolphinView::createView()
{
KFileItemDelegate::InformationList infoList;
if (m_fileItemDelegate != 0) {
infoList = m_fileItemDelegate->showInformation();
}
// delete current view
QAbstractItemView* view = itemView();
if (view != 0) {
@ -869,7 +871,6 @@ void DolphinView::createView()
Q_ASSERT(view != 0);
m_fileItemDelegate = new KFileItemDelegate(view);
m_fileItemDelegate->setShowInformation(infoList);
view->setItemDelegate(m_fileItemDelegate);
view->setModel(m_proxyModel);
@ -897,11 +898,6 @@ QAbstractItemView* DolphinView::itemView() const
return m_iconsView;
}
bool DolphinView::isValidNameIndex(const QModelIndex& index) const
{
return index.isValid() && (index.column() == DolphinModel::Name);
}
bool DolphinView::isCutItem(const KFileItem& item) const
{
const QMimeData* mimeData = QApplication::clipboard()->mimeData();

View file

@ -395,7 +395,7 @@ signals:
void sortOrderChanged(Qt::SortOrder order);
/** Is emitted if the additional information for an item has been changed. */
void additionalInfoChanged(KFileItemDelegate::InformationList info);
void additionalInfoChanged(const KFileItemDelegate::InformationList& info);
/**
* Is emitted if information of an item is requested to be shown e. g. in the sidebar.
@ -489,12 +489,12 @@ private slots:
/**
* Drops the URLs \a urls to the destination path \a destPath. If
* the URLs are dropped above an item inside the destination path,
* the item is indicated by \a destIndex. \a source
* the item is indicated by \a destItem. \a source
* indicates the widget where the dragging has been started from.
*/
void dropUrls(const KUrl::List& urls,
const KUrl& destPath,
const QModelIndex& destIndex,
const KFileItem& destItem,
QWidget* source);
/**
@ -515,6 +515,12 @@ private slots:
*/
void updateSortOrder(Qt::SortOrder order);
/**
* Updates the view properties of the current URL to the
* additional informations given by \a info.
*/
void updateAdditionalInfo(const KFileItemDelegate::InformationList& info);
/**
* Emits the signal contentsMoved with the current coordinates
* of the viewport as parameters.
@ -568,12 +574,6 @@ private:
*/
QAbstractItemView* itemView() const;
/**
* Returns true if the index is valid and represents
* the column DolphinModel::Name.
*/
bool isValidNameIndex(const QModelIndex& index) const;
/**
* Returns true, if the item \a item has been cut into
* the clipboard.

View file

@ -296,7 +296,12 @@ void InfoSidebarPage::showMetaInfo()
// TODO: See convertMetaInfo below, find a way to display only interesting information
// in a readable way
const KFileMetaInfo metaInfo(fileItem.url());
const KFileMetaInfo::WhatFlags flags = KFileMetaInfo::Fastest |
KFileMetaInfo::TechnicalInfo |
KFileMetaInfo::ContentInfo |
KFileMetaInfo::Thumbnail;
const QString path = fileItem.url().url();
const KFileMetaInfo metaInfo(path, QString(), flags);
if (metaInfo.isValid()) {
const QHash<QString, KFileMetaInfoItem>& items = metaInfo.items();
QHash<QString, KFileMetaInfoItem>::const_iterator it = items.constBegin();

View file

@ -202,15 +202,24 @@ void ViewProperties::setAdditionalInfo(KFileItemDelegate::InformationList list)
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;
case KFileItemDelegate::Permissions:
info = info | PermissionsInfo;
break;
case KFileItemDelegate::Owner:
info = info | OwnerInfo;
break;
case KFileItemDelegate::OwnerAndGroup:
info = info | GroupInfo;
break;
case KFileItemDelegate::FriendlyMimeType:
info = info | TypeInfo;
break;
default:
break;
}
@ -227,15 +236,24 @@ KFileItemDelegate::InformationList ViewProperties::additionalInfo() const
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 & PermissionsInfo) {
list.append(KFileItemDelegate::Permissions);
}
if (info & OwnerInfo) {
list.append(KFileItemDelegate::Owner);
}
if (info & GroupInfo) {
list.append(KFileItemDelegate::OwnerAndGroup);
}
if (info & TypeInfo) {
list.append(KFileItemDelegate::FriendlyMimeType);
}
return list;
}

View file

@ -123,9 +123,12 @@ private:
enum AdditionalInfoValues
{
NoInfo = 0,
TypeInfo = 1,
SizeInfo = 2,
DateInfo = 4
SizeInfo = 1,
DateInfo = 2,
PermissionsInfo = 4,
OwnerInfo = 8,
GroupInfo = 16,
TypeInfo = 32,
};
bool m_changedProps;

View file

@ -252,7 +252,10 @@ void ViewPropertiesDialog::slotViewModeChanged(int index)
const bool iconsViewEnabled = (m_viewProps->viewMode() == DolphinView::IconsView);
m_showInGroups->setEnabled(iconsViewEnabled);
m_additionalInfo->setEnabled(iconsViewEnabled);
// TODO: a different approach is required now due to having a lot more additional infos
m_additionalInfo->setEnabled(false);
//m_additionalInfo->setEnabled(iconsViewEnabled);
}
void ViewPropertiesDialog::slotSortingChanged(int index)
@ -410,7 +413,9 @@ void ViewPropertiesDialog::loadSettings()
const int addInfoIndex = m_additionalInfo->findData(info);
m_additionalInfo->setCurrentIndex(addInfoIndex);
m_additionalInfo->setEnabled(iconsViewEnabled);
// TODO: a different approach is required now due to having a lot more additional infos
m_additionalInfo->setEnabled(false);
//m_additionalInfo->setEnabled(iconsViewEnabled);
// load show preview, show in groups and show hidden files settings
m_showPreview->setChecked(m_viewProps->showPreview());