#include "dolphin_detailsmodesettings.h"
+#include <kdirmodel.h>
#include <klocale.h>
#include <kmenu.h>
+#include <QAbstractProxyModel>
#include <QAction>
#include <QApplication>
#include <QHeaderView>
// RETURN-key in keyPressEvent().
if (KGlobalSettings::singleClick()) {
connect(this, SIGNAL(clicked(const QModelIndex&)),
- this, SLOT(slotItemActivated(const QModelIndex&)));
+ this, SLOT(triggerItem(const QModelIndex&)));
} else {
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
- this, SLOT(slotItemActivated(const QModelIndex&)));
+ this, SLOT(triggerItem(const QModelIndex&)));
}
connect(this, SIGNAL(entered(const QModelIndex&)),
this, SLOT(slotEntered(const QModelIndex&)));
// check avoids a division by zero happening on versions before 4.3.1.
// Right now KDE in theory can be shipped with Qt 4.3.0 and above.
// ereslibre
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2))
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2) || defined(QT_KDE_QT_COPY))
setVerticalScrollMode(QTreeView::ScrollPerPixel);
setHorizontalScrollMode(QTreeView::ScrollPerPixel);
#endif
updateDecorationSize();
+
+ setFocus();
}
DolphinDetailsView::~DolphinDetailsView()
// check avoids a division by zero happening on versions before 4.3.1.
// Right now KDE in theory can be shipped with Qt 4.3.0 and above.
// ereslibre
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2))
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2) || defined(QT_KDE_QT_COPY))
else if (event->type() == QEvent::UpdateRequest) {
// a wheel movement will scroll 4 items
if (model()->rowCount() > 0) {
void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
{
- m_controller->triggerActivation();
+ m_controller->requestActivation();
QTreeView::mousePressEvent(event);
const QItemSelectionModel* selModel = selectionModel();
const QModelIndex currentIndex = selModel->currentIndex();
- const bool triggerItem = currentIndex.isValid()
- && (event->key() == Qt::Key_Return)
- && (selModel->selectedIndexes().count() <= 1);
- if (triggerItem) {
- m_controller->triggerItem(currentIndex);
+ const bool trigger = currentIndex.isValid()
+ && (event->key() == Qt::Key_Return)
+ && (selModel->selectedIndexes().count() <= 1);
+ if (trigger) {
+ triggerItem(currentIndex);
}
}
const QPoint pos = viewport()->mapFromGlobal(QCursor::pos());
const int nameColumnWidth = header()->sectionSize(DolphinModel::Name);
if (pos.x() < nameColumnWidth) {
- m_controller->emitItemEntered(index);
+ m_controller->emitItemEntered(itemForIndex(index));
}
else {
m_controller->emitViewportEntered();
setDirtyRegion(dirtyRegion);
}
+QRect DolphinDetailsView::elasticBandRect() const
+{
+ const QPoint pos(contentsPos());
+ const QPoint topLeft(m_elasticBandOrigin.x() - pos.x(), m_elasticBandOrigin.y() - pos.y());
+ return QRect(topLeft, m_elasticBandDestination).normalized();
+}
+
void DolphinDetailsView::zoomIn()
{
if (isZoomInPossible()) {
}
}
-void DolphinDetailsView::slotItemActivated(const QModelIndex& index)
+void DolphinDetailsView::triggerItem(const QModelIndex& index)
{
+ const KFileItem item = itemForIndex(index);
if (index.isValid() && (index.column() == KDirModel::Name)) {
- m_controller->triggerItem(index);
+ m_controller->triggerItem(item);
} else {
clearSelection();
- m_controller->emitItemEntered(index);
+ m_controller->emitItemEntered(item);
}
}
return QPoint(0, y);
}
-QRect DolphinDetailsView::elasticBandRect() const
-{
- const QPoint pos(contentsPos());
- const QPoint topLeft(m_elasticBandOrigin.x() - pos.x(), m_elasticBandOrigin.y() - pos.y());
- return QRect(topLeft, m_elasticBandDestination).normalized();
-}
-
-static bool isValidNameIndex(const QModelIndex& index)
+KFileItem DolphinDetailsView::itemForIndex(const QModelIndex& index) const
{
- return index.isValid() && (index.column() == KDirModel::Name);
+ QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(model());
+ KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
+ const QModelIndex dirIndex = proxyModel->mapToSource(index);
+ return dirModel->itemForIndex(dirIndex);
}
#include "dolphindetailsview.moc"