]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincolumnview.h
Restore the "Edit->Selection" menu from Konqueror 3 for file
[dolphin.git] / src / dolphincolumnview.h
index 15dddf47fca2b0076a44cd0e94841f6f7f9ee7f5..c742b46cf65eadccd4a9791e8817a36fe4851af5 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
+ *   Copyright (C) 2007-2009 by Peter Penz <peter.penz@gmx.at>             *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
 #ifndef DOLPHINCOLUMNVIEW_H
 #define DOLPHINCOLUMNVIEW_H
 
-#include <QColumnView>
-#include <QStyleOptionViewItem>
+#include "dolphinview.h"
 
-class DolphinController;
-class DolphinView;
+#include <QFont>
+#include <QListView>
+#include <QSize>
+#include <QStyleOption>
+
+#include <kurl.h>
+
+class DolphinColumnViewContainer;
+class DolphinModel;
+class DolphinSortFilterProxyModel;
+class DolphinDirLister;
+class KFileItem;
+class KFileItemList;
+class SelectionManager;
+class ViewExtensionsFactory;
 
 /**
- * @brief TODO
+ * Represents one column inside the DolphinColumnViewContainer.
  */
-class DolphinColumnView : public QColumnView
+class DolphinColumnView : public QListView
 {
     Q_OBJECT
 
 public:
-    explicit DolphinColumnView(QWidget* parent, DolphinController* controller);
+    DolphinColumnView(QWidget* parent,
+                      DolphinColumnViewContainer* container,
+                      const KUrl& url);
     virtual ~DolphinColumnView();
 
+    /**
+     * An active column is defined as column, which shows the same URL
+     * as indicated by the URL navigator. The active column is usually
+     * drawn in a lighter color. All operations are applied to this column.
+     */
+    void setActive(bool active);
+    bool isActive() const;
+
+    /**
+     * Sets the directory URL of the child column that is shown next to
+     * this column. This property is only used for a visual indication
+     * of the shown directory, it does not trigger a loading of the model.
+     */
+    void setChildUrl(const KUrl& url);
+    KUrl childUrl() const;
+
+    /** Sets the directory URL that is shown inside the column widget. */
+    void setUrl(const KUrl& url);
+
+    /** Returns the directory URL that is shown inside the column widget. */
+    KUrl url() const;
+
+    /**
+     * Updates the background color dependent from the activation state
+     * \a isViewActive of the column view.
+     */
+    void updateBackground();
+
+    /**
+     * Returns the item on the position \a pos. The KFileItem instance
+     * is null if no item is below the position.
+     */
+    KFileItem itemAt(const QPoint& pos) const;
+
 protected:
     virtual QStyleOptionViewItem viewOptions() const;
-    virtual void contextMenuEvent(QContextMenuEvent* event);
-    virtual void mouseReleaseEvent(QMouseEvent* event);
+    virtual void startDrag(Qt::DropActions supportedActions);
     virtual void dragEnterEvent(QDragEnterEvent* event);
+    virtual void dragLeaveEvent(QDragLeaveEvent* event);
+    virtual void dragMoveEvent(QDragMoveEvent* event);
     virtual void dropEvent(QDropEvent* event);
+    virtual void paintEvent(QPaintEvent* event);
+    virtual void mousePressEvent(QMouseEvent* event);
+    virtual void keyPressEvent(QKeyEvent* event);
+    virtual void contextMenuEvent(QContextMenuEvent* event);
+    virtual void wheelEvent(QWheelEvent* event);
+    virtual void leaveEvent(QEvent* event);
+    virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
+    virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
 
 private slots:
-    void zoomIn();
-    void zoomOut();
+    void setZoomLevel(int level);
+
+    void slotEntered(const QModelIndex& index);
+    void requestActivation();
+    void updateFont();
+
+    void slotShowPreviewChanged();
 
 private:
-    bool isZoomInPossible() const;
-    bool isZoomOutPossible() const;
+    /** Used by DolphinColumnView::setActive(). */
+    void activate();
 
-    /**
-     * Updates the size of the decoration dependent on the
-     * icon size of the ColumnModeSettings. The controller
-     * will get informed about possible zoom in/zoom out
-     * operations.
-     */
-    void updateDecorationSize();
+    /** Used by DolphinColumnView::setActive(). */
+    void deactivate();
+
+    void updateDecorationSize(bool showPreview);
 
 private:
-    DolphinController* m_controller;
-    QStyleOptionViewItem m_viewOptions;
+    bool m_active;
+    DolphinColumnViewContainer* m_container;
+    SelectionManager* m_selectionManager;
+    ViewExtensionsFactory* m_extensionsFactory;
+    KUrl m_url;      // URL of the directory that is shown
+    KUrl m_childUrl; // URL of the next column that is shown
+
+    QFont m_font;
+    QSize m_decorationSize;
+
+    DolphinDirLister* m_dirLister;
+    DolphinModel* m_dolphinModel;
+    DolphinSortFilterProxyModel* m_proxyModel;
+
+    QRect m_dropRect;
+
+    friend class DolphinColumnViewContainer;
 };
 
+inline bool DolphinColumnView::isActive() const
+{
+    return m_active;
+}
+
+inline void DolphinColumnView::setChildUrl(const KUrl& url)
+{
+    m_childUrl = url;
+}
+
+inline KUrl DolphinColumnView::childUrl() const
+{
+    return m_childUrl;
+}
+
+inline void DolphinColumnView::setUrl(const KUrl& url)
+{
+    if (url != m_url) {
+        m_url = url;
+        //reload();
+    }
+}
+
+inline KUrl DolphinColumnView::url() const
+{
+    return m_url;
+}
+
 #endif