┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/places/placesitemmodel.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-06-02 15:02:34 +0200
committerPeter Penz <[email protected]>2012-06-02 15:03:22 +0200
commit12215d6f0f7768fc943347a349d9817844e0528a (patch)
tree76db3b0f6c32900b397246de3c8f731c703708f3 /src/panels/places/placesitemmodel.cpp
parent665c44821e32ba4bdfcd94889eb17e08ac25a315 (diff)
Use PlacesItemModel instead of KFilePlacesModel
This allows inserting items to the corresponding group.
Diffstat (limited to 'src/panels/places/placesitemmodel.cpp')
-rw-r--r--src/panels/places/placesitemmodel.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp
index c1a5426af..02e1944bd 100644
--- a/src/panels/places/placesitemmodel.cpp
+++ b/src/panels/places/placesitemmodel.cpp
@@ -226,6 +226,32 @@ int PlacesItemModel::closestItem(const KUrl& url) const
return foundIndex;
}
+void PlacesItemModel::appendItemToGroup(PlacesItem* item)
+{
+ if (!item) {
+ return;
+ }
+
+ int i = 0;
+ while (i < count() && placesItem(i)->group() != item->group()) {
+ ++i;
+ }
+
+ bool inserted = false;
+ while (!inserted && i < count()) {
+ if (placesItem(i)->group() != item->group()) {
+ insertItem(i, item);
+ inserted = true;
+ }
+ ++i;
+ }
+
+ if (!inserted) {
+ appendItem(item);
+ }
+}
+
+
QAction* PlacesItemModel::ejectAction(int index) const
{
const PlacesItem* item = placesItem(index);
@@ -370,11 +396,7 @@ void PlacesItemModel::dropMimeData(int index, const QMimeData* mimeData)
text = url.host();
}
- KBookmark bookmark = PlacesItem::createBookmark(m_bookmarkManager,
- text,
- url,
- "folder");
- PlacesItem* newItem = new PlacesItem(bookmark);
+ PlacesItem* newItem = createPlacesItem(text, url);
const int dropIndex = groupedDropIndex(index, newItem);
insertItem(dropIndex, newItem);
}
@@ -567,7 +589,7 @@ void PlacesItemModel::updateBookmarks()
if (item->isHidden() && !m_hiddenItemsShown) {
m_bookmarkedItems.append(item);
} else {
- appendItem(item);
+ appendItemToGroup(item);
}
}
}