/***************************************************************************
- * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
+ * Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
* *
* This program is free software; you can redistribute it and/or modify *
#include "libdolphin_export.h"
#include <kparts/part.h>
-#include <kfileitem.h>
-#include <kfileitemdelegate.h>
+#include <KFileItem>
+#include <KFileItemDelegate>
#include <kio/fileundomanager.h>
-#include <kio/job.h>
+#include <KIO/Job>
#include <QBoxLayout>
#include <QKeyEvent>
class DolphinColumnViewContainer;
class DolphinDetailsView;
+class DolphinDetailsViewExpander;
class DolphinIconsView;
class DolphinModel;
class DolphinSortFilterProxyModel;
class KUrl;
class ViewModeController;
class ViewProperties;
-class DolphinDetailsViewExpander;
+class QRegExp;
/**
* @short Represents a view for the directory content.
};
/**
- * @param parent Parent widget of the view.
* @param url Specifies the content which should be shown.
- * @param proxyModel Used proxy model which specifies the sorting. The
- * model is not owned by the view and won't get
- * deleted.
+ * @param parent Parent widget of the view.
*/
- DolphinView(QWidget* parent,
- const KUrl& url,
- DolphinSortFilterProxyModel* proxyModel);
+ DolphinView( const KUrl& url, QWidget* parent);
virtual ~DolphinView();
bool supportsCategorizedSorting() const;
/**
- * Marks the items indicated by \p urls to get selected after the
- * directory DolphinView::url() has been loaded. Note that nothing
- * gets selected if no loading of a directory has been triggered
- * by DolphinView::setUrl() or DolphinView::reload().
+ * Returns the root item which represents the current URL. Note that the returned
+ * item can be null (KFileItem::isNull() will return true) in case that the directory
+ * has not been loaded.
*/
- void markUrlsAsSelected(const QList<KUrl>& urls);
+ KFileItem rootItem() const;
/**
- * Returns the selected items. The list is empty if no item has been
- * selected.
- * @see DolphinView::selectedUrls()
+ * Returns the items of the view.
*/
- KFileItemList selectedItems() const;
+ KFileItemList items() const;
/**
- * Returns a list of URLs for all selected items. An empty list
- * is returned, if no item is selected.
- * @see DolphinView::selectedItems()
+ * Returns the selected items. The list is empty if no item has been
+ * selected.
*/
- KUrl::List selectedUrls() const;
+ KFileItemList selectedItems() const;
/**
* Returns the number of selected items (this is faster than
*/
int selectedItemsCount() const;
- QItemSelectionModel* selectionModel() const;
+ /**
+ * Marks the items indicated by \p urls to get selected after the
+ * directory DolphinView::url() has been loaded. Note that nothing
+ * gets selected if no loading of a directory has been triggered
+ * by DolphinView::setUrl() or DolphinView::reload().
+ */
+ void markUrlsAsSelected(const QList<KUrl>& urls);
+
+ /**
+ * All items that match to the pattern \a pattern will get selected
+ * if \a enabled is true and deselected if \a enabled is false.
+ */
+ void setItemSelectionEnabled(const QRegExp& pattern, bool enabled);
/**
* Sets the zoom level to \a level. It is assured that the used
/** Reloads the current directory. */
void reload();
+ void stopLoading();
+
/**
* Refreshes the view to get synchronized with the (updated) Dolphin settings.
* This method only needs to get invoked if the view settings for the Icons View,
* which contain the given filter string will be shown.
*/
void setNameFilter(const QString& nameFilter);
+ QString nameFilter() const;
/**
* Calculates the number of currently shown files into
*/
void saveState(QDataStream& stream);
+ /** Returns true, if at least one item is selected. */
+ bool hasSelection() const;
+
public slots:
/**
* Changes the directory to \a url. If the current directory is equal to
*/
void invertSelection();
- /** Returns true, if at least one item is selected. */
- bool hasSelection() const;
-
void clearSelection();
/**
*/
void setCategorizedSorting(bool categorized);
- /** Switches between an ascending and descending sorting order. */
- void toggleSortOrder();
-
- /** Switches between a separate sorting (with folders first) and a mixed sorting of files and folders. */
- void toggleSortFoldersFirst();
-
- /**
- * Switches on or off the displaying of additional information
- * as specified by \a action.
- */
- void toggleAdditionalInfo(QAction* action);
-
signals:
/**
* Is emitted if the view has been activated by e. g. a mouse click.
*/
void itemTriggered(const KFileItem& item);
+ /**
+ * Is emitted if items have been added or deleted.
+ */
+ void itemCountChanged();
+
/**
* Is emitted if a new tab should be opened for the URL \a url.
*/
*/
void startedPathLoading(const KUrl& url);
+ /**
+ * Is emitted after the path triggered by DolphinView::setUrl()
+ * has been loaded.
+ */
+ void finishedPathLoading(const KUrl& url);
+
+ /**
+ * Is emitted after DolphinView::setUrl() has been invoked and provides
+ * the information how much percent of the current path have been loaded.
+ */
+ void pathLoadingProgress(int percent);
+
+ /**
+ * Is emitted if the DolphinView::setUrl() is invoked but the URL is not
+ * a directory.
+ */
+ void urlIsFileError(const KUrl& file);
+
/**
* Emitted when KDirLister emits redirection.
* Testcase: fish://localhost
*/
void redirection(const KUrl& oldUrl, const KUrl& newUrl);
+ /**
+ * Is emitted when the write state of the folder has been changed. The application
+ * should disable all actions like "Create New..." that depend on the write
+ * state.
+ */
+ void writeStateChanged(bool isFolderWritable);
+
protected:
/** @see QWidget::mouseReleaseEvent */
virtual void mouseReleaseEvent(QMouseEvent* event);
*/
void slotDeleteFileFinished(KJob* job);
+ /**
+ * Invoked when the directory lister has been started the
+ * loading of \a url.
+ */
+ void slotDirListerStarted(const KUrl& url);
+
/**
* Invoked when the directory lister has completed the loading of
* items. Assures that pasted items and renamed items get seleced.
*/
void restoreContentsPosition();
+ void slotUrlChangeRequested(const KUrl& url);
+
private:
void loadDirectory(const KUrl& url, bool reload = false);
*/
void addNewFileNames(const QMimeData* mimeData);
+ /**
+ * Helper method for DolphinView::setItemSelectionEnabled(): Returns the selection for
+ * all items of \p parent that match with the regular expression defined by \p pattern.
+ */
+ QItemSelection childrenMatchingPattern(const QModelIndex& parent, const QRegExp& pattern) const;
+
+ void connectViewAccessor();
+ void disconnectViewAccessor();
+
+ /**
+ * Updates m_isFolderWritable dependent on whether the folder represented by
+ * the current URL is writable. If the state has changed, the signal
+ * writeableStateChanged() will be emitted.
+ */
+ void updateWritableState();
+
private:
/**
* Abstracts the access to the different view implementations
class ViewAccessor
{
public:
- ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
+ ViewAccessor();
~ViewAccessor();
void createView(QWidget* parent,
*/
QWidget* layoutTarget() const;
+ void setRootUrl(const KUrl& rootUrl);
KUrl rootUrl() const;
bool supportsCategorizedSorting() const;
KDirLister* dirLister() const;
private:
+ KUrl m_rootUrl;
DolphinIconsView* m_iconsView;
DolphinDetailsView* m_detailsView;
DolphinColumnViewContainer* m_columnsContainer;
+ DolphinModel* m_dolphinModel;
DolphinSortFilterProxyModel* m_proxyModel;
QAbstractItemView* m_dragSource;
QPointer<DolphinDetailsViewExpander> m_detailsViewExpander;
+
+ // For unit tests
+ friend class DolphinDetailsViewTest;
};
bool m_active : 1;
bool m_isContextMenuOpen : 1; // TODO: workaround for Qt-issue 207192
bool m_assureVisibleCurrentIndex : 1;
bool m_expanderActive : 1;
+ bool m_isFolderWritable : 1;
Mode m_mode;
QTimer* m_selectionChangedTimer;
- KUrl m_rootUrl;
KUrl m_activeItemUrl;
QPoint m_restoredContentsPosition;
KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
* slotDirListerCompleted().
*/
QSet<QString> m_newFileNames;
+
+ // For unit tests
+ friend class TestBase;
+ friend class DolphinDetailsViewTest;
};
/// Allow using DolphinView::Mode in QVariant