+ return index >= 0 && index < count();
+}
+
+void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
+{
+ if (mimeData->hasFormat(internalMimeType())) {
+ // The item has been moved inside the view
+ QByteArray itemData = mimeData->data(internalMimeType());
+ QDataStream stream(&itemData, QIODevice::ReadOnly);
+ int oldIndex;
+ stream >> oldIndex;
+ if (oldIndex == index || oldIndex == index - 1) {
+ // No moving has been done
+ return;
+ }
+
+ PlacesItem* oldItem = placesItem(oldIndex);
+ if (!oldItem) {
+ return;
+ }
+
+ PlacesItem* newItem = new PlacesItem(oldItem->bookmark());
+ removeItem(oldIndex);
+
+ if (oldIndex < index) {
+ --index;
+ }
+
+ const int dropIndex = groupedDropIndex(index, newItem);
+ insertItem(dropIndex, newItem);
+ } else if (mimeData->hasFormat("text/uri-list")) {
+ // One or more items must be added to the model
+ const QList<QUrl> urls = KUrlMimeData::urlsFromMimeData(mimeData);
+ for (int i = urls.count() - 1; i >= 0; --i) {
+ const QUrl& url = urls[i];
+
+ QString text = url.fileName();
+ if (text.isEmpty()) {
+ text = url.host();
+ }
+
+ if ((url.isLocalFile() && !QFileInfo(url.toLocalFile()).isDir())
+ || url.scheme() == "trash") {
+ // Only directories outside the trash are allowed
+ continue;
+ }
+
+ PlacesItem* newItem = createPlacesItem(text, url);
+ const int dropIndex = groupedDropIndex(index, newItem);
+ insertItem(dropIndex, newItem);
+ }
+ }
+}
+
+QUrl PlacesItemModel::convertedUrl(const QUrl& url)
+{
+ QUrl newUrl = url;
+ if (url.scheme() == QLatin1String("timeline")) {