┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/places
diff options
context:
space:
mode:
Diffstat (limited to 'src/panels/places')
-rw-r--r--src/panels/places/placesitemlistgroupheader.cpp5
-rw-r--r--src/panels/places/placesitemlistgroupheader.h2
-rw-r--r--src/panels/places/placesitemlistwidget.cpp2
-rw-r--r--src/panels/places/placesitemlistwidget.h2
-rw-r--r--src/panels/places/placesitemmodel.cpp28
-rw-r--r--src/panels/places/placespanel.cpp73
-rw-r--r--src/panels/places/placespanel.h8
7 files changed, 108 insertions, 12 deletions
diff --git a/src/panels/places/placesitemlistgroupheader.cpp b/src/panels/places/placesitemlistgroupheader.cpp
index 27d4c7917..ec7c4b18c 100644
--- a/src/panels/places/placesitemlistgroupheader.cpp
+++ b/src/panels/places/placesitemlistgroupheader.cpp
@@ -37,4 +37,9 @@ void PlacesItemListGroupHeader::paintSeparator(QPainter* painter, const QColor&
Q_UNUSED(color);
}
+QPalette::ColorRole PlacesItemListGroupHeader::normalTextColorRole() const
+{
+ return QPalette::WindowText;
+}
+
#include "placesitemlistgroupheader.moc"
diff --git a/src/panels/places/placesitemlistgroupheader.h b/src/panels/places/placesitemlistgroupheader.h
index fbcd116f1..1c2d5cc25 100644
--- a/src/panels/places/placesitemlistgroupheader.h
+++ b/src/panels/places/placesitemlistgroupheader.h
@@ -32,6 +32,8 @@ public:
protected:
virtual void paintSeparator(QPainter* painter, const QColor& color);
+
+ virtual QPalette::ColorRole normalTextColorRole() const;
};
#endif
diff --git a/src/panels/places/placesitemlistwidget.cpp b/src/panels/places/placesitemlistwidget.cpp
index 00f0fdab0..e33d1daf9 100644
--- a/src/panels/places/placesitemlistwidget.cpp
+++ b/src/panels/places/placesitemlistwidget.cpp
@@ -35,7 +35,7 @@ bool PlacesItemListWidget::isHidden() const
return data().value("isHidden").toBool();
}
-QPalette::ColorRole PlacesItemListWidget::normalTextColorPalette() const
+QPalette::ColorRole PlacesItemListWidget::normalTextColorRole() const
{
return QPalette::WindowText;
}
diff --git a/src/panels/places/placesitemlistwidget.h b/src/panels/places/placesitemlistwidget.h
index 93cd8f468..a2a88c1f0 100644
--- a/src/panels/places/placesitemlistwidget.h
+++ b/src/panels/places/placesitemlistwidget.h
@@ -36,7 +36,7 @@ public:
protected:
virtual bool isHidden() const;
- virtual QPalette::ColorRole normalTextColorPalette() const;
+ virtual QPalette::ColorRole normalTextColorRole() const;
};
#endif
diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp
index 497901345..4770c6b10 100644
--- a/src/panels/places/placesitemmodel.cpp
+++ b/src/panels/places/placesitemmodel.cpp
@@ -54,7 +54,7 @@
#include <Nepomuk/ResourceManager>
#include <Nepomuk/Query/ComparisonTerm>
#include <Nepomuk/Query/LiteralTerm>
- #include <Nepomuk/Query/Query>
+ #include <Nepomuk/Query/FileQuery>
#include <Nepomuk/Query/ResourceTypeTerm>
#include <Nepomuk/Vocabulary/NFO>
#include <Nepomuk/Vocabulary/NIE>
@@ -659,11 +659,22 @@ void PlacesItemModel::updateBookmarks()
}
if (!found) {
- PlacesItem* item = new PlacesItem(newBookmark);
- if (item->isHidden() && !m_hiddenItemsShown) {
- m_bookmarkedItems.append(item);
- } else {
- appendItemToGroup(item);
+ const QString udi = newBookmark.metaDataItem("UDI");
+
+ /*
+ * See Bug 304878
+ * Only add a new places item, if the item text is not empty
+ * and if the device is available. Fixes the strange behaviour -
+ * add a places item without text in the Places section - when you
+ * remove a device (e.g. a usb stick) without unmounting.
+ */
+ if (udi.isEmpty() || Solid::Device(udi).isValid()) {
+ PlacesItem* item = new PlacesItem(newBookmark);
+ if (item->isHidden() && !m_hiddenItemsShown) {
+ m_bookmarkedItems.append(item);
+ } else {
+ appendItemToGroup(item);
+ }
}
}
}
@@ -885,8 +896,7 @@ void PlacesItemModel::createSystemBookmarks()
Q_ASSERT(m_systemBookmarks.isEmpty());
Q_ASSERT(m_systemBookmarksIndexes.isEmpty());
- const QString timeLineIcon = "package_utility_time"; // TODO: Ask the Oxygen team to create
- // a custom icon for the timeline-protocol
+ const QString timeLineIcon = "chronometer";
// Note: The context of the I18N_NOOP2 must be "KFile System Bookmarks". The real
// i18nc call is done after reading the bookmark. The reason why the i18nc call is not
@@ -1162,7 +1172,7 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
#ifdef HAVE_NEPOMUK
KUrl PlacesItemModel::searchUrlForTerm(const Nepomuk::Query::Term& term)
{
- const Nepomuk::Query::Query query(term);
+ const Nepomuk::Query::FileQuery query(term);
return query.toSearchUrl();
}
#endif
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp
index 429c5399a..e483f9b83 100644
--- a/src/panels/places/placespanel.cpp
+++ b/src/panels/places/placespanel.cpp
@@ -23,6 +23,8 @@
#include "placespanel.h"
+#include "dolphin_generalsettings.h"
+
#include <KDebug>
#include <KDirNotify>
#include <KIcon>
@@ -52,7 +54,10 @@ PlacesPanel::PlacesPanel(QWidget* parent) :
m_controller(0),
m_model(0),
m_storageSetupFailedUrl(),
- m_triggerStorageSetupButton()
+ m_triggerStorageSetupButton(),
+ m_itemDropEventIndex(-1),
+ m_itemDropEventMimeData(0),
+ m_itemDropEvent(0)
{
}
@@ -62,9 +67,27 @@ PlacesPanel::~PlacesPanel()
bool PlacesPanel::urlChanged()
{
+ if (!url().isValid() || url().protocol().contains("search")) {
+ // Skip results shown by a search, as possible identical
+ // directory names are useless without parent-path information.
+ return false;
+ }
+
+ if (m_controller) {
+ selectClosestItem();
+ }
+
return true;
}
+void PlacesPanel::readSettings()
+{
+ if (m_controller) {
+ const int delay = GeneralSettings::autoExpandFolders() ? 750 : -1;
+ m_controller->setAutoActivationDelay(delay);
+ }
+}
+
void PlacesPanel::showEvent(QShowEvent* event)
{
if (event->spontaneous()) {
@@ -88,6 +111,9 @@ void PlacesPanel::showEvent(QShowEvent* event)
m_controller = new KItemListController(m_model, view, this);
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
m_controller->setSingleClickActivation(true);
+
+ readSettings();
+
connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
@@ -258,6 +284,30 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
return;
}
+ if (m_model->storageSetupNeeded(index)) {
+ connect(m_model, SIGNAL(storageSetupDone(int,bool)),
+ this, SLOT(slotItemDropEventStorageSetupDone(int,bool)));
+
+ m_itemDropEventIndex = index;
+
+ // Make a full copy of the Mime-Data
+ m_itemDropEventMimeData = new QMimeData;
+ m_itemDropEventMimeData->setText(event->mimeData()->text());
+ m_itemDropEventMimeData->setHtml(event->mimeData()->html());
+ m_itemDropEventMimeData->setUrls(event->mimeData()->urls());
+ m_itemDropEventMimeData->setImageData(event->mimeData()->imageData());
+ m_itemDropEventMimeData->setColorData(event->mimeData()->colorData());
+
+ m_itemDropEvent = new QDropEvent(event->pos().toPoint(),
+ event->possibleActions(),
+ m_itemDropEventMimeData,
+ event->buttons(),
+ event->modifiers());
+
+ m_model->requestStorageSetup(index);
+ return;
+ }
+
KUrl destUrl = m_model->placesItem(index)->url();
QDropEvent dropEvent(event->pos().toPoint(),
event->possibleActions(),
@@ -268,6 +318,27 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
DragAndDropHelper::dropUrls(KFileItem(), destUrl, &dropEvent);
}
+void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
+{
+ disconnect(m_model, SIGNAL(storageSetupDone(int,bool)),
+ this, SLOT(slotItemDropEventStorageSetupDone(int,bool)));
+
+ if ((index == m_itemDropEventIndex) && m_itemDropEvent && m_itemDropEventMimeData) {
+ if (success) {
+ KUrl destUrl = m_model->placesItem(index)->url();
+
+ DragAndDropHelper::dropUrls(KFileItem(), destUrl, m_itemDropEvent);
+ }
+
+ delete m_itemDropEventMimeData;
+ delete m_itemDropEvent;
+
+ m_itemDropEventIndex = -1;
+ m_itemDropEventMimeData = 0;
+ m_itemDropEvent = 0;
+ }
+}
+
void PlacesPanel::slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
{
m_model->dropMimeDataBefore(index, event->mimeData());
diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h
index 8a84e00a0..7951cdd9c 100644
--- a/src/panels/places/placespanel.h
+++ b/src/panels/places/placespanel.h
@@ -50,12 +50,16 @@ protected:
virtual bool urlChanged();
virtual void showEvent(QShowEvent* event);
+public slots:
+ virtual void readSettings();
+
private slots:
void slotItemActivated(int index);
void slotItemMiddleClicked(int index);
void slotItemContextMenuRequested(int index, const QPointF& pos);
void slotViewContextMenuRequested(const QPointF& pos);
void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
+ void slotItemDropEventStorageSetupDone(int index, bool success);
void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent);
void slotTrashUpdated(KJob* job);
@@ -80,6 +84,10 @@ private:
KUrl m_storageSetupFailedUrl;
Qt::MouseButton m_triggerStorageSetupButton;
+
+ int m_itemDropEventIndex;
+ QMimeData* m_itemDropEventMimeData;
+ QDropEvent* m_itemDropEvent;
};
#endif // PLACESPANEL_H