#include "dolphin_generalsettings.h"
#include "draganddrophelper.h"
#include "selectionmanager.h"
+#include "tooltipmanager.h"
#include <kcolorscheme.h>
#include <kdirlister.h>
QListView(parent),
m_active(true),
m_view(columnView),
+ m_selectionManager(0),
m_url(url),
m_childUrl(),
m_font(),
m_dolphinModel(0),
m_proxyModel(0),
m_iconManager(0),
- m_dragging(false),
m_dropRect()
{
setMouseTracking(true);
- viewport()->setAttribute(Qt::WA_Hover);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setSelectionBehavior(SelectItems);
setDragDropMode(QAbstractItemView::DragDrop);
setDropIndicatorShown(false);
setSelectionRectVisible(true);
+ setEditTriggers(QAbstractItemView::NoEditTriggers);
setVerticalScrollMode(QListView::ScrollPerPixel);
setHorizontalScrollMode(QListView::ScrollPerPixel);
const bool useSelManager = KGlobalSettings::singleClick() &&
DolphinSettings::instance().generalSettings()->showSelectionToggle();
if (useSelManager) {
- SelectionManager* selManager = new SelectionManager(this);
- connect(selManager, SIGNAL(selectionChanged()),
+ m_selectionManager = new SelectionManager(this);
+ connect(m_selectionManager, SIGNAL(selectionChanged()),
this, SLOT(requestActivation()));
connect(m_view->m_controller, SIGNAL(urlChanged(const KUrl&)),
- selManager, SLOT(reset()));
+ m_selectionManager, SLOT(reset()));
}
new KMimeTypeResolver(this, m_dolphinModel);
m_iconManager = new IconManager(this, m_proxyModel);
m_iconManager->setShowPreview(m_view->m_controller->dolphinView()->showPreview());
+ if (DolphinSettings::instance().generalSettings()->showToolTips()) {
+ new ToolTipManager(this, m_proxyModel);
+ }
+
m_dirLister->openUrl(url, KDirLister::NoFlags);
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
setIconSize(size);
m_decorationSize = size;
doItemsLayout();
+ if (m_iconManager != 0) {
+ m_iconManager->updatePreviews();
+ }
+ if (m_selectionManager != 0) {
+ m_selectionManager->reset();
+ }
}
void DolphinColumnWidget::setActive(bool active)
m_proxyModel->setFilterRegExp(nameFilter);
}
+void DolphinColumnWidget::editItem(const KFileItem& item)
+{
+ const QModelIndex dirIndex = m_dolphinModel->indexForItem(item);
+ const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
+ if (proxyIndex.isValid()) {
+ edit(proxyIndex);
+ }
+}
QStyleOptionViewItem DolphinColumnWidget::viewOptions() const
{
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
-
- m_dragging = true;
}
void DolphinColumnWidget::dragLeaveEvent(QDragLeaveEvent* event)
{
QListView::dragLeaveEvent(event);
-
- // TODO: remove this code when the issue #160611 is solved in Qt 4.4
- m_dragging = false;
setDirtyRegion(m_dropRect);
}
event->acceptProposedAction();
}
QListView::dropEvent(event);
- m_dragging = false;
}
void DolphinColumnWidget::paintEvent(QPaintEvent* event)
if (proxyIndex.isValid() && !selectionModel()->isSelected(proxyIndex)) {
const QRect itemRect = visualRect(proxyIndex);
QPainter painter(viewport());
- painter.save();
-
QColor color = KColorScheme(QPalette::Active, KColorScheme::View).foreground().color();
color.setAlpha(32);
painter.setPen(Qt::NoPen);
painter.setBrush(color);
painter.drawRect(itemRect);
-
- painter.restore();
}
}
QListView::paintEvent(event);
-
- // TODO: remove this code when the issue #160611 is solved in Qt 4.4
- if (m_dragging) {
- const QBrush& brush = viewOptions().palette.brush(QPalette::Normal, QPalette::Highlight);
- DragAndDropHelper::drawHoverIndication(this, m_dropRect, brush);
- }
}
void DolphinColumnWidget::mousePressEvent(QMouseEvent* event)
{
requestActivation();
+ if (indexAt(event->pos()).isValid() && (event->button() == Qt::LeftButton)) {
+ // TODO: see comment in DolphinIconsView::mousePressEvent()
+ setState(QAbstractItemView::DraggingState);
+ }
QListView::mousePressEvent(event);
}
void DolphinColumnWidget::wheelEvent(QWheelEvent* event)
{
+ if (m_selectionManager != 0) {
+ m_selectionManager->reset();
+ }
+
// let Ctrl+wheel events propagate to the DolphinView for icon zooming
if (event->modifiers() & Qt::ControlModifier) {
event->ignore();
return;
}
+
QListView::wheelEvent(event);
}
+void DolphinColumnWidget::leaveEvent(QEvent* event)
+{
+ QListView::leaveEvent(event);
+ // if the mouse is above an item and moved very fast outside the widget,
+ // no viewportEntered() signal might be emitted although the mouse has been moved
+ // above the viewport
+ m_view->m_controller->emitViewportEntered();
+}
+
void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
{
QListView::selectionChanged(selected, deselected);
void DolphinColumnWidget::requestActivation()
{
+ m_view->m_controller->setItemView(this);
m_view->m_controller->requestActivation();
if (!m_active) {
m_view->requestActivation(this);
m_view->m_controller->triggerUrlChangeRequest(m_url);
selectionModel()->clear();
}
- Q_ASSERT(m_view->m_controller->itemView() == this);
}
void DolphinColumnWidget::updateFont()
// necessary connecting the signal 'singleClick()' or 'doubleClick'.
if (KGlobalSettings::singleClick()) {
disconnect(this, SIGNAL(clicked(const QModelIndex&)),
- this, SLOT(triggerItem(const QModelIndex&)));
+ m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
} else {
disconnect(this, SIGNAL(doubleClicked(const QModelIndex&)),
- this, SLOT(triggerItem(const QModelIndex&)));
+ m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
}
const QModelIndex current = selectionModel()->currentIndex();