* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef DOLPHINDETAILSVIEW_H
#define DOLPHINDETAILSVIEW_H
-#include <kfiledetailview.h>
-#include <itemeffectsmanager.h>
-//Added by qt3to4:
-#include <QPixmap>
-#include <QResizeEvent>
-#include <QEvent>
-#include <QDropEvent>
-#include <QMouseEvent>
-#include <QDragMoveEvent>
-#include <QPaintEvent>
-
-class QRect;
-class QTimer;
-class DolphinView;
+#include <dolphinview.h>
+#include <QTreeView>
+#include <libdolphin_export.h>
+
+class DolphinController;
/**
* @brief Represents the details view which shows the name, size,
- * date, permissions, owner and group of an item.
+ * date, permissions, owner and group of an item.
*
- * The width of the columns are automatically adjusted in a way
+ * The width of the columns is automatically adjusted in a way
* that full available width of the view is used by stretching the width
* of the name column.
- *
- * @author Peter Penz
*/
-class DolphinDetailsView : public KFileDetailView, public ItemEffectsManager
+class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView : public QTreeView
{
Q_OBJECT
public:
- /**
- * Maps the column indices of KFileDetailView to a
- * descriptive column name.
- */
- enum ColumnName {
- NameColumn = 0,
- SizeColumn = 1,
- DateColumn = 2,
- PermissionsColumn = 3,
- OwnerColumn = 4,
- GroupColumn = 5
- };
-
- DolphinDetailsView(DolphinView* parent);
-
+ explicit DolphinDetailsView(QWidget* parent, DolphinController* controller);
virtual ~DolphinDetailsView();
- /** @see ItemEffectsManager::updateItems */
- virtual void beginItemUpdates();
-
- /** @see ItemEffectsManager::updateItems */
- virtual void endItemUpdates();
-
- /** @see KFileView::insertItem */
- virtual void insertItem(KFileItem* fileItem);
+protected:
+ virtual bool event(QEvent* event);
+ virtual QStyleOptionViewItem viewOptions() const;
+ virtual void contextMenuEvent(QContextMenuEvent* event);
+ virtual void mousePressEvent(QMouseEvent* event);
+ virtual void mouseMoveEvent(QMouseEvent* 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 keyPressEvent(QKeyEvent* event);
+ virtual void resizeEvent(QResizeEvent* event);
+ virtual void closeEvent(QCloseEvent* event);
+private slots:
/**
- * @return True, if the position \a pos is above the name of
- * item \a item.
+ * Sets the sort indicator section of the header view
+ * corresponding to \a sorting.
*/
- bool isOnFilename(const Q3ListViewItem* item, const QPoint& pos) const;
+ void setSortIndicatorSection(DolphinView::Sorting sorting);
/**
- * Reads out the dolphin settings for the details view and refreshs
- * the details view.
+ * Sets the sort indicator order of the header view
+ * corresponding to \a sortOrder.
*/
- // TODO: Other view implementations use a similar interface. When using
- // Interview in Qt4 this method should be moved to a base class (currently
- // not possible due to having different base classes for the views).
- void refreshSettings();
+ void setSortIndicatorOrder(Qt::SortOrder sortOrder);
- /** @see ItemEffectsManager::zoomIn() */
- virtual void zoomIn();
-
- /** @see ItemEffectsManager::zoomOut() */
- virtual void zoomOut();
-
- /** @see ItemEffectsManager::isZoomInPossible() */
- virtual bool isZoomInPossible() const;
-
- /** @see ItemEffectsManager::isZoomOutPossible() */
- virtual bool isZoomOutPossible() const;
-
-signals:
/**
- * Is send, if the details view should be activated. Usually an activation
- * is triggered by a mouse click.
+ * Synchronizes the sorting state of the Dolphin menu 'View -> Sort'
+ * with the current state of the details view.
+ * @param column Index of the current sorting column.
*/
- void signalRequestActivation();
-
-public slots:
- /** @see KFileDetailView::resizeContents */
- virtual void resizeContents(int width, int height);
-
- /** Is connected to the onItem-signal from KFileDetailView. */
- void slotOnItem(Q3ListViewItem* item);
-
- /** Is connected to the onViewport-signal from KFileDetailView. */
- void slotOnViewport();
-
-protected:
- /** @see ItemEffectsManager::setContextPixmap() */
- virtual void setContextPixmap(void* context,
- const QPixmap& pixmap);
-
- /** @see ItemEffectsManager::setContextPixmap() */
- virtual const QPixmap* contextPixmap(void* context);
-
- /** @see ItemEffectsManager::setContextPixmap() */
- virtual void* firstContext();
+ void synchronizeSortingState(int column);
- /** @see ItemEffectsManager::setContextPixmap() */
- virtual void* nextContext(void* context);
-
- /** @see ItemEffectsManager::setContextPixmap() */
- virtual KFileItem* contextFileInfo(void* context);
-
- /** @see KFileDetailView::contentsDragMoveEvent() */
- virtual void contentsDragMoveEvent(QDragMoveEvent* event);
+ /**
+ * Is invoked when the mouse cursor has entered an item. The controller
+ * gets informed to emit the itemEntered() signal if the mouse cursor
+ * is above the name column. Otherwise the controller gets informed
+ * to emit the itemViewportEntered() signal (all other columns should
+ * behave as viewport area).
+ */
+ void slotEntered(const QModelIndex& index);
- /** @see KFileDetailView::resizeEvent() */
- virtual void resizeEvent(QResizeEvent* event);
+ /**
+ * Updates the destination \a m_elasticBandDestination from
+ * the elastic band to the current mouse position and triggers
+ * an update.
+ */
+ void updateElasticBand();
- /** @see KFileDetailView::acceptDrag() */
- virtual bool acceptDrag (QDropEvent* event) const;
+ /**
+ * Returns the rectangle for the elastic band dependent from the
+ * origin \a m_elasticBandOrigin, the current destination
+ * \a m_elasticBandDestination and the viewport position.
+ */
+ QRect elasticBandRect() const;
- /** @see KFileDetailView::contentsDropEvent() */
- virtual void contentsDropEvent(QDropEvent* event);
+ void zoomIn();
+ void zoomOut();
- /** @see KFileDetailView::contentsMousePressEvent() */
- virtual void contentsMousePressEvent(QMouseEvent* event);
+ /**
+ * Called by QTreeView when an item is activated (clicked or double-clicked)
+ */
+ void triggerItem(const QModelIndex& index);
- /** @see KFileDetailView::contentsMouseMoveEvent() */
- virtual void contentsMouseMoveEvent(QMouseEvent* event);
+ /**
+ * Opens a context menu at the position \a pos and allows to
+ * configure the visibility of the header columns.
+ */
+ void configureColumns(const QPoint& pos);
- /** @see KFileDetailView::contentsMouseReleaseEvent() */
- virtual void contentsMouseReleaseEvent(QMouseEvent* event);
+ void updateColumnVisibility();
- /** @see QListView::paintEmptyArea() */
- virtual void paintEmptyArea(QPainter* painter, const QRect& rect);
+private:
+ bool isZoomInPossible() const;
+ bool isZoomOutPossible() const;
- /** Draws the selection rubber. */
- void drawRubber();
+ /**
+ * Updates the size of the decoration dependent on the
+ * icon size of the DetailsModeSettings. The controller
+ * will get informed about possible zoom in/zoom out
+ * operations.
+ */
+ void updateDecorationSize();
- /** @see QListView::viewportPaintEvent() */
- virtual void viewportPaintEvent(QPaintEvent* paintEvent);
+ /** Return the upper left position in pixels of the viewport content. */
+ QPoint contentsPos() const;
- /** @see QWidget::leaveEvent() */
- virtual void leaveEvent(QEvent* event);
+ KFileItem itemForIndex(const QModelIndex& index) const;
-private slots:
- void slotActivationUpdate();
- void slotContextMenuRequested(Q3ListViewItem* item,
- const QPoint& pos,
- int col);
- void slotUpdateDisabledItems();
- void slotAutoScroll();
- void updateColumnsWidth();
- void slotItemRenamed(Q3ListViewItem* item,
- const QString& name,
- int column);
+ KFileItemDelegate::Information infoForColumn(int columnIndex) const;
/**
- * Is invoked when a section from the header has
- * been clicked and stores the sort column and sort
- * order.
+ * Resizes all columns in a way to use the whole available width of the view.
*/
- void slotHeaderClicked(int section);
+ void resizeColumns();
private:
- class DolphinListViewItem : public KFileListViewItem {
- public:
- DolphinListViewItem(Q3ListView* parent,
- KFileItem* fileItem);
- virtual ~DolphinListViewItem();
- virtual void paintCell(QPainter* painter,
- const QColorGroup& colorGroup,
- int column,
- int cellWidth,
- int alignment);
-
- virtual void paintFocus(QPainter* painter,
- const QColorGroup& colorGroup,
- const QRect& rect);
- };
-
- DolphinView* m_dolphinView;
- QTimer* m_resizeTimer;
- QTimer* m_scrollTimer;
- QRect* m_rubber;
+ DolphinController* m_controller;
- /**
- * Returns the width of the filename in pixels including
- * the icon. It is assured that the returned width is
- * <= the width of the filename column.
- */
- int filenameWidth(const Q3ListViewItem* item) const;
+ QFont m_font;
+ QSize m_decorationSize;
+
+ bool m_clearAdditionalInfo;
+
+ 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
+ bool m_showElasticBand;
+ QPoint m_elasticBandOrigin;
+ QPoint m_elasticBandDestination;
};
#endif