┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphincontroller.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-02-21 12:49:11 +0000
committerPeter Penz <[email protected]>2008-02-21 12:49:11 +0000
commit188754a3e5b298683b88fbe6786c524c172ed6a9 (patch)
treed17b3f04bf2fe17c380862ec3f9b28f090ca9cd2 /src/dolphincontroller.cpp
parente287058acb772b55b679a694062361d3fb0e8f89 (diff)
Let the DolphinController be aware on which QAbstractItemView instance he is working. This allows to connect signals from the view implementations (icons view, details view, column view) directly to the slots of the DolphinController without a helper slot.
svn path=/trunk/KDE/kdebase/apps/; revision=777737
Diffstat (limited to 'src/dolphincontroller.cpp')
-rw-r--r--src/dolphincontroller.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp
index 1bd59fffa..a0aa1d895 100644
--- a/src/dolphincontroller.cpp
+++ b/src/dolphincontroller.cpp
@@ -27,7 +27,8 @@ DolphinController::DolphinController(DolphinView* dolphinView) :
m_zoomInPossible(false),
m_zoomOutPossible(false),
m_url(),
- m_dolphinView(dolphinView)
+ m_dolphinView(dolphinView),
+ m_itemView(0)
{
}
@@ -43,6 +44,11 @@ void DolphinController::setUrl(const KUrl& url)
}
}
+void DolphinController::setItemView(QAbstractItemView* view)
+{
+ m_itemView = view;
+}
+
void DolphinController::triggerUrlChangeRequest(const KUrl& url)
{
if (m_url != url) {
@@ -99,9 +105,11 @@ void DolphinController::triggerZoomOut()
emit zoomOut();
}
-void DolphinController::handleKeyPressEvent(QKeyEvent* event, QAbstractItemView* view)
+void DolphinController::handleKeyPressEvent(QKeyEvent* event)
{
- const QItemSelectionModel* selModel = view->selectionModel();
+ Q_ASSERT(m_itemView != 0);
+
+ const QItemSelectionModel* selModel = m_itemView->selectionModel();
const QModelIndex currentIndex = selModel->currentIndex();
const bool trigger = currentIndex.isValid()
&& (event->key() == Qt::Key_Return)
@@ -109,33 +117,35 @@ void DolphinController::handleKeyPressEvent(QKeyEvent* event, QAbstractItemView*
if (trigger) {
const QModelIndexList indexList = selModel->selectedIndexes();
foreach (const QModelIndex& index, indexList) {
- triggerItem(index, view);
+ triggerItem(index);
}
}
}
-KFileItem DolphinController::itemForIndex(const QModelIndex& index, QAbstractItemView* view) const
+KFileItem DolphinController::itemForIndex(const QModelIndex& index) const
{
- QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(view->model());
+ Q_ASSERT(m_itemView != 0);
+
+ QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(m_itemView->model());
KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
const QModelIndex dirIndex = proxyModel->mapToSource(index);
return dirModel->itemForIndex(dirIndex);
}
-void DolphinController::triggerItem(const QModelIndex& index, QAbstractItemView* view)
+void DolphinController::triggerItem(const QModelIndex& index)
{
- const KFileItem item = itemForIndex(index, view);
+ const KFileItem item = itemForIndex(index);
if (index.isValid() && (index.column() == KDirModel::Name)) {
emit itemTriggered(item);
} else {
- view->clearSelection();
+ m_itemView->clearSelection();
emit itemEntered(item);
}
}
-void DolphinController::emitItemEntered(const QModelIndex& index, QAbstractItemView* view)
+void DolphinController::emitItemEntered(const QModelIndex& index)
{
- KFileItem item = itemForIndex(index, view);
+ KFileItem item = itemForIndex(index);
if (!item.isNull()) {
emit itemEntered(item);
}