/***************************************************************************
- * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
+ * Copyright (C) 2006-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 *
#include "dolphincategorydrawer.h"
#include "dolphincontroller.h"
#include "settings/dolphinsettings.h"
-#include "dolphinviewautoscroller.h"
+#include "dolphinsortfilterproxymodel.h"
#include "dolphin_iconsmodesettings.h"
#include "dolphin_generalsettings.h"
#include "draganddrophelper.h"
#include "selectionmanager.h"
+#include "viewextensionsfactory.h"
#include "zoomlevelinfo.h"
#include <kcategorizedsortfilterproxymodel.h>
#include <kdialog.h>
-#include <kdirmodel.h>
#include <kfileitemdelegate.h>
#include <QAbstractProxyModel>
#include <QApplication>
#include <QScrollBar>
-DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
+DolphinIconsView::DolphinIconsView(QWidget* parent,
+ DolphinController* controller,
+ DolphinSortFilterProxyModel* proxyModel) :
KCategorizedView(parent),
m_controller(controller),
- m_selectionManager(0),
- m_autoScroller(0),
m_categoryDrawer(0),
+ m_extensionsFactory(0),
m_font(),
m_decorationSize(),
m_decorationPosition(QStyleOptionViewItem::Top),
m_dropRect()
{
Q_ASSERT(controller != 0);
+ setModel(proxyModel);
setLayoutDirection(Qt::LeftToRight);
setViewMode(QListView::IconMode);
setResizeMode(QListView::Adjust);
viewport()->setAcceptDrops(true);
setMouseTracking(true);
- m_autoScroller = new DolphinViewAutoScroller(this);
connect(this, SIGNAL(clicked(const QModelIndex&)),
controller, SLOT(requestTab(const QModelIndex&)));
controller, SLOT(triggerItem(const QModelIndex&)));
}
- if (DolphinSettings::instance().generalSettings()->showSelectionToggle()) {
- m_selectionManager = new SelectionManager(this);
- connect(m_selectionManager, SIGNAL(selectionChanged()),
- this, SLOT(requestActivation()));
- connect(m_controller, SIGNAL(urlChanged(const KUrl&)),
- m_selectionManager, SLOT(reset()));
- }
-
connect(this, SIGNAL(entered(const QModelIndex&)),
controller, SLOT(emitItemEntered(const QModelIndex&)));
connect(this, SIGNAL(viewportEntered()),
}
setWordWrap(settings->numberOfTextlines() > 1);
- updateGridSize(view->showPreview(), 0);
if (settings->arrangement() == QListView::TopToBottom) {
setFlow(QListView::LeftToRight);
connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
this, SLOT(slotGlobalSettingsChanged(int)));
+
+ updateGridSize(view->showPreview(), 0);
+ m_extensionsFactory = new ViewExtensionsFactory(this, controller);
}
DolphinIconsView::~DolphinIconsView()
{
QStyleOptionViewItem viewOptions = KCategorizedView::viewOptions();
viewOptions.font = m_font;
+ viewOptions.fontMetrics = QFontMetrics(m_font);
viewOptions.decorationPosition = m_decorationPosition;
viewOptions.decorationSize = m_decorationSize;
viewOptions.displayAlignment = m_displayAlignment;
void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
{
- Q_UNUSED(event);
+ KCategorizedView::dragLeaveEvent(event);
setDirtyRegion(m_dropRect);
}
void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
{
+ KCategorizedView::dragMoveEvent(event);
+
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
setDirtyRegion(m_dropRect);
const QModelIndex index = indexAt(event->pos());
const KFileItem item = m_controller->itemForIndex(index);
m_controller->indicateDroppedUrls(item, m_controller->url(), event);
+ // don't call KCategorizedView::dropEvent(event), as it moves
+ // the items which is not wanted
}
QModelIndex DolphinIconsView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
void DolphinIconsView::wheelEvent(QWheelEvent* event)
{
- if (m_selectionManager != 0) {
- m_selectionManager->reset();
- }
-
- // let Ctrl+wheel events propagate to the DolphinView for icon zooming
- if (event->modifiers() & Qt::ControlModifier) {
- event->ignore();
- return;
- }
-
- horizontalScrollBar()->setSingleStep(m_itemSize.width() / 10);
- verticalScrollBar()->setSingleStep(m_itemSize.height() / 10);
+ horizontalScrollBar()->setSingleStep(m_itemSize.width() / 5);
+ verticalScrollBar()->setSingleStep(m_itemSize.height() / 5);
KCategorizedView::wheelEvent(event);
// if the icons are aligned left to right, the vertical wheel event should
void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
KCategorizedView::currentChanged(current, previous);
- m_autoScroller->handleCurrentIndexChange(current, previous);
+ m_extensionsFactory->handleCurrentIndexChange(current, previous);
}
void DolphinIconsView::resizeEvent(QResizeEvent* event)
if (delegate != 0) {
delegate->setMaximumSize(m_itemSize);
}
-
- if (m_selectionManager != 0) {
- m_selectionManager->reset();
- }
}
int DolphinIconsView::additionalInfoCount() const