diff options
| author | Peter Penz <[email protected]> | 2011-11-20 19:32:52 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-11-20 19:35:01 +0100 |
| commit | b27e599429731337af4bb18b986933c968bea279 (patch) | |
| tree | e807863400a9c3f6f48194a0f69f4c3d450ca092 /src/panels | |
| parent | 693f254252da3932d1307f65bc2a1bcaaad566ac (diff) | |
Initial draft for bringing back the "Folders" panel
The folders panel has been adjusted to use the new view-engine.
A lot of things don't work yet, but are mostly minor issues that
should be fixable during the next 10 days.
Diffstat (limited to 'src/panels')
| -rw-r--r-- | src/panels/folders/folderspanel.cpp | 166 | ||||
| -rw-r--r-- | src/panels/folders/folderspanel.h | 23 | ||||
| -rw-r--r-- | src/panels/folders/ktreeview.cpp | 149 | ||||
| -rw-r--r-- | src/panels/folders/ktreeview.h | 47 | ||||
| -rw-r--r-- | src/panels/folders/paneltreeview.cpp | 140 | ||||
| -rw-r--r-- | src/panels/folders/paneltreeview.h | 58 |
6 files changed, 85 insertions, 498 deletions
diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 76a4b4e08..23911f8fc 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -21,34 +21,34 @@ #include "dolphin_folderspanelsettings.h" #include "dolphin_generalsettings.h" -#include "paneltreeview.h" #include "treeviewcontextmenu.h" +#include <kitemviews/kitemlistselectionmanager.h> +#include <kitemviews/kfileitemlistview.h> +#include <kitemviews/kfileitemlistwidget.h> +#include <kitemviews/kitemlistcontainer.h> +#include <kitemviews/kitemlistcontroller.h> +#include <kitemviews/kfileitemmodel.h> + #include <KDirLister> #include <KFileItem> #include <konq_operations.h> #include <QApplication> #include <QBoxLayout> -#include <QItemSelection> -#include <QModelIndex> -#include <QPointer> -#include <QTreeView> -#include <QScrollBar> +#include <QGraphicsView> #include <QTimer> -#include <views/dolphinview.h> -#include <views/folderexpander.h> #include <views/renamedialog.h> +#include <KDebug> + FoldersPanel::FoldersPanel(QWidget* parent) : Panel(parent), m_setLeafVisible(false), m_mouseButtons(Qt::NoButton), m_dirLister(0), - //m_dolphinModel(0), - //m_proxyModel(0), - m_treeView(0), + m_controller(0), m_leafDir() { setLayoutDirection(Qt::LeftToRight); @@ -58,10 +58,10 @@ FoldersPanel::~FoldersPanel() { FoldersPanelSettings::self()->writeConfig(); - //delete m_proxyModel; - //m_proxyModel = 0; - //delete m_dolphinModel; - //m_dolphinModel = 0; + KItemListView* view = m_controller->view(); + m_controller->setView(0); + delete view; + delete m_dirLister; m_dirLister = 0; } @@ -70,8 +70,11 @@ void FoldersPanel::setHiddenFilesShown(bool show) { FoldersPanelSettings::setHiddenFilesShown(show); if (m_dirLister) { + KFileItemModel* model = fileItemModel(); + const QSet<KUrl> expandedUrls = model->expandedUrls(); m_dirLister->setShowingDotFiles(show); m_dirLister->openUrl(m_dirLister->url(), KDirLister::Reload); + model->setExpanded(expandedUrls); } } @@ -82,7 +85,7 @@ bool FoldersPanel::hiddenFilesShown() const void FoldersPanel::setAutoScrolling(bool enable) { - m_treeView->setAutoHorizontalScroll(enable); + //m_treeView->setAutoHorizontalScroll(enable); FoldersPanelSettings::setAutoScrolling(enable); } @@ -141,43 +144,48 @@ void FoldersPanel::showEvent(QShowEvent* event) m_dirLister->setDelayedMimeTypes(true); m_dirLister->setAutoErrorHandlingEnabled(false, this); m_dirLister->setShowingDotFiles(FoldersPanelSettings::hiddenFilesShown()); - connect(m_dirLister, SIGNAL(completed()), this, SLOT(slotDirListerCompleted())); - /*Q_ASSERT(!m_dolphinModel); - m_dolphinModel = new DolphinModel(this); - m_dolphinModel->setDirLister(m_dirLister); - m_dolphinModel->setDropsAllowed(DolphinModel::DropOnDirectory); - connect(m_dolphinModel, SIGNAL(expand(QModelIndex)), - this, SLOT(expandToDir(QModelIndex))); + KFileItemListView* view = new KFileItemListView(); + view->setWidgetCreator(new KItemListWidgetCreator<KFileItemListWidget>()); - Q_ASSERT(!m_proxyModel); - m_proxyModel = new DolphinSortFilterProxyModel(this); - m_proxyModel->setSourceModel(m_dolphinModel); + KItemListStyleOption styleOption = view->styleOption(); + styleOption.margin = 2; + styleOption.iconSize = KIconLoader::SizeSmall; + view->setStyleOption(styleOption); - Q_ASSERT(!m_treeView); - m_treeView = new PanelTreeView(this); - m_treeView->setModel(m_proxyModel); - m_proxyModel->setSorting(DolphinView::SortByName); - m_proxyModel->setSortOrder(Qt::AscendingOrder); - m_treeView->setAutoHorizontalScroll(FoldersPanelSettings::autoScrolling()); + const qreal itemHeight = qMax(int(KIconLoader::SizeSmall), styleOption.fontMetrics.height()); + view->setItemSize(QSizeF(-1, itemHeight + 2 * styleOption.margin)); + view->setItemLayout(KFileItemListView::DetailsLayout); - new FolderExpander(m_treeView, m_proxyModel); + KFileItemModel* model = new KFileItemModel(m_dirLister, this); + // Use a QueuedConnection to give the view the possibility to react first on the + // finished loading. + connect(model, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()), Qt::QueuedConnection); - connect(m_treeView, SIGNAL(clicked(QModelIndex)), - this, SLOT(updateActiveView(QModelIndex))); - connect(m_treeView, SIGNAL(urlsDropped(QModelIndex,QDropEvent*)), - this, SLOT(dropUrls(QModelIndex,QDropEvent*))); - connect(m_treeView, SIGNAL(pressed(QModelIndex)), - this, SLOT(updateMouseButtons())); + KItemListContainer* container = new KItemListContainer(this); + m_controller = container->controller(); + m_controller->setView(view); + m_controller->setModel(model); - connect(m_treeView->horizontalScrollBar(), SIGNAL(sliderMoved(int)), - this, SLOT(slotHorizontalScrollBarMoved(int))); - connect(m_treeView->verticalScrollBar(), SIGNAL(valueChanged(int)), - this, SLOT(slotVerticalScrollBarMoved(int))); + // TODO: Check whether it makes sense to make an explicit API for KItemListContainer + // to make the background transparent. + container->setFrameShape(QFrame::NoFrame); + QGraphicsView* graphicsView = qobject_cast<QGraphicsView*>(container->viewport()); + if (graphicsView) { + // Make the background of the container transparent and apply the window-text color + // to the text color, so that enough contrast is given for all color + // schemes + QPalette p = graphicsView->palette(); + p.setColor(QPalette::Active, QPalette::Text, p.color(QPalette::Active, QPalette::WindowText)); + p.setColor(QPalette::Inactive, QPalette::Text, p.color(QPalette::Inactive, QPalette::WindowText)); + p.setColor(QPalette::Disabled, QPalette::Text, p.color(QPalette::Disabled, QPalette::WindowText)); + graphicsView->setPalette(p); + graphicsView->viewport()->setAutoFillBackground(false); + } QVBoxLayout* layout = new QVBoxLayout(this); layout->setMargin(0); - layout->addWidget(m_treeView);*/ + layout->addWidget(container); } loadTree(url()); @@ -205,59 +213,23 @@ void FoldersPanel::keyPressEvent(QKeyEvent* event) const int key = event->key(); if ((key == Qt::Key_Enter) || (key == Qt::Key_Return)) { event->accept(); - updateActiveView(m_treeView->currentIndex()); + //updateActiveView(m_treeView->currentIndex()); } else { Panel::keyPressEvent(event); } } -void FoldersPanel::updateActiveView(const QModelIndex& index) -{ - Q_UNUSED(index); - /*const QModelIndex dirIndex = m_proxyModel->mapToSource(index); - const KFileItem item = m_dolphinModel->itemForIndex(dirIndex); - if (!item.isNull()) { - emit changeUrl(item.url(), m_mouseButtons); - }*/ -} - -void FoldersPanel::dropUrls(const QModelIndex& index, QDropEvent* event) -{ - Q_UNUSED(event); - if (index.isValid()) { - /*const QModelIndex dirIndex = m_proxyModel->mapToSource(index); - KFileItem item = m_dolphinModel->itemForIndex(dirIndex); - Q_ASSERT(!item.isNull()); - if (item.isDir()) { - Q_UNUSED(event); - //DragAndDropHelper::instance().dropUrls(item, item.url(), event, this); - }*/ - } -} - -void FoldersPanel::expandToDir(const QModelIndex& index) -{ - m_treeView->setExpanded(index, true); - selectLeafDirectory(); -} - -void FoldersPanel::scrollToLeaf() -{ - /*const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_leafDir); - const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex); - if (proxyIndex.isValid()) { - m_treeView->scrollTo(proxyIndex); - }*/ -} - void FoldersPanel::updateMouseButtons() { m_mouseButtons = QApplication::mouseButtons(); } -void FoldersPanel::slotDirListerCompleted() +void FoldersPanel::slotLoadingCompleted() { -// m_treeView->resizeColumnToContents(DolphinModel::Name); + const int index = fileItemModel()->index(url()); + if (index >= 0) { + m_controller->selectionManager()->setCurrentItem(index); + } } void FoldersPanel::slotHorizontalScrollBarMoved(int value) @@ -265,7 +237,7 @@ void FoldersPanel::slotHorizontalScrollBarMoved(int value) Q_UNUSED(value); // Disable the auto-scrolling until the vertical scrollbar has // been moved by the user. - m_treeView->setAutoHorizontalScroll(false); + //m_treeView->setAutoHorizontalScroll(false); } void FoldersPanel::slotVerticalScrollBarMoved(int value) @@ -273,7 +245,7 @@ void FoldersPanel::slotVerticalScrollBarMoved(int value) Q_UNUSED(value); // Enable the auto-scrolling again (it might have been disabled by // moving the horizontal scrollbar). - m_treeView->setAutoHorizontalScroll(FoldersPanelSettings::autoScrolling()); + //m_treeView->setAutoHorizontalScroll(FoldersPanelSettings::autoScrolling()); } void FoldersPanel::loadTree(const KUrl& url) @@ -283,10 +255,10 @@ void FoldersPanel::loadTree(const KUrl& url) KUrl baseUrl; if (url.isLocalFile()) { - // use the root directory as base for local URLs (#150941) + // Use the root directory as base for local URLs (#150941) baseUrl = QDir::rootPath(); } else { - // clear the path for non-local URLs and use it as base + // Clear the path for non-local URLs and use it as base baseUrl = url; baseUrl.setPath(QString('/')); } @@ -295,7 +267,14 @@ void FoldersPanel::loadTree(const KUrl& url) m_dirLister->stop(); m_dirLister->openUrl(baseUrl, KDirLister::Reload); } - //m_dolphinModel->expandToUrl(m_leafDir); + + KFileItemModel* model = fileItemModel(); + const int index = model->index(url); + if (index >= 0) { + m_controller->selectionManager()->setCurrentItem(index); + } else { + model->setExpanded(QSet<KUrl>() << url); + } } void FoldersPanel::selectLeafDirectory() @@ -317,4 +296,9 @@ void FoldersPanel::selectLeafDirectory() }*/ } +KFileItemModel* FoldersPanel::fileItemModel() const +{ + return static_cast<KFileItemModel*>(m_controller->model()); +} + #include "folderspanel.moc" diff --git a/src/panels/folders/folderspanel.h b/src/panels/folders/folderspanel.h index 727fc7c71..70390da60 100644 --- a/src/panels/folders/folderspanel.h +++ b/src/panels/folders/folderspanel.h @@ -24,11 +24,8 @@ #include <panels/panel.h> class KDirLister; -class DolphinModel; - -class DolphinSortFilterProxyModel; -class PanelTreeView; -class QModelIndex; +class KFileItemModel; +class KItemListController; /** * @brief Shows a tree view of the directories starting from @@ -77,28 +74,28 @@ private slots: * Updates the active view to the URL * which is given by the item with the index \a index. */ - void updateActiveView(const QModelIndex& index); + //void updateActiveView(const QModelIndex& index); /** * Is emitted if URLs have been dropped * to the index \a index. */ - void dropUrls(const QModelIndex& index, QDropEvent* event); + //void dropUrls(const QModelIndex& index, QDropEvent* event); /** * Expands the treeview to show the directory * specified by \a index. */ - void expandToDir(const QModelIndex& index); + //void expandToDir(const QModelIndex& index); /** * Assures that the leaf folder gets visible. */ - void scrollToLeaf(); + //void scrollToLeaf(); void updateMouseButtons(); - void slotDirListerCompleted(); + void slotLoadingCompleted(); void slotHorizontalScrollBarMoved(int value); @@ -119,13 +116,13 @@ private: */ void selectLeafDirectory(); + KFileItemModel* fileItemModel() const; + private: bool m_setLeafVisible; Qt::MouseButtons m_mouseButtons; KDirLister* m_dirLister; - //DolphinModel* m_dolphinModel; - //DolphinSortFilterProxyModel* m_proxyModel; - PanelTreeView* m_treeView; + KItemListController* m_controller; KUrl m_leafDir; }; diff --git a/src/panels/folders/ktreeview.cpp b/src/panels/folders/ktreeview.cpp deleted file mode 100644 index 765b934be..000000000 --- a/src/panels/folders/ktreeview.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by <haraldhv (at) stud.ntnu.no> * - * Copyright (C) 2008 by <[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 "ktreeview.h" -#include "ktreeview_p.h" - -#include <KGlobalSettings> - -#include <QItemSelectionModel> -#include <QScrollBar> -#include <QTimer> -#include <QTimeLine> - -KTreeView::KTreeViewPrivate::KTreeViewPrivate(KTreeView *parent) : - parent(parent), - autoHorizontalScroll(false), - timeLine(0) -{ - timeLine = new QTimeLine(500, this); - connect(timeLine, SIGNAL(frameChanged(int)), - this, SLOT(updateVerticalScrollBar(int))); - - connect(parent->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), - this, SLOT(startScrolling())); - connect(parent->verticalScrollBar(), SIGNAL(valueChanged(int)), - this, SLOT(startScrolling())); - connect(parent, SIGNAL(collapsed(QModelIndex)), - this, SLOT(startScrolling())); - connect(parent, SIGNAL(expanded(QModelIndex)), - this, SLOT(startScrolling())); -} - -void KTreeView::KTreeViewPrivate::startScrolling() -{ - if (!autoHorizontalScroll) { - return; - } - - // Determine the most left visual index - QModelIndex visibleIndex = parent->indexAt(QPoint(0, 0)); - if (!visibleIndex.isValid()) { - return; - } - - QModelIndex index = visibleIndex; - int minimum = parent->width(); - do { - const QRect rect = parent->visualRect(visibleIndex); - if (rect.top() > parent->viewport()->height()) { - // the current index and all successors are not visible anymore - break; - } - if (rect.left() < minimum) { - minimum = rect.left(); - index = visibleIndex; - } - visibleIndex = parent->indexBelow(visibleIndex); - } while (visibleIndex.isValid()); - - // Start the horizontal scrolling to assure that the item indicated by 'index' gets fully visible - Q_ASSERT(index.isValid()); - const QRect rect = parent->visualRect(index); - - QScrollBar* scrollBar = parent->horizontalScrollBar(); - const int oldScrollBarPos = scrollBar->value(); - - const int itemRight = oldScrollBarPos + rect.left() + rect.width() - 1; - const int availableWidth = parent->viewport()->width(); - int scrollBarPos = itemRight - availableWidth; - const int scrollBarPosMax = oldScrollBarPos + rect.left() - parent->indentation(); - if (scrollBarPos > scrollBarPosMax) { - scrollBarPos = scrollBarPosMax; - } - - if (scrollBarPos != oldScrollBarPos) { - timeLine->setFrameRange(oldScrollBarPos, scrollBarPos); - if (timeLine->state() == QTimeLine::Running) { - timeLine->stop(); - } - timeLine->start(); - } -} - -void KTreeView::KTreeViewPrivate::updateVerticalScrollBar(int value) -{ - QScrollBar *scrollBar = parent->horizontalScrollBar(); - scrollBar->setValue(value); -} - -// ************************************************ - -KTreeView::KTreeView(QWidget *parent) : - QTreeView(parent), - d(new KTreeViewPrivate(this)) -{ - if (KGlobalSettings::graphicEffectsLevel() >= KGlobalSettings::SimpleAnimationEffects) { - setAutoHorizontalScroll(true); - } -} - -KTreeView::~KTreeView() -{ -} - -void KTreeView::setAutoHorizontalScroll(bool enable) -{ - d->autoHorizontalScroll = enable; - if (!enable) { - d->timeLine->stop(); - } -} - -bool KTreeView::autoHorizontalScroll() const -{ - return d->autoHorizontalScroll; -} - -void KTreeView::scrollTo(const QModelIndex& index, ScrollHint hint) -{ - const int value = horizontalScrollBar()->value(); - QTreeView::scrollTo(index, hint); - horizontalScrollBar()->setValue(value); -} - -void KTreeView::hideEvent(QHideEvent *event) -{ - d->timeLine->stop(); - QTreeView::hideEvent(event); -} - -#include "ktreeview.moc" -#include "ktreeview_p.moc" diff --git a/src/panels/folders/ktreeview.h b/src/panels/folders/ktreeview.h deleted file mode 100644 index 754ea6db3..000000000 --- a/src/panels/folders/ktreeview.h +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by <haraldhv (at) stud.ntnu.no> * - * Copyright (C) 2008 by <[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 KTREEVIEW_H -#define KTREEVIEW_H - -#include <QTreeView> - -class KTreeView : public QTreeView -{ - Q_OBJECT - -public: - KTreeView(QWidget *parent = 0); - virtual ~KTreeView(); - - void setAutoHorizontalScroll(bool enable); - bool autoHorizontalScroll() const; - - virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible); - -protected: - virtual void hideEvent(QHideEvent *event); - -private: - class KTreeViewPrivate; - KTreeViewPrivate *d; -}; - -#endif /* ifndef KTREEVIEW_H */ diff --git a/src/panels/folders/paneltreeview.cpp b/src/panels/folders/paneltreeview.cpp deleted file mode 100644 index 26a543d56..000000000 --- a/src/panels/folders/paneltreeview.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/*************************************************************************** - * 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 "paneltreeview.h" - -#include <KFileItemDelegate> -#include <QListView> -#include <QKeyEvent> -#include <QPainter> -#include <QHeaderView> -#include <QScrollBar> - -PanelTreeView::PanelTreeView(QWidget* parent) : - KTreeView(parent) -{ - setAcceptDrops(true); - setUniformRowHeights(true); - setSelectionMode(QAbstractItemView::SingleSelection); - setEditTriggers(QAbstractItemView::NoEditTriggers); - setSortingEnabled(true); - setFrameStyle(QFrame::NoFrame); - setDragDropMode(QAbstractItemView::DragDrop); - setDropIndicatorShown(false); - - setVerticalScrollMode(QListView::ScrollPerPixel); - setHorizontalScrollMode(QListView::ScrollPerPixel); - - viewport()->setAttribute(Qt::WA_Hover); - - // make the background transparent and apply the window-text color - // to the text color, so that enough contrast is given for all color - // schemes - QPalette p = palette(); - p.setColor(QPalette::Active, QPalette::Text, p.color(QPalette::Active, QPalette::WindowText)); - p.setColor(QPalette::Inactive, QPalette::Text, p.color(QPalette::Inactive, QPalette::WindowText)); - p.setColor(QPalette::Disabled, QPalette::Text, p.color(QPalette::Disabled, QPalette::WindowText)); - setPalette(p); - viewport()->setAutoFillBackground(false); - - KFileItemDelegate* delegate = new KFileItemDelegate(this); - setItemDelegate(delegate); -} - -PanelTreeView::~PanelTreeView() -{ -} - -bool PanelTreeView::event(QEvent* event) -{ - switch (event->type()) { - case QEvent::Polish: - // Hide all columns except of the 'Name' column - /*for (int i = DolphinModel::Name + 1; i < DolphinModel::ExtraColumnCount; ++i) { - hideColumn(i); - } - header()->hide();*/ - break; - - case QEvent::Show: - // TODO: The opening/closing animation of subtrees flickers in combination with the - // panel when using the Oxygen style. As workaround the animation is turned off: - setAnimated(false); - break; - - case QEvent::UpdateRequest: - // a wheel movement will scroll 1 item - if (model()->rowCount() > 0) { - verticalScrollBar()->setSingleStep(sizeHintForRow(0) / 3); - } - break; - - default: - break; - } - - return KTreeView::event(event); -} - -void PanelTreeView::startDrag(Qt::DropActions supportedActions) -{ - Q_UNUSED(supportedActions); - //DragAndDropHelper::instance().startDrag(this, supportedActions); -} - -void PanelTreeView::dragEnterEvent(QDragEnterEvent* event) -{ - KTreeView::dragEnterEvent(event); - if (event->mimeData()->hasUrls()) { - event->acceptProposedAction(); - } -} - -void PanelTreeView::dragLeaveEvent(QDragLeaveEvent* event) -{ - KTreeView::dragLeaveEvent(event); - setDirtyRegion(m_dropRect); -} - -void PanelTreeView::dragMoveEvent(QDragMoveEvent* event) -{ - KTreeView::dragMoveEvent(event); - - // TODO: remove this code when the issue #160611 is solved in Qt 4.4 - const QModelIndex index = indexAt(event->pos()); - setDirtyRegion(m_dropRect); - m_dropRect = visualRect(index); - setDirtyRegion(m_dropRect); - - if (event->mimeData()->hasUrls()) { - // accept url drops, independently from the destination item - event->acceptProposedAction(); - } -} - -void PanelTreeView::dropEvent(QDropEvent* event) -{ - const QModelIndex index = indexAt(event->pos()); - if (index.isValid()) { - emit urlsDropped(index, event); - } - KTreeView::dropEvent(event); -} - -#include "paneltreeview.moc" diff --git a/src/panels/folders/paneltreeview.h b/src/panels/folders/paneltreeview.h deleted file mode 100644 index 73d17c236..000000000 --- a/src/panels/folders/paneltreeview.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * 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 PANELTREEVIEW_H -#define PANELTREEVIEW_H - -#include <KUrl> -#include <panels/folders/ktreeview.h> - -/** - * @brief Tree view widget which is used for the folders panel. - * - * @see FoldersPanel - */ -class PanelTreeView : public KTreeView -{ - Q_OBJECT - -public: - explicit PanelTreeView(QWidget* parent = 0); - virtual ~PanelTreeView(); - -signals: - /** - * Is emitted if the URL have been dropped to - * the index \a index. - */ - void urlsDropped(const QModelIndex& index, QDropEvent* event); - -protected: - virtual bool event(QEvent* event); - virtual void startDrag(Qt::DropActions supportedActions); - virtual void dragEnterEvent(QDragEnterEvent* event); - virtual void dragLeaveEvent(QDragLeaveEvent* event); - virtual void dragMoveEvent(QDragMoveEvent* event); - virtual void dropEvent(QDropEvent* event); - -private: - QRect m_dropRect; -}; - -#endif |
