[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/kjots
From:       Stephen Kelly <steveire () gmail ! com>
Date:       2008-06-19 21:56:26
Message-ID: 1213912586.623044.10115.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 822355 by skelly:

Fix preselection in the combo box for internal kjots links.

This involves using a proxy model copied from kdepimlibs/akonadi.



 M  +1 -0      CMakeLists.txt  
 A             flatcollectionproxymodel.cpp   \
trunk/KDE/kdepimlibs/akonadi/flatcollectionproxymodel.cpp#822351 [License: LGPL \
(v2+)]  A             flatcollectionproxymodel.h   \
trunk/KDE/kdepimlibs/akonadi/flatcollectionproxymodel.h#822351 [License: LGPL (v2+)]  \
M  +26 -10    kjotslinkdialog.cpp  


--- trunk/KDE/kdepim/kjots/CMakeLists.txt #822354:822355
@@ -19,6 +19,7 @@
    kjotsreplacenextdialog.cpp
    kjotsbrowser.cpp
    kjotslinkdialog.cpp
+   flatcollectionproxymodel.cpp
  )
 
 
--- trunk/KDE/kdepim/kjots/kjotslinkdialog.cpp #822354:822355
@@ -32,6 +32,7 @@
 #include <kdebug.h>
 
 #include "KJotsSettings.h"
+#include "flatcollectionproxymodel.h"
 #include "kjotsentry.h"
 #include "bookshelf.h"
 
@@ -44,8 +45,11 @@
     setModal(true);
     showButtonSeparator(true);
     mBookshelf = bookshelf;
-    QAbstractItemModel* model = mBookshelf->model();
 
+    FlatCollectionProxyModel* proxyModel = new FlatCollectionProxyModel( this );
+    proxyModel->setSourceModel( mBookshelf->model() );
+    proxyModel->setAncestorSeparator( QLatin1String( " / " ) );
+
     QWidget *entries = new QWidget(this);
 
     QGridLayout *layout = new QGridLayout(entries);
@@ -59,10 +63,10 @@
     linkUrlLineEdit->setClearButtonShown(true);
 
     tree = new QTreeView();
-    tree->setModel(model);
+    tree->setModel(proxyModel);
     tree->expandAll();
     tree->setColumnHidden(1, true);
-    hrefCombo->setModel(mBookshelf->model());
+    hrefCombo->setModel(proxyModel);
     hrefCombo->setView(tree);
 
     QGridLayout* linkLayout = new QGridLayout();
@@ -99,17 +103,29 @@
 void KJotsLinkDialog::setLinkUrl(const QString &linkUrl)
 {
     if (KJotsEntry::isKJotsLink(linkUrl)) {
-        kDebug() << KJotsEntry::idFromLinkUrl(linkUrl);
 
-        KJotsEntry* item = \
mBookshelf->entryFromId(KJotsEntry::idFromLinkUrl(linkUrl)); +        quint64 id = \
KJotsEntry::idFromLinkUrl(linkUrl); +        KJotsEntry* item = \
mBookshelf->entryFromId(id);  if ( item ) {
+
             QModelIndex index = hrefCombo->model()->index(0,1);
-            index = index.sibling(index.row(), 0);
-            index = index.sibling(index.row() + 1, 0);
-            index = index.sibling(index.row(), 1);
-            index = index.sibling(index.row(), 0);
+            if ( hrefCombo->model()->data(index).toULongLong() == id )
+            {
+                hrefCombo->view()->setCurrentIndex(index);
+                hrefCombo->setCurrentIndex( index.row() );
+            } else {
+                while ( index.sibling(index.row() + 1, 1).isValid() )
+                {
+                    index = index.sibling(index.row() + 1, 1);
 
-            hrefCombo->view()->setCurrentIndex(index);
+                    if ( hrefCombo->model()->data(index).toULongLong() == id )
+                    {
+                        hrefCombo->view()->setCurrentIndex(index);
+                        hrefCombo->setCurrentIndex( index.row() );
+                        break;
+                    }
+                }
+            }
         }
         hrefComboRadioButton->setChecked(true);
     } else {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic