<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>konqbookmark/itemviews/locationbardelegate.cpp</filename>
    </added>
    <added>
      <filename>konqbookmark/itemviews/locationbardelegate.h</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -11,10 +11,14 @@ TODO:
  
  #6 Wait for EntityTreeView to get out of akonadi_next and into kdepimlibs.
  
- #7 Segfaults with EntityTreeModel.
-
-Planning:
- Fix #1, create own model
+ #7 Segfaults with EntityTreeModel
+ 
+ #9 continue work on location bar delegate
+ 
+ #11 write plugins for the location bar
+ 
+ #12 add support *in akonadi* for undo &amp; redo
+---
  
  * Nepomuk is used by the wrapper class KonqBookmark for accessing to the data.
  * Akonadi is used to administrate collections and virtual collections and to allow</diff>
      <filename>TODO</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,8 @@
 #include &lt;QtGui/QPainter&gt;
 #include &lt;QtGui/QPrinter&gt;
 #include &lt;QtCore/QTimer&gt;
+#include &lt;QtCore/QTimer&gt;
+#include &lt;QtDBus&gt;
 
 #include &lt;Nepomuk/ResourceManager&gt; 
 #include &lt;kconfigdialog.h&gt;
@@ -66,7 +68,7 @@ Bookmarks::Bookmarks()
     setupGUI();
     
     // Start Akonadi
-    QTimer::singleShot( 0, this, SLOT( delayedInit() ) );
+    QTimer::singleShot(0, this, SLOT(delayedInit()));
 }
 
 Bookmarks::~Bookmarks()
@@ -88,6 +90,15 @@ void Bookmarks::setupActions()
 
     Akonadi::Session* session = new Akonadi::Session(QByteArray( &quot;BookmarksMain-&quot; ) + QByteArray::number( qrand() ), this);
     Akonadi::Monitor* monitor = new Akonadi::Monitor( this );
+    
+    // create Konqueror Bookmarks Resource if needed
+    QDBusConnection bus = QDBusConnection::sessionBus();
+    QDBusInterface *interface = new QDBusInterface(&quot;org.freedesktop.Akonadi&quot;,
+        &quot;/ResourceManager&quot;, &quot;org.freedesktop.Akonadi.ResourceManager&quot;,  bus,
+        this);
+    QString resourceName(&quot;akonadi_konquerorbookmarks_resource&quot;);  
+    interface-&gt;call(&quot;addResourceInstance&quot;, resourceName);
+    
     Akonadi::KonqBookmarkModel* bookmarkModel = new Akonadi::KonqBookmarkModel( session, monitor, this );
     KonqBookmarkModelMenu* bookmarksMenu = new KonqBookmarkModelMenu(bookmarkModel, 0, actionCollection(), this);
     </diff>
      <filename>bookmarks_editor/src/bookmarks.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -49,7 +49,9 @@
 #include &lt;akonadi/collectionfilterproxymodel.h&gt;
 #include &lt;akonadi/collectionmodel.h&gt;
 #include &lt;akonadi/collectioncreatejob.h&gt;
+#include &lt;akonadi/collectiondeletejob.h&gt;
 #include &lt;akonadi/itemcreatejob.h&gt;
+#include &lt;akonadi/itemdeletejob.h&gt;
 #include &lt;akonadi/itemfetchscope.h&gt;
 #include &lt;akonadi/monitor.h&gt;
 #include &lt;akonadi/session.h&gt;
@@ -59,8 +61,6 @@
 
 #include &lt;konqbookmark/konqbookmark.h&gt;
 #include &lt;konqbookmark/kcompletionview.h&gt;
-#include &lt;konqbookmark/kcompletionmodel.h&gt;
-#include &lt;konqbookmark/kaggregatedmodel.h&gt;
 #include &lt;konqbookmark/konqbookmarkproxymodel.h&gt;
 #include &lt;konqbookmark/konqbookmarkmodel.h&gt;
 #include &lt;konqbookmark/placesproxymodel.h&gt;
@@ -78,7 +78,7 @@ public:
     Private(BookmarksView *parent);
     
     void expand(const QModelIndex&amp; index);
-    void selectBookmarkFolder(const QModelIndex&amp; index = QModelIndex());
+    void selectBookmarkFolder(const QModelIndex&amp; index = QModelIndex(), int start = -1);
     
     Akonadi::KonqBookmarkModel *mBookmarkModel;
     Akonadi::KonqBookmarkProxyModel *mBookmarkProxyModel;
@@ -87,8 +87,6 @@ public:
     ModelWatcher *mModelWatcher;
     Akonadi::Monitor *mMonitor;
     BookmarksView *mParent;
-    
-    QSortFilterProxyModel* fpModel;
 };
 
 BookmarksView::Private::Private(BookmarksView *parent)
@@ -101,36 +99,33 @@ void BookmarksView::Private::expand(const QModelIndex&amp; index)
 {
     // If index is invalid it means that the inserted index is the root index
     // and thus we need to expand all children
-    if(!index.isValid())
-    {
+    if (!index.isValid()) {
         mParent-&gt;ui_bookmarksview_base.bookmarksView-&gt;expandAll();
     } else {
         mParent-&gt;ui_bookmarksview_base.bookmarksView-&gt;expand(index);
     }
 }
 
-void BookmarksView::Private::selectBookmarkFolder(const QModelIndex&amp; index)
+void BookmarksView::Private::selectBookmarkFolder(const QModelIndex&amp; index, int start)
 {
-    static QModelIndex savedIndex;
+    QModelIndex newChild = mParent-&gt;ui_bookmarksview_base.collectionsView-&gt;model()-&gt;index(start, 0, index);
     
-    kDebug() &lt;&lt; index &lt;&lt; index.data(Akonadi::KonqBookmarkModel::Title);
+    kDebug() &lt;&lt; newChild &lt;&lt; newChild.data(Akonadi::KonqBookmarkModel::Title);
     
-    if(index.isValid()) {
-        QTimer::singleShot(0, mParent, SLOT(selectBookmarkFolder()));
-        savedIndex = index;
-        
-        disconnect(mParent-&gt;ui_bookmarksview_base.collectionsView-&gt;model(),
-            SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
-            mParent, SLOT(selectBookmarkFolder(const QModelIndex&amp;)));
-            
-    } else if(savedIndex.isValid()) {
-        mParent-&gt;ui_bookmarksview_base.collectionsView-&gt;selectionModel()-&gt;
-            setCurrentIndex(savedIndex, QItemSelectionModel::SelectCurrent);   
+    if (!newChild.isValid()) {
+        return;
     }
+    
+    disconnect(mParent-&gt;ui_bookmarksview_base.collectionsView-&gt;model(),
+        SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
+        mParent, SLOT(selectBookmarkFolder(const QModelIndex&amp;, int)));
+        
+    mParent-&gt;ui_bookmarksview_base.collectionsView-&gt;selectionModel()-&gt;
+        setCurrentIndex(newChild, QItemSelectionModel::SelectCurrent);
 }
 
 BookmarksView::BookmarksView(QWidget *)
-    : d( new Private ( this ) )
+    : d(new Private(this))
 {
     ui_bookmarksview_base.setupUi(this);
     setAutoFillBackground(true);
@@ -142,41 +137,25 @@ BookmarksView::~BookmarksView()
 
 void BookmarksView::createModels()
 {
-    QStringListModel* strlstModel = new QStringListModel(QStringList() &lt;&lt; &quot;a&quot; &lt;&lt; &quot;b&quot; &lt;&lt; &quot;c&quot; &lt;&lt; &quot;cd&quot;);
-    d-&gt;fpModel = new QSortFilterProxyModel();
-    d-&gt;fpModel-&gt;setSourceModel(strlstModel);
-    d-&gt;fpModel-&gt;setFilterKeyColumn(-1);
-    d-&gt;fpModel-&gt;setDynamicSortFilter(true);
-    
-//     ui_bookmarksview_base.locationBar-&gt;completionView()-&gt;setModel(d-&gt;fpModel);
-//     ui_bookmarksview_base.locationBar-&gt;setCompletionMode(KGlobalSettings::CompletionPopup);
-//     ui_bookmarksview_base.locationBar-&gt;setView(new QTreeView(ui_bookmarksview_base.locationBar));
-    
-//     connect(ui_bookmarksview_base.locationBar, SIGNAL(textChanged(const QString&amp;)),
-//         d-&gt;fpModel, SLOT(setFilterFixedString(const QString&amp;)));
-        
-    KCompletionModel *completionModel = Konqueror::PlacesManager::self()-&gt;urlCompletionModel();
-    completionModel-&gt;setCompletion(new KUrlCompletion());
-    
     d-&gt;mBookmarkModel = Konqueror::PlacesManager::self()-&gt;bookmarkModel();
     
-    d-&gt;mCollectionProxyModel = new Konqueror::CollectionsProxyModel( this );
+    d-&gt;mCollectionProxyModel = new Konqueror::CollectionsProxyModel(this);
     d-&gt;mCollectionProxyModel-&gt;setSourceModel(d-&gt;mBookmarkModel);
     
-    ui_bookmarksview_base.collectionsView-&gt;setModel( d-&gt;mCollectionProxyModel );
-    ui_bookmarksview_base.navigatorBreadCrumb-&gt;setModel( d-&gt;mCollectionProxyModel );
-    ui_bookmarksview_base.navigatorBreadCrumb-&gt;setSelectionModel( ui_bookmarksview_base.collectionsView-&gt;selectionModel() );
+    ui_bookmarksview_base.collectionsView-&gt;setModel(d-&gt;mCollectionProxyModel);
+    ui_bookmarksview_base.navigatorBreadCrumb-&gt;setModel(d-&gt;mCollectionProxyModel);
+    ui_bookmarksview_base.navigatorBreadCrumb-&gt;setSelectionModel(ui_bookmarksview_base.collectionsView-&gt;selectionModel());
     
     KSelectionProxyModel *selectionProxy = new KSelectionProxyModel(ui_bookmarksview_base.collectionsView-&gt;selectionModel(), this);
     selectionProxy-&gt;setSourceModel(d-&gt;mBookmarkModel);
     
-    d-&gt;mBookmarkProxyModel = new Akonadi::KonqBookmarkProxyModel( this );
+    d-&gt;mBookmarkProxyModel = new Akonadi::KonqBookmarkProxyModel(this);
     d-&gt;mBookmarkProxyModel-&gt;setSourceModel(selectionProxy);
     
-    Akonadi::KonqBookmarkDelegate *itemDelegate = new Akonadi::KonqBookmarkDelegate( this );
-    ui_bookmarksview_base.bookmarksView-&gt;setModel( d-&gt;mBookmarkProxyModel );
-    ui_bookmarksview_base.bookmarksView-&gt;setItemDelegate( itemDelegate );
-    ui_bookmarksview_base.searchBox-&gt;setTreeView( ui_bookmarksview_base.bookmarksView );
+    Akonadi::KonqBookmarkDelegate *itemDelegate = new Akonadi::KonqBookmarkDelegate(this);
+    ui_bookmarksview_base.bookmarksView-&gt;setModel(d-&gt;mBookmarkProxyModel);
+    ui_bookmarksview_base.bookmarksView-&gt;setItemDelegate(itemDelegate);
+    ui_bookmarksview_base.searchBox-&gt;setTreeView(ui_bookmarksview_base.bookmarksView);
     ui_bookmarksview_base.searchBox-&gt;setClickMessage(i18n(&quot;Search in bookmarks...&quot;));
     
     d-&gt;mMapper = new KDataWidgetSelectionMapper(this);
@@ -200,8 +179,9 @@ void BookmarksView::createModels()
     ui_bookmarksview_base.bookmarksView-&gt;setFocus();
     ui_bookmarksview_base.bookmarksView-&gt;setEditTriggers(QAbstractItemView::DoubleClicked);
     
-    for(int i = KonqBookmarkModel::Url; i &lt; KonqBookmarkModel::ColumnCount; i++)
+    for(int i = KonqBookmarkModel::Url; i &lt; KonqBookmarkModel::ColumnCount; i++) {
         ui_bookmarksview_base.collectionsView-&gt;setColumnHidden(i, true);
+    }
         
     ui_bookmarksview_base.collectionsView-&gt;setFocusPolicy(Qt::NoFocus);
     ui_bookmarksview_base.collectionsView-&gt;header()-&gt;hide();
@@ -210,14 +190,13 @@ void BookmarksView::createModels()
     ui_bookmarksview_base.collectionsView-&gt;setDragEnabled(true);
     ui_bookmarksview_base.collectionsView-&gt;viewport()-&gt;setAcceptDrops(true);
     ui_bookmarksview_base.collectionsView-&gt;setDropIndicatorShown(true);
-//     ui_bookmarksview_base.collectionsView-&gt;setDragDropMode(QAbstractItemView::InternalMove);
     ui_bookmarksview_base.collectionsView-&gt;setStyleSheet(&quot;QTreeView { background: transparent; border-style: none; }&quot;);
     
     connect(ui_bookmarksview_base.collectionsView-&gt;model(), SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
             ui_bookmarksview_base.collectionsView, SLOT(expand(const QModelIndex&amp;)));
     
     connect(ui_bookmarksview_base.collectionsView-&gt;model(), SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
-        this, SLOT(selectBookmarkFolder(const QModelIndex&amp;)));
+        this, SLOT(selectBookmarkFolder(const QModelIndex&amp;, int)));
         
     connect(ui_bookmarksview_base.bookmarksView-&gt;model(), SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
             this, SLOT(expand(const QModelIndex&amp;)));
@@ -230,8 +209,7 @@ void BookmarksView::addBookmark()
     
     QModelIndex current = ui_bookmarksview_base.bookmarksView-&gt;selectionModel()-&gt;currentIndex();
     Collection parent = getParentCollection(current);
-    if(parent == Collection::root())
-    {
+    if(parent == Collection::root()) {
         KMessageBox::sorry(this, i18n(&quot;Please select first a valid parent folder in which to insert the new bookmark&quot;),
             i18n(&quot;Can't create new bookmark&quot;));
         return;
@@ -240,16 +218,17 @@ void BookmarksView::addBookmark()
     KonqBookmark bookmark;
     
     Item item;
-    item.setMimeType( KonqBookmark::mimeType() );
-    item.setPayload&lt;KonqBookmark&gt;( bookmark );
+    item.setMimeType(KonqBookmark::mimeType());
+    item.setPayload&lt;KonqBookmark&gt;(bookmark);
     
     ItemCreateJob *job = new ItemCreateJob(item, parent);
-    if( job-&gt;exec() )
-    {
+    if (job-&gt;exec()) {
         d-&gt;mModelWatcher = new ModelWatcher(job-&gt;item().id(), d-&gt;mBookmarkProxyModel, this);
-        connect(d-&gt;mModelWatcher, SIGNAL(newEntity(const QModelIndex &amp;)), this, SLOT(slotBookmarkAdded(const QModelIndex &amp;)));
-    } else
+        connect(d-&gt;mModelWatcher, SIGNAL(newEntity(const QModelIndex &amp;)),
+            this, SLOT(slotBookmarkAdded(const QModelIndex &amp;)));
+    } else {
         kWarning() &lt;&lt; &quot;job-&gt;exec() failed&quot;;
+    }
 }
 
 void BookmarksView::slotBookmarkAdded(const QModelIndex &amp;newIndex)
@@ -262,37 +241,55 @@ void BookmarksView::slotBookmarkAdded(const QModelIndex &amp;newIndex)
 
 void BookmarksView::slotDelete()
 {
-    d-&gt;mBookmarkModel-&gt;removeRows(ui_bookmarksview_base.bookmarksView-&gt;currentIndex().row(), 1, ui_bookmarksview_base.bookmarksView-&gt;currentIndex().parent());
+    QModelIndex currentIndex = ui_bookmarksview_base.bookmarksView-&gt;currentIndex();
+    kDebug() &lt;&lt; currentIndex;
+    
+    if (!currentIndex.isValid()) {
+        return;
+    }
+        
+    Akonadi::Item item = qVariantValue&lt;Akonadi::Item&gt;(currentIndex.data(EntityTreeModel::ItemRole));
+    Akonadi::Collection collection = qVariantValue&lt;Akonadi::Collection&gt;(currentIndex.data(EntityTreeModel::CollectionRole));
+    if (item.isValid() &amp;&amp; !item.remoteId().isEmpty()) {
+        kDebug() &lt;&lt; &quot;removing item remoteId = &quot; &lt;&lt; item.remoteId();
+        new Akonadi::ItemDeleteJob(item);
+    } else  if (collection.isValid()) {
+        kDebug() &lt;&lt; &quot;removing collection (name, remoteId) = &quot; &lt;&lt; collection.name() &lt;&lt; collection.remoteId();
+        new Akonadi::CollectionDeleteJob(collection);
+    }
 }
 
 Akonadi::Collection BookmarksView::getParentCollection(QModelIndex current)
 {
-    Collection defaultCollection = d-&gt;mBookmarkModel-&gt;rootCollection();
+    QModelIndex defaultIndex = ui_bookmarksview_base.collectionsView-&gt;selectionModel()-&gt;currentIndex();
+    Collection defaultCollection = defaultIndex.data(EntityTreeModel::CollectionRole).value&lt;Akonadi::Collection&gt;();
     return getParentCollection(current, defaultCollection);
 }
 
 Akonadi::Collection BookmarksView::getParentCollection(QModelIndex current, Collection defaultCollection)
 {
     Akonadi::Collection parent = defaultCollection;
-    if(!current.isValid())
+    if (!current.isValid()) {
         return parent;
+    }
     
     QVariant var = current.data(EntityTreeModel::ItemRole);
     Akonadi::Item item = var.value&lt;Akonadi::Item&gt;();
     // If current selection is an item, then the parent collection for our new
     // collection will be the same parent collection as the current item. else
     // ff current selection is a collection, that will be our new collection's parent
-    if ( item.isValid() )
-    {
+    if (item.isValid()) {
         current = current.parent();
-        if(!current.isValid())
+        if (!current.isValid()) {
             return parent;
+        }
     }
 
     var = current.data(EntityTreeModel::CollectionRole);
     Akonadi::Collection collection = var.value&lt;Akonadi::Collection&gt;();
-    if(collection.isValid())
+    if (collection.isValid()) {
         parent = collection;
+    }
     
     return parent;
 }
@@ -302,18 +299,17 @@ void BookmarksView::slotAddFolder(const QString &amp;folderName)
     // TODO see addBookmark()
     QModelIndex current = ui_bookmarksview_base.bookmarksView-&gt;selectionModel()-&gt;currentIndex();
     Collection parent = getParentCollection(current);
-    if(parent == Collection::root())
-    {
+    if (parent == Collection::root()) {
         KMessageBox::sorry(this, i18n(&quot;Please select first a valid parent folder in which to insert the new folder&quot;),
             i18n(&quot;Can't create new folder&quot;));
         return;
     }
     Akonadi::Collection collection;
-    collection.setParent( parent );
-    collection.setName( folderName );
-    collection.setContentMimeTypes( QStringList( KonqBookmark::mimeType() ) );
+    collection.setParent(parent);
+    collection.setName(folderName);
+    collection.setContentMimeTypes(QStringList(KonqBookmark::mimeType()));
     
-    new Akonadi::CollectionCreateJob( collection );
+    new Akonadi::CollectionCreateJob(collection);
 }
 
 #include &quot;bookmarksview.moc&quot;</diff>
      <filename>bookmarks_editor/src/bookmarksview.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -90,7 +90,7 @@ private:
     class Private;
     QSharedDataPointer&lt;Private&gt; d;
     Q_PRIVATE_SLOT(d, void expand(const QModelIndex&amp; index))
-    Q_PRIVATE_SLOT(d, void selectBookmarkFolder(const QModelIndex&amp; index = QModelIndex()))
+    Q_PRIVATE_SLOT(d, void selectBookmarkFolder(const QModelIndex&amp; index = QModelIndex(), int start = -1))
 };
 
 #endif // BOOKMARSVIEW_H</diff>
      <filename>bookmarks_editor/src/bookmarksview.h</filename>
    </modified>
    <modified>
      <diff>@@ -57,6 +57,7 @@ set(konqbookmark_LIB_SRCS
     itemviews/ktreeviewsearchline.cpp
     itemviews/modelmenusearchline.cpp
     itemviews/locationbar.cpp
+    itemviews/locationbardelegate.cpp
     itemviews/kcompletionview.cpp
     itemviews/klineeditview.cpp
 #     itemviews/placesdelegate.cpp
@@ -75,6 +76,7 @@ target_link_libraries(konqbookmark
     ${QT_QTCORE_LIBRARY}
     ${KDE4_KDECORE_LIBS}
     ${KDE4_KDEUI_LIBS}
+    ${KDE4_KIO_LIBS} # for KUrlCompletion
     ${NEPOMUK_LIBRARIES}
     ${SOPRANO_LIBRARIES}
 )
@@ -111,6 +113,7 @@ set(konqbookmark_LIB_HDRS
     itemviews/konqbookmarkmodelmenu.h
     itemviews/modelmenusearchline.h
     itemviews/locationbar.h
+    itemviews/locationbardelegate.h
     itemviews/kcompletionview.h
     itemviews/klineeditview.h
 #     itemviews/placesdelegate.h</diff>
      <filename>konqbookmark/CMakeLists.txt</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,7 @@
 using namespace Konqueror;
 using namespace Akonadi;
 
-CollectionsProxyModel::CollectionsProxyModel( QObject *parent )
+CollectionsProxyModel::CollectionsProxyModel(QObject *parent)
     : QSortFilterProxyModel(parent)
 {
     setDynamicSortFilter(true);
@@ -34,15 +34,15 @@ CollectionsProxyModel::CollectionsProxyModel( QObject *parent )
 static int indexTypeHelper(const QModelIndex &amp; index)
 {
     QString mimeType = index.data(EntityTreeModel::MimeTypeRole).toString();
-    if(mimeType == Collection::mimeType()) {
+    if (mimeType == Collection::mimeType()) {
         return EntityTreeModel::CollectionRole;
     } else {
         return EntityTreeModel::ItemRole;
     }
 }
 
-bool CollectionsProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex &amp;sourceParent ) const
+bool CollectionsProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &amp;sourceParent) const
 {
-    QModelIndex sourceIndex = sourceModel()-&gt;index(sourceRow, 0, sourceParent);    
+    QModelIndex sourceIndex = sourceModel()-&gt;index(sourceRow, 0, sourceParent);
     return indexTypeHelper(sourceIndex) == EntityTreeModel::CollectionRole;
 }</diff>
      <filename>konqbookmark/itemmodels/collectionsproxymodel.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -27,19 +27,20 @@
 namespace Konqueror
 {
     /** 
-     * class created because because of some reason EntityFilterProxyModel doesn't
-     * seem to be working right now.
+     * Class created because because of some reason EntityFilterProxyModel doesn't
+     * seem to be working right now. It filters out indexes which are not Akonadi
+     * Collections.
      */
     class KONQBOOKMARK_EXPORT CollectionsProxyModel : public QSortFilterProxyModel
     {        
     public:
-        CollectionsProxyModel( QObject *parent = 0 );
-    protected:
+        CollectionsProxyModel(QObject *parent = 0);
         
+    protected:
         /**
-        * Reimplemented to show only folders
-        */
-        virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &amp;sourceParent ) const;
+         * Reimplemented to show only folders
+         */
+        virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &amp;sourceParent) const;
     };
 
 }</diff>
      <filename>konqbookmark/itemmodels/collectionsproxymodel.h</filename>
    </modified>
    <modified>
      <diff>@@ -92,12 +92,12 @@ int KAggregatedModel::Private::indexRowDiff(const QAbstractItemModel *sourceMode
     int prevCount = 0;
     int modelAt = m_sourceModels.indexOf(sourceModel);
     
-    if(modelAt == -1) {
+    if (modelAt == -1) {
         return -1;
     }
     
-    foreach(const QAbstractItemModel *model, m_sourceModels) {
-        if(model == sourceModel) {
+    foreach (const QAbstractItemModel *model, m_sourceModels) {
+        if (model == sourceModel) {
             break;
         }
         prevCount += model-&gt;rowCount(QModelIndex());
@@ -108,11 +108,11 @@ int KAggregatedModel::Private::indexRowDiff(const QAbstractItemModel *sourceMode
 
 void KAggregatedModel::Private::rowsAboutToBeInserted(const QModelIndex&amp; sourceParent, int sourceStart, int sourceEnd)
 {
-    if(sourceParent.isValid()) {
+    if (sourceParent.isValid()) {
         return;
     }
     
-    if(sourceStart &lt; 0 || sourceStart &gt; sourceEnd) {
+    if (sourceStart &lt; 0 || sourceStart &gt; sourceEnd) {
        return;
     }
     
@@ -121,7 +121,7 @@ void KAggregatedModel::Private::rowsAboutToBeInserted(const QModelIndex&amp; sourceP
     int diff = indexRowDiff(sourceModel, 0);
     
     int rowCount = q-&gt;rowCount(QModelIndex());
-    if(diff &lt; 0 || sourceStart + diff &gt; rowCount) {
+    if (diff &lt; 0 || sourceStart + diff &gt; rowCount) {
         return;
     }
     int start = sourceStart + diff;
@@ -132,11 +132,11 @@ void KAggregatedModel::Private::rowsAboutToBeInserted(const QModelIndex&amp; sourceP
 
 void KAggregatedModel::Private::rowsInserted(const QModelIndex&amp; sourceParent, int sourceStart, int sourceEnd)
 {
-    if(sourceParent.isValid()) {
+    if (sourceParent.isValid()) {
         return;
     }
     
-    if(sourceStart &lt; 0 || sourceStart &gt; sourceEnd) {
+    if (sourceStart &lt; 0 || sourceStart &gt; sourceEnd) {
        return;
     }
     
@@ -144,7 +144,7 @@ void KAggregatedModel::Private::rowsInserted(const QModelIndex&amp; sourceParent, in
 
     int diff = indexRowDiff(sourceModel, 0);
     int rowCount = q-&gt;rowCount(QModelIndex());
-    if(diff &lt; 0 || sourceEnd + diff &gt; rowCount) {
+    if (diff &lt; 0 || sourceEnd + diff &gt; rowCount) {
         return;
     }
     
@@ -153,11 +153,11 @@ void KAggregatedModel::Private::rowsInserted(const QModelIndex&amp; sourceParent, in
 
 void KAggregatedModel::Private::rowsAboutToBeRemoved(const QModelIndex&amp; sourceParent, int sourceStart, int sourceEnd)
 {
-    if(sourceParent.isValid()) {
+    if (sourceParent.isValid()) {
         return;
     }
     
-    if(sourceStart &lt; 0 || sourceStart &gt; sourceEnd) {
+    if (sourceStart &lt; 0 || sourceStart &gt; sourceEnd) {
        return;
     }
     
@@ -165,7 +165,7 @@ void KAggregatedModel::Private::rowsAboutToBeRemoved(const QModelIndex&amp; sourcePa
 
     int diff = indexRowDiff(sourceModel, 0);
     int rowCount = q-&gt;rowCount(QModelIndex());
-    if(diff &lt; 0 || sourceStart + diff &gt; rowCount) {
+    if (diff &lt; 0 || sourceStart + diff &gt; rowCount) {
         return;
     }
     
@@ -177,11 +177,11 @@ void KAggregatedModel::Private::rowsAboutToBeRemoved(const QModelIndex&amp; sourcePa
 
 void KAggregatedModel::Private::rowsRemoved(const QModelIndex&amp; sourceParent, int sourceStart, int sourceEnd)
 {
-    if(sourceParent.isValid()) {
+    if (sourceParent.isValid()) {
         return;
     }
     
-    if(sourceStart &lt; 0 || sourceStart &gt; sourceEnd) {
+    if (sourceStart &lt; 0 || sourceStart &gt; sourceEnd) {
        return;
     }
     
@@ -189,7 +189,7 @@ void KAggregatedModel::Private::rowsRemoved(const QModelIndex&amp; sourceParent, int
 
     int diff = indexRowDiff(sourceModel, sourceStart);
     int rowCount = q-&gt;rowCount(QModelIndex());
-    if(diff &lt; 0 || sourceEnd + diff &gt; rowCount) {
+    if (diff &lt; 0 || sourceEnd + diff &gt; rowCount) {
         return;
     }
     
@@ -210,11 +210,11 @@ KAggregatedModel::~KAggregatedModel()
     
 void KAggregatedModel::addSourceModel(QAbstractItemModel *sourceModel)
 {
-    if(!sourceModel) {
+    if (!sourceModel) {
         return;
     }
     
-    if(d-&gt;m_sourceModels.contains(sourceModel)) {
+    if (d-&gt;m_sourceModels.contains(sourceModel)) {
         return;
     }
     
@@ -249,7 +249,7 @@ void KAggregatedModel::addSourceModel(QAbstractItemModel *sourceModel)
 
 void KAggregatedModel::removeSourceModel(QAbstractItemModel *sourceModel)
 {
-    if(!d-&gt;m_sourceModels.contains(sourceModel)) {
+    if (!d-&gt;m_sourceModels.contains(sourceModel)) {
         return;
     }
     
@@ -283,11 +283,11 @@ void KAggregatedModel::removeSourceModel(QAbstractItemModel *sourceModel)
 
 int KAggregatedModel::rowCount(const QModelIndex &amp;parent) const
 {
-    if(parent.isValid()) {
+    if (parent.isValid()) {
         return 0;
     }
     
-    if(!d-&gt;m_sourceModels.isEmpty()) {
+    if (!d-&gt;m_sourceModels.isEmpty()) {
         const QAbstractItemModel *model = d-&gt;m_sourceModels.last();
         
         return d-&gt;indexRowDiff(model, model-&gt;rowCount(QModelIndex()));
@@ -298,7 +298,7 @@ int KAggregatedModel::rowCount(const QModelIndex &amp;parent) const
 
 QVariant KAggregatedModel::headerData(int section, Qt::Orientation orientation, int role) const
 {
-    if ( role == Qt::DisplayRole &amp;&amp; orientation == Qt::Horizontal )
+    if (role == Qt::DisplayRole &amp;&amp; orientation == Qt::Horizontal)
     {
         switch(section) {
         case 0:
@@ -313,16 +313,16 @@ QVariant KAggregatedModel::headerData(int section, Qt::Orientation orientation,
 
 QVariant KAggregatedModel::data(const QModelIndex &amp;index, int role) const
 {
-    if(!index.isValid()) {
+    if (!index.isValid()) {
         return QVariant();
     }
     
     const QModelIndex sourceIndex = mapToSource(index);
-    if(!sourceIndex.isValid()) {
+    if (!sourceIndex.isValid()) {
         return QVariant();
     }
     
-    switch(role) {
+    switch (role) {
     case Qt::DisplayRole:
         return sourceIndex.data(role);
     default:
@@ -332,11 +332,11 @@ QVariant KAggregatedModel::data(const QModelIndex &amp;index, int role) const
     
 QModelIndex KAggregatedModel::index(int row, int column, const QModelIndex&amp; parent) const
 {
-    if(column != 0 || parent.isValid()) {
+    if (column != 0 || parent.isValid()) {
         return QModelIndex();
     }
     
-    if(row &lt; 0 || row &gt; rowCount(QModelIndex())) {
+    if (row &lt; 0 || row &gt; rowCount(QModelIndex())) {
         return QModelIndex();
     }
     
@@ -357,11 +357,11 @@ int KAggregatedModel::columnCount(const QModelIndex&amp; index) const
         
 QModelIndex KAggregatedModel::mapFromSource(const QModelIndex&amp; sourceIndex) const
 {   
-    if(!sourceIndex.isValid() || sourceIndex.parent().isValid()) {
+    if (!sourceIndex.isValid() || sourceIndex.parent().isValid()) {
         return QModelIndex();
     }
     
-    if(!d-&gt;m_sourceModels.contains(sourceIndex.model())) {
+    if (!d-&gt;m_sourceModels.contains(sourceIndex.model())) {
         return QModelIndex();
     }
     
@@ -372,15 +372,15 @@ QModelIndex KAggregatedModel::mapFromSource(const QModelIndex&amp; sourceIndex) cons
 
 QModelIndex KAggregatedModel::mapToSource(const QModelIndex&amp; index) const
 {
-    if(!index.isValid()) {
+    if (!index.isValid()) {
         return QModelIndex();
     }
     
     int prevRows = 0;
     
-    foreach(const QAbstractItemModel *model, d-&gt;m_sourceModels) {
+    foreach (const QAbstractItemModel *model, d-&gt;m_sourceModels) {
         int rowCount = model-&gt;rowCount(QModelIndex());
-        if(index.row() &lt; prevRows + rowCount) {
+        if (index.row() &lt; prevRows + rowCount) {
             return model-&gt;index(index.row() - prevRows, 0);
         }
         prevRows += rowCount;</diff>
      <filename>konqbookmark/itemmodels/kaggregatedmodel.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -100,20 +100,21 @@ void KCompletionModel::Private::slotMatches(const QStringList &amp;matches)
     
     while (it.hasNext()) {
         it.next();
-        if(!matches.contains(it.key())) {
+        if (!matches.contains(it.key())) {
             indexesToRemove.append(it.value());
             kDebug() &lt;&lt; &quot;removing &quot; &lt;&lt; it.key() &lt;&lt; &quot;with row =&quot; &lt;&lt; it.value().row();
         }
     }
     
-    if(!indexesToRemove.empty())
+    if (!indexesToRemove.empty()) {
         removeRows(indexesToRemove);
+    }
     
     QList&lt;QPair&lt;QModelIndex, QVariant&gt; &gt; indexesToAppend;
     QList&lt;QString&gt;::const_iterator strIt;
     int count = m_strings.size();
     for (strIt = matches.constBegin(); strIt != matches.constEnd(); ++strIt) {
-        if(!m_reverseIndexes.contains(*strIt)) {
+        if (!m_reverseIndexes.contains(*strIt)) {
             QPair&lt;QModelIndex, QVariant&gt; indexPair;
             indexPair.first = q-&gt;createIndex(count++, 0);
             indexPair.second = *strIt;
@@ -123,15 +124,16 @@ void KCompletionModel::Private::slotMatches(const QStringList &amp;matches)
         }
     }
 
-    if(!indexesToAppend.empty())
+    if (!indexesToAppend.empty()) {
         insertRows(indexesToAppend);
+    }
     
     kDebug() &lt;&lt; &quot;rowCount = &quot; &lt;&lt; q-&gt;rowCount();
 }
 
 void KCompletionModel::Private::insertRows(const QList&lt;QPair&lt;QModelIndex, QVariant&gt; &gt;&amp; indexes)
 {
-    if(indexes.empty()) {
+    if (indexes.empty()) {
         return;
     }
     
@@ -188,7 +190,7 @@ void KCompletionModel::Private::removeRows(const QModelIndexList&amp; list)
 
 QModelIndex KCompletionModel::Private::indexForMatch(const QString&amp; match) const
 {
-    if(m_reverseIndexes.contains(match)) {
+    if (m_reverseIndexes.contains(match)) {
         return m_reverseIndexes.value(match);
     }
     
@@ -210,7 +212,7 @@ KCompletionModel::~KCompletionModel()
 
 int KCompletionModel::rowCount(const QModelIndex &amp;parent) const
 {
-    if(parent.isValid()) {
+    if (parent.isValid()) {
         return 0;
     }
     
@@ -220,10 +222,11 @@ int KCompletionModel::rowCount(const QModelIndex &amp;parent) const
 QVariant KCompletionModel::data(const QModelIndex &amp;index, int role) const
 {
     
-    if (index.row() &lt; 0 || index.row() &gt;= d-&gt;m_strings.size())
+    if (index.row() &lt; 0 || index.row() &gt;= d-&gt;m_strings.size()) {
         return QVariant();
+    }
     
-    switch( role ) {
+    switch(role) {
     case Qt::DisplayRole:
     case Qt::EditRole:
     case CompletionMatchRole:
@@ -238,12 +241,11 @@ KCompletion* KCompletionModel::completion() const
 }
 void KCompletionModel::setCompletion(KCompletion* completion)
 {
-    if(!completion) {
+    if (!completion) {
         return;
     }
     
-    if(d-&gt;m_completion)
-    {
+    if (d-&gt;m_completion) {
         disconnect(d-&gt;m_completion, SIGNAL(matches(const QStringList &amp;)),
             this, SLOT(slotMatches(const QStringList &amp;)));
         
@@ -269,11 +271,10 @@ void KCompletionModel::setCompletion(KCompletion* completion)
 
 QModelIndex KCompletionModel::index(int row, int column, const QModelIndex&amp; parent) const
 {   
-    if(parent.isValid())
-    {
+    if (parent.isValid()) {
         return QModelIndex();
     }
-    if(row &lt; 0 || row &gt;= d-&gt;m_strings.size() || column != 0) {
+    if (row &lt; 0 || row &gt;= d-&gt;m_strings.size() || column != 0) {
         return QModelIndex();
     }
     
@@ -282,11 +283,11 @@ QModelIndex KCompletionModel::index(int row, int column, const QModelIndex&amp; pare
 
 QModelIndex KCompletionModel::parent(const QModelIndex&amp; index) const
 {
-    if(!index.isValid()) {
+    if (!index.isValid()) {
         return QModelIndex();
     }
     
-    if(index.column() != 0) {
+    if (index.column() != 0) {
         QModelIndex index = createIndex(index.row(), 0);
         return (d-&gt;m_indexes.contains(index)) ? index : QModelIndex();
     }</diff>
      <filename>konqbookmark/itemmodels/kcompletionmodel.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -54,8 +54,11 @@ public:
     enum Roles {
         CompletionMatchRole = Qt::UserRole + 1
     };
+    
     enum {ColumnCount = 1 }; // Qt::DisplayRole
+    
     KCompletionModel(QObject * parent);
+    
     virtual ~KCompletionModel();
     
     virtual int rowCount(const QModelIndex &amp;parent = QModelIndex()) const;
@@ -74,8 +77,8 @@ private:
     friend class Private;
     Private* const d;
     
-    Q_PRIVATE_SLOT( d, void slotMatches(const QStringList &amp;) )
-    Q_PRIVATE_SLOT( d, void slotMatches() )
+    Q_PRIVATE_SLOT(d, void slotMatches(const QStringList &amp;))
+    Q_PRIVATE_SLOT(d, void slotMatches())
 };
 
 #endif // KCOMPLETION_MODEL_H</diff>
      <filename>konqbookmark/itemmodels/kcompletionmodel.h</filename>
    </modified>
    <modified>
      <diff>@@ -72,7 +72,7 @@ KonqBookmarkModel::KonqBookmarkModel( Akonadi::Session *session, Akonadi::Monito
     monitor-&gt;fetchCollection( true );
     monitor-&gt;setItemFetchScope( scope );
     monitor-&gt;setMimeTypeMonitored( mimeType() );
-    monitor-&gt;setMimeTypeMonitored( Akonadi::Collection::mimeType() );
+//     monitor-&gt;setMimeTypeMonitored( Akonadi::Collection::mimeType() );
     // FIXME Set all monitored because otherwise the model doesn't get updates 
     // from items/collections being removed.
     monitor-&gt;setAllMonitored(true);
@@ -83,19 +83,17 @@ KonqBookmarkModel::~KonqBookmarkModel()
     delete d;
 }
 
-int KonqBookmarkModel::columnCount( const QModelIndex&amp; index) const
+int KonqBookmarkModel::columnCount(const QModelIndex&amp; index) const
 {
     Q_UNUSED(index);
     
     return 9;
 }
 
-QVariant KonqBookmarkModel::getHeaderData( int section, Qt::Orientation orientation, int role, int headerSet ) const
+QVariant KonqBookmarkModel::getHeaderData(int section, Qt::Orientation orientation, int role, int headerSet ) const
 {   
-    if ( role == Qt::DisplayRole &amp;&amp; orientation == Qt::Horizontal )
-    {
-        switch( section )
-        {
+    if (role == Qt::DisplayRole &amp;&amp; orientation == Qt::Horizontal) {
+        switch(section) {
         case Title:
             return i18nc( &quot;@title:column, bookmark title&quot;, &quot;Title&quot; );
         case Url:
@@ -308,12 +306,14 @@ bool KonqBookmarkModel::setData(const QModelIndex &amp;index, const QVariant &amp;value,
 
 bool KonqBookmarkModel::removeRows( int row, int count, const QModelIndex &amp; parent)
 {
+    kDebug();
     Akonadi::TransactionSequence *transaction = new TransactionSequence;
-    for(int i = row; i &lt; row + count; i++)
-    {
+    for (int i = row; i &lt; row + count; i++) {
         const QModelIndex&amp; entityIndex = index(i, 0, parent);
-        if(!entityIndex.isValid())
+        kDebug() &lt;&lt; entityIndex &lt;&lt; i &lt;&lt; parent;
+        if (!entityIndex.isValid()) {
             continue;
+        }
         
         Item item = qVariantValue&lt;Item&gt;(data(entityIndex, EntityTreeModel::ItemRole));
         Collection collection = qVariantValue&lt;Collection&gt;(data(entityIndex, EntityTreeModel::CollectionRole));
@@ -326,8 +326,7 @@ bool KonqBookmarkModel::removeRows( int row, int count, const QModelIndex &amp; pare
         }
     }
 
-    if(!transaction-&gt;exec())
-    {
+    if(!transaction-&gt;exec()) {
         kDebug() &lt;&lt; transaction-&gt;errorString();
         return false;
     }
@@ -336,7 +335,7 @@ bool KonqBookmarkModel::removeRows( int row, int count, const QModelIndex &amp; pare
 
 QString KonqBookmarkModel::mimeType() const
 {
-    return QString(&quot;application/x-vnd.kde.konqbookmark&quot;);
+    return KonqBookmark::mimeType();
 }
 
 QStringList KonqBookmarkModel::mimeTypes() const</diff>
      <filename>konqbookmark/itemmodels/konqbookmarkmodel.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -51,12 +51,12 @@ namespace Akonadi
         };
         enum { ColumnCount =  9 };
 
-        KonqBookmarkModel(Akonadi::Session *session, Akonadi::Monitor *monitor, QObject *parent = 0 );
+        KonqBookmarkModel(Akonadi::Session *session, Akonadi::Monitor *monitor, QObject *parent = 0);
 
         virtual ~KonqBookmarkModel();
 
-        virtual int columnCount( const QModelIndex &amp; parent = QModelIndex() ) const;
-        virtual QVariant getHeaderData( int section, Qt::Orientation orientation, int role, int headerSet ) const;
+        virtual int columnCount(const QModelIndex &amp; parent = QModelIndex()) const;
+        virtual QVariant getHeaderData(int section, Qt::Orientation orientation, int role, int headerSet) const;
         
         // We let the delegate know that we are editable
         Qt::ItemFlags flags(const QModelIndex &amp;index) const;
@@ -69,10 +69,11 @@ namespace Akonadi
          * and also for collections in the next function. EntityTreeModel::data() will then call these
          * functions.
          */
-        virtual QVariant getData( const Item &amp;item, int column, int role = Qt::DisplayRole ) const;
-        virtual QVariant getData( const Collection &amp;collection, int column, int role = Qt::DisplayRole ) const;
+        virtual QVariant getData(const Item &amp;item, int column, int role = Qt::DisplayRole) const;
+        virtual QVariant getData(const Collection &amp;collection, int column, int role = Qt::DisplayRole) const;
     
-        bool removeRows ( int row, int count, const QModelIndex &amp; parent = QModelIndex() );
+        bool removeRows(int row, int count, const QModelIndex &amp; parent = QModelIndex());
+        
         // Drag &amp; drop related functions
         bool dropMimeData(const QMimeData *data, Qt::DropAction action,
             int row, int column, const QModelIndex &amp;parent);</diff>
      <filename>konqbookmark/itemmodels/konqbookmarkmodel.h</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,7 @@
 
 using namespace Akonadi;
 
-KonqBookmarkProxyModel::KonqBookmarkProxyModel( QObject *parent )
+KonqBookmarkProxyModel::KonqBookmarkProxyModel(QObject *parent)
     : QSortFilterProxyModel(parent)
 {
     setDynamicSortFilter(true);
@@ -33,22 +33,23 @@ KonqBookmarkProxyModel::KonqBookmarkProxyModel( QObject *parent )
 static int indexTypeHelper(const QModelIndex &amp; index)
 {
     QString mimeType = index.data(EntityTreeModel::MimeTypeRole).toString();
-    if(mimeType == Collection::mimeType()) {
+    if (mimeType == Collection::mimeType()) {
         return EntityTreeModel::CollectionRole;
     } else {
         return EntityTreeModel::ItemRole;
     }
 }
 
-bool KonqBookmarkProxyModel::lessThan ( const QModelIndex &amp; left, const QModelIndex &amp; right ) const
+bool KonqBookmarkProxyModel::lessThan(const QModelIndex &amp; left, const QModelIndex &amp; right) const
 {
     bool leftIsCollection = indexTypeHelper(left) == EntityTreeModel::CollectionRole;
     bool rightIsCollection = indexTypeHelper(right) == EntityTreeModel::CollectionRole;
     
-    if(leftIsCollection &amp;&amp; !rightIsCollection)
+    if (leftIsCollection &amp;&amp; !rightIsCollection) {
         return true;
-    else if(!leftIsCollection &amp;&amp; rightIsCollection)
+    } else if (!leftIsCollection &amp;&amp; rightIsCollection) {
         return false;
-    else
+    } else {
         return QSortFilterProxyModel::lessThan(left, right);
+    }
 }</diff>
      <filename>konqbookmark/itemmodels/konqbookmarkproxymodel.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -29,13 +29,13 @@ namespace Akonadi
     class KONQBOOKMARK_EXPORT KonqBookmarkProxyModel : public QSortFilterProxyModel
     {        
     public:
-        KonqBookmarkProxyModel( QObject *parent = 0 );
-    protected:
+        KonqBookmarkProxyModel(QObject *parent = 0);
         
+    protected:
         /**
         * Reimplemented only to show always folders first
         */
-        bool lessThan ( const QModelIndex &amp; left, const QModelIndex &amp; right ) const;
+        bool lessThan(const QModelIndex &amp; left, const QModelIndex &amp; right) const;
     };
 
 }</diff>
      <filename>konqbookmark/itemmodels/konqbookmarkproxymodel.h</filename>
    </modified>
    <modified>
      <diff>@@ -101,11 +101,12 @@ int PlacesProxyModel::Private::matches(Place* place)
     matches += place-&gt;url().toString().count(m_strQuery, Qt::CaseInsensitive);
     matches += place-&gt;tags().join(&quot;,&quot;).count(m_strQuery, Qt::CaseInsensitive);
     matches += place-&gt;description().count(m_strQuery, Qt::CaseInsensitive);
+    kDebug() &lt;&lt; place-&gt;url() &lt;&lt; place-&gt;url().toString().count(m_strQuery, Qt::CaseInsensitive) &lt;&lt; matches;
     return matches;
 }
 
 bool PlacesProxyModel::Private::updateRelevance(const QModelIndex&amp; index)
-{   
+{
     Place* place = placeFromIndex(index);
     QDateTime currentTime = QDateTime::currentDateTime();
     
@@ -115,13 +116,13 @@ bool PlacesProxyModel::Private::updateRelevance(const QModelIndex&amp; index)
     
     int days = place-&gt;lastVisited().daysTo(currentTime);
     
-    if(days &lt; first_bucket_days) {
+    if (days &lt; first_bucket_days) {
         weight = first_bucket_weight;
-    } else if(days &lt; second_bucket_days) {
+    } else if (days &lt; second_bucket_days) {
         weight = second_bucket_weight;
-    } else if(days &lt; third_bucket_days) {
+    } else if (days &lt; third_bucket_days) {
         weight = third_bucket_weight;
-    } else if(days &lt; fourth_bucket_days) {
+    } else if (days &lt; fourth_bucket_days) {
         weight = fourth_bucket_weight;
     } else {
         weight = default_bucket_weight;
@@ -129,7 +130,7 @@ bool PlacesProxyModel::Private::updateRelevance(const QModelIndex&amp; index)
     
     relevance += matches * weight + place-&gt;numVisits() * weight;
     
-    if(m_relevance[index] == relevance) {
+    if (m_relevance[index] == relevance) {
         return false;
     }
     
@@ -140,7 +141,7 @@ bool PlacesProxyModel::Private::updateRelevance(const QModelIndex&amp; index)
 void PlacesProxyModel::Private::slotRowsInserted(const QModelIndex&amp; parent, int start, int end)
 {
     Q_UNUSED(parent);
-    for(int i = start; i &lt;= end; i++) {
+    for (int i = start; i &lt;= end; i++) {
         QModelIndex index = q-&gt;index(i, 0);
         updateRelevance(index);
     }
@@ -149,7 +150,7 @@ void PlacesProxyModel::Private::slotRowsInserted(const QModelIndex&amp; parent, int
 void PlacesProxyModel::Private::slotRowsRemoved(const QModelIndex&amp; parent, int start, int end)
 {
     Q_UNUSED(parent);
-    for(int i = start; i &lt;= end; i++) {
+    for (int i = start; i &lt;= end; i++) {
         QModelIndex index = q-&gt;index(i, 0);
         m_relevance.remove(index);
     }
@@ -170,6 +171,7 @@ PlacesProxyModel::PlacesProxyModel(QObject *parent)
 {
     setSortRole(Place::PlaceRelevanceRole);
     setSortCaseSensitivity(Qt::CaseInsensitive);
+    setDynamicSortFilter(false);
     
     connect(this, SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
         this, SLOT(slotRowsInserted(const QModelIndex&amp;, int, int)));
@@ -191,10 +193,16 @@ PlacesProxyModel::~PlacesProxyModel()
 
 void PlacesProxyModel::setQuery(QString query)
 {
-    kDebug() &lt;&lt; &quot;query&quot;;
+    if (query.isEmpty()) {
+        return;
+    }
+    
+    kDebug() &lt;&lt; &quot;query=&quot; &lt;&lt; query;
+    emit layoutAboutToBeChanged();
     d-&gt;m_strQuery = query;
-    // HACK: triggers a call to d-&gt;filter_changed();
-    setFilterKeyColumn(0);
+    d-&gt;m_relevance.clear();
+    invalidateFilter();
+    emit layoutChanged();
 }
 
 void PlacesProxyModel::setQuery(QVariant query)
@@ -209,7 +217,7 @@ QVariant PlacesProxyModel::query() const
 
 void PlacesProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
 {
-    if(!sourceModel) {
+    if (!sourceModel) {
         return;
     }
     
@@ -224,13 +232,13 @@ void PlacesProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
 }
 
 QVariant PlacesProxyModel::data(const QModelIndex&amp; index, int role) const
-{    
-    switch( role )
-    {
+{
+    switch (role) {
     case Place::PlaceRelevanceRole:
         if(!d-&gt;m_relevance.contains(index)) {
             d-&gt;updateRelevance(index);
         }
+        kDebug() &lt;&lt; d-&gt;m_relevance[index];
         return d-&gt;m_relevance[index];
     default:
         return QSortFilterProxyModel::data(index, role);
@@ -241,22 +249,25 @@ bool PlacesProxyModel::filterAcceptsRow(int source_row, const QModelIndex&amp; sourc
 {
     QModelIndex sourceIndex = sourceModel()-&gt;index(source_row, 0, source_parent);
     
-    if(!sourceIndex.isValid() || sourceModel()-&gt;hasChildren(sourceIndex)) {
+    if (!sourceIndex.isValid() || sourceModel()-&gt;hasChildren(sourceIndex)) {
         return false;
     }
     
     QVariant variant = sourceIndex.data(Place::PlaceUrlRole);
-    if(variant == QVariant()) {
+    if (variant == QVariant()) {
         return false;
     }
     
     QUrl url = variant.toString();
     Place* place = PlacesManager::self()-&gt;place(url);
+    kDebug() &lt;&lt; sourceIndex &lt;&lt; (d-&gt;matches(place) &gt; 0);
         
     // Places manager should have all the places!
     Q_ASSERT_X(place != 0, &quot;placemanager&quot;, &quot;Places manager should have all the places!&quot;);    
     
-    return d-&gt;matches(place) &gt; 0;
+    bool accept = d-&gt;matches(place) &gt; 0;
+    
+    return accept;
 }
 
 #include &quot;placesproxymodel.moc&quot;</diff>
      <filename>konqbookmark/itemmodels/placesproxymodel.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -18,6 +18,7 @@
 */
 
 #include &quot;locationbar.h&quot;
+#include &quot;locationbardelegate.h&quot;
 #include &quot;kcompletionview.h&quot;
 #include &quot;placesmanager.h&quot;
 #include &quot;klineeditview_p.h&quot;
@@ -32,6 +33,7 @@
 #include &lt;QStringListModel&gt;
 #include &lt;QStringList&gt;
 #include &lt;QWidget&gt;
+#include &lt;QSortFilterProxyModel&gt;
 
 #include &lt;kurlcompletion.h&gt;
 #include &lt;kurl.h&gt;
@@ -72,11 +74,11 @@ void LocationBar::init()
 {
     setCompletionMode(KGlobalSettings::CompletionPopup);
     setClearButtonShown(true);
-    
-    // FIXME for now, only one location bar is supported because of this
-    // completion model. We just need to be able to create new completion models
-    // that automatically connected to places manager, so it's quite easy.
-    KCompletionModel* completionModel = PlacesManager::self()-&gt;urlCompletionModel();
+    completionView()-&gt;setItemDelegate(new LocationBarDelegate(this));
+
+    KCompletionModel *completionModel = new KCompletionModel(this);
+    completionModel-&gt;setCompletion(new KUrlCompletion());
+    PlacesManager::self()-&gt;registerUrlCompletionModel(completionModel);
 //     connect(this, SIGNAL(textChanged(const QString&amp;)),
 //         completionModel-&gt;completion(), SLOT(slotMakeCompletion(const QString &amp;)));
     
@@ -89,11 +91,15 @@ void LocationBar::init()
     placesProxyModel-&gt;setSourceModel(PlacesManager::self()-&gt;historyEntriesModel());
         
     KAggregatedModel* aggregatedModel = new KAggregatedModel(this);
-    aggregatedModel-&gt;addSourceModel(completionModel);
-    aggregatedModel-&gt;addSourceModel(historyProxyModel);
+//     aggregatedModel-&gt;addSourceModel(completionModel);
+//     aggregatedModel-&gt;addSourceModel(historyProxyModel);
     aggregatedModel-&gt;addSourceModel(placesProxyModel);
     
-    completionView()-&gt;setModel(aggregatedModel);
+    QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this);
+    sortModel-&gt;setSourceModel(placesProxyModel);
+    sortModel-&gt;setSortRole(Place::PlaceRelevanceRole);
+    sortModel-&gt;setDynamicSortFilter(true);
+    completionView()-&gt;setModel(sortModel);
     
     KLineEditViewButton* tempButton = new KLineEditViewButton(this);
     tempButton-&gt;setCursor(Qt::ArrowCursor);</diff>
      <filename>konqbookmark/itemviews/locationbar.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -70,11 +70,11 @@ KonqBookmark::KonqBookmark(const QUrl&amp; uniqueUri) : d( new Private(uniqueUri.toS
 {
 }
 
-KonqBookmark::KonqBookmark() : d( new Private )
+KonqBookmark::KonqBookmark() : d(new Private)
 {   
 }
 
-KonqBookmark::KonqBookmark( const KonqBookmark &amp;other ) : d( other.d )
+KonqBookmark::KonqBookmark(const KonqBookmark &amp;other) : d(other.d)
 {
 }
 
@@ -82,14 +82,20 @@ KonqBookmark::~KonqBookmark()
 {
 }
 
-KonqBookmark &amp;KonqBookmark::operator=( const KonqBookmark &amp;other )
+KonqBookmark &amp;KonqBookmark::operator=(const KonqBookmark &amp;other)
 {
-    if ( this != &amp;other )
+    if (this != &amp;other) {
         d = other.d;
+    }
 
     return *this;
 }
 
+bool KonqBookmark::operator==(const KonqBookmark &amp;other)
+{
+    return other.uniqueUri() == uniqueUri();
+}
+
 Nepomuk::Bookmark KonqBookmark::bookmark() const
 {
     return d-&gt;m_bookmark;</diff>
      <filename>konqbookmark/konqbookmark.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -68,24 +68,25 @@ public:
      * Copy constructor.
      * @overload
      */
-    KonqBookmark( const KonqBookmark &amp;other );
+    KonqBookmark(const KonqBookmark &amp;other);
 
     /**
      * Destructor.
      */
     virtual ~KonqBookmark();
 
-    KonqBookmark &amp;operator=( const KonqBookmark &amp;other );
+    KonqBookmark &amp;operator=(const KonqBookmark &amp;other);
+    bool operator==(const KonqBookmark &amp;other);
 
 // Properties
     
     Nepomuk::Bookmark bookmark() const;
     
-    void setUrl( const QUrl &amp;url );
+    void setUrl(const QUrl &amp;url);
 
     QUrl url() const;
 
-    void setTitle( const QString &amp;title );
+    void setTitle(const QString &amp;title);
 
     QString title() const;
     </diff>
      <filename>konqbookmark/konqbookmark.h</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,7 @@ public:
 
     void slotBookmarksInserted(const QModelIndex&amp; parent, int start, int end);
     void slotBookmarksRemoved(const QModelIndex&amp; parent, int start, int end);
+    void slotBookmarksChanged(const QModelIndex&amp; topLeft, const QModelIndex&amp; bottomRight);
     
     void slotUrlsInserted(const QModelIndex&amp; parent, int start, int end);
     void slotUrlsRemoved(const QModelIndex&amp; parent, int start, int end);
@@ -63,35 +64,28 @@ public:
     PlacesManager *q;
     
     KonqBookmarkModel *m_bookmarksModel;
-    KCompletionModel *m_urlCompletionModel;
     
     QHash&lt;QUrl, KonqHistoryEntry*&gt; m_historyEntries;
     QHash&lt;QUrl, KonqBookmark*&gt; m_bookmarks;
+    QHash&lt;QUrl, QUrl&gt; m_uniqueBookmarks; // QHash&lt;uniqueUri(), url()&gt;
     QHash&lt;QUrl, Place*&gt; m_places;
 };
 
 PlacesManager::Private::Private(PlacesManager *parent)
     : q(parent)
 {   
-    Session* session = new Session(QByteArray( &quot;PlacesManager-&quot; ) + QByteArray::number( qrand() ), q);
-    Monitor* monitor = new Monitor( q );
-    m_bookmarksModel = new KonqBookmarkModel( session, monitor, q );
+    Session* session = new Session(QByteArray(&quot;PlacesManager-&quot;) + QByteArray::number(qrand()), q);
+    Monitor* monitor = new Monitor(q);
+    m_bookmarksModel = new KonqBookmarkModel(session, monitor, q);
     
     connect(m_bookmarksModel, SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
         q, SLOT(slotBookmarksInserted(const QModelIndex&amp;, int, int)));
         
     connect(m_bookmarksModel, SIGNAL(rowsRemoved(const QModelIndex&amp;, int, int)),
         q, SLOT(slotBookmarksRemoved(const QModelIndex&amp;, int, int)));
-        
-    m_urlCompletionModel = new KCompletionModel(q);
-    // FIXME Undefined reference
-//     m_urlCompletionModel-&gt;setCompletion(new KUrlCompletion());
-        
-    connect(m_urlCompletionModel, SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
-        q, SLOT(slotUrlsInserted(const QModelIndex&amp;, int, int)));
-        
-    connect(m_urlCompletionModel, SIGNAL(rowsRemoved(const QModelIndex&amp;, int, int)),
-        q, SLOT(slotUrlsRemoved(const QModelIndex&amp;, int, int)));
+    
+    connect(m_bookmarksModel, SIGNAL(dataChanged(const QModelIndex&amp;, const QModelIndex&amp;)),
+        q, SLOT(slotBookmarksChanged(const QModelIndex&amp;, const QModelIndex&amp;)));
 }
 
 PlacesManager::Private::~Private()
@@ -105,18 +99,17 @@ void PlacesManager::Private::slotBookmarksInserted(const QModelIndex&amp; parent, in
         if(index.data().toString().isEmpty()) {
             continue;
         }
-        
         KonqBookmark *konqBookmark = new KonqBookmark(index.data().toString());
+        m_uniqueBookmarks[konqBookmark-&gt;uniqueUri()] = konqBookmark-&gt;url();
+        if(konqBookmark-&gt;url().toString().isEmpty() || m_bookmarks.contains(konqBookmark-&gt;url())) {
+            continue;
+        }
         
         m_bookmarks[konqBookmark-&gt;url()] = konqBookmark;
-        
-        kDebug() &lt;&lt; konqBookmark-&gt;url() &lt;&lt; konqBookmark-&gt;title();
+        kDebug() &lt;&lt; konqBookmark-&gt;url() &lt;&lt; konqBookmark-&gt;uniqueUri();
         
         // Update/insert place
-        Place *place = q-&gt;place(konqBookmark-&gt;url());
-        if(place) {
-            place-&gt;setBookmark(konqBookmark);
-        }
+        q-&gt;place(konqBookmark-&gt;url())-&gt;setBookmark(konqBookmark);
     }
 }
 
@@ -131,31 +124,85 @@ void PlacesManager::Private::slotBookmarksRemoved(const QModelIndex&amp; parent, int
         
         QUrl url(index.data().toString());
         if(m_bookmarks.contains(url)) {
-            
             // Update/remove place
-            Place *place = q-&gt;place(url);
-            
-            Q_ASSERT(place != 0);
+            Q_ASSERT(m_places[url] != 0);
             
             // if history entry is null and the url is not set either, just 
             // remove this place (otherwise we would end up with a place with 
             // both bookmark and history entry unset). Otherwise, we just update the place.
             m_places[url]-&gt;setBookmark(0);
-            if(!place-&gt;historyEntry() &amp;&amp; place-&gt;url().isEmpty()) {
+            if(!m_places[url]-&gt;historyEntry() &amp;&amp; m_places[url]-&gt;url().isEmpty()) {
                 delete m_places[url];
                 m_places.remove(url);
             }
             
+            m_uniqueBookmarks.remove(m_bookmarks[url]-&gt;uniqueUri());
             delete m_bookmarks[url];
             m_bookmarks.remove(url);
         }
     }
 }
 
+void PlacesManager::Private::slotBookmarksChanged(const QModelIndex&amp; topLeft, const QModelIndex&amp; bottomRight)
+{
+    kDebug() &lt;&lt; topLeft &lt;&lt; bottomRight;
+    int start = topLeft.row();
+    int end = bottomRight.row();
+    if(start &gt; end || start &lt; 0 || topLeft.parent() != bottomRight.parent()) {
+        return;
+    }
+    QModelIndex parent = topLeft.parent();
+    
+    for(int i = start; i &lt;= end; i++) {
+        QModelIndex index = m_bookmarksModel-&gt;index(i, KonqBookmarkModel::UniqueUri, parent);
+        
+        kDebug() &lt;&lt; index &lt;&lt; index.data() &lt;&lt; index.data().toString();
+        if(index.data().toString().isEmpty() ||
+            !m_uniqueBookmarks.contains(index.data().toString())) {
+            continue;
+        }
+        KonqBookmark *konqBookmark = new KonqBookmark(index.data().toString());
+        QUrl oldUrl = m_uniqueBookmarks[index.data().toString()];
+        if(!oldUrl.isEmpty() &amp;&amp; oldUrl == konqBookmark-&gt;url()) {
+            delete konqBookmark;
+            continue;
+        }
+        // 1. Remove old bookmark
+        if(!oldUrl.isEmpty()) {
+            Q_ASSERT(m_places[oldUrl] != 0);
+            // if history entry is null and the url is not set either, just 
+            // remove this place (otherwise we would end up with a place with 
+            // both bookmark and history entry unset). Otherwise, we just update the place.
+            m_places[oldUrl]-&gt;setBookmark(0);
+            if(!m_places[oldUrl]-&gt;historyEntry() &amp;&amp; m_places[oldUrl]-&gt;url().isEmpty()) {
+                delete m_places[oldUrl];
+                m_places.remove(oldUrl);
+            }
+            
+            m_uniqueBookmarks[konqBookmark-&gt;uniqueUri()] = konqBookmark-&gt;url();
+            m_bookmarks.remove(oldUrl);
+        }
+        
+        // 2. Add new bookmark if needed
+        if(konqBookmark-&gt;url().toString().isEmpty() ||
+            m_bookmarks.contains(konqBookmark-&gt;url())) {
+            delete konqBookmark;
+            continue;
+        }
+        m_bookmarks[konqBookmark-&gt;url()] = konqBookmark;
+        kDebug() &lt;&lt; konqBookmark-&gt;url() &lt;&lt; konqBookmark-&gt;title();
+        
+        // Update/insert place
+        q-&gt;place(konqBookmark-&gt;url())-&gt;setBookmark(konqBookmark);
+        
+    }
+}
+
 void PlacesManager::Private::slotUrlsInserted(const QModelIndex&amp; parent, int start, int end)
 {
+    KCompletionModel *urlCompletionModel = qobject_cast&lt;KCompletionModel*&gt;(q-&gt;sender());
     for(int i = start; i &lt;= end; i++) {
-        QModelIndex index = parent.child(i, 0);
+        QModelIndex index = urlCompletionModel-&gt;index(i, 0, parent);
         
         QUrl url = index.data().toString();
         
@@ -164,17 +211,15 @@ void PlacesManager::Private::slotUrlsInserted(const QModelIndex&amp; parent, int sta
         }
         
         // Update/insert place
-        Place *place = q-&gt;place(url);
-        if(!place) {
-            m_places[url] = new Place(url, q);
-        }
+        q-&gt;place(url);
     }
 }
 
 void PlacesManager::Private::slotUrlsRemoved(const QModelIndex&amp; parent, int start, int end)
 {
+    KCompletionModel *urlCompletionModel = qobject_cast&lt;KCompletionModel*&gt;(q-&gt;sender());
     for(int i = start; i &lt;= end; i++) {
-        QModelIndex index = parent.child(i, 0);
+        QModelIndex index = urlCompletionModel-&gt;index(i, 0, parent);
         QUrl url = index.data().toString();
         
         if(!url.isValid()) {
@@ -182,8 +227,7 @@ void PlacesManager::Private::slotUrlsRemoved(const QModelIndex&amp; parent, int star
         }
         
         // Remove
-        Place *place = q-&gt;place(url);
-        if(place &amp;&amp; !place-&gt;bookmark() &amp;&amp; !place-&gt;historyEntry()) {
+        if(m_places.contains(url) &amp;&amp; !m_places[url]-&gt;bookmark() &amp;&amp; !m_places[url]-&gt;historyEntry()) {
             delete m_places[url];
             m_places.remove(url);
         }
@@ -258,9 +302,13 @@ KonqBookmarkModel* PlacesManager::bookmarkModel()
     return d-&gt;m_bookmarksModel;
 }
 
-KCompletionModel* PlacesManager::urlCompletionModel()
+void PlacesManager::registerUrlCompletionModel(KCompletionModel* urlCompletionModel)
 {
-    return d-&gt;m_urlCompletionModel;
+    connect(urlCompletionModel, SIGNAL(rowsInserted(const QModelIndex&amp;, int, int)),
+        this, SLOT(slotUrlsInserted(const QModelIndex&amp;, int, int)));
+        
+    connect(urlCompletionModel, SIGNAL(rowsRemoved(const QModelIndex&amp;, int, int)),
+        this, SLOT(slotUrlsRemoved(const QModelIndex&amp;, int, int)));
 }
 
 </diff>
      <filename>konqbookmark/placesmanager.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -67,8 +67,8 @@ namespace Konqueror
         static PlacesManager* self();
         
         virtual Akonadi::KonqBookmarkModel* bookmarkModel();
-        virtual KCompletionModel* urlCompletionModel();
         virtual QAbstractItemModel* historyEntriesModel() { return 0; }
+        void registerUrlCompletionModel(KCompletionModel* urlCompletionModel);
         
         KonqBookmark* bookmark(const QUrl&amp; url);
         KonqBookmark* bookmark(const KonqHistoryEntry* historyEntry);
@@ -102,6 +102,7 @@ namespace Konqueror
         
         Q_PRIVATE_SLOT(d, void slotBookmarksInserted(const QModelIndex&amp;, int, int))
         Q_PRIVATE_SLOT(d, void slotBookmarksRemoved(const QModelIndex&amp;, int, int))
+        Q_PRIVATE_SLOT(d, void slotBookmarksChanged(const QModelIndex&amp; topLeft, const QModelIndex&amp; bottomRight))
         
         Q_PRIVATE_SLOT(d, void slotHistoryEntryAdded(const KonqHistoryEntry &amp;))
         Q_PRIVATE_SLOT(d, void slotHistoryEntryRemoved(const KonqHistoryEntry &amp;))</diff>
      <filename>konqbookmark/placesmanager.h</filename>
    </modified>
    <modified>
      <diff>@@ -77,32 +77,32 @@ private:
 };
 
 KonquerorBookmarksResource::Private::Private(KonquerorBookmarksResource *parent) :
-    mParent( parent )
+    mParent(parent)
 {
 }
 
 KonquerorBookmarksResource::KonquerorBookmarksResource( const QString &amp;id )
-  : ResourceBase( id ),  d( new Private ( this ) )
+  : ResourceBase(id),  d(new Private(this))
 {
     kDebug();
     Nepomuk::ResourceManager::instance()-&gt;init();
-    new SettingsAdaptor( Settings::self() );
-    QDBusConnection::sessionBus().registerObject( QLatin1String( &quot;/Settings&quot; ),
-        Settings::self(), QDBusConnection::ExportAdaptors ); 
+    new SettingsAdaptor(Settings::self());
+    QDBusConnection::sessionBus().registerObject(QLatin1String(&quot;/Settings&quot;),
+        Settings::self(), QDBusConnection::ExportAdaptors); 
     changeRecorder()-&gt;itemFetchScope().fetchFullPayload();
-    changeRecorder()-&gt;fetchCollection( true );
+    changeRecorder()-&gt;fetchCollection(true);
 
     QStringList mimeTypes;
     mimeTypes &lt;&lt; KonqBookmark::mimeType() &lt;&lt; Collection::mimeType();
     
-    d-&gt;mBookmarksRootCollection.setParent( Collection::root() );
-    d-&gt;mBookmarksRootCollection.setRemoteId( &quot;konqbookmark:/&quot; );
-    d-&gt;mBookmarksRootCollection.setName( i18n(&quot;Konqueror Bookmarks&quot;) );
-    d-&gt;mBookmarksRootCollection.setContentMimeTypes( mimeTypes );
+    d-&gt;mBookmarksRootCollection.setParent(Collection::root());
+    d-&gt;mBookmarksRootCollection.setRemoteId(&quot;konqbookmark:/&quot;);
+    d-&gt;mBookmarksRootCollection.setName(i18n(&quot;Konqueror Bookmarks&quot;));
+    d-&gt;mBookmarksRootCollection.setContentMimeTypes(mimeTypes);
     EntityDisplayAttribute* attr =
-    d-&gt;mBookmarksRootCollection.attribute&lt;EntityDisplayAttribute&gt;( Collection::AddIfMissing );
-    attr-&gt;setDisplayName( i18n(&quot;Konqueror Bookmarks&quot;) );
-    attr-&gt;setIconName( QLatin1String( &quot;bookmarks&quot; ) );
+        d-&gt;mBookmarksRootCollection.attribute&lt;EntityDisplayAttribute&gt;(Collection::AddIfMissing);
+    attr-&gt;setDisplayName(i18n(&quot;Konqueror Bookmarks&quot;));
+    attr-&gt;setIconName(QLatin1String(&quot;bookmarks&quot;));
 
     
     QString latestBookmarksQuery = QString(
@@ -114,7 +114,7 @@ KonquerorBookmarksResource::KonquerorBookmarksResource( const QString &amp;id )
         &quot;?r nao:created ?time . } &quot;
         &quot;ORDER BY DESC(?time) &quot;
         &quot;LIMIT 20&quot;)
-        .arg( Soprano::Vocabulary::NAO::naoNamespace().toString() );
+        .arg(Soprano::Vocabulary::NAO::naoNamespace().toString());
         
         
     QString unclasifiedBookmarksQuery = QString(
@@ -126,7 +126,7 @@ KonquerorBookmarksResource::KonquerorBookmarksResource( const QString &amp;id )
         &quot;?r nao:created ?time . } &quot;
         &quot;ORDER BY DESC(?time) &quot;
         &quot;LIMIT 20&quot;)
-        .arg( Soprano::Vocabulary::NAO::naoNamespace().toString() );
+        .arg(Soprano::Vocabulary::NAO::naoNamespace().toString());
      
     // TODO: What happens if it aleady exists? we should not create a new one
     // or at least we should remove the pre-existing virtual collection 
@@ -191,28 +191,28 @@ Collection::List listRecursive( const Nepomuk::BookmarkFolder&amp; parent, const Col
     Collection::List list;
     QStringList mimeTypes;
         
-    if(!parent.hasProperty(Nepomuk::BookmarkFolder::containsBookmarkFolderUri()))
+    if (!parent.hasProperty(Nepomuk::BookmarkFolder::containsBookmarkFolderUri())) {
         return list;
+    }
     
     QList&lt;Nepomuk::BookmarkFolder&gt; bookmarkFolders = parent.containsBookmarkFolders();
     
     mimeTypes &lt;&lt; KonqBookmark::mimeType() &lt;&lt; Collection::mimeType();
 
-    foreach( const Nepomuk::BookmarkFolder&amp; bookmarkFolder, bookmarkFolders )
-    {
+    foreach(const Nepomuk::BookmarkFolder&amp; bookmarkFolder, bookmarkFolders) {
         Collection col;
-        if(!bookmarkFolder.titles().empty())
-        {
+        if (!bookmarkFolder.titles().empty()) {
             kDebug() &lt;&lt; &quot;folder:&quot; &lt;&lt; bookmarkFolder.titles().first() &lt;&lt; bookmarkFolder.containsBookmarks().size();
             col.setName( bookmarkFolder.titles().first() );
-        } else  // shouldn't happen
+        } else  { // shouldn't happen
             col.setName( &quot;&quot; );
+        }
         
-        col.setRemoteId( bookmarkFolder.resourceUri().toString() );
-        col.setParent( parentCol );
-        col.setContentMimeTypes( mimeTypes );
+        col.setRemoteId(bookmarkFolder.resourceUri().toString());
+        col.setParent(parentCol);
+        col.setContentMimeTypes(mimeTypes);
         list &lt;&lt; col;
-        list &lt;&lt; listRecursive( bookmarkFolder, col );
+        list &lt;&lt; listRecursive(bookmarkFolder, col);
     }
 
     return list;
@@ -221,14 +221,14 @@ Collection::List listRecursive( const Nepomuk::BookmarkFolder&amp; parent, const Col
 void KonquerorBookmarksResource::retrieveCollections()
 {
     kDebug();
-    Nepomuk::BookmarkFolder bookmarkFolder( d-&gt;mBookmarksRootCollection.remoteId() );
+    Nepomuk::BookmarkFolder bookmarkFolder(d-&gt;mBookmarksRootCollection.remoteId());
     Collection::List list;
     list &lt;&lt; d-&gt;mBookmarksRootCollection;
-    list += listRecursive( bookmarkFolder, d-&gt;mBookmarksRootCollection );
-    collectionsRetrieved( list );
+    list += listRecursive(bookmarkFolder, d-&gt;mBookmarksRootCollection);
+    collectionsRetrieved(list);
 }
 
-void KonquerorBookmarksResource::retrieveItems( const Akonadi::Collection &amp;collection )
+void KonquerorBookmarksResource::retrieveItems(const Akonadi::Collection &amp;collection)
 {
     // this method is called when Akonadi wants to know about all the
     // items in the given collection. You can but don't have to provide all the
@@ -236,26 +236,25 @@ void KonquerorBookmarksResource::retrieveItems( const Akonadi::Collection &amp;colle
     // Depending on how your resource accesses the data, there are several
     // different ways to tell Akonadi when you are done.
   
-    Nepomuk::BookmarkFolder folder( collection.remoteId() );
+    Nepomuk::BookmarkFolder folder(collection.remoteId());
     QList&lt;Nepomuk::Bookmark&gt; bookmarks = folder.containsBookmarks();
     kDebug() &lt;&lt; collection.name() &lt;&lt; folder.containsBookmarks().size();
     Item::List items;
-    foreach( const Nepomuk::Bookmark&amp; bookmark, bookmarks )
-    {
+    foreach (const Nepomuk::Bookmark&amp; bookmark, bookmarks) {
         Item item;
-        KonqBookmark konqBookmark(bookmark.resourceUri().toString() );
-        item.setRemoteId( bookmark.resourceUri().toString() );
-        item.setMimeType( KonqBookmark::mimeType() );
-        item.setPayload&lt;KonqBookmark&gt;( konqBookmark );
+        KonqBookmark konqBookmark(bookmark.resourceUri().toString());
+        item.setRemoteId(bookmark.resourceUri().toString());
+        item.setMimeType(KonqBookmark::mimeType());
+        item.setPayload&lt;KonqBookmark&gt;(konqBookmark);
         items &lt;&lt; item;
     }
-    itemsRetrieved( items );
+    itemsRetrieved(items);
 }
 
-bool KonquerorBookmarksResource::retrieveItem( const Akonadi::Item &amp;item, const QSet&lt;QByteArray&gt; &amp;parts )
+bool KonquerorBookmarksResource::retrieveItem(const Akonadi::Item &amp;item, const QSet&lt;QByteArray&gt; &amp;parts)
 {
-    Q_UNUSED( item );
-    Q_UNUSED( parts );
+    Q_UNUSED(item);
+    Q_UNUSED(parts);
 
     // this method is called when Akonadi wants more data for a given item.
     // You can only provide the parts that have been requested but you are allowed
@@ -273,136 +272,136 @@ void KonquerorBookmarksResource::aboutToQuit()
     // to do at the moment
 }
 
-void KonquerorBookmarksResource::configure( WId windowId )
+void KonquerorBookmarksResource::configure(WId windowId)
 {
-    Q_UNUSED( windowId );
+    Q_UNUSED(windowId);
     
     // TODO Here we will show the &quot;Organize bookmarks..&quot; dialog.
 }
 
-void KonquerorBookmarksResource::itemAdded( const Akonadi::Item &amp;item, const Akonadi::Collection &amp;collection )
+void KonquerorBookmarksResource::itemAdded(const Akonadi::Item &amp;item, const Akonadi::Collection &amp;collection)
 {
     kDebug() &lt;&lt; collection.name();
-    if(!item.hasPayload&lt;KonqBookmark&gt;())
-    {
+    if (!item.hasPayload&lt;KonqBookmark&gt;()) {
         kDebug() &lt;&lt; &quot;!item.hasPayload&lt;KonqBookmark&gt;()&quot;;
         return;
     }
     
     KonqBookmark konqBookmark = item.payload&lt;KonqBookmark&gt;();
     
-    Nepomuk::BookmarkFolder folder( collection.remoteId() );
+    Nepomuk::BookmarkFolder folder(collection.remoteId());
     folder.addContainsBookmark(konqBookmark.bookmark());
     
     // Set the remote Id (as suggested by vkrause)
     kDebug() &lt;&lt; &quot;Setting item's remote id to &quot; &lt;&lt; konqBookmark.uniqueUri();
     Akonadi::Item itemCopy = item;
-    itemCopy.setRemoteId( konqBookmark.uniqueUri() );
+    itemCopy.setRemoteId(konqBookmark.uniqueUri());
     changeCommitted(itemCopy);
 }
 
-void KonquerorBookmarksResource::itemChanged( const Akonadi::Item &amp;item, const QSet&lt;QByteArray&gt; &amp;parts )
+void KonquerorBookmarksResource::itemChanged(const Akonadi::Item &amp;item, const QSet&lt;QByteArray&gt; &amp;parts)
 {
     kDebug() &lt;&lt; item.remoteId();
-    Q_UNUSED( parts );
-    if(!item.hasPayload&lt;KonqBookmark&gt;())
-    {
+    Q_UNUSED(parts);
+    if (!item.hasPayload&lt;KonqBookmark&gt;()) {
         kDebug() &lt;&lt; &quot;!item.hasPayload&lt;KonqBookmark&gt;()&quot;;
         return;
     }
    
     KonqBookmark konqBookmark = item.payload&lt;KonqBookmark&gt;();
-    if(item.remoteId() != konqBookmark.uniqueUri())
-    {
+    if(item.remoteId() != konqBookmark.uniqueUri()) {
         // Set the remote Id (as suggested by vkrause)
         kDebug() &lt;&lt; &quot;Setting item's remote id to &quot; &lt;&lt; konqBookmark.uniqueUri();
         Akonadi::Item itemCopy = item;
-        itemCopy.setRemoteId( konqBookmark.uniqueUri() );
+        itemCopy.setRemoteId(konqBookmark.uniqueUri());
         changeCommitted(itemCopy);
     }
 }
 
 void KonquerorBookmarksResource::itemRemoved( const Akonadi::Item &amp;item )
 {
-    if(!item.hasPayload&lt;KonqBookmark&gt;())
-    {
+    kDebug();
+    if (!item.hasPayload&lt;KonqBookmark&gt;()) {
         kDebug() &lt;&lt; &quot;!item.hasPayload&lt;KonqBookmark&gt;()&quot;;
         return;
     }
     
     KonqBookmark konqBookmark = item.payload&lt;KonqBookmark&gt;();
-    Nepomuk::Bookmark bookmark( konqBookmark.uniqueUri() );
-    if(bookmark.isValid())
+    Nepomuk::Bookmark bookmark(konqBookmark.uniqueUri());
+    if (bookmark.isValid()) {
         bookmark.remove();
+    }
+    
+    changeCommitted(item);
 }
 
-void KonquerorBookmarksResource::collectionAdded( const Akonadi::Collection &amp;collection, const Akonadi::Collection &amp;parent )
+void KonquerorBookmarksResource::collectionAdded(const Akonadi::Collection &amp;collection, const Akonadi::Collection &amp;parent)
 {
     QString uniqueUri = KonqBookmark::generateUniqueUri();
     kDebug() &lt;&lt; &quot;adding &quot; &lt;&lt; collection.name() &lt;&lt; &quot; with remoteId = &quot; &lt;&lt; uniqueUri &lt;&lt; &quot; to parent = &quot; &lt;&lt; parent.remoteId() &lt;&lt; &quot;, parent.name() =&quot; &lt;&lt; parent.name();
     
     Akonadi::Collection parentCollection = parent;
-    if(parent.remoteId().isEmpty())
+    if (parent.remoteId().isEmpty()) {
         parentCollection = d-&gt;mBookmarksRootCollection;
+    }
     
     // Create bookmark folder
-    Nepomuk::BookmarkFolder bookmarkFolder( uniqueUri );
-    bookmarkFolder.setTitles( QStringList(collection.name()) );
+    Nepomuk::BookmarkFolder bookmarkFolder(uniqueUri);
+    bookmarkFolder.setTitles(QStringList(collection.name()));
     
     // Set parent folder
-    Nepomuk::BookmarkFolder parentBookmarkFolder( parentCollection.remoteId() );
-    if(!parentBookmarkFolder.containsBookmarkFolders().contains(bookmarkFolder))
+    Nepomuk::BookmarkFolder parentBookmarkFolder(parentCollection.remoteId());
+    if (!parentBookmarkFolder.containsBookmarkFolders().contains(bookmarkFolder)) {
         parentBookmarkFolder.addContainsBookmarkFolder( bookmarkFolder );
+    }
     
     // Set the remote Id (as suggested by vkrause)
     Akonadi::Collection collectionCopy = collection;
-    collectionCopy.setRemoteId( uniqueUri );
-    collectionCopy.setParent( parentCollection );
+    collectionCopy.setRemoteId(uniqueUri);
+    collectionCopy.setParent(parentCollection);
     changeCommitted(collectionCopy);
 }
 
-void KonquerorBookmarksResource::collectionChanged( const Akonadi::Collection &amp;collection )
+void KonquerorBookmarksResource::collectionChanged(const Akonadi::Collection &amp;collection)
 {
     kDebug() &lt;&lt; collection.name();
     // At the moment, the only thing a collection can change is it's name
-    Nepomuk::BookmarkFolder bookmarkFolder( collection.remoteId() );
+    Nepomuk::BookmarkFolder bookmarkFolder(collection.remoteId());
     
     // Set parent folder;
-    if(bookmarkFolder.titles() != QStringList(collection.name()))
+    if (bookmarkFolder.titles() != QStringList(collection.name())) {
         bookmarkFolder.setTitles( QStringList(collection.name()) );
+    }
 }
 
-void KonquerorBookmarksResource::collectionRemoved( const Akonadi::Collection &amp;collection )
+void KonquerorBookmarksResource::collectionRemoved(const Akonadi::Collection &amp;collection)
 {
     kDebug() &lt;&lt; collection.name();
     // Root collection cannot be removed
-    if(collection.remoteId() == &quot;konqbookmark:/&quot;)
+    if (collection.remoteId() == &quot;konqbookmark:/&quot;) {
         return;
+    }
     
     // Remove all the bookmarks inside this folder
-    Nepomuk::BookmarkFolder bookmarkFolder( collection.remoteId() );
+    Nepomuk::BookmarkFolder bookmarkFolder(collection.remoteId());
     QList&lt;Nepomuk::Bookmark&gt; bookmarks = bookmarkFolder.containsBookmarks();
-    foreach( const Nepomuk::Bookmark&amp; bookmark, bookmarks )
-    {
+    foreach (const Nepomuk::Bookmark&amp; bookmark, bookmarks) {
         Item item;
-        item.setRemoteId( bookmark.resourceUri().toString() );
-        Akonadi::ItemDeleteJob *job = new Akonadi::ItemDeleteJob( item );
-        if ( !job-&gt;exec() )
-        {
+        item.setRemoteId(bookmark.resourceUri().toString());
+        Akonadi::ItemDeleteJob *job = new Akonadi::ItemDeleteJob(item);
+        if (!job-&gt;exec()) {
             kDebug() &lt;&lt; &quot;Error deleting an bookmark item&quot;;
         }
     }
     
     // Remove recursively all the subfolders
     QList&lt;Nepomuk::BookmarkFolder&gt; bookmarkFolders = bookmarkFolder.containsBookmarkFolders();
-    foreach( const Nepomuk::BookmarkFolder&amp; subFolder, bookmarkFolders )
-    {
+    foreach (const Nepomuk::BookmarkFolder&amp; subFolder, bookmarkFolders) {
         Collection subCollection;
-        subCollection.setRemoteId( subFolder.resourceUri().toString() );
+        subCollection.setRemoteId(subFolder.resourceUri().toString());
         
-        Akonadi::CollectionDeleteJob *job = new Akonadi::CollectionDeleteJob( subCollection );
-        if ( !job-&gt;exec() )
-        {
+        Akonadi::CollectionDeleteJob *job = new Akonadi::CollectionDeleteJob(subCollection);
+        if (!job-&gt;exec()) {
             kDebug() &lt;&lt; &quot;Error deleting a bookmark folder&quot;;
         }
     }
@@ -410,6 +409,6 @@ void KonquerorBookmarksResource::collectionRemoved( const Akonadi::Collection &amp;c
     changeCommitted(collection);
 }
 
-AKONADI_RESOURCE_MAIN( KonquerorBookmarksResource )
+AKONADI_RESOURCE_MAIN(KonquerorBookmarksResource)
 
 #include &quot;konquerorbookmarksresource.moc&quot;</diff>
      <filename>konquerorbookmarks/konquerorbookmarksresource.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -6,5 +6,5 @@ Exec=akonadi_konquerorbookmarks_resource
 Icon=bookmarks
 
 X-Akonadi-MimeTypes=application/x-vnd.kde.konqbookmark
-X-Akonadi-Capabilities=Resource
+X-Akonadi-Capabilities=Resource,Unique,Autostart
 X-Akonadi-Identifier=akonadi_konquerorbookmarks_resource</diff>
      <filename>konquerorbookmarks/konquerorbookmarksresource.desktop</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e7c1e58fc76597370c9de4a808b68d6d68bc9dc3</id>
    </parent>
  </parents>
  <author>
    <name>Eduardo RE</name>
    <email>edulix@edulix-laptop.(none)</email>
  </author>
  <url>http://github.com/edulix/gsoc/commit/4e12d9b721f4d8c2c0478598a7735af31aa3569c</url>
  <id>4e12d9b721f4d8c2c0478598a7735af31aa3569c</id>
  <committed-date>2009-09-03T04:16:40-07:00</committed-date>
  <authored-date>2009-09-03T04:16:40-07:00</authored-date>
  <message> * delete works again
 * default selected collection gets set again to the first collection inserted
 * starts the work on the LocationDelegate
 * Now it's possible to have more than one location bar, needed if we want to be
 able to use the loation bar as the editor widget for urls in the bookmarks
 organizer
 * adapting the code to kdelibs style (not finished)
 * location bar now gets newly added bookmarks too
 * BookmarksView::getParentCollection(): adding a bookmark no longer has problems
 when no collection is selected in the bookmarks view.</message>
  <tree>f32ac4a4c469d77cc325a156be0178ee0d4b0157</tree>
  <committer>
    <name>Eduardo RE</name>
    <email>edulix@edulix-laptop.(none)</email>
  </committer>
</commit>
