┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-09-14 22:08:34 +0000
committerPeter Penz <[email protected]>2007-09-14 22:08:34 +0000
commitc1ad266e93a48f8d41d12db703645f78ea3ab731 (patch)
tree37ec10e0b4b73ee4d50ff411a64ccc10aa8bf30d /src
parent26b2ce327f715c805f6cf524d041b30866e41538 (diff)
selection model fixes
svn path=/trunk/KDE/kdebase/apps/; revision=712610
Diffstat (limited to 'src')
-rw-r--r--src/dolphincolumnview.cpp69
1 files changed, 47 insertions, 22 deletions
diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp
index 931cb9eab..b5afa9d08 100644
--- a/src/dolphincolumnview.cpp
+++ b/src/dolphincolumnview.cpp
@@ -80,6 +80,7 @@ protected:
virtual void paintEvent(QPaintEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void contextMenuEvent(QContextMenuEvent* event);
+ virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
private:
/** Used by ColumnWidget::setActive(). */
@@ -134,6 +135,11 @@ ColumnWidget::ColumnWidget(QWidget* parent,
setItemDelegate(delegate);
activate();
+
+ connect(this, SIGNAL(entered(const QModelIndex&)),
+ m_view->m_controller, SLOT(emitItemEntered(const QModelIndex&)));
+ connect(this, SIGNAL(viewportEntered()),
+ m_view->m_controller, SLOT(emitViewportEntered()));
}
ColumnWidget::~ColumnWidget()
@@ -286,8 +292,26 @@ void ColumnWidget::contextMenuEvent(QContextMenuEvent* event)
}
}
+void ColumnWidget::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
+{
+ QItemSelectionModel* selModel = m_view->selectionModel();
+ selModel->select(selected, QItemSelectionModel::Select);
+ selModel->select(deselected, QItemSelectionModel::Deselect);
+}
+
void ColumnWidget::activate()
{
+ // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
+ // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
+ // necessary connecting the signal 'singleClick()' or 'doubleClick'.
+ if (KGlobalSettings::singleClick()) {
+ connect(this, SIGNAL(clicked(const QModelIndex&)),
+ m_view, SLOT(triggerItem(const QModelIndex&)));
+ } else {
+ connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
+ m_view, SLOT(triggerItem(const QModelIndex&)));
+ }
+
const QColor bgColor = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
QPalette palette = viewport()->palette();
palette.setColor(viewport()->backgroundRole(), bgColor);
@@ -298,6 +322,17 @@ void ColumnWidget::activate()
void ColumnWidget::deactivate()
{
+ // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
+ // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
+ // necessary connecting the signal 'singleClick()' or 'doubleClick'.
+ if (KGlobalSettings::singleClick()) {
+ disconnect(this, SIGNAL(clicked(const QModelIndex&)),
+ m_view, SLOT(triggerItem(const QModelIndex&)));
+ } else {
+ disconnect(this, SIGNAL(doubleClicked(const QModelIndex&)),
+ m_view, SLOT(triggerItem(const QModelIndex&)));
+ }
+
QColor bgColor = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
const QColor fgColor = KColorScheme(QPalette::Active, KColorScheme::View).foreground().color();
bgColor = KColorUtils::mix(bgColor, fgColor, 0.04);
@@ -358,7 +393,17 @@ DolphinColumnView::~DolphinColumnView()
QModelIndex DolphinColumnView::indexAt(const QPoint& point) const
{
+ foreach (ColumnWidget* column, m_columns) {
+ const QPoint topLeft = column->frameGeometry().topLeft();
+ const QPoint adjustedPoint(point.x() - topLeft.x(), point.y() - topLeft.y());
+ QModelIndex index = column->indexAt(adjustedPoint);
+ if (index.isValid()) {
+ return index;
+ }
+ }
return activeColumn()->indexAt(point);
+
+ return QModelIndex();
}
void DolphinColumnView::scrollTo(const QModelIndex& index, ScrollHint hint)
@@ -586,28 +631,8 @@ void DolphinColumnView::setActiveColumnIndex(int index)
m_columns[m_index]->setActive(false);
}
- // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
- // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
- // necessary connecting the signal 'singleClick()' or 'doubleClick'.
- if (KGlobalSettings::singleClick()) {
- if (hasActiveColumn) {
- disconnect(m_columns[m_index], SIGNAL(clicked(const QModelIndex&)),
- this, SLOT(triggerItem(const QModelIndex&)));
- }
- m_index = index;
- m_columns[m_index]->setActive(true);
- connect(m_columns[m_index], SIGNAL(clicked(const QModelIndex&)),
- this, SLOT(triggerItem(const QModelIndex&)));
- } else {
- if (hasActiveColumn) {
- disconnect(m_columns[m_index], SIGNAL(doubleClicked(const QModelIndex&)),
- this, SLOT(triggerItem(const QModelIndex&)));
- }
- m_index = index;
- m_columns[m_index]->setActive(true);
- connect(m_columns[m_index], SIGNAL(doubleClicked(const QModelIndex&)),
- this, SLOT(triggerItem(const QModelIndex&)));
- }
+ m_index = index;
+ m_columns[m_index]->setActive(true);
}
void DolphinColumnView::layoutColumns()