diff options
| author | Peter Penz <[email protected]> | 2008-02-21 11:56:31 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2008-02-21 11:56:31 +0000 |
| commit | e287058acb772b55b679a694062361d3fb0e8f89 (patch) | |
| tree | 624ba47b804fbddecd0e3d52a992a0f58223ee58 /src/dolphindetailsview.cpp | |
| parent | c73591380173b52504aaceb74314f617b2e04f6c (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/dolphindetailsview.cpp')
| -rw-r--r-- | src/dolphindetailsview.cpp | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 3f23795ba..f364900b6 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -310,7 +310,7 @@ void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event) m_dragging = false; } else { m_dragging = true; - const KFileItem item = itemForIndex(index); + const KFileItem item = m_controller->itemForIndex(index, this); if (!item.isNull() && item.isDir()) { m_dropRect = visualRect(index); } else { @@ -333,7 +333,7 @@ void DolphinDetailsView::dropEvent(QDropEvent* event) const QModelIndex index = indexAt(event->pos()); KFileItem item; if (index.isValid() && (index.column() == DolphinModel::Name)) { - item = itemForIndex(index); + item = m_controller->itemForIndex(index, this); } m_controller->indicateDroppedUrls(urls, m_controller->url(), @@ -372,21 +372,7 @@ void DolphinDetailsView::paintEvent(QPaintEvent* event) void DolphinDetailsView::keyPressEvent(QKeyEvent* event) { QTreeView::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 DolphinDetailsView::resizeEvent(QResizeEvent* event) @@ -434,7 +420,7 @@ void DolphinDetailsView::slotEntered(const QModelIndex& index) const QPoint pos = viewport()->mapFromGlobal(QCursor::pos()); const int nameColumnWidth = header()->sectionSize(DolphinModel::Name); if (pos.x() < nameColumnWidth) { - m_controller->emitItemEntered(itemForIndex(index)); + m_controller->emitItemEntered(index, this); } else { m_controller->emitViewportEntered(); @@ -486,13 +472,7 @@ void DolphinDetailsView::zoomOut() void DolphinDetailsView::triggerItem(const QModelIndex& index) { - const KFileItem item = itemForIndex(index); - if (index.isValid() && (index.column() == KDirModel::Name)) { - m_controller->triggerItem(item); - } else { - clearSelection(); - m_controller->emitItemEntered(item); - } + m_controller->triggerItem(index, this); } void DolphinDetailsView::configureColumns(const QPoint& pos) @@ -618,14 +598,6 @@ QPoint DolphinDetailsView::contentsPos() const return QPoint(0, y); } -KFileItem DolphinDetailsView::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); -} - KFileItemDelegate::Information DolphinDetailsView::infoForColumn(int columnIndex) const { KFileItemDelegate::Information info = KFileItemDelegate::NoInformation; |
