2007-03-27 19:08:44 +00:00
|
|
|
/***************************************************************************
|
2007-06-20 21:04:36 +00:00
|
|
|
* Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
|
2007-03-27 19:08:44 +00:00
|
|
|
* *
|
|
|
|
* 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 *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* 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., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef DOLPHINCOLUMNVIEW_H
|
|
|
|
#define DOLPHINCOLUMNVIEW_H
|
|
|
|
|
2008-02-11 18:27:49 +00:00
|
|
|
#include "dolphinview.h"
|
|
|
|
|
2007-10-05 22:32:13 +00:00
|
|
|
#include <kurl.h>
|
|
|
|
|
2007-09-14 20:50:08 +00:00
|
|
|
#include <QAbstractItemView>
|
|
|
|
#include <QList>
|
2007-10-09 22:32:54 +00:00
|
|
|
#include <QString>
|
2007-07-10 20:33:17 +00:00
|
|
|
#include <QStyleOption>
|
2007-03-27 19:08:44 +00:00
|
|
|
|
2007-10-05 21:00:44 +00:00
|
|
|
class DolphinColumnWidget;
|
2007-03-27 19:08:44 +00:00
|
|
|
class DolphinController;
|
2007-09-19 13:34:40 +00:00
|
|
|
class DolphinModel;
|
|
|
|
class QAbstractProxyModel;
|
2007-10-16 22:24:52 +00:00
|
|
|
class QFrame;
|
2007-09-14 20:50:08 +00:00
|
|
|
class QTimeLine;
|
2007-03-27 19:08:44 +00:00
|
|
|
|
|
|
|
/**
|
2007-06-17 15:04:01 +00:00
|
|
|
* @brief Represents the view, where each directory is show as separate column.
|
|
|
|
*
|
|
|
|
* @see DolphinIconsView
|
|
|
|
* @see DolphinDetailsView
|
2007-03-27 19:08:44 +00:00
|
|
|
*/
|
2007-09-14 20:50:08 +00:00
|
|
|
class DolphinColumnView : public QAbstractItemView
|
2007-03-27 19:08:44 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit DolphinColumnView(QWidget* parent, DolphinController* controller);
|
|
|
|
virtual ~DolphinColumnView();
|
|
|
|
|
2008-06-18 19:34:03 +00:00
|
|
|
/** @see QAbstractItemView::indexAt() */
|
2007-09-14 20:50:08 +00:00
|
|
|
virtual QModelIndex indexAt(const QPoint& point) const;
|
2008-06-18 19:34:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the item on the position \a pos. The KFileItem instance
|
|
|
|
* is null if no item is below the position.
|
|
|
|
*/
|
|
|
|
KFileItem itemAt(const QPoint& point) const;
|
|
|
|
|
|
|
|
/** @see QAbstractItemView::scrollTo() */
|
2007-09-14 20:50:08 +00:00
|
|
|
virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
|
2008-06-18 19:34:03 +00:00
|
|
|
|
|
|
|
/** @see QAbstractItemView::visualRect() */
|
2007-09-14 20:50:08 +00:00
|
|
|
virtual QRect visualRect(const QModelIndex& index) const;
|
2007-08-06 06:56:36 +00:00
|
|
|
|
2007-09-26 07:23:09 +00:00
|
|
|
/** Inverts the selection of the currently active column. */
|
|
|
|
void invertSelection();
|
|
|
|
|
2007-09-21 18:52:46 +00:00
|
|
|
/**
|
|
|
|
* Reloads the content of all columns. In opposite to non-hierarchical views
|
|
|
|
* it is not enough to reload the KDirLister, instead this method must be explicitly
|
|
|
|
* invoked.
|
|
|
|
*/
|
|
|
|
void reload();
|
|
|
|
|
2007-10-05 22:32:13 +00:00
|
|
|
/**
|
|
|
|
* Adjusts the root URL of the first column and removes all
|
|
|
|
* other columns.
|
|
|
|
*/
|
|
|
|
void setRootUrl(const KUrl& url);
|
|
|
|
|
|
|
|
/** Returns the URL of the first column. */
|
|
|
|
KUrl rootUrl() const;
|
|
|
|
|
2007-10-09 22:32:54 +00:00
|
|
|
/**
|
|
|
|
* Filters the currently shown items by \a nameFilter. All items
|
|
|
|
* which contain the given filter string will be shown.
|
|
|
|
*/
|
|
|
|
void setNameFilter(const QString& nameFilter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the currently used name filter. All items
|
|
|
|
* which contain the name filter will be shown.
|
|
|
|
*/
|
|
|
|
QString nameFilter() const;
|
|
|
|
|
2007-09-24 13:50:31 +00:00
|
|
|
/**
|
|
|
|
* Shows the column which represents the URL \a url. If the column
|
|
|
|
* is already shown, it gets activated, otherwise it will be created.
|
|
|
|
*/
|
|
|
|
void showColumn(const KUrl& url);
|
|
|
|
|
2008-03-23 15:53:12 +00:00
|
|
|
/**
|
|
|
|
* Does an inline editing for the item \a item
|
|
|
|
* inside the active column.
|
|
|
|
*/
|
|
|
|
void editItem(const KFileItem& item);
|
|
|
|
|
2008-06-18 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Returns the selected items of the active column.
|
|
|
|
*/
|
|
|
|
KFileItemList selectedItems() const;
|
2009-02-24 08:09:35 +00:00
|
|
|
|
2008-12-03 07:14:37 +00:00
|
|
|
/**
|
|
|
|
* Returns the MIME data for the selected items
|
|
|
|
* of the active column.
|
|
|
|
*/
|
|
|
|
QMimeData* selectionMimeData() const;
|
2008-06-18 19:34:03 +00:00
|
|
|
|
2007-11-07 20:10:13 +00:00
|
|
|
public slots:
|
2007-09-25 13:53:08 +00:00
|
|
|
/** @see QAbstractItemView::selectAll() */
|
|
|
|
virtual void selectAll();
|
|
|
|
|
2009-01-25 19:46:08 +00:00
|
|
|
signals:
|
|
|
|
/**
|
|
|
|
* Requests that the given column be deleted at the discretion
|
|
|
|
* of the receiver of the signal.
|
|
|
|
*/
|
|
|
|
void requestColumnDeletion(QAbstractItemView* column);
|
|
|
|
|
2007-03-27 19:08:44 +00:00
|
|
|
protected:
|
2007-09-14 20:50:08 +00:00
|
|
|
virtual bool isIndexHidden(const QModelIndex& index) const;
|
|
|
|
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
|
|
|
|
virtual void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags);
|
|
|
|
virtual QRegion visualRegionForSelection(const QItemSelection& selection) const;
|
|
|
|
virtual int horizontalOffset() const;
|
|
|
|
virtual int verticalOffset() const;
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
virtual void mousePressEvent(QMouseEvent* event);
|
2007-09-14 20:50:08 +00:00
|
|
|
virtual void resizeEvent(QResizeEvent* event);
|
2008-02-12 09:27:26 +00:00
|
|
|
virtual void wheelEvent(QWheelEvent* event);
|
2007-03-27 19:08:44 +00:00
|
|
|
|
|
|
|
private slots:
|
2008-08-05 20:15:51 +00:00
|
|
|
void setZoomLevel(int level);
|
2007-03-27 19:08:44 +00:00
|
|
|
|
2007-06-28 18:52:54 +00:00
|
|
|
/**
|
2007-09-14 20:50:08 +00:00
|
|
|
* Moves the content of the columns view to represent
|
|
|
|
* the scrollbar position \a x.
|
2007-06-28 18:52:54 +00:00
|
|
|
*/
|
2007-09-14 20:50:08 +00:00
|
|
|
void moveContentHorizontally(int x);
|
|
|
|
|
2007-06-28 18:52:54 +00:00
|
|
|
/**
|
2007-07-28 22:27:58 +00:00
|
|
|
* 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.
|
2007-06-28 18:52:54 +00:00
|
|
|
*/
|
2008-08-18 19:30:25 +00:00
|
|
|
void updateDecorationSize(bool showPreview);
|
2007-06-28 18:52:54 +00:00
|
|
|
|
2007-10-07 10:53:33 +00:00
|
|
|
/**
|
|
|
|
* Updates the background color of the columns to respect
|
|
|
|
* the current activation state \a active.
|
|
|
|
*/
|
|
|
|
void updateColumnsBackground(bool active);
|
|
|
|
|
2008-02-11 18:27:49 +00:00
|
|
|
void slotSortingChanged(DolphinView::Sorting sorting);
|
|
|
|
void slotSortOrderChanged(Qt::SortOrder order);
|
2009-04-20 17:52:21 +00:00
|
|
|
void slotSortFoldersFirstChanged(bool foldersFirst);
|
2007-10-26 18:34:45 +00:00
|
|
|
void slotShowHiddenFilesChanged();
|
2007-10-26 19:02:33 +00:00
|
|
|
void slotShowPreviewChanged();
|
2007-09-26 07:23:09 +00:00
|
|
|
|
2007-07-28 22:27:58 +00:00
|
|
|
private:
|
2007-10-05 21:00:44 +00:00
|
|
|
DolphinColumnWidget* activeColumn() const;
|
2007-09-19 13:00:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Deactivates the currently active column and activates
|
|
|
|
* the new column indicated by \a index. m_index represents
|
|
|
|
* the active column afterwards. Also the URL of the navigator
|
|
|
|
* will be adjusted to reflect the column URL.
|
|
|
|
*/
|
2007-09-14 20:50:08 +00:00
|
|
|
void setActiveColumnIndex(int index);
|
|
|
|
|
|
|
|
void layoutColumns();
|
|
|
|
void updateScrollBar();
|
|
|
|
|
2007-04-01 17:57:53 +00:00
|
|
|
/**
|
2007-09-14 20:50:08 +00:00
|
|
|
* Assures that the currently active column is fully visible
|
|
|
|
* by adjusting the horizontal position of the content.
|
2007-04-01 17:57:53 +00:00
|
|
|
*/
|
2007-09-14 20:50:08 +00:00
|
|
|
void assureVisibleActiveColumn();
|
2007-04-01 17:57:53 +00:00
|
|
|
|
2007-08-03 18:46:49 +00:00
|
|
|
/**
|
2007-09-14 20:50:08 +00:00
|
|
|
* Request the activation for the column \a column. It is assured
|
|
|
|
* that the columns gets fully visible by adjusting the horizontal
|
|
|
|
* position of the content.
|
2007-08-03 18:46:49 +00:00
|
|
|
*/
|
2007-10-05 21:00:44 +00:00
|
|
|
void requestActivation(DolphinColumnWidget* column);
|
2007-08-03 18:46:49 +00:00
|
|
|
|
2007-10-05 22:32:13 +00:00
|
|
|
/** Removes all columns except of the root column. */
|
|
|
|
void removeAllColumns();
|
|
|
|
|
2008-06-18 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Returns the position of the point \a point relative to the column
|
|
|
|
* \a column.
|
|
|
|
*/
|
|
|
|
QPoint columnPosition(DolphinColumnWidget* column, const QPoint& point) const;
|
|
|
|
|
2008-07-24 19:50:40 +00:00
|
|
|
/**
|
|
|
|
* Deletes the column. If the itemview of the controller is set to the column,
|
|
|
|
* the controllers itemview is set to 0.
|
|
|
|
*/
|
|
|
|
void deleteColumn(DolphinColumnWidget* column);
|
|
|
|
|
2007-03-27 19:08:44 +00:00
|
|
|
private:
|
|
|
|
DolphinController* m_controller;
|
2007-10-07 10:53:33 +00:00
|
|
|
bool m_active;
|
2007-09-14 20:50:08 +00:00
|
|
|
int m_index;
|
|
|
|
int m_contentX;
|
2007-10-05 21:00:44 +00:00
|
|
|
QList<DolphinColumnWidget*> m_columns;
|
2007-10-16 22:24:52 +00:00
|
|
|
QFrame* m_emptyViewport;
|
2007-09-14 20:50:08 +00:00
|
|
|
QTimeLine* m_animation;
|
2007-10-26 17:36:16 +00:00
|
|
|
QString m_nameFilter;
|
2007-06-15 18:52:06 +00:00
|
|
|
|
2007-10-05 21:00:44 +00:00
|
|
|
friend class DolphinColumnWidget;
|
2007-03-27 19:08:44 +00:00
|
|
|
};
|
|
|
|
|
2007-10-05 21:00:44 +00:00
|
|
|
inline DolphinColumnWidget* DolphinColumnView::activeColumn() const
|
2007-09-14 20:50:08 +00:00
|
|
|
{
|
|
|
|
return m_columns[m_index];
|
|
|
|
}
|
|
|
|
|
2007-03-27 19:08:44 +00:00
|
|
|
#endif
|