#include "dolphindirlister.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinsettings.h"
+#include "dolphinviewautoscroller.h"
#include "dolphin_columnmodesettings.h"
#include "dolphin_generalsettings.h"
#include "draganddrophelper.h"
#include "folderexpander.h"
-#include "kfilepreviewgenerator.h"
#include "selectionmanager.h"
#include "tooltipmanager.h"
#include <kcolorscheme.h>
#include <kdirlister.h>
#include <kfileitem.h>
+#include <kfilepreviewgenerator.h>
#include <kio/previewjob.h>
#include <kiconeffect.h>
#include <kjob.h>
#include <QClipboard>
#include <QPainter>
#include <QPoint>
+#include <QScrollBar>
DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
DolphinColumnView* columnView,
m_active(true),
m_view(columnView),
m_selectionManager(0),
+ m_autoScroller(0),
m_url(url),
m_childUrl(),
m_font(),
setVerticalScrollMode(QListView::ScrollPerPixel);
setHorizontalScrollMode(QListView::ScrollPerPixel);
+ m_autoScroller = new DolphinViewAutoScroller(this);
+
// apply the column mode settings to the widget
const ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
Q_ASSERT(settings != 0);
setDecorationSize(QSize(iconSize, iconSize));
KFileItemDelegate* delegate = new KFileItemDelegate(this);
+ delegate->setShowToolTipWhenElided(false);
setItemDelegate(delegate);
activate();
connect(this, SIGNAL(entered(const QModelIndex&)),
this, SLOT(slotEntered(const QModelIndex&)));
- //m_dirLister = new DolphinDirLister(); TODO
- m_dirLister = new KDirLister();
+ m_dirLister = new DolphinDirLister();
m_dirLister->setAutoUpdate(true);
m_dirLister->setMainWindow(window());
m_dirLister->setDelayedMimeTypes(true);
m_selectionManager, SLOT(reset()));
}
- m_previewGenerator = new KFilePreviewGenerator(this, m_proxyModel);
- m_previewGenerator->setShowPreview(m_view->m_controller->dolphinView()->showPreview());
+ m_previewGenerator = new KFilePreviewGenerator(this);
+ m_previewGenerator->setPreviewShown(m_view->m_controller->dolphinView()->showPreview());
if (DolphinSettings::instance().generalSettings()->showToolTips()) {
new ToolTipManager(this, m_proxyModel);
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
this, SLOT(updateFont()));
-
+
FolderExpander* folderExpander = new FolderExpander(this, m_proxyModel);
folderExpander->setEnabled(DolphinSettings::instance().generalSettings()->autoExpandFolders());
connect (folderExpander, SIGNAL(enterDir(const QModelIndex&)),
void DolphinColumnWidget::setActive(bool active)
{
- if (m_active == active) {
- return;
+ if (active && (m_view->focusProxy() != this)) {
+ m_view->setFocusProxy(this);
}
- m_active = active;
+ if (m_active != active) {
+ m_active = active;
- if (active) {
- activate();
- } else {
- deactivate();
+ if (active) {
+ activate();
+ } else {
+ deactivate();
+ }
}
}
void DolphinColumnWidget::setShowPreview(bool show)
{
- m_previewGenerator->setShowPreview(show);
+ m_previewGenerator->setPreviewShown(show);
m_dirLister->stop();
m_dirLister->openUrl(m_url, KDirLister::Reload);
return itemList;
}
+QMimeData* DolphinColumnWidget::selectionMimeData() const
+{
+ const QItemSelection selection = m_proxyModel->mapSelectionToSource(selectionModel()->selection());
+ return m_dolphinModel->mimeData(selection.indexes());
+}
+
QStyleOptionViewItem DolphinColumnWidget::viewOptions() const
{
QStyleOptionViewItem viewOptions = QListView::viewOptions();
void DolphinColumnWidget::startDrag(Qt::DropActions supportedActions)
{
- DragAndDropHelper::startDrag(this, supportedActions);
+ DragAndDropHelper::instance().startDrag(this, supportedActions, m_view->m_controller);
}
void DolphinColumnWidget::dragEnterEvent(QDragEnterEvent* event)
{
- if (event->mimeData()->hasUrls()) {
+ if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
event->acceptProposedAction();
+ requestActivation();
}
}
}
setDirtyRegion(m_dropRect);
- if (event->mimeData()->hasUrls()) {
+ if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
// accept url drops, independently from the destination item
event->acceptProposedAction();
}
void DolphinColumnWidget::dropEvent(QDropEvent* event)
{
- const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
- if (!urls.isEmpty()) {
- const QModelIndex index = indexAt(event->pos());
- m_view->m_controller->setItemView(this);
- const KFileItem item = m_view->m_controller->itemForIndex(index);
- m_view->m_controller->indicateDroppedUrls(urls,
- url(),
- item);
- event->acceptProposedAction();
- }
+ const QModelIndex index = indexAt(event->pos());
+ m_view->m_controller->setItemView(this);
+ const KFileItem item = m_view->m_controller->itemForIndex(index);
+ m_view->m_controller->indicateDroppedUrls(item, url(), event);
QListView::dropEvent(event);
}
return;
}
+ const int height = m_decorationSize.height();
+ const int step = (height >= KIconLoader::SizeHuge) ? height / 10 : (KIconLoader::SizeHuge - height) / 2;
+ verticalScrollBar()->setSingleStep(step);
+
QListView::wheelEvent(event);
}
selModel->select(deselected, QItemSelectionModel::Deselect);
}
+void DolphinColumnWidget::currentChanged(const QModelIndex& current, const QModelIndex& previous)
+{
+ QListView::currentChanged(current, previous);
+ if (current.isValid() && !m_autoScroller->isActive()) {
+ scrollTo(current);
+ }
+}
+
void DolphinColumnWidget::slotEntered(const QModelIndex& index)
{
m_view->m_controller->setItemView(this);
{
setFocus(Qt::OtherFocusReason);
- // 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'.
+ connect(this, SIGNAL(clicked(const QModelIndex&)),
+ m_view->m_controller, SLOT(requestTab(const QModelIndex&)));
if (KGlobalSettings::singleClick()) {
connect(this, SIGNAL(clicked(const QModelIndex&)),
m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));