-/**
- * Represents one column inside the DolphinColumnView and has been
- * extended to respect view options and hovering information.
- */
-class ColumnWidget : public QListView
-{
-public:
- ColumnWidget(QWidget* parent,
- DolphinColumnView* columnView,
- const KUrl& url);
- virtual ~ColumnWidget();
-
- /** Sets the size of the icons. */
- void setDecorationSize(const QSize& size);
-
- /**
- * 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);
- inline 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.
- */
- inline void setChildUrl(const KUrl& url);
- inline const KUrl& childUrl() const;
-
- /**
- * Returns the directory URL that is shown inside the column widget.
- */
- inline const KUrl& url() const;
-
-protected:
- virtual QStyleOptionViewItem viewOptions() const;
- 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 contextMenuEvent(QContextMenuEvent* event);
- virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
-
-private:
- /** Used by ColumnWidget::setActive(). */
- void activate();
-
- /** Used by ColumnWidget::setActive(). */
- void deactivate();
-
-private:
- bool m_active;
- DolphinColumnView* m_view;
- KUrl m_url; // URL of the directory that is shown
- KUrl m_childUrl; // URL of the next column that is shown
- QStyleOptionViewItem m_viewOptions;
-
- bool m_dragging; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
- QRect m_dropRect; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
-};
-
-ColumnWidget::ColumnWidget(QWidget* parent,
- DolphinColumnView* columnView,
- const KUrl& url) :
- QListView(columnView),
- m_active(true),
- m_view(columnView),
- m_url(url),
- m_childUrl(),
- m_dragging(false),
- m_dropRect()
-{
- setMouseTracking(true);
- viewport()->setAttribute(Qt::WA_Hover);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
- setSelectionMode(QAbstractItemView::ExtendedSelection);
-
- // apply the column mode settings to the widget
- const ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
- Q_ASSERT(settings != 0);
-
- m_viewOptions = QListView::viewOptions();
-
- QFont font(settings->fontFamily(), settings->fontSize());
- font.setItalic(settings->italicFont());
- font.setBold(settings->boldFont());
- m_viewOptions.font = font;
-
- const int iconSize = settings->iconSize();
- m_viewOptions.decorationSize = QSize(iconSize, iconSize);
-
- KFileItemDelegate* delegate = new KFileItemDelegate(this);
- setItemDelegate(delegate);
-
- activate();
-
- connect(this, SIGNAL(entered(const QModelIndex&)),
- m_view->m_controller, SLOT(emitItemEntered(const QModelIndex&)));
- connect(this, SIGNAL(viewportEntered()),
- m_view->m_controller, SLOT(emitViewportEntered()));
-}
-
-ColumnWidget::~ColumnWidget()