┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphiniconsview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-02-21 11:56:31 +0000
committerPeter Penz <[email protected]>2008-02-21 11:56:31 +0000
commite287058acb772b55b679a694062361d3fb0e8f89 (patch)
tree624ba47b804fbddecd0e3d52a992a0f58223ee58 /src/dolphiniconsview.cpp
parentc73591380173b52504aaceb74314f617b2e04f6c (diff)
Prevent code duplication by moving the duplications into the DolphinController.
Maybe it might be a good idea to let the DolphinController be aware also about his QAbstractItemView -> it might be possible to directly connect signals of the dolphin view implementations with the controller. I'll check this... (I did not backport this cleanup as I think it has too many changes to be handled as bugfix) CCMAIL: [email protected] CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=777719
Diffstat (limited to 'src/dolphiniconsview.cpp')
-rw-r--r--src/dolphiniconsview.cpp34
1 files changed, 6 insertions, 28 deletions
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index b1ffd401c..f51671e8a 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -244,7 +244,7 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
m_dropRect.setSize(QSize()); // set as invalid
if (index.isValid()) {
- const KFileItem item = itemForIndex(index);
+ const KFileItem item = m_controller->itemForIndex(index, this);
if (!item.isNull() && item.isDir()) {
m_dropRect = visualRect(index);
} else {
@@ -265,7 +265,7 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty()) {
const QModelIndex index = indexAt(event->pos());
- const KFileItem item = itemForIndex(index);
+ const KFileItem item = m_controller->itemForIndex(index, this);
m_controller->indicateDroppedUrls(urls,
m_controller->url(),
item);
@@ -292,21 +292,7 @@ void DolphinIconsView::paintEvent(QPaintEvent* event)
void DolphinIconsView::keyPressEvent(QKeyEvent* event)
{
KCategorizedView::keyPressEvent(event);
-
- const QItemSelectionModel* selModel = selectionModel();
- const QModelIndex currentIndex = selModel->currentIndex();
- const bool trigger = currentIndex.isValid()
- && (event->key() == Qt::Key_Return)
- && (selModel->selectedIndexes().count() > 0);
- if(trigger) {
- const QModelIndexList indexList = selModel->selectedIndexes();
- foreach (const QModelIndex &index, indexList) {
- KFileItem item = itemForIndex(index);
- if (!item.isNull()) {
- triggerItem(index);
- }
- }
- }
+ m_controller->handleKeyPressEvent(event, this);
}
void DolphinIconsView::wheelEvent(QWheelEvent* event)
@@ -314,7 +300,7 @@ void DolphinIconsView::wheelEvent(QWheelEvent* event)
// let Ctrl+wheel events propagate to the DolphinView for icon zooming
if ((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) {
event->ignore();
- return;
+ return;
}
KCategorizedView::wheelEvent(event);
// if the icons are aligned left to right, the vertical wheel event should
@@ -334,12 +320,12 @@ void DolphinIconsView::wheelEvent(QWheelEvent* event)
void DolphinIconsView::triggerItem(const QModelIndex& index)
{
- m_controller->triggerItem(itemForIndex(index));
+ m_controller->triggerItem(index, this);
}
void DolphinIconsView::slotEntered(const QModelIndex& index)
{
- m_controller->emitItemEntered(itemForIndex(index));
+ m_controller->emitItemEntered(index, this);
}
void DolphinIconsView::slotShowPreviewChanged()
@@ -516,14 +502,6 @@ void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
m_controller->setZoomOutPossible(isZoomOutPossible());
}
-KFileItem DolphinIconsView::itemForIndex(const QModelIndex& index) const
-{
- QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(model());
- KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
- const QModelIndex dirIndex = proxyModel->mapToSource(index);
- return dirModel->itemForIndex(dirIndex);
-}
-
int DolphinIconsView::additionalInfoCount() const
{
const DolphinView* view = m_controller->dolphinView();