┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/places/placespanel.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-21 21:28:16 +0200
committerPeter Penz <[email protected]>2012-04-21 21:32:42 +0200
commitae4d11d918938fd9087f2035dac247969c1f2313 (patch)
tree0303667797c81814b46b9ed5ed20b48ef31f2d71 /src/panels/places/placespanel.cpp
parent47d7cdffdd2d2c04067a5088eaeff67add53dde3 (diff)
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.
Diffstat (limited to 'src/panels/places/placespanel.cpp')
-rw-r--r--src/panels/places/placespanel.cpp66
1 files changed, 48 insertions, 18 deletions
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 <[email protected]> *
+ * Copyright (C) 2008-2012 by Peter Penz <[email protected]> *
* Copyright (C) 2010 by Christian Muehlhaeuser <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -20,40 +20,70 @@
#include "placespanel.h"
-#include <KFileItem>
-#include <konq_operations.h>
+#include <KIcon>
+#include <kitemviews/kitemlistcontainer.h>
+#include <kitemviews/kitemlistcontroller.h>
+#include <kitemviews/kstandarditem.h>
+#include <kitemviews/kstandarditemlistview.h>
+#include <kitemviews/kstandarditemmodel.h>
#include <views/draganddrophelper.h>
+#include <QVBoxLayout>
+#include <QShowEvent>
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"