#include <QBoxLayout>
#include <QTimer>
#include <QScrollBar>
-#include <QClipboard>
#include <kcolorscheme.h>
#include <kdirlister.h>
#include <kio/deletejob.h>
#include <kio/netaccess.h>
#include <kio/previewjob.h>
+#include <kjob.h>
+#include <kmenu.h>
#include <kmimetyperesolver.h>
#include <konqmimedata.h>
#include <konq_operations.h>
#include <kurl.h>
+#include "dolphindropcontroller.h"
#include "dolphinmodel.h"
#include "dolphincolumnview.h"
#include "dolphincontroller.h"
m_selectionModel(0),
m_dolphinModel(dolphinModel),
m_dirLister(dirLister),
- m_proxyModel(proxyModel)
+ m_proxyModel(proxyModel),
+ m_previewJob(0)
{
setFocusPolicy(Qt::StrongFocus);
m_topLayout = new QVBoxLayout(this);
DolphinView::~DolphinView()
{
+ if (m_previewJob != 0) {
+ m_previewJob->kill();
+ m_previewJob = 0;
+ }
}
const KUrl& DolphinView::url() const
void DolphinView::selectAll()
{
- itemView()->selectAll();
+ QAbstractItemView* view = itemView();
+ // TODO: there seems to be a bug in QAbstractItemView::selectAll(); if
+ // the Ctrl-key is pressed (e. g. for Ctrl+A), selectAll() inverts the
+ // selection instead of selecting all items. This is bypassed for KDE 4.0
+ // by invoking clearSelection() first.
+ view->clearSelection();
+ view->selectAll();
}
void DolphinView::invertSelection()
void DolphinView::generatePreviews(const KFileItemList& items)
{
if (m_controller->dolphinView()->showPreview()) {
- KIO::PreviewJob* job = KIO::filePreview(items, 128);
- connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
- this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
+ if (m_previewJob != 0) {
+ m_previewJob->kill();
+ m_previewJob = 0;
+ }
+
+ m_previewJob = KIO::filePreview(items, 128);
+ connect(m_previewJob, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
+ this, SLOT(replaceIcon(const KFileItem&, const QPixmap&)));
+ connect(m_previewJob, SIGNAL(finished(KJob*)),
+ this, SLOT(slotPreviewJobFinished(KJob*)));
}
}
-void DolphinView::showPreview(const KFileItem& item, const QPixmap& pixmap)
+void DolphinView::replaceIcon(const KFileItem& item, const QPixmap& pixmap)
{
Q_ASSERT(!item.isNull());
- if (item.url().directory() != m_dirLister->url().path()) {
- // the preview job is still working on items of an older URL, hence
+ if (!m_showPreview || (item.url().directory() != m_dirLister->url().path())) {
+ // the preview has been deactivated in the meanwhile or the preview
+ // job is still working on items of an older URL, hence
// the item is not part of the directory model anymore
return;
}
const KUrl& destPath,
const KFileItem& destItem)
{
+ Q_ASSERT(!urls.isEmpty());
const KUrl& destination = !destItem.isNull() && destItem.isDir() ?
destItem.url() : destPath;
const KUrl sourceDir = KUrl(urls.first().directory());
void DolphinView::dropUrls(const KUrl::List& urls,
const KUrl& destination)
{
- emit urlsDropped(urls, destination);
+ DolphinDropController dropController(this);
+ // forward doingOperation signal up to the mainwindow
+ connect(&dropController, SIGNAL(doingOperation(KonqFileUndoManager::CommandType)),
+ this, SIGNAL(doingOperation(KonqFileUndoManager::CommandType)));
+ dropController.dropUrls(urls, destination);
}
void DolphinView::updateSorting(DolphinView::Sorting sorting)
m_selectionModel = view->selectionModel();
}
- m_selectionModel->setParent(this); //Reparent the selection model. We do not want it to be deleted when we delete the model
+ // reparent the selection model, as it should not be deleted
+ // when deleting the model
+ m_selectionModel->setParent(this);
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
}
+void DolphinView::slotPreviewJobFinished(KJob* job)
+{
+ Q_ASSERT(job == m_previewJob);
+ m_previewJob = 0;
+}
+
void DolphinView::cutSelectedItems()
{
QMimeData* mimeData = new QMimeData();