mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
I wanted to this for KDE 4.1 already, but well...
Columview refactoring: Get rid of "isColumnView()" special cases in DolphinView and the interface code duplications due to delegating non-QAbstractItemView interfaces to the column view. This reduces the code size + complexity a lot and will make future maintainance of the columnview and DolphinView a lot easier. Currently there are some regressions in the column view, but this will be fixed during the next 14 days. svn path=/trunk/KDE/kdebase/apps/; revision=1016776
This commit is contained in:
parent
dcf397ae51
commit
41c14c5f8e
12 changed files with 1526 additions and 1055 deletions
|
@ -20,7 +20,7 @@ set(dolphinprivate_LIB_SRCS
|
|||
dolphindetailsview.cpp
|
||||
dolphiniconsview.cpp
|
||||
dolphincolumnview.cpp
|
||||
dolphincolumnwidget.cpp
|
||||
dolphincolumnviewcontainer.cpp
|
||||
dolphindirlister.cpp
|
||||
dolphinfileitemdelegate.cpp
|
||||
dolphinmodel.cpp
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 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 *
|
||||
|
@ -22,211 +22,153 @@
|
|||
|
||||
#include "dolphinview.h"
|
||||
|
||||
#include <kurl.h>
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QFont>
|
||||
#include <QListView>
|
||||
#include <QSize>
|
||||
#include <QStyleOption>
|
||||
|
||||
class DolphinColumnWidget;
|
||||
class DolphinController;
|
||||
class QFrame;
|
||||
class QTimeLine;
|
||||
#include <kurl.h>
|
||||
|
||||
class DolphinColumnViewContainer;
|
||||
class DolphinModel;
|
||||
class DolphinSortFilterProxyModel;
|
||||
class DolphinDirLister;
|
||||
class DolphinViewAutoScroller;
|
||||
class KFilePreviewGenerator;
|
||||
class KFileItem;
|
||||
class KFileItemList;
|
||||
class SelectionManager;
|
||||
class ToolTipManager;
|
||||
|
||||
/**
|
||||
* @brief Represents the view, where each directory is show as separate column.
|
||||
*
|
||||
* @see DolphinIconsView
|
||||
* @see DolphinDetailsView
|
||||
* Represents one column inside the DolphinColumnViewContainer.
|
||||
*/
|
||||
class DolphinColumnView : public QAbstractItemView
|
||||
class DolphinColumnView : public QListView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DolphinColumnView(QWidget* parent, DolphinController* controller);
|
||||
DolphinColumnView(QWidget* parent,
|
||||
DolphinColumnViewContainer* container,
|
||||
const KUrl& url);
|
||||
virtual ~DolphinColumnView();
|
||||
|
||||
/** @see QAbstractItemView::indexAt() */
|
||||
virtual QModelIndex indexAt(const QPoint& point) const;
|
||||
/**
|
||||
* 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);
|
||||
const 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. */
|
||||
const 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& point) const;
|
||||
|
||||
/** @see QAbstractItemView::scrollTo() */
|
||||
virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
|
||||
|
||||
/** @see QAbstractItemView::visualRect() */
|
||||
virtual QRect visualRect(const QModelIndex& index) const;
|
||||
|
||||
/** Inverts the selection of the currently active column. */
|
||||
void invertSelection();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Does an inline editing for the item \a item
|
||||
* inside the active column.
|
||||
*/
|
||||
void editItem(const KFileItem& item);
|
||||
|
||||
/**
|
||||
* Returns the selected items of the active column.
|
||||
*/
|
||||
KFileItemList selectedItems() const;
|
||||
|
||||
/**
|
||||
* Returns the MIME data for the selected items
|
||||
* of the active column.
|
||||
*/
|
||||
QMimeData* selectionMimeData() const;
|
||||
|
||||
public slots:
|
||||
/** @see QAbstractItemView::selectAll() */
|
||||
virtual void selectAll();
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Requests that the given column be deleted at the discretion
|
||||
* of the receiver of the signal.
|
||||
*/
|
||||
void requestColumnDeletion(QAbstractItemView* column);
|
||||
KFileItem itemAt(const QPoint& pos) const;
|
||||
|
||||
protected:
|
||||
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;
|
||||
|
||||
virtual QStyleOptionViewItem viewOptions() const;
|
||||
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 resizeEvent(QResizeEvent* 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 setZoomLevel(int level);
|
||||
void slotEntered(const QModelIndex& index);
|
||||
void requestActivation();
|
||||
void updateFont();
|
||||
|
||||
/**
|
||||
* Moves the content of the columns view to represent
|
||||
* the scrollbar position \a x.
|
||||
*/
|
||||
void moveContentHorizontally(int x);
|
||||
|
||||
/**
|
||||
* 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(bool showPreview);
|
||||
|
||||
/**
|
||||
* Updates the background color of the columns to respect
|
||||
* the current activation state \a active.
|
||||
*/
|
||||
void updateColumnsBackground(bool active);
|
||||
|
||||
void slotSortingChanged(DolphinView::Sorting sorting);
|
||||
void slotSortOrderChanged(Qt::SortOrder order);
|
||||
void slotSortFoldersFirstChanged(bool foldersFirst);
|
||||
void slotShowHiddenFilesChanged();
|
||||
void slotShowPreviewChanged();
|
||||
|
||||
private:
|
||||
DolphinColumnWidget* activeColumn() const;
|
||||
/** Used by DolphinColumnView::setActive(). */
|
||||
void activate();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void setActiveColumnIndex(int index);
|
||||
/** Used by DolphinColumnView::setActive(). */
|
||||
void deactivate();
|
||||
|
||||
void layoutColumns();
|
||||
void updateScrollBar();
|
||||
|
||||
/**
|
||||
* Assures that the currently active column is fully visible
|
||||
* by adjusting the horizontal position of the content.
|
||||
*/
|
||||
void assureVisibleActiveColumn();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void requestActivation(DolphinColumnWidget* column);
|
||||
|
||||
/** Removes all columns except of the root column. */
|
||||
void removeAllColumns();
|
||||
|
||||
/**
|
||||
* Returns the position of the point \a point relative to the column
|
||||
* \a column.
|
||||
*/
|
||||
QPoint columnPosition(DolphinColumnWidget* column, const QPoint& point) const;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
void updateDecorationSize(bool showPreview);
|
||||
|
||||
private:
|
||||
DolphinController* m_controller;
|
||||
bool m_active;
|
||||
int m_index;
|
||||
int m_contentX;
|
||||
QList<DolphinColumnWidget*> m_columns;
|
||||
QFrame* m_emptyViewport;
|
||||
QTimeLine* m_animation;
|
||||
QString m_nameFilter;
|
||||
DolphinColumnViewContainer* m_container;
|
||||
SelectionManager* m_selectionManager;
|
||||
DolphinViewAutoScroller* m_autoScroller;
|
||||
KUrl m_url; // URL of the directory that is shown
|
||||
KUrl m_childUrl; // URL of the next column that is shown
|
||||
|
||||
friend class DolphinColumnWidget;
|
||||
QFont m_font;
|
||||
QSize m_decorationSize;
|
||||
|
||||
DolphinDirLister* m_dirLister;
|
||||
DolphinModel* m_dolphinModel;
|
||||
DolphinSortFilterProxyModel* m_proxyModel;
|
||||
|
||||
KFilePreviewGenerator* m_previewGenerator;
|
||||
|
||||
ToolTipManager* m_toolTipManager;
|
||||
|
||||
QRect m_dropRect;
|
||||
|
||||
friend class DolphinColumnViewContainer;
|
||||
};
|
||||
|
||||
inline DolphinColumnWidget* DolphinColumnView::activeColumn() const
|
||||
inline bool DolphinColumnView::isActive() const
|
||||
{
|
||||
return m_columns[m_index];
|
||||
return m_active;
|
||||
}
|
||||
|
||||
inline void DolphinColumnView::setChildUrl(const KUrl& url)
|
||||
{
|
||||
m_childUrl = url;
|
||||
}
|
||||
|
||||
inline const KUrl& DolphinColumnView::childUrl() const
|
||||
{
|
||||
return m_childUrl;
|
||||
}
|
||||
|
||||
inline void DolphinColumnView::setUrl(const KUrl& url)
|
||||
{
|
||||
if (url != m_url) {
|
||||
m_url = url;
|
||||
//reload();
|
||||
}
|
||||
}
|
||||
|
||||
inline const KUrl& DolphinColumnView::url() const
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
409
src/dolphincolumnviewcontainer.cpp
Normal file
409
src/dolphincolumnviewcontainer.cpp
Normal file
|
@ -0,0 +1,409 @@
|
|||
/***************************************************************************
|
||||
* 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 *
|
||||
* 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 *
|
||||
***************************************************************************/
|
||||
|
||||
#include "dolphincolumnviewcontainer.h"
|
||||
|
||||
#include "dolphincolumnview.h"
|
||||
#include "dolphincontroller.h"
|
||||
#include "dolphinsortfilterproxymodel.h"
|
||||
#include "settings/dolphinsettings.h"
|
||||
#include "zoomlevelinfo.h"
|
||||
|
||||
#include "dolphin_columnmodesettings.h"
|
||||
|
||||
#include <kfilepreviewgenerator.h>
|
||||
|
||||
#include <QPoint>
|
||||
#include <QScrollBar>
|
||||
#include <QTimeLine>
|
||||
|
||||
DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent, DolphinController* controller) :
|
||||
QScrollArea(parent),
|
||||
m_controller(controller),
|
||||
m_active(false),
|
||||
m_index(-1),
|
||||
m_contentX(0),
|
||||
m_columns(),
|
||||
m_emptyViewport(0),
|
||||
m_animation(0),
|
||||
m_nameFilter()
|
||||
{
|
||||
Q_ASSERT(controller != 0);
|
||||
|
||||
setAcceptDrops(true);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
setLayoutDirection(Qt::LeftToRight);
|
||||
|
||||
connect(this, SIGNAL(viewportEntered()),
|
||||
controller, SLOT(emitViewportEntered()));
|
||||
connect(controller, SIGNAL(zoomLevelChanged(int)),
|
||||
this, SLOT(setZoomLevel(int)));
|
||||
connect(controller, SIGNAL(activationChanged(bool)),
|
||||
this, SLOT(updateColumnsBackground(bool)));
|
||||
|
||||
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
|
||||
this, SLOT(moveContentHorizontally(int)));
|
||||
|
||||
m_animation = new QTimeLine(500, this);
|
||||
connect(m_animation, SIGNAL(frameChanged(int)), horizontalScrollBar(), SLOT(setValue(int)));
|
||||
|
||||
DolphinColumnView* column = new DolphinColumnView(viewport(), this, m_controller->url());
|
||||
m_columns.append(column);
|
||||
setActiveColumnIndex(0);
|
||||
|
||||
m_emptyViewport = new QFrame(viewport());
|
||||
m_emptyViewport->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
||||
|
||||
updateColumnsBackground(true);
|
||||
}
|
||||
|
||||
DolphinColumnViewContainer::~DolphinColumnViewContainer()
|
||||
{
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::setNameFilter(const QString& nameFilter)
|
||||
{
|
||||
if (nameFilter != m_nameFilter) {
|
||||
m_nameFilter = nameFilter;
|
||||
foreach (DolphinColumnView* column, m_columns) {
|
||||
DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(column->model());
|
||||
proxyModel->setFilterRegExp(nameFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString DolphinColumnViewContainer::nameFilter() const
|
||||
{
|
||||
return m_nameFilter;
|
||||
}
|
||||
|
||||
KUrl DolphinColumnViewContainer::rootUrl() const
|
||||
{
|
||||
return m_columns[0]->url();
|
||||
}
|
||||
|
||||
QAbstractItemView* DolphinColumnViewContainer::activeColumn() const
|
||||
{
|
||||
return m_columns[m_index];
|
||||
}
|
||||
|
||||
bool DolphinColumnViewContainer::showColumn(const KUrl& url)
|
||||
{
|
||||
if (!rootUrl().isParentOf(url)) {
|
||||
removeAllColumns();
|
||||
m_columns[0]->setUrl(url);
|
||||
return false;
|
||||
}
|
||||
|
||||
int columnIndex = 0;
|
||||
foreach (DolphinColumnView* column, m_columns) {
|
||||
if (column->url() == url) {
|
||||
// the column represents already the requested URL, hence activate it
|
||||
requestActivation(column);
|
||||
layoutColumns();
|
||||
return false;
|
||||
} else if (!column->url().isParentOf(url)) {
|
||||
// the column is no parent of the requested URL, hence
|
||||
// just delete all remaining columns
|
||||
if (columnIndex > 0) {
|
||||
QList<DolphinColumnView*>::iterator start = m_columns.begin() + columnIndex;
|
||||
QList<DolphinColumnView*>::iterator end = m_columns.end();
|
||||
for (QList<DolphinColumnView*>::iterator it = start; it != end; ++it) {
|
||||
deleteColumn(*it);
|
||||
}
|
||||
m_columns.erase(start, end);
|
||||
|
||||
const int maxIndex = m_columns.count() - 1;
|
||||
Q_ASSERT(maxIndex >= 0);
|
||||
if (m_index > maxIndex) {
|
||||
m_index = maxIndex;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
++columnIndex;
|
||||
}
|
||||
|
||||
// Create missing columns. Assuming that the path is "/home/peter/Temp/" and
|
||||
// the target path is "/home/peter/Temp/a/b/c/", then the columns "a", "b" and
|
||||
// "c" will be created.
|
||||
const int lastIndex = m_columns.count() - 1;
|
||||
Q_ASSERT(lastIndex >= 0);
|
||||
|
||||
const KUrl& activeUrl = m_columns[lastIndex]->url();
|
||||
Q_ASSERT(activeUrl.isParentOf(url));
|
||||
Q_ASSERT(activeUrl != url);
|
||||
|
||||
QString path = activeUrl.url(KUrl::AddTrailingSlash);
|
||||
const QString targetPath = url.url(KUrl::AddTrailingSlash);
|
||||
|
||||
columnIndex = lastIndex;
|
||||
int slashIndex = path.count('/');
|
||||
bool hasSubPath = (slashIndex >= 0);
|
||||
while (hasSubPath) {
|
||||
const QString subPath = targetPath.section('/', slashIndex, slashIndex);
|
||||
if (subPath.isEmpty()) {
|
||||
hasSubPath = false;
|
||||
} else {
|
||||
path += subPath + '/';
|
||||
++slashIndex;
|
||||
|
||||
const KUrl childUrl = KUrl(path);
|
||||
m_columns[columnIndex]->setChildUrl(childUrl);
|
||||
columnIndex++;
|
||||
|
||||
DolphinColumnView* column = new DolphinColumnView(viewport(), this, childUrl);
|
||||
if (!m_nameFilter.isEmpty()) {
|
||||
DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(column->model());
|
||||
proxyModel->setFilterRegExp(m_nameFilter);
|
||||
}
|
||||
column->setActive(false);
|
||||
|
||||
m_columns.append(column);
|
||||
|
||||
// Before invoking layoutColumns() the column must be set visible temporary.
|
||||
// To prevent a flickering the initial geometry is set to a hidden position.
|
||||
column->setGeometry(QRect(-1, -1, 1, 1));
|
||||
column->show();
|
||||
layoutColumns();
|
||||
updateScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
// set the last column as active column without modifying the controller
|
||||
// and hence the history
|
||||
m_columns[m_index]->setActive(false);
|
||||
m_index = columnIndex;
|
||||
m_columns[m_index]->setActive(true);
|
||||
assureVisibleActiveColumn();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
m_controller->requestActivation();
|
||||
QScrollArea::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QScrollArea::resizeEvent(event);
|
||||
layoutColumns();
|
||||
updateScrollBar();
|
||||
assureVisibleActiveColumn();
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
// let Ctrl+wheel events propagate to the DolphinView for icon zooming
|
||||
if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) {
|
||||
event->ignore();
|
||||
} else {
|
||||
QScrollArea::wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::setZoomLevel(int level)
|
||||
{
|
||||
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
|
||||
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
|
||||
|
||||
const bool showPreview = m_controller->dolphinView()->showPreview();
|
||||
if (showPreview) {
|
||||
settings->setPreviewSize(size);
|
||||
} else {
|
||||
settings->setIconSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::moveContentHorizontally(int x)
|
||||
{
|
||||
m_contentX = isRightToLeft() ? +x : -x;
|
||||
layoutColumns();
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::updateColumnsBackground(bool active)
|
||||
{
|
||||
if (active == m_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_active = active;
|
||||
|
||||
// dim the background of the viewport
|
||||
const QPalette::ColorRole role = viewport()->backgroundRole();
|
||||
QColor background = viewport()->palette().color(role);
|
||||
background.setAlpha(0); // make background transparent
|
||||
|
||||
QPalette palette = viewport()->palette();
|
||||
palette.setColor(role, background);
|
||||
viewport()->setPalette(palette);
|
||||
|
||||
foreach (DolphinColumnView* column, m_columns) {
|
||||
column->updateBackground();
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::setActiveColumnIndex(int index)
|
||||
{
|
||||
if (m_index == index) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool hasActiveColumn = (m_index >= 0);
|
||||
if (hasActiveColumn) {
|
||||
m_columns[m_index]->setActive(false);
|
||||
}
|
||||
|
||||
m_index = index;
|
||||
m_columns[m_index]->setActive(true);
|
||||
|
||||
assureVisibleActiveColumn();
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::layoutColumns()
|
||||
{
|
||||
const int gap = 4;
|
||||
|
||||
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
|
||||
const int columnWidth = settings->columnWidth();
|
||||
|
||||
QRect emptyViewportRect;
|
||||
if (isRightToLeft()) {
|
||||
int x = viewport()->width() - columnWidth + m_contentX;
|
||||
foreach (DolphinColumnView* column, m_columns) {
|
||||
column->setGeometry(QRect(x, 0, columnWidth - gap, viewport()->height()));
|
||||
x -= columnWidth;
|
||||
}
|
||||
emptyViewportRect = QRect(0, 0, x + columnWidth - gap, viewport()->height());
|
||||
} else {
|
||||
int x = m_contentX;
|
||||
foreach (DolphinColumnView* column, m_columns) {
|
||||
column->setGeometry(QRect(x, 0, columnWidth - gap, viewport()->height()));
|
||||
x += columnWidth;
|
||||
}
|
||||
emptyViewportRect = QRect(x, 0, viewport()->width() - x - gap, viewport()->height());
|
||||
}
|
||||
|
||||
if (emptyViewportRect.isValid()) {
|
||||
m_emptyViewport->show();
|
||||
m_emptyViewport->setGeometry(emptyViewportRect);
|
||||
} else {
|
||||
m_emptyViewport->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::updateScrollBar()
|
||||
{
|
||||
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
|
||||
const int contentWidth = m_columns.count() * settings->columnWidth();
|
||||
|
||||
horizontalScrollBar()->setPageStep(contentWidth);
|
||||
horizontalScrollBar()->setRange(0, contentWidth - viewport()->width());
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::assureVisibleActiveColumn()
|
||||
{
|
||||
const int viewportWidth = viewport()->width();
|
||||
const int x = activeColumn()->x();
|
||||
|
||||
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
|
||||
const int width = settings->columnWidth();
|
||||
|
||||
if (x + width > viewportWidth) {
|
||||
const int newContentX = m_contentX - x - width + viewportWidth;
|
||||
if (isRightToLeft()) {
|
||||
m_animation->setFrameRange(m_contentX, newContentX);
|
||||
} else {
|
||||
m_animation->setFrameRange(-m_contentX, -newContentX);
|
||||
}
|
||||
if (m_animation->state() != QTimeLine::Running) {
|
||||
m_animation->start();
|
||||
}
|
||||
} else if (x < 0) {
|
||||
const int newContentX = m_contentX - x;
|
||||
if (isRightToLeft()) {
|
||||
m_animation->setFrameRange(m_contentX, newContentX);
|
||||
} else {
|
||||
m_animation->setFrameRange(-m_contentX, -newContentX);
|
||||
}
|
||||
if (m_animation->state() != QTimeLine::Running) {
|
||||
m_animation->start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::requestActivation(DolphinColumnView* column)
|
||||
{
|
||||
m_controller->setItemView(column);
|
||||
if (column->isActive()) {
|
||||
assureVisibleActiveColumn();
|
||||
} else {
|
||||
int index = 0;
|
||||
foreach (DolphinColumnView* currColumn, m_columns) {
|
||||
if (currColumn == column) {
|
||||
setActiveColumnIndex(index);
|
||||
return;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::removeAllColumns()
|
||||
{
|
||||
QList<DolphinColumnView*>::iterator start = m_columns.begin() + 1;
|
||||
QList<DolphinColumnView*>::iterator end = m_columns.end();
|
||||
for (QList<DolphinColumnView*>::iterator it = start; it != end; ++it) {
|
||||
deleteColumn(*it);
|
||||
}
|
||||
m_columns.erase(start, end);
|
||||
m_index = 0;
|
||||
m_columns[0]->setActive(true);
|
||||
assureVisibleActiveColumn();
|
||||
}
|
||||
|
||||
QPoint DolphinColumnViewContainer::columnPosition(DolphinColumnView* column, const QPoint& point) const
|
||||
{
|
||||
const QPoint topLeft = column->frameGeometry().topLeft();
|
||||
return QPoint(point.x() - topLeft.x(), point.y() - topLeft.y());
|
||||
}
|
||||
|
||||
void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column)
|
||||
{
|
||||
if (column != 0) {
|
||||
if (m_controller->itemView() == column) {
|
||||
m_controller->setItemView(0);
|
||||
}
|
||||
// deleteWhenNotDragSource(column) does not necessarily delete column,
|
||||
// and we want its preview generator destroyed immediately.
|
||||
column->m_previewGenerator->deleteLater();
|
||||
column->m_previewGenerator = 0;
|
||||
column->hide();
|
||||
// Prevent automatic destruction of column when this DolphinColumnViewContainer
|
||||
// is destroyed.
|
||||
column->setParent(0);
|
||||
column->disconnect();
|
||||
emit requestColumnDeletion(column);
|
||||
}
|
||||
}
|
||||
|
||||
#include "dolphincolumnviewcontainer.moc"
|
152
src/dolphincolumnviewcontainer.h
Normal file
152
src/dolphincolumnviewcontainer.h
Normal file
|
@ -0,0 +1,152 @@
|
|||
/***************************************************************************
|
||||
* 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 *
|
||||
* 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 DOLPHINCOLUMNVIEWCONTAINER_H
|
||||
#define DOLPHINCOLUMNVIEWCONTAINER_H
|
||||
|
||||
#include "dolphinview.h"
|
||||
|
||||
#include <kurl.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QScrollArea>
|
||||
#include <QString>
|
||||
|
||||
class DolphinColumnView;
|
||||
class DolphinController;
|
||||
class QFrame;
|
||||
class QTimeLine;
|
||||
|
||||
/**
|
||||
* @brief Represents a container for columns represented as instances
|
||||
* of DolphinColumnView.
|
||||
*
|
||||
* @see DolphinColumnView
|
||||
*/
|
||||
class DolphinColumnViewContainer : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DolphinColumnViewContainer(QWidget* parent, DolphinController* controller);
|
||||
virtual ~DolphinColumnViewContainer();
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
KUrl rootUrl() const;
|
||||
|
||||
QAbstractItemView* activeColumn() const;
|
||||
|
||||
/**
|
||||
* Shows the column which represents the URL \a url. If the column
|
||||
* is already shown, it gets activated, otherwise it will be created.
|
||||
*/
|
||||
bool showColumn(const KUrl& url);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Requests that the given column be deleted at the discretion
|
||||
* of the receiver of the signal.
|
||||
*/
|
||||
void requestColumnDeletion(QAbstractItemView* column);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent* event);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void wheelEvent(QWheelEvent* event);
|
||||
|
||||
private slots:
|
||||
void setZoomLevel(int level);
|
||||
|
||||
/**
|
||||
* Moves the content of the columns view to represent
|
||||
* the scrollbar position \a x.
|
||||
*/
|
||||
void moveContentHorizontally(int x);
|
||||
|
||||
/**
|
||||
* Updates the background color of the columns to respect
|
||||
* the current activation state \a active.
|
||||
*/
|
||||
void updateColumnsBackground(bool active);
|
||||
|
||||
private:
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void setActiveColumnIndex(int index);
|
||||
|
||||
void layoutColumns();
|
||||
void updateScrollBar();
|
||||
|
||||
/**
|
||||
* Assures that the currently active column is fully visible
|
||||
* by adjusting the horizontal position of the content.
|
||||
*/
|
||||
void assureVisibleActiveColumn();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void requestActivation(DolphinColumnView* column);
|
||||
|
||||
/** Removes all columns except of the root column. */
|
||||
void removeAllColumns();
|
||||
|
||||
/**
|
||||
* Returns the position of the point \a point relative to the column
|
||||
* \a column.
|
||||
*/
|
||||
QPoint columnPosition(DolphinColumnView* column, const QPoint& point) const;
|
||||
|
||||
/**
|
||||
* Deletes the column. If the itemview of the controller is set to the column,
|
||||
* the controllers itemview is set to 0.
|
||||
*/
|
||||
void deleteColumn(DolphinColumnView* column);
|
||||
|
||||
private:
|
||||
DolphinController* m_controller;
|
||||
bool m_active;
|
||||
int m_index;
|
||||
int m_contentX;
|
||||
QList<DolphinColumnView*> m_columns;
|
||||
QFrame* m_emptyViewport;
|
||||
QTimeLine* m_animation;
|
||||
QString m_nameFilter;
|
||||
|
||||
friend class DolphinColumnView;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,3 +1,5 @@
|
|||
Don't compile
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
|
@ -49,6 +51,8 @@
|
|||
#include <QPoint>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
|
||||
DolphinColumnView* columnView,
|
||||
const KUrl& url) :
|
||||
|
@ -96,9 +100,6 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
|
|||
settings->italicFont());
|
||||
}
|
||||
|
||||
const int iconSize = settings->iconSize();
|
||||
setDecorationSize(QSize(iconSize, iconSize));
|
||||
|
||||
KFileItemDelegate* delegate = new KFileItemDelegate(this);
|
||||
delegate->setShowToolTipWhenElided(false);
|
||||
setItemDelegate(delegate);
|
||||
|
@ -110,6 +111,18 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
|
|||
connect(this, SIGNAL(entered(const QModelIndex&)),
|
||||
this, SLOT(slotEntered(const QModelIndex&)));
|
||||
|
||||
const DolphinView* dolphinView = m_view->m_controller->dolphinView();
|
||||
connect(dolphinView, SIGNAL(sortingChanged(DolphinView::Sorting)),
|
||||
this, SLOT(slotSortingChanged(DolphinView::Sorting)));
|
||||
connect(dolphinView, SIGNAL(sortOrderChanged(Qt::SortOrder)),
|
||||
this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
|
||||
connect(dolphinView, SIGNAL(sortFoldersFirstChanged(bool)),
|
||||
this, SLOT(slotSortFoldersFirstChanged(bool)));
|
||||
connect(dolphinView, SIGNAL(showHiddenFilesChanged()),
|
||||
this, SLOT(slotShowHiddenFilesChanged()));
|
||||
connect(dolphinView, SIGNAL(showPreviewChanged()),
|
||||
this, SLOT(slotShowPreviewChanged()));
|
||||
|
||||
m_dirLister = new DolphinDirLister();
|
||||
m_dirLister->setAutoUpdate(true);
|
||||
m_dirLister->setMainWindow(window());
|
||||
|
@ -124,7 +137,7 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
|
|||
m_proxyModel = new DolphinSortFilterProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_dolphinModel);
|
||||
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
const DolphinView* dolphinView = m_view->m_controller->dolphinView();
|
||||
|
||||
m_proxyModel->setSorting(dolphinView->sorting());
|
||||
m_proxyModel->setSortOrder(dolphinView->sortOrder());
|
||||
m_proxyModel->setSortFoldersFirst(dolphinView->sortFoldersFirst());
|
||||
|
@ -139,24 +152,26 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
|
|||
m_selectionManager, SLOT(reset()));
|
||||
}
|
||||
|
||||
m_previewGenerator = new KFilePreviewGenerator(this);
|
||||
m_previewGenerator->setPreviewShown(m_view->m_controller->dolphinView()->showPreview());
|
||||
//m_previewGenerator = new KFilePreviewGenerator(this);
|
||||
//m_previewGenerator->setPreviewShown(m_view->m_controller->dolphinView()->showPreview());
|
||||
|
||||
if (DolphinSettings::instance().generalSettings()->showToolTips()) {
|
||||
m_toolTipManager = new ToolTipManager(this, m_proxyModel);
|
||||
}
|
||||
//if (DolphinSettings::instance().generalSettings()->showToolTips()) {
|
||||
// m_toolTipManager = new ToolTipManager(this, m_proxyModel);
|
||||
//}
|
||||
|
||||
m_dirLister->openUrl(url, KDirLister::NoFlags);
|
||||
//m_dirLister->openUrl(url, KDirLister::NoFlags);
|
||||
|
||||
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
|
||||
this, SLOT(updateFont()));
|
||||
|
||||
FolderExpander* folderExpander = new FolderExpander(this, m_proxyModel);
|
||||
/*FolderExpander* folderExpander = new FolderExpander(this, m_proxyModel);
|
||||
folderExpander->setEnabled(DolphinSettings::instance().generalSettings()->autoExpandFolders());
|
||||
connect (folderExpander, SIGNAL(enterDir(const QModelIndex&)),
|
||||
m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
|
||||
|
||||
new VersionControlObserver(this);
|
||||
new VersionControlObserver(this);*/
|
||||
|
||||
updateDecorationSize(m_view->m_controller->dolphinView()->showPreview());
|
||||
}
|
||||
|
||||
DolphinColumnWidget::~DolphinColumnWidget()
|
||||
|
@ -168,19 +183,6 @@ DolphinColumnWidget::~DolphinColumnWidget()
|
|||
m_dirLister = 0; // deleted by m_dolphinModel
|
||||
}
|
||||
|
||||
void DolphinColumnWidget::setDecorationSize(const QSize& size)
|
||||
{
|
||||
setIconSize(size);
|
||||
m_decorationSize = size;
|
||||
doItemsLayout();
|
||||
if (m_previewGenerator != 0) {
|
||||
m_previewGenerator->updateIcons();
|
||||
}
|
||||
if (m_selectionManager != 0) {
|
||||
m_selectionManager->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinColumnWidget::setActive(bool active)
|
||||
{
|
||||
if (active && (m_view->focusProxy() != this)) {
|
||||
|
@ -198,13 +200,13 @@ void DolphinColumnWidget::setActive(bool active)
|
|||
}
|
||||
}
|
||||
|
||||
void DolphinColumnWidget::reload()
|
||||
/*void DolphinColumnWidget::reload()
|
||||
{
|
||||
m_dirLister->stop();
|
||||
m_dirLister->openUrl(m_url, KDirLister::Reload);
|
||||
}
|
||||
}*/
|
||||
|
||||
void DolphinColumnWidget::setSorting(DolphinView::Sorting sorting)
|
||||
/*void DolphinColumnWidget::setSorting(DolphinView::Sorting sorting)
|
||||
{
|
||||
m_proxyModel->setSorting(sorting);
|
||||
}
|
||||
|
@ -234,7 +236,7 @@ void DolphinColumnWidget::setShowPreview(bool show)
|
|||
|
||||
m_dirLister->stop();
|
||||
m_dirLister->openUrl(m_url, KDirLister::Reload);
|
||||
}
|
||||
}*/
|
||||
|
||||
void DolphinColumnWidget::updateBackground()
|
||||
{
|
||||
|
@ -487,8 +489,8 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const
|
|||
QListView::selectionChanged(selected, deselected);
|
||||
|
||||
QItemSelectionModel* selModel = m_view->selectionModel();
|
||||
selModel->select(selected, QItemSelectionModel::Select);
|
||||
selModel->select(deselected, QItemSelectionModel::Deselect);
|
||||
//selModel->select(selected, QItemSelectionModel::Select);
|
||||
//selModel->select(deselected, QItemSelectionModel::Deselect);
|
||||
}
|
||||
|
||||
void DolphinColumnWidget::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
|
@ -524,6 +526,13 @@ void DolphinColumnWidget::updateFont()
|
|||
}
|
||||
}
|
||||
|
||||
void DolphinColumnWidget::slotShowPreviewChanged()
|
||||
{
|
||||
kDebug() << "--- slotpreviewchanged";
|
||||
const DolphinView* view = m_view->m_controller->dolphinView();
|
||||
updateDecorationSize(view->showPreview());
|
||||
}
|
||||
|
||||
void DolphinColumnWidget::activate()
|
||||
{
|
||||
setFocus(Qt::OtherFocusReason);
|
||||
|
@ -560,4 +569,20 @@ void DolphinColumnWidget::deactivate()
|
|||
updateBackground();
|
||||
}
|
||||
|
||||
void DolphinColumnWidget::updateDecorationSize(bool showPreview)
|
||||
{
|
||||
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
|
||||
const int iconSize = showPreview ? settings->previewSize() : settings->iconSize();
|
||||
const QSize size(iconSize, iconSize);
|
||||
setIconSize(size);
|
||||
|
||||
m_decorationSize = size;
|
||||
|
||||
if (m_selectionManager != 0) {
|
||||
m_selectionManager->reset();
|
||||
}
|
||||
|
||||
doItemsLayout();
|
||||
}
|
||||
|
||||
#include "dolphincolumnwidget.moc"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Don't compile
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
|
@ -54,9 +56,6 @@ public:
|
|||
const KUrl& url);
|
||||
virtual ~DolphinColumnWidget();
|
||||
|
||||
/** 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
|
||||
|
@ -80,13 +79,13 @@ public:
|
|||
const KUrl& url() const;
|
||||
|
||||
/** Reloads the directory DolphinColumnWidget::url(). */
|
||||
void reload();
|
||||
//void reload();
|
||||
|
||||
void setSorting(DolphinView::Sorting sorting);
|
||||
/*void setSorting(DolphinView::Sorting sorting);
|
||||
void setSortOrder(Qt::SortOrder order);
|
||||
void setSortFoldersFirst(bool foldersFirst);
|
||||
void setShowHiddenFiles(bool show);
|
||||
void setShowPreview(bool show);
|
||||
void setShowPreview(bool show);*/
|
||||
|
||||
/**
|
||||
* Updates the background color dependent from the activation state
|
||||
|
@ -94,12 +93,6 @@ public:
|
|||
*/
|
||||
void updateBackground();
|
||||
|
||||
/**
|
||||
* Filters the currently shown items by \a nameFilter. All items
|
||||
* which contain the given filter string will be shown.
|
||||
*/
|
||||
void setNameFilter(const QString& nameFilter);
|
||||
|
||||
/**
|
||||
* Does an inline editing for the item \a item.
|
||||
*/
|
||||
|
@ -139,6 +132,8 @@ private slots:
|
|||
void requestActivation();
|
||||
void updateFont();
|
||||
|
||||
void slotShowPreviewChanged();
|
||||
|
||||
private:
|
||||
/** Used by DolphinColumnWidget::setActive(). */
|
||||
void activate();
|
||||
|
@ -146,6 +141,8 @@ private:
|
|||
/** Used by DolphinColumnWidget::setActive(). */
|
||||
void deactivate();
|
||||
|
||||
void updateDecorationSize(bool showPreview);
|
||||
|
||||
private:
|
||||
bool m_active;
|
||||
DolphinColumnView* m_view;
|
||||
|
@ -189,7 +186,7 @@ inline void DolphinColumnWidget::setUrl(const KUrl& url)
|
|||
{
|
||||
if (url != m_url) {
|
||||
m_url = url;
|
||||
reload();
|
||||
//reload();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -546,7 +546,6 @@ void DolphinDetailsView::setZoomLevel(int level)
|
|||
updateDecorationSize(showPreview);
|
||||
}
|
||||
|
||||
|
||||
void DolphinDetailsView::slotShowPreviewChanged()
|
||||
{
|
||||
const DolphinView* view = m_controller->dolphinView();
|
||||
|
|
|
@ -70,7 +70,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
|
|||
}
|
||||
m_dirLister->setDelayedMimeTypes(true);
|
||||
|
||||
//connect(m_dirLister, SIGNAL(started(KUrl)), this, SLOT(slotStarted()));
|
||||
connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted(KUrl)));
|
||||
connect(m_dirLister, SIGNAL(canceled(KUrl)), this, SLOT(slotCanceled(KUrl)));
|
||||
connect(m_dirLister, SIGNAL(percent(int)), this, SLOT(updateProgress(int)));
|
||||
|
@ -81,11 +80,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
|
|||
m_proxyModel = new DolphinSortFilterProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_dolphinModel);
|
||||
|
||||
m_view = new DolphinView(parentWidget,
|
||||
KUrl(),
|
||||
m_dirLister,
|
||||
m_dolphinModel,
|
||||
m_proxyModel);
|
||||
m_view = new DolphinView(parentWidget, KUrl(), m_proxyModel);
|
||||
m_view->setTabsForFilesEnabled(true);
|
||||
setWidget(m_view);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -42,7 +42,7 @@
|
|||
typedef KIO::FileUndoManager::CommandType CommandType;
|
||||
|
||||
class DolphinController;
|
||||
class DolphinColumnView;
|
||||
class DolphinColumnViewContainer;
|
||||
class DolphinDetailsView;
|
||||
class DolphinFileItemDelegate;
|
||||
class DolphinIconsView;
|
||||
|
@ -123,18 +123,12 @@ public:
|
|||
/**
|
||||
* @param parent Parent widget of the view.
|
||||
* @param url Specifies the content which should be shown.
|
||||
* @param dirLister Used directory lister. The lister is not owned
|
||||
* by the view and won't get deleted.
|
||||
* @param dolphinModel Used directory model. The model is not owned
|
||||
* by the view and won't get deleted.
|
||||
* @param proxyModel Used proxy model which specifies the sorting. The
|
||||
* model is not owned by the view and won't get
|
||||
* deleted.
|
||||
*/
|
||||
DolphinView(QWidget* parent,
|
||||
const KUrl& url,
|
||||
KDirLister* dirLister,
|
||||
DolphinModel* dolphinModel,
|
||||
DolphinSortFilterProxyModel* proxyModel);
|
||||
|
||||
virtual ~DolphinView();
|
||||
|
@ -713,20 +707,11 @@ private slots:
|
|||
private:
|
||||
void loadDirectory(const KUrl& url, bool reload = false);
|
||||
|
||||
/**
|
||||
* Returns the URL where the view properties should be stored. Usually
|
||||
* DolphinView::url() is returned, but in the case of a Column View the
|
||||
* view properties are always stored in the directory represented by the
|
||||
* first column. It is recommendend whenever using the ViewProperties class
|
||||
* to use DolphinView::viewPropertiesUrl() as URL.
|
||||
*/
|
||||
KUrl viewPropertiesUrl() const;
|
||||
|
||||
/**
|
||||
* Applies the view properties which are defined by the current URL
|
||||
* m_url to the DolphinView properties.
|
||||
* to the DolphinView properties.
|
||||
*/
|
||||
void applyViewProperties(const KUrl& url);
|
||||
void applyViewProperties();
|
||||
|
||||
/**
|
||||
* Creates a new view representing the given view mode (DolphinView::mode()).
|
||||
|
@ -736,11 +721,7 @@ private:
|
|||
|
||||
void deleteView();
|
||||
|
||||
/**
|
||||
* Returns a pointer to the currently used item view, which is either
|
||||
* a ListView or a TreeView.
|
||||
*/
|
||||
QAbstractItemView* itemView() const;
|
||||
void initializeView();
|
||||
|
||||
/**
|
||||
* Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
|
||||
|
@ -763,13 +744,6 @@ private:
|
|||
*/
|
||||
KUrl::List simplifiedSelectedUrls() const;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Returns the MIME data for all selected items.
|
||||
*/
|
||||
|
@ -784,6 +758,53 @@ private:
|
|||
void addNewFileNames(const QMimeData* mimeData);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Abstracts the access to the different view implementations
|
||||
* for icons-, details- and column-view.
|
||||
*/
|
||||
class ViewAccessor
|
||||
{
|
||||
public:
|
||||
ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
|
||||
|
||||
void createView(QWidget* parent, DolphinController* controller, Mode mode);
|
||||
void deleteView();
|
||||
bool prepareUrlChange(const KUrl& url);
|
||||
QAbstractItemView* itemView() const;
|
||||
|
||||
/**
|
||||
* Returns the widget that should be added to the layout as target. Usually
|
||||
* the item view itself is returned, but in the case of the column view
|
||||
* a container widget is returned.
|
||||
*/
|
||||
QWidget* layoutTarget() const;
|
||||
|
||||
void setNameFilter(const QString& nameFilter);
|
||||
|
||||
KUrl rootUrl() const;
|
||||
|
||||
bool supportsCategorizedSorting() const;
|
||||
bool hasExpandableFolders() const;
|
||||
bool itemsExpandable() const;
|
||||
|
||||
/**
|
||||
* Returns true, if a reloading of the items is required
|
||||
* when the additional information properties have been changed
|
||||
* by the user.
|
||||
*/
|
||||
bool reloadOnAdditionalInfoChange() const;
|
||||
|
||||
DolphinModel* dirModel() const;
|
||||
DolphinSortFilterProxyModel* proxyModel() const;
|
||||
KDirLister* dirLister() const;
|
||||
|
||||
private:
|
||||
DolphinIconsView* m_iconsView;
|
||||
DolphinDetailsView* m_detailsView;
|
||||
DolphinColumnViewContainer* m_columnsContainer;
|
||||
DolphinSortFilterProxyModel* m_proxyModel;
|
||||
};
|
||||
|
||||
bool m_active : 1;
|
||||
bool m_showPreview : 1;
|
||||
bool m_loadingDirectory : 1;
|
||||
|
@ -799,18 +820,12 @@ private:
|
|||
QVBoxLayout* m_topLayout;
|
||||
|
||||
DolphinController* m_controller;
|
||||
DolphinIconsView* m_iconsView;
|
||||
DolphinDetailsView* m_detailsView;
|
||||
DolphinColumnView* m_columnView;
|
||||
DolphinFileItemDelegate* m_fileItemDelegate;
|
||||
ViewAccessor m_viewAccessor;
|
||||
|
||||
QItemSelectionModel* m_selectionModel;
|
||||
QTimer* m_selectionChangedTimer;
|
||||
|
||||
DolphinModel* m_dolphinModel;
|
||||
KDirLister* m_dirLister;
|
||||
DolphinSortFilterProxyModel* m_proxyModel;
|
||||
|
||||
KFilePreviewGenerator* m_previewGenerator;
|
||||
ToolTipManager* m_toolTipManager;
|
||||
|
||||
|
@ -828,14 +843,9 @@ private:
|
|||
*/
|
||||
QSet<QString> m_newFileNames;
|
||||
|
||||
QAbstractItemView* m_expandedDragSource;
|
||||
QAbstractItemView* m_expandedDragSource; // TODO: move to ViewAccessor
|
||||
};
|
||||
|
||||
inline bool DolphinView::isColumnViewActive() const
|
||||
{
|
||||
return m_columnView != 0;
|
||||
}
|
||||
|
||||
/// Allow using DolphinView::Mode in QVariant
|
||||
Q_DECLARE_METATYPE(DolphinView::Mode)
|
||||
|
||||
|
|
|
@ -128,11 +128,7 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
|
|||
connect(m_dirLister, SIGNAL(urlIsFileError(const KUrl&)),
|
||||
this, SLOT(openFile(const KUrl&)));
|
||||
|
||||
m_view = new DolphinView(this,
|
||||
url,
|
||||
m_dirLister,
|
||||
m_dolphinModel,
|
||||
m_proxyModel);
|
||||
m_view = new DolphinView(this, url, m_proxyModel);
|
||||
connect(m_view, SIGNAL(urlChanged(const KUrl&)),
|
||||
m_urlNavigator, SLOT(setUrl(const KUrl&)));
|
||||
connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)),
|
||||
|
|
Loading…
Reference in a new issue