* 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
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),
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);
{
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;
{
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);
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;
<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>
m_contentX(0),
m_columns(),
m_emptyViewport(0),
- m_animation(0)
+ m_animation(0),
+ m_nameFilter()
{
Q_ASSERT(controller != 0);
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
QList<DolphinColumnWidget*> m_columns;
QFrame* m_emptyViewport;
QTimeLine* m_animation;
+ QString m_nameFilter;
friend class DolphinColumnWidget;
};
#include <kfileitem.h>
#include <kio/previewjob.h>
#include <kiconeffect.h>
+#include <kmimetyperesolver.h>
#include <konqmimedata.h>
#include <QAbstractProxyModel>
m_proxyModel->setSourceModel(m_dolphinModel);
setModel(m_proxyModel);
+ new KMimeTypeResolver(this, m_dolphinModel);
m_dirLister->openUrl(url, KDirLister::NoFlags);
}
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)
{
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;
}
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);
}
return false;
}
+KFileItem DolphinColumnWidget::itemForIndex(const QModelIndex& index) const
+{
+ const QModelIndex dirIndex = m_proxyModel->mapToSource(index);
+ return m_dolphinModel->itemForIndex(dirIndex);
+}
+
+
#include "dolphincolumnwidget.moc"
*/
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);
*/
bool isCutItem(const KFileItem& item) const;
+ KFileItem itemForIndex(const QModelIndex& index) const;
+
private:
bool m_active;
bool m_showPreview;
#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)
{
}
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);
}
emit sortOrderChanged(order);
}
+void DolphinController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info)
+{
+ emit additionalInfoChanged(info);
+}
+
void DolphinController::setShowHiddenFiles(bool show)
{
if (m_showHiddenFiles != 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)
{
#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.
* by passing it in the constructor:
*
* \code
- * DolphinController* controller = new DolphinController(parent);
+ * DolphinController* controller = new DolphinController(dolphinView);
* QAbstractItemView* view = new DolphinIconsView(parent, controller);
* \endcode
*
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
* 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);
/**
*/
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.
* 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
/**
* 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);
/**
*/
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
* 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
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;
return m_showPreview;
}
-inline bool DolphinController::additionalInfoCount() const
+/*inline bool DolphinController::additionalInfoCount() const
{
return m_additionalInfoCount;
-}
+}*/
inline void DolphinController::setZoomInPossible(bool possible)
{
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();
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);
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;
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);
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();
*/
void configureColumns(const QPoint& pos);
+ void updateColumnVisibility();
+
private:
bool isZoomInPossible() const;
bool isZoomOutPossible() const;
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()),
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);
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();
+ }
}
}
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()
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);
}
}
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);
}
}
#include <kcategorizedview.h>
#include <kfileitem.h>
+#include <kfileitemdelegate.h>
#include <QSize>
#include <QStyleOption>
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();
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;
}
view->setCategorizedSorting(!categorizedSorting);
}
-void DolphinMainWindow::toggleMimeInfo()
-{
- toggleAdditionalInfo("show_mime_info", KFileItemDelegate::FriendlyMimeType);
-}
-
void DolphinMainWindow::toggleSizeInfo()
{
toggleAdditionalInfo("show_size_info", KFileItemDelegate::Size);
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) {
// 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);
}
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()));
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"));
/** 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.
</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" />
<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" />
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()),
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.
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
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
KFileItemDelegate::InformationList info = props.additionalInfo();
if (info != m_fileItemDelegate->showInformation()) {
- m_controller->setAdditionalInfoCount(info.count());
m_fileItemDelegate->setShowInformation(info);
emit additionalInfoChanged(info);
}
KFileItem item;
const QModelIndex index = itemView()->indexAt(pos);
- if (isValidNameIndex(index)) {
+ if (index.isValid() && (index.column() == DolphinModel::Name)) {
item = fileItem(index);
}
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);
}
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:
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);
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();
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.
/**
* 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);
/**
*/
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.
*/
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.
// 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();
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;
}
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;
}
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;
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)
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());