┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dolphincolumnview.cpp66
-rw-r--r--src/dolphincolumnview.h19
-rw-r--r--src/dolphincolumnwidget.cpp10
-rw-r--r--src/dolphincontroller.cpp4
-rw-r--r--src/dolphincontroller.h10
-rw-r--r--src/dolphindetailsview.cpp21
-rw-r--r--src/dolphindetailsview.h2
-rw-r--r--src/dolphiniconsview.cpp35
-rw-r--r--src/dolphiniconsview.h5
-rw-r--r--src/dolphinview.cpp25
-rw-r--r--src/dolphinview.h4
11 files changed, 105 insertions, 96 deletions
diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp
index b8be24bf0..5af15c56b 100644
--- a/src/dolphincolumnview.cpp
+++ b/src/dolphincolumnview.cpp
@@ -47,9 +47,7 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
m_index(-1),
m_contentX(0),
m_columns(),
- m_animation(0),
- m_dolphinModel(0),
- m_proxyModel(0)
+ m_animation(0)
{
Q_ASSERT(controller != 0);
@@ -66,8 +64,6 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
this, SLOT(zoomIn()));
connect(controller, SIGNAL(zoomOut()),
this, SLOT(zoomOut()));
- connect(controller, SIGNAL(urlChanged(const KUrl&)),
- this, SLOT(showColumn(const KUrl&)));
connect(controller, SIGNAL(showHiddenFilesChanged(bool)),
this, SLOT(slotShowHiddenFilesChanged(bool)));
connect(controller, SIGNAL(showPreviewChanged(bool)),
@@ -123,13 +119,6 @@ QRect DolphinColumnView::visualRect(const QModelIndex& index) const
return activeColumn()->visualRect(index);
}
-void DolphinColumnView::setModel(QAbstractItemModel* model)
-{
- m_proxyModel = static_cast<QAbstractProxyModel*>(model);
- m_dolphinModel = static_cast<DolphinModel*>(m_proxyModel->sourceModel());
- QAbstractItemView::setModel(model);
-}
-
void DolphinColumnView::invertSelection()
{
QItemSelectionModel* selectionModel = activeColumn()->selectionModel();
@@ -150,34 +139,25 @@ void DolphinColumnView::reload()
}
}
+void DolphinColumnView::setRootUrl(const KUrl& url)
+{
+ removeAllColumns();
+ m_columns[0]->setUrl(url);
+}
+
+KUrl DolphinColumnView::rootUrl() const
+{
+ return m_columns[0]->url();
+}
+
void DolphinColumnView::showColumn(const KUrl& url)
{
const KUrl& rootUrl = m_columns[0]->url();
if (!rootUrl.isParentOf(url)) {
- // the URL is no child URL of the column view, hence clear all columns
- // and reset the root column
- QList<DolphinColumnWidget*>::iterator start = m_columns.begin() + 1;
- QList<DolphinColumnWidget*>::iterator end = m_columns.end();
- for (QList<DolphinColumnWidget*>::iterator it = start; it != end; ++it) {
- (*it)->deleteLater();
- }
- m_columns.erase(start, end);
- m_index = 0;
- m_columns[0]->setActive(true);
- m_columns[0]->setUrl(url);
- assureVisibleActiveColumn();
+ setRootUrl(url);
return;
}
- KDirLister* dirLister = m_dolphinModel->dirLister();
- const KUrl dirListerUrl = dirLister->url();
- if (dirListerUrl != rootUrl) {
- // It is possible that root URL of the directory lister is adjusted
- // after creating the column widget (e. g. when restoring the history
- // having a different root URL than the controller indicates).
- m_columns[0]->setUrl(dirListerUrl);
- }
-
int columnIndex = 0;
foreach (DolphinColumnWidget* column, m_columns) {
if (column->url() == url) {
@@ -231,9 +211,6 @@ void DolphinColumnView::showColumn(const KUrl& url)
++slashIndex;
const KUrl childUrl = KUrl(path);
- const QModelIndex dirIndex = m_dolphinModel->indexForUrl(KUrl(path));
- const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
-
m_columns[columnIndex]->setChildUrl(childUrl);
columnIndex++;
@@ -248,10 +225,6 @@ void DolphinColumnView::showColumn(const KUrl& url)
column->show();
layoutColumns();
updateScrollBar();
-
- // the layout is finished, now let the column be invisible until it
- // gets a valid root index due to expandToActiveUrl()
- //column->hide();
}
}
@@ -514,4 +487,17 @@ void DolphinColumnView::requestActivation(DolphinColumnWidget* column)
}
}
+void DolphinColumnView::removeAllColumns()
+{
+ QList<DolphinColumnWidget*>::iterator start = m_columns.begin() + 1;
+ QList<DolphinColumnWidget*>::iterator end = m_columns.end();
+ for (QList<DolphinColumnWidget*>::iterator it = start; it != end; ++it) {
+ (*it)->deleteLater();
+ }
+ m_columns.erase(start, end);
+ m_index = 0;
+ m_columns[0]->setActive(true);
+ assureVisibleActiveColumn();
+}
+
#include "dolphincolumnview.moc"
diff --git a/src/dolphincolumnview.h b/src/dolphincolumnview.h
index b473e790e..6837815a0 100644
--- a/src/dolphincolumnview.h
+++ b/src/dolphincolumnview.h
@@ -20,6 +20,8 @@
#ifndef DOLPHINCOLUMNVIEW_H
#define DOLPHINCOLUMNVIEW_H
+#include <kurl.h>
+
#include <QAbstractItemView>
#include <QList>
#include <QStyleOption>
@@ -27,7 +29,6 @@
class DolphinColumnWidget;
class DolphinController;
class DolphinModel;
-class KUrl;
class QAbstractProxyModel;
class QTimeLine;
@@ -48,7 +49,6 @@ public:
virtual QModelIndex indexAt(const QPoint& point) const;
virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
virtual QRect visualRect(const QModelIndex& index) const;
- virtual void setModel(QAbstractItemModel* model);
/** Inverts the selection of the currently active column. */
void invertSelection();
@@ -60,6 +60,15 @@ public:
*/
void reload();
+ /**
+ * Adjusts the root URL of the first column and removes all
+ * other columns.
+ */
+ void setRootUrl(const KUrl& url);
+
+ /** Returns the URL of the first column. */
+ KUrl rootUrl() const;
+
public slots:
/**
* Shows the column which represents the URL \a url. If the column
@@ -132,6 +141,9 @@ private:
*/
void requestActivation(DolphinColumnWidget* column);
+ /** Removes all columns except of the root column. */
+ void removeAllColumns();
+
private:
DolphinController* m_controller;
bool m_restoreActiveColumnFocus;
@@ -140,9 +152,6 @@ private:
QList<DolphinColumnWidget*> m_columns;
QTimeLine* m_animation;
- DolphinModel* m_dolphinModel;
- QAbstractProxyModel* m_proxyModel;
-
friend class DolphinColumnWidget;
};
diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp
index 94bee2bee..4c6faacea 100644
--- a/src/dolphincolumnwidget.cpp
+++ b/src/dolphincolumnwidget.cpp
@@ -101,13 +101,8 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
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()));
connect(this, SIGNAL(viewportEntered()),
m_view->m_controller, SLOT(emitViewportEntered()));
-
connect(this, SIGNAL(entered(const QModelIndex&)),
this, SLOT(slotEntered(const QModelIndex&)));
@@ -305,6 +300,9 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const
}
void DolphinColumnWidget::triggerItem(const QModelIndex& index)
{
+ const KFileItem item = m_dolphinModel->itemForIndex(m_proxyModel->mapToSource(index));
+ m_view->m_controller->triggerItem(item);
+ /*
const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) {
// items are selected by the user, hence don't trigger the
@@ -321,7 +319,7 @@ void DolphinColumnWidget::triggerItem(const QModelIndex& index)
m_view->m_controller->setUrl(url);
} else if (item.isFile()) {
item.run();
- }
+ }*/
}
void DolphinColumnWidget::generatePreviews(const KFileItemList& items)
diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp
index 4666e617b..59cc20f0f 100644
--- a/src/dolphincontroller.cpp
+++ b/src/dolphincontroller.cpp
@@ -135,9 +135,9 @@ void DolphinController::drawHoverIndication(QWidget* widget,
painter.restore();
}
-void DolphinController::triggerItem(const QModelIndex& index)
+void DolphinController::triggerItem(const KFileItem& item)
{
- emit itemTriggered(index);
+ emit itemTriggered(item);
}
void DolphinController::emitItemEntered(const KFileItem& item)
diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h
index 3a2720471..31b80e7bf 100644
--- a/src/dolphincontroller.h
+++ b/src/dolphincontroller.h
@@ -100,7 +100,7 @@ public slots:
/**
* Emits the signal itemTriggered(). The method should be invoked by the
* controller parent whenever the user has triggered an item. */
- void triggerItem(const QModelIndex& index);
+ void triggerItem(const KFileItem& item);
/**
* Emits the signal itemEntered(). The method should be invoked by
@@ -171,12 +171,12 @@ signals:
void additionalInfoCountChanged(int count);
/**
- * Is emitted if the item with the index \a index should be triggered.
+ * Is emitted if the item \a item should be triggered.
* Usually triggering on a directory opens the directory, triggering
- * on a file opens the corresponding application.
- * Emitted with an invalid \a index when clicking on the viewport itself.
+ * on a file opens the corresponding application. The item is null
+ * (see KFileItem::isNull()), when clicking on the viewport itself.
*/
- void itemTriggered(const QModelIndex& index);
+ void itemTriggered(const KFileItem& item);
/**
* Is emitted if the mouse cursor has entered the item
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index 078f51bf1..6cd9fbaf9 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -84,10 +84,10 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
// 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&)));
@@ -317,11 +317,11 @@ void DolphinDetailsView::keyPressEvent(QKeyEvent* 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);
}
}
@@ -434,13 +434,14 @@ void DolphinDetailsView::zoomOut()
}
}
-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(itemForIndex(index));
+ m_controller->emitItemEntered(item);
}
}
diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h
index 06cd9a833..c8fd90aa8 100644
--- a/src/dolphindetailsview.h
+++ b/src/dolphindetailsview.h
@@ -108,7 +108,7 @@ private slots:
/**
* Called by QTreeView when an item is activated (clicked or double-clicked)
*/
- void slotItemActivated(const QModelIndex& index);
+ void triggerItem(const QModelIndex& index);
/**
* Opens a context menu at the position \a pos and allows to
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index 042c9a76c..f1ad25e3d 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -54,10 +54,10 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
// RETURN-key in keyPressEvent().
if (KGlobalSettings::singleClick()) {
connect(this, SIGNAL(clicked(const QModelIndex&)),
- controller, SLOT(triggerItem(const QModelIndex&)));
+ this, SLOT(triggerItem(const QModelIndex&)));
} else {
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
- controller, SLOT(triggerItem(const QModelIndex&)));
+ this, SLOT(triggerItem(const QModelIndex&)));
}
connect(this, SIGNAL(viewportEntered()),
controller, SLOT(emitViewportEntered()));
@@ -222,22 +222,22 @@ void DolphinIconsView::keyPressEvent(QKeyEvent* 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);
}
}
-void DolphinIconsView::slotEntered(const QModelIndex& index)
+void DolphinIconsView::triggerItem(const QModelIndex& index)
{
- QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(model());
- KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
- const QModelIndex dirIndex = proxyModel->mapToSource(index);
+ m_controller->triggerItem(itemForIndex(index));
+}
- const KFileItem item = dirModel->itemForIndex(dirIndex);
- m_controller->emitItemEntered(item);
+void DolphinIconsView::slotEntered(const QModelIndex& index)
+{
+ m_controller->emitItemEntered(itemForIndex(index));
}
void DolphinIconsView::slotShowPreviewChanged(bool showPreview)
@@ -393,4 +393,13 @@ 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);
+}
+
+
#include "dolphiniconsview.moc"
diff --git a/src/dolphiniconsview.h b/src/dolphiniconsview.h
index a95163f3a..5838a98dd 100644
--- a/src/dolphiniconsview.h
+++ b/src/dolphiniconsview.h
@@ -22,6 +22,8 @@
#include <kcategorizedview.h>
+#include <kfileitem.h>
+
#include <QSize>
#include <QStyleOption>
@@ -59,6 +61,7 @@ protected:
virtual void keyPressEvent(QKeyEvent* event);
private slots:
+ void triggerItem(const QModelIndex& index);
void slotEntered(const QModelIndex& index);
void slotShowPreviewChanged(bool show);
void slotAdditionalInfoCountChanged(int count);
@@ -81,6 +84,8 @@ private:
*/
void updateGridSize(bool showPreview, int additionalInfoCount);
+ KFileItem itemForIndex(const QModelIndex& index) const;
+
private:
DolphinController* m_controller;
DolphinCategoryDrawer* m_categoryDrawer;
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index ad760fb13..53d8acae5 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -98,8 +98,8 @@ DolphinView::DolphinView(QWidget* parent,
this, SLOT(updateSorting(DolphinView::Sorting)));
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
this, SLOT(updateSortOrder(Qt::SortOrder)));
- connect(m_controller, SIGNAL(itemTriggered(const QModelIndex&)),
- this, SLOT(triggerItem(const QModelIndex&)));
+ connect(m_controller, SIGNAL(itemTriggered(const KFileItem&)),
+ this, SLOT(triggerItem(const KFileItem&)));
connect(m_controller, SIGNAL(activated()),
this, SLOT(activate()));
connect(m_controller, SIGNAL(itemEntered(const KFileItem&)),
@@ -122,7 +122,7 @@ const KUrl& DolphinView::url() const
KUrl DolphinView::rootUrl() const
{
- return isColumnViewActive() ? m_dirLister->url() : url();
+ return isColumnViewActive() ? m_columnView->rootUrl() : url();
}
void DolphinView::setActive(bool active)
@@ -457,6 +457,7 @@ void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
// that the view properties have been changed or deleted in the meantime, so
// it cannot be asserted that really a column view has been created:
if (itemView() == m_columnView) {
+ m_columnView->setRootUrl(rootUrl);
m_columnView->showColumn(url);
}
} else {
@@ -484,10 +485,8 @@ void DolphinView::activate()
setActive(true);
}
-void DolphinView::triggerItem(const QModelIndex& index)
+void DolphinView::triggerItem(const KFileItem& item)
{
- Q_ASSERT(index.isValid());
-
const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) {
// items are selected by the user, hence don't trigger the
@@ -495,8 +494,6 @@ void DolphinView::triggerItem(const QModelIndex& index)
return;
}
- const KFileItem item = m_dolphinModel->itemForIndex(m_proxyModel->mapToSource(index));
-
if (item.isNull()) {
return;
}
@@ -558,10 +555,14 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload)
m_dirLister->stop();
m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
- if (isColumnViewActive() && reload) {
- // reloading the directory lister is not enough in the case of the
+ if (isColumnViewActive()) {
+ // adjusting the directory lister is not enough in the case of the
// column view, as each column has its own directory lister internally...
- m_columnView->reload();
+ if (reload) {
+ m_columnView->reload();
+ } else {
+ m_columnView->showColumn(url);
+ }
}
}
@@ -576,7 +577,7 @@ KUrl DolphinView::viewPropertiesUrl() const
void DolphinView::applyViewProperties(const KUrl& url)
{
- if (isColumnViewActive() && m_dirLister->url().isParentOf(url)) {
+ if (isColumnViewActive() && rootUrl().isParentOf(url)) {
// The column view is active, hence don't apply the view properties
// of sub directories (represented by columns) to the view. The
// view always represents the properties of the first column.
diff --git a/src/dolphinview.h b/src/dolphinview.h
index d9d2f5cca..2f3bdadb4 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -418,11 +418,11 @@ private slots:
void activate();
/**
- * If the item specified by \a index is a directory, then this
+ * If the item \a item is a directory, then this
* directory will be loaded. If the item is a file, the corresponding
* application will get started.
*/
- void triggerItem(const QModelIndex& index);
+ void triggerItem(const KFileItem& index);
/**
* Generates a preview image for each file item in \a items.