bookmarkssidebarpage.cpp
detailsviewsettingspage.cpp
dolphinapplication.cpp
+ dolphincolumnview.cpp
dolphinmainwindow.cpp
dolphinnewmenu.cpp
dolphinview.cpp
<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>
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
+ * *
+ * 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"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
+ * *
+ * 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
m_activeView->setMode(DolphinView::DetailsView);\r
}\r
\r
+void DolphinMainWindow::setColumnView()\r
+{\r
+ m_activeView->setMode(DolphinView::ColumnView);\r
+}\r
+\r
void DolphinMainWindow::sortByName()\r
{\r
m_activeView->setSorting(DolphinView::SortByName);\r
detailsView->setIcon(KIcon("fileview-text"));\r
connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView()));\r
\r
+ KToggleAction* columnView = actionCollection()->add<KToggleAction>("columns");\r
+ columnView->setText(i18n("Columns"));\r
+ columnView->setShortcut(Qt::CTRL | Qt::Key_3);\r
+ columnView->setIcon(KIcon("view-tree"));\r
+ connect(columnView, SIGNAL(triggered()), this, SLOT(setColumnView()));\r
+\r
QActionGroup* viewModeGroup = new QActionGroup(this);\r
viewModeGroup->addAction(iconsView);\r
viewModeGroup->addAction(detailsView);\r
+ viewModeGroup->addAction(columnView);\r
\r
KToggleAction* sortByName = actionCollection()->add<KToggleAction>("by_name");\r
sortByName->setText(i18n("By Name"));\r
case DolphinView::DetailsView:\r
action = actionCollection()->action("details");\r
break;\r
+ case DolphinView::ColumnView:\r
+ action = actionCollection()->action("columns");\r
+ break;\r
default:\r
break;\r
}\r
/** 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();
<text>View Mode</text>
<Action name="icons" />
<Action name="details" />
+ <Action name="columns" />
</Menu>
<Menu name="sort">
<text>Sort</text>
<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" />
#include <konq_operations.h>
#include <kurl.h>
+#include "dolphincolumnview.h"
#include "dolphincontroller.h"
#include "dolphinstatusbar.h"
#include "dolphinmainwindow.h"
m_controller(0),
m_iconsView(0),
m_detailsView(0),
+ m_columnView(0),
m_fileItemDelegate(0),
m_filterBar(0),
m_statusBar(0),
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();
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
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) {
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);
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;
}
class KUrl;
class KDirModel;
class UrlNavigator;
+class DolphinColumnView;
class DolphinDetailsView;
class DolphinDirLister;
class DolphinIconsView;
* @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
*/
* 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. */
/** 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
DolphinController* m_controller;
DolphinIconsView* m_iconsView;
DolphinDetailsView* m_detailsView;
+ DolphinColumnView* m_columnView;
KFileItemDelegate* m_fileItemDelegate;
FilterBar* m_filterBar;