#include <kparts/part.h>
#include <kfileitem.h>
#include <kfileitemdelegate.h>
-#include <kfileiconview.h>
#include <kio/job.h>
-#include <urlnavigator.h>
+#include <kurlnavigator.h>
-#include <QDropEvent>
-#include <QLinkedList>
-#include <QListView>
-#include <QMouseEvent>
-#include <QVBoxLayout>
-#include <QWidget>
+#include <QtGui/QKeyEvent>
+#include <QtCore/QLinkedList>
+#include <QtGui/QListView>
+#include <QtGui/QBoxLayout>
+#include <QtGui/QWidget>
class DolphinController;
class FilterBar;
class KFileItemDelegate;
class KUrl;
class KDirModel;
-class UrlNavigator;
+class KUrlNavigator;
+class DolphinColumnView;
class DolphinDetailsView;
class DolphinDirLister;
class DolphinIconsView;
* @short Represents a view for the directory content
* including the navigation bar, filter bar and status bar.
*
- * View modes for icons and details are supported. Currently
+ * View modes for icons, details and columns are supported. Currently
* Dolphin allows to have up to two views inside the main window.
*
* @see DolphinIconsView
* @see DolphinDetailsView
- * @see UrlNavigator
+ * @see DolphinColumnView
+ * @see KUrlNavigator
* @see DolphinStatusBar
*/
class DolphinView : public QWidget
Q_OBJECT
public:
- /**
- * Defines the view mode for a directory. The view mode
- * can be defined when constructing a DolphinView. The
- * view mode is automatically updated if the directory itself
- * defines a view mode (see class ViewProperties for details).
- */
+ /**
+ * Defines the view mode for a directory. The view mode
+ * can be defined when constructing a DolphinView. The
+ * view mode is automatically updated if the directory itself
+ * defines a view mode (see class ViewProperties for details).
+ */
enum Mode
{
/**
* for date, group and permissions.
*/
DetailsView = 1,
- MaxModeEnum = DetailsView
+
+ /**
+ * Each folder is shown in a separate column.
+ */
+ ColumnView = 2,
+ MaxModeEnum = ColumnView
};
/** Defines the sort order for the items of a directory. */
SortByPermissions,
SortByOwner,
SortByGroup,
- MaxSortEnum = SortByGroup
+ SortByType,
+ MaxSortEnum = SortByType
};
DolphinView(DolphinMainWindow* mainwindow,
/**
* Sets the current active URL.
- * The signals UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
+ * The signals KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
* are emitted.
*/
void setUrl(const KUrl& url);
void setShowHiddenFiles(bool show);
bool showHiddenFiles() const;
+ /**
+ * Summarizes all sorted items by their category \a categorized
+ * is true.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * categorized sorting setting will be be stored automatically.
+ */
+ void setCategorizedSorting(bool categorized);
+ bool categorizedSorting() const;
+
+ /**
+ * Returns true, if the categorized sorting is supported by the current
+ * used mode (see DolphinView::setMode()). Currently only DolphinView::IconsView
+ * supports categorizations. To check whether the categorized
+ * sorting is set, use DolphinView::categorizedSorting().
+ */
+ bool supportsCategorizedSorting() const;
+
/**
* Triggers the renaming of the currently selected items, where
* the user must input a new name for the items.
/**
* Goes back one step in the URL history. The signals
- * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
+ * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
* are submitted.
*/
void goBack();
/**
* Goes forward one step in the Url history. The signals
- * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
+ * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
* are submitted.
*/
void goForward();
/**
* Goes up one step of the Url path. The signals
- * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
+ * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
* are submitted.
*/
void goUp();
/**
- * Goes to the home URL. The signals UrlNavigator::urlChanged()
- * and UrlNavigator::historyChanged() are submitted.
+ * Goes to the home URL. The signals KUrlNavigator::urlChanged()
+ * and KUrlNavigator::historyChanged() are submitted.
*/
void goHome();
*/
void setUrlEditable(bool editable);
- /**
- * Returns the complete URL history. The index 0 indicates the oldest
- * history element.
- * @param index Output parameter which indicates the current
- * index of the location.
- */
- const QLinkedList<UrlNavigator::HistoryElem> urlHistory(int& index) const;
-
/** Returns true, if at least one item is selected. */
bool hasSelection() const;
/**
* Returns true, if the URL shown by the navigation bar is editable.
- * @see UrlNavigator
+ * @see KUrlNavigator
*/
bool isUrlEditable() const;
/** Returns the additional information which should be shown for the items. */
KFileItemDelegate::AdditionalInformation additionalInfo() const;
- /** Refreshs the view settings by reading out the stored settings. */
- void refreshSettings();
-
- /** Returns the UrlNavigator of the view for read access. */
- const UrlNavigator* urlNavigator() const { return m_urlNavigator; }
+ /** Returns the KUrlNavigator of the view for read access. */
+ const KUrlNavigator* urlNavigator() const
+ {
+ return m_urlNavigator;
+ }
/**
* Triggers to request user information for the item given
/** Reloads the current directory. */
void reload();
+ /**
+ * Refreshs 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,
+ * Details View or Columns View have been changed.
+ */
+ void refresh();
+
public slots:
/**
* Popups the filter bar above the status bar if \a show is true.
*/
void requestActivation();
- /** Applies an item effect to all cut items of the clipboard. */
- void updateCutItems();
+ /**
+ * Request of a selection change. The view will do its best to accommodate
+ * the request, but it is not guaranteed that all items in \a selection
+ * will actually get selected. The view will e.g. not select items which
+ * are not in the currently displayed folder.
+ */
+ void changeSelection(const KFileItemList& selection);
signals:
/** Is emitted if URL of the view has been changed to \a url. */
/** Is emitted if the 'show hidden files' property has been changed. */
void showHiddenFilesChanged();
+ /** Is emitted if the 'categorized sorting' property has been changed. */
+ void categorizedSortingChanged();
+
/** Is emitted if the sorting by name, size or date has been changed. */
void sortingChanged(DolphinView::Sorting sorting);
void contentsMoved(int x, int y);
/**
- * Is emitted whenever the selection has been changed. The current selection can
- * be retrieved by mainWindow()->activeView()->selectedItems() or by
- * mainWindow()->activeView()->selectedUrls().
+ * Is emitted whenever the selection has been changed.
*/
- void selectionChanged();
+ void selectionChanged(const KFileItemList& selection);
/**
* Is emitted whenever the filter bar has been turned show or hidden.
virtual void mouseReleaseEvent(QMouseEvent* event);
private slots:
- void loadDirectory(const KUrl& kurl);
+ void changeDirectory(const KUrl& url);
void triggerItem(const QModelIndex& index);
void updateProgress(int percent);
* Replaces the icon of the item \a item by the preview pixmap
* \a pixmap.
*/
- void showPreview(const KFileItem* item, const QPixmap& pixmap);
+ void showPreview(const KFileItem& item, const QPixmap& pixmap);
/**
* Restores the x- and y-position of the contents if the
*/
void updateActivationState();
+ /** Applies an item effect to all cut items of the clipboard. */
+ void updateCutItems();
+
private:
void startDirLister(const KUrl& url, bool reload = false);
*/
bool isCutItem(const KFileItem& item) const;
+ /** Applies an item effect to all cut items. */
+ void applyCutItemEffect();
+
+ /**
+ * Returns true, if the ColumnView is activated. As the column view
+ * requires some special handling for iterating through directories,
+ * this method has been introduced for convenience.
+ */
+ bool isColumnViewActive() const
+ {
+ return m_columnView != 0;
+ }
+
private:
+ /**
+ * Remembers the original pixmap for an item before
+ * the cut effect is applied.
+ */
+ struct CutItem
+ {
+ KUrl url;
+ QPixmap pixmap;
+ };
+
bool m_showProgress;
+ bool m_blockContentsMovedSignal;
+ bool m_initializeColumnView;
Mode m_mode;
int m_iconSize;
DolphinMainWindow* m_mainWindow;
QVBoxLayout* m_topLayout;
- UrlNavigator* m_urlNavigator;
+ KUrlNavigator* m_urlNavigator;
DolphinController* m_controller;
DolphinIconsView* m_iconsView;
DolphinDetailsView* m_detailsView;
+ DolphinColumnView* m_columnView;
KFileItemDelegate* m_fileItemDelegate;
FilterBar* m_filterBar;
KDirModel* m_dirModel;
DolphinDirLister* m_dirLister;
DolphinSortFilterProxyModel* m_proxyModel;
+
+ QList<CutItem> m_cutItemsCache;
};
#endif // _DOLPHINVIEW_H_