From ae4d11d918938fd9087f2035dac247969c1f2313 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 21 Apr 2012 21:28:16 +0200 Subject: Prepare view-engine for non-KFileItem usecase Up to now the view-engine only provided a model-implementation that supports file-items. The view-engine always had been designed to be able to work with any kind of model, so now a KStandardItemModel is available. The plan is to convert the places panel to the new view-engine. It should be no problem to fix this until the feature freeze - in the worst case the places-panel code could be reverted while still keeping the KStandardItemModel changes. --- src/panels/places/placespanel.cpp | 66 ++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 18 deletions(-) (limited to 'src/panels/places/placespanel.cpp') diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 902c436cf..4ac822760 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Peter Penz * + * Copyright (C) 2008-2012 by Peter Penz * * Copyright (C) 2010 by Christian Muehlhaeuser * * * * This program is free software; you can redistribute it and/or modify * @@ -20,40 +20,70 @@ #include "placespanel.h" -#include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include PlacesPanel::PlacesPanel(QWidget* parent) : - KFilePlacesView(parent), - m_mouseButtons(Qt::NoButton) + Panel(parent), + m_controller(0), + m_model(0) { - setDropOnPlaceEnabled(true); - connect(this, SIGNAL(urlsDropped(KUrl,QDropEvent*,QWidget*)), - this, SLOT(slotUrlsDropped(KUrl,QDropEvent*,QWidget*))); - connect(this, SIGNAL(urlChanged(KUrl)), - this, SLOT(emitExtendedUrlChangedSignal(KUrl))); } PlacesPanel::~PlacesPanel() { } -void PlacesPanel::mousePressEvent(QMouseEvent* event) +bool PlacesPanel::urlChanged() { - m_mouseButtons = event->buttons(); - KFilePlacesView::mousePressEvent(event); + return true; } -void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent) +void PlacesPanel::showEvent(QShowEvent* event) { - Q_UNUSED(parent); - DragAndDropHelper::dropUrls(KFileItem(), dest, event); + if (event->spontaneous()) { + Panel::showEvent(event); + return; + } + + if (!m_controller) { + // Postpone the creating of the controller to the first show event. + // This assures that no performance and memory overhead is given when the folders panel is not + // used at all and stays invisible. + KStandardItemListView* view = new KStandardItemListView(); + m_model = new KStandardItemModel(this); + m_model->appendItem(new KStandardItem("Temporary")); + m_model->appendItem(new KStandardItem("out of")); + m_model->appendItem(new KStandardItem("order. Press")); + m_model->appendItem(new KStandardItem("F9 and use")); + m_model->appendItem(new KStandardItem("the left icon")); + m_model->appendItem(new KStandardItem("of the location")); + m_model->appendItem(new KStandardItem("bar instead.")); + + m_controller = new KItemListController(m_model, view, this); + + KItemListContainer* container = new KItemListContainer(m_controller, this); + container->setEnabledFrame(false); + + QVBoxLayout* layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(container); + } + + Panel::showEvent(event); } -void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl& url) +void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent) { - emit urlChanged(url, m_mouseButtons); + Q_UNUSED(parent); + DragAndDropHelper::dropUrls(KFileItem(), dest, event); } #include "placespanel.moc" -- cgit v1.3.1