┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-03-27 19:08:44 +0000
committerPeter Penz <[email protected]>2007-03-27 19:08:44 +0000
commitfd060ce7f67a95b1e3f41d3ff091595f34704920 (patch)
treeb5735e2c268b8461ede653ab2dfe83318122e42e
parent3546be263253a3982077122fb861ebfb64d7de1d (diff)
Initial version for a column view support (thanks a lot to Benjamin Meyer for QColumnView in Qt4.3!). Currently there is a problem when using the DolphinSortFilterProxyModel: some items get duplicated, but I doubt it's an issue in QColumnView (the same issue occurs when using QTreeView) -> further investigations necessary...
svn path=/trunk/KDE/kdebase/apps/; revision=647234
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/dolphin_directoryviewpropertysettings.kcfg2
-rw-r--r--src/dolphincolumnview.cpp134
-rw-r--r--src/dolphincolumnview.h61
-rw-r--r--src/dolphinmainwindow.cpp15
-rw-r--r--src/dolphinmainwindow.h3
-rw-r--r--src/dolphinui.rc2
-rw-r--r--src/dolphinview.cpp35
-rw-r--r--src/dolphinview.h19
9 files changed, 266 insertions, 6 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2ad4814e2..81eaf9452 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -41,6 +41,7 @@ set(dolphin_SRCS
bookmarkssidebarpage.cpp
detailsviewsettingspage.cpp
dolphinapplication.cpp
+ dolphincolumnview.cpp
dolphinmainwindow.cpp
dolphinnewmenu.cpp
dolphinview.cpp
diff --git a/src/dolphin_directoryviewpropertysettings.kcfg b/src/dolphin_directoryviewpropertysettings.kcfg
index bd8cf6c16..1d074100a 100644
--- a/src/dolphin_directoryviewpropertysettings.kcfg
+++ b/src/dolphin_directoryviewpropertysettings.kcfg
@@ -17,7 +17,7 @@
<group name="Dolphin">
<entry name="ViewMode" type="Int" >
<label>View Mode</label>
- <whatsthis>This option controls the style of the view. Currently supported values include icons (0) and details (1) views.</whatsthis>
+ <whatsthis>This option controls the style of the view. Currently supported values include icons (0), details (1) and column (2) views.</whatsthis>
<default>DolphinView::IconsView</default>
<min>0</min>
<max code="true">DolphinView::MaxModeEnum</max>
diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp
new file mode 100644
index 000000000..41fb89f97
--- /dev/null
+++ b/src/dolphincolumnview.cpp
@@ -0,0 +1,134 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz ([email protected]) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "dolphincolumnview.h"
+
+#include "dolphincontroller.h"
+#include "dolphinsettings.h"
+
+//#include "dolphin_iconsmodesettings.h"
+
+#include <kdirmodel.h>
+#include <kfileitem.h>
+#include <kfileitemdelegate.h>
+
+#include <QAbstractProxyModel>
+#include <QPoint>
+
+DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* controller) :
+ QColumnView(parent),
+ m_controller(controller)
+{
+ Q_ASSERT(controller != 0);
+
+ viewport()->setAttribute(Qt::WA_Hover);
+
+ connect(this, SIGNAL(clicked(const QModelIndex&)),
+ controller, SLOT(triggerItem(const QModelIndex&)));
+ connect(this, SIGNAL(activated(const QModelIndex&)),
+ controller, SLOT(triggerItem(const QModelIndex&)));
+ connect(controller, SIGNAL(showPreviewChanged(bool)),
+ this, SLOT(updateGridSize(bool)));
+ connect(controller, SIGNAL(zoomIn()),
+ this, SLOT(zoomIn()));
+ connect(controller, SIGNAL(zoomOut()),
+ this, SLOT(zoomOut()));
+
+ // apply the icons mode settings to the widget
+ //const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ //Q_ASSERT(settings != 0);
+
+ m_viewOptions = QColumnView::viewOptions();
+
+ /*QFont font(settings->fontFamily(), settings->fontSize());
+ font.setItalic(settings->italicFont());
+ font.setBold(settings->boldFont());
+ m_viewOptions.font = font;
+
+ updateGridSize(controller->showPreview());
+
+ if (settings->arrangement() == QColumnView::TopToBottom) {
+ setFlow(QColumnView::LeftToRight);
+ m_viewOptions.decorationPosition = QStyleOptionViewItem::Top;
+ }
+ else {
+ setFlow(QColumnView::TopToBottom);
+ m_viewOptions.decorationPosition = QStyleOptionViewItem::Left;
+ }*/
+}
+
+DolphinColumnView::~DolphinColumnView()
+{
+}
+
+QStyleOptionViewItem DolphinColumnView::viewOptions() const
+{
+ return m_viewOptions;
+}
+
+void DolphinColumnView::contextMenuEvent(QContextMenuEvent* event)
+{
+ QColumnView::contextMenuEvent(event);
+ m_controller->triggerContextMenuRequest(event->pos());
+}
+
+void DolphinColumnView::mouseReleaseEvent(QMouseEvent* event)
+{
+ QColumnView::mouseReleaseEvent(event);
+ m_controller->triggerActivation();
+}
+
+void DolphinColumnView::dragEnterEvent(QDragEnterEvent* event)
+{
+ if (event->mimeData()->hasUrls()) {
+ event->acceptProposedAction();
+ }
+}
+
+void DolphinColumnView::dropEvent(QDropEvent* event)
+{
+ const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
+ if (!urls.isEmpty()) {
+ m_controller->indicateDroppedUrls(urls,
+ indexAt(event->pos()),
+ event->source());
+ event->acceptProposedAction();
+ }
+ QColumnView::dropEvent(event);
+}
+
+void DolphinColumnView::zoomIn()
+{
+}
+
+void DolphinColumnView::zoomOut()
+{
+}
+
+bool DolphinColumnView::isZoomInPossible() const
+{
+ return false;
+}
+
+bool DolphinColumnView::isZoomOutPossible() const
+{
+ return false;
+}
+
+#include "dolphincolumnview.moc"
diff --git a/src/dolphincolumnview.h b/src/dolphincolumnview.h
new file mode 100644
index 000000000..649d2a7d4
--- /dev/null
+++ b/src/dolphincolumnview.h
@@ -0,0 +1,61 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz ([email protected]) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#ifndef DOLPHINCOLUMNVIEW_H
+#define DOLPHINCOLUMNVIEW_H
+
+#include <QColumnView>
+#include <QStyleOptionViewItem>
+#include <libdolphin_export.h>
+
+class DolphinController;
+class DolphinView;
+
+/**
+ * @brief TODO
+ */
+class LIBDOLPHINPRIVATE_EXPORT DolphinColumnView : public QColumnView
+{
+ Q_OBJECT
+
+public:
+ explicit DolphinColumnView(QWidget* parent, DolphinController* controller);
+ virtual ~DolphinColumnView();
+
+protected:
+ virtual QStyleOptionViewItem viewOptions() const;
+ virtual void contextMenuEvent(QContextMenuEvent* event);
+ virtual void mouseReleaseEvent(QMouseEvent* event);
+ virtual void dragEnterEvent(QDragEnterEvent* event);
+ virtual void dropEvent(QDropEvent* event);
+
+private slots:
+ void zoomIn();
+ void zoomOut();
+
+private:
+ bool isZoomInPossible() const;
+ bool isZoomOutPossible() const;
+
+private:
+ DolphinController* m_controller;
+ QStyleOptionViewItem m_viewOptions;
+};
+
+#endif
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index e86ad13fa..278d63c97 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -704,6 +704,11 @@ void DolphinMainWindow::setDetailsView()
m_activeView->setMode(DolphinView::DetailsView);
}
+void DolphinMainWindow::setColumnView()
+{
+ m_activeView->setMode(DolphinView::ColumnView);
+}
+
void DolphinMainWindow::sortByName()
{
m_activeView->setSorting(DolphinView::SortByName);
@@ -1152,9 +1157,16 @@ void DolphinMainWindow::setupActions()
detailsView->setIcon(KIcon("fileview-text"));
connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView()));
+ KToggleAction* columnView = actionCollection()->add<KToggleAction>("columns");
+ columnView->setText(i18n("Columns"));
+ columnView->setShortcut(Qt::CTRL | Qt::Key_3);
+ columnView->setIcon(KIcon("view-tree"));
+ connect(columnView, SIGNAL(triggered()), this, SLOT(setColumnView()));
+
QActionGroup* viewModeGroup = new QActionGroup(this);
viewModeGroup->addAction(iconsView);
viewModeGroup->addAction(detailsView);
+ viewModeGroup->addAction(columnView);
KToggleAction* sortByName = actionCollection()->add<KToggleAction>("by_name");
sortByName->setText(i18n("By Name"));
@@ -1414,6 +1426,9 @@ void DolphinMainWindow::updateViewActions()
case DolphinView::DetailsView:
action = actionCollection()->action("details");
break;
+ case DolphinView::ColumnView:
+ action = actionCollection()->action("columns");
+ break;
default:
break;
}
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index d8c64da7c..c6b46817f 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -232,6 +232,9 @@ private slots:
/** The current active view is switched to the details mode. */
void setDetailsView();
+ /** The current active view is switched to the column mode. */
+ void setColumnView();
+
/** The sorting of the current view should be done by the name. */
void sortByName();
diff --git a/src/dolphinui.rc b/src/dolphinui.rc
index 06f94826c..bb3e2d729 100644
--- a/src/dolphinui.rc
+++ b/src/dolphinui.rc
@@ -20,6 +20,7 @@
<text>View Mode</text>
<Action name="icons" />
<Action name="details" />
+ <Action name="columns" />
</Menu>
<Menu name="sort">
<text>Sort</text>
@@ -111,6 +112,7 @@
<Separator name="separator_1" />
<Action name="icons" />
<Action name="details" />
+ <Action name="columns" />
<Separator name="separator_0" />
<Action name="show_preview" />
<Action name="split_view" />
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 17bbd608d..04b949a7d 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -39,6 +39,7 @@
#include <konq_operations.h>
#include <kurl.h>
+#include "dolphincolumnview.h"
#include "dolphincontroller.h"
#include "dolphinstatusbar.h"
#include "dolphinmainwindow.h"
@@ -71,6 +72,7 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow,
m_controller(0),
m_iconsView(0),
m_detailsView(0),
+ m_columnView(0),
m_fileItemDelegate(0),
m_filterBar(0),
m_statusBar(0),
@@ -597,7 +599,16 @@ void DolphinView::loadDirectory(const KUrl& url)
const ViewProperties props(url);
const Mode mode = props.viewMode();
- if (m_mode != mode) {
+ bool changeMode = (m_mode != mode);
+ if (changeMode && isColumnViewActive()) {
+ // The column view is active. Only change the
+ // mode if the current URL is no child of the column view.
+ if (m_dirLister->url().isParentOf(url)) {
+ changeMode = false;
+ }
+ }
+
+ if (changeMode) {
m_mode = mode;
createView();
emit modeChanged();
@@ -824,7 +835,15 @@ void DolphinView::startDirLister(const KUrl& url, bool reload)
m_cutItemsCache.clear();
m_blockContentsMovedSignal = true;
m_dirLister->stop();
- m_dirLister->openUrl(url, false, reload);
+
+ bool keepOldDirs = isColumnViewActive();
+ if (keepOldDirs && !m_dirLister->url().isParentOf(url)) {
+ // The current URL is not a child of the dir lister
+ // URL. This may happen when e. g. a bookmark has been selected
+ // and hence the view must be reset.
+ keepOldDirs = false;
+ }
+ m_dirLister->openUrl(url, keepOldDirs, reload);
}
QString DolphinView::defaultStatusBarText() const
@@ -1072,11 +1091,13 @@ void DolphinView::createView()
view = 0;
m_iconsView = 0;
m_detailsView = 0;
+ m_columnView = 0;
m_fileItemDelegate = 0;
}
Q_ASSERT(m_iconsView == 0);
Q_ASSERT(m_detailsView == 0);
+ Q_ASSERT(m_columnView == 0);
// ... and recreate it representing the current mode
switch (m_mode) {
@@ -1089,6 +1110,11 @@ void DolphinView::createView()
m_detailsView = new DolphinDetailsView(this, m_controller);
view = m_detailsView;
break;
+
+ case ColumnView:
+ m_columnView = new DolphinColumnView(this, m_controller);
+ view = m_columnView;
+ break;
}
Q_ASSERT(view != 0);
@@ -1125,10 +1151,13 @@ void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags)
QAbstractItemView* DolphinView::itemView() const
{
- Q_ASSERT((m_iconsView == 0) || (m_detailsView == 0));
if (m_detailsView != 0) {
return m_detailsView;
}
+ else if (m_columnView != 0) {
+ return m_columnView;
+ }
+
return m_iconsView;
}
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 14c8372d3..6aabf2d34 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -43,6 +43,7 @@ class KFileItemDelegate;
class KUrl;
class KDirModel;
class UrlNavigator;
+class DolphinColumnView;
class DolphinDetailsView;
class DolphinDirLister;
class DolphinIconsView;
@@ -58,11 +59,12 @@ class ViewProperties;
* @short Represents a view for the directory content
* including the navigation bar, filter bar and status bar.
*
- * View modes for icons and details are supported. Currently
+ * View modes for icons, details and columns are supported. Currently
* Dolphin allows to have up to two views inside the main window.
*
* @see DolphinIconsView
* @see DolphinDetailsView
+ * @see DolphinColumnView
* @see UrlNavigator
* @see DolphinStatusBar
*/
@@ -90,7 +92,12 @@ public:
* for date, group and permissions.
*/
DetailsView = 1,
- MaxModeEnum = DetailsView
+
+ /**
+ * Each folder is shown in a separate column.
+ */
+ ColumnView = 2,
+ MaxModeEnum = ColumnView
};
/** Defines the sort order for the items of a directory. */
@@ -542,6 +549,13 @@ private:
/** Applies an item effect to all cut items. */
void applyCutItemEffect();
+ /**
+ * Returns true, if the ColumnView is activated. As the column view
+ * requires some special handling for iterating through directories,
+ * this method has been introduced for convenience.
+ */
+ bool isColumnViewActive() const { return m_columnView != 0; }
+
private:
/**
* Remembers the original pixmap for an item before
@@ -567,6 +581,7 @@ private:
DolphinController* m_controller;
DolphinIconsView* m_iconsView;
DolphinDetailsView* m_detailsView;
+ DolphinColumnView* m_columnView;
KFileItemDelegate* m_fileItemDelegate;
FilterBar* m_filterBar;