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

List:       kde-commits
Subject:    playground/pim/kjotsrewrite/kjots_common
From:       Stephen Kelly <steveire () gmail ! com>
Date:       2009-02-20 19:32:52
Message-ID: 1235158372.919347.12685.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 929150 by skelly:

Add some code to use the new models stuff.



 M  +59 -38    kjotswidget.cpp  
 M  +5 -7      kjotswidget.h  
 M  +13 -6     kjotswidgetpimstyle.cpp  


--- trunk/playground/pim/kjotsrewrite/kjots_common/kjotswidget.cpp #929149:929150
@@ -29,15 +29,20 @@
 #include <QTextDocumentFragment>
 #include <QTextBrowser>
 
+#include <QDirModel>
+#include <QColumnView>
+
 #include <QSortFilterProxyModel>
 
+#include <akonadi/agentinstancecreatejob.h>
+#include <akonadi/agentmanager.h>
+#include <akonadi/agenttype.h>
 #include <akonadi/control.h>
 #include "collectionchildorderattribute.h"
 #include <akonadi/collectionfetchjob.h>
 #include <akonadi/collectionmodel.h>
-#include "clientsideentitystorage.h"
-// #include "descendantentitiesproxymodel.h"
-#include "descendantentitiesmodel.h"
+#include "descendantentitiesproxymodel.h"
+#include "flatcollectionproxymodel.h"
 #include <akonadi/entitydisplayattribute.h>
 #include "entityfilterproxymodel.h"
 #include "entitytreemodel.h"
@@ -51,7 +56,6 @@
 
 #include <KTextEdit>
 
-// #include "kjotsbookshelf.h"
 #include "kjotspage.h"
 
 #include <kdebug.h>
@@ -66,10 +70,9 @@
   QSplitter *splitter = new QSplitter( this );
   QHBoxLayout *layout = new QHBoxLayout( this );
 
-//   bookshelf = new KJotsBookshelf( splitter );
-
   treeview = new EntityTreeView( splitter );
-  treeview->setSortingEnabled(false);
+//   treeview = new QColumnView(splitter);
+//   treeview->setSortingEnabled(false);
 
   if ( !Akonadi::Control::start() ) {
     kFatal() << "Unable to start Akonadi server, exit application";
@@ -83,7 +86,29 @@
   // Check  Akonadi::AgentManager::self()->instances() if it contains one, if it \
doesn't create one and report errors  // if necessary.
 
+//   Akonadi::AgentManager *manager = Akonadi::AgentManager::self();
+//
+//   Akonadi::AgentType::List types = manager->types();
+//   foreach( const Akonadi::AgentType &type, types ) {
+//     qDebug() << "Type:" << type.name() << type.description() << \
type.identifier(); +//     Akonadi::AgentInstance instance = \
manager->instance(type.identifier()); +// // //     kDebug() << "instance:" << \
instance.identifier() << instance.name(); +// // //     instance.setIsOnline(true);
+//     instance.synchronize();
+// //     Akonadi::AgentInstanceCreateJob *job = new \
Akonadi::AgentInstanceCreateJob( type ); +// //     job->start();
+//   }
+// //   kFatal();
 
+//   kDebug() << "ins";
+//   foreach( Akonadi::AgentInstance instance, manager->instances() ) {
+//     qDebug() << "Type:" << instance.name() << instance.identifier();
+//     instance.setIsOnline(true);
+//     instance.synchronize();
+// //     Akonadi::AgentInstance instance = m
+//   }
+//   kDebug() << "ins done";
+
   // Use Collection::root as the top level 'bookshelf'
   Collection rootCollection = Collection::root();
 
@@ -101,44 +126,39 @@
 //   monitor->fetchCollectionStatistics( false );
 
   Session *session = new Session( QByteArray( "EntityTreeModel-" ) + \
QByteArray::number( qrand() ), this ); +
   EntityUpdateAdapter *eua = new EntityUpdateAdapter( session, this );
 
-  m_clientSideEntityStorage = new ClientSideEntityStorage( monitor,
-                     QStringList() << KJotsPage::mimeType(),
-                     rootCollection,
-                     this, ClientSideEntityStorage::FetchCollectionsRecursive,
-                     ClientSideEntityStorage::LazyPopulation
-                     );
+  etm = new Akonadi::EntityTreeModel(eua, monitor, this);
+  etm->fetchMimeTypes(QStringList() << KJotsPage::mimeType());
+//   etm->setItemPopulationStrategy(EntityTreeModel::NoItemPopulation);
+//   etm->setItemPopulationStrategy(EntityTreeModel::LazyPopulation);
+//   etm->setIncludeRootCollection(true);
+//   etm->setRootCollectionDisplayName("[All]");
 
-  etm = new Akonadi::EntityTreeModel( eua, m_clientSideEntityStorage, this);
+//   DescendantEntitiesProxyModel *demp = new DescendantEntitiesProxyModel( \
//QModelIndex(), +//   this );
+//   demp->setSourceModel(etm);
+//   demp->setRootIndex(QModelIndex());
 
-//   DescendantEntitiesProxyModel *dem = new DescendantEntitiesProxyModel( cses, \
                rootCollection, this );
-//   dem->setSourceModel(etm);
-  DescendantEntitiesModel *dem = new DescendantEntitiesModel(eua, \
m_clientSideEntityStorage, this); +//   demp->setDisplayAncestorData(true, QString(" \
/ "));  
-  EntityFilterProxyModel *proxy = new EntityFilterProxyModel();
-  proxy->setSourceModel(dem);
-  proxy->addMimeTypeExclusionFilter( Collection::mimeType() );
+//   EntityFilterProxyModel *proxy = new EntityFilterProxyModel();
+//   proxy->setSourceModel(demp);
+//   proxy->addMimeTypeExclusionFilter( Collection::mimeType() );
 
-//   QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
-
-//   proxy = new Akonadi::EntityOrderProxyModel(this);
-//   proxy = new Akonadi::EntitySortFilterProxyModel( this );
-//   proxy->addMimeTypeFilters( QStringList()
-//                              << KJotsPage::mimeType() );
-//   proxy->setDynamicSortFilter ( true );
-//   proxy->setSourceModel( etm );
-//   proxy->sort( 0 );  // Sort ascending.
-
 //   new ModelTest(proxy, this);
 //   new ModelTest( etm, this );
 //   new ModelTest( dem, this );
+//   new ModelTest( demp, this );
 
-//   bookshelf->setModel( etm );
-//   bookshelf->setModel( proxy );
-
 //   treeview->setModel(proxy);
 //   treeview->setModel( dem );
+//   treeview->setModel( demp );
+//   treeview->setModel( fcp );
+
+//   QDirModel *dm = new QDirModel(this);
+//   treeview->setModel( dm );
   treeview->setModel( etm );
 
   stackedWidget = new QStackedWidget( splitter );
@@ -158,6 +178,7 @@
 
   connect( etm, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
       SLOT( dataChanged(const QModelIndex &, const QModelIndex &)));
+
 }
 
 KJotsWidget::~KJotsWidget()
@@ -298,7 +319,7 @@
       Collection col = etm->data(idx, \
EntityTreeModel::CollectionRole).value<Collection>();  if (col.isValid())
       {
-        m_clientSideEntityStorage->purgeCollection(col.id());
+//         m_clientSideEntityStorage->purgeCollection(col.id());
 //         treeview->collapse(idx);
       }
     }
@@ -318,11 +339,11 @@
       return;
     }
     Collection col = etm->data(idx, \
                EntityTreeModel::CollectionRole).value<Collection>();
-    if (col.isValid() && m_clientSideEntityStorage->canPopulate(col.id()))
-    {
-      m_clientSideEntityStorage->populateCollection(col.id());
+//     if (col.isValid() && m_clientSideEntityStorage->canPopulate(col.id()))
+//     {
+//       m_clientSideEntityStorage->populateCollection(col.id());
       //         treeview->collapse(idx);
-    }
+//     }
   }
   // selected is not a single page. May be a book or a range of books/pages.
   // Render the selection to the browser.
--- trunk/playground/pim/kjotsrewrite/kjots_common/kjotswidget.h #929149:929150
@@ -26,15 +26,15 @@
 class QTextBrowser;
 class QTextCursor;
 class QStackedWidget;
-// class KJotsBookshelf;
 class QModelIndex;
 class QItemSelection;
+class QColumnView;
+class QAbstractItemView;
 
 namespace Akonadi
 {
 class EntityTreeModel;
 class EntityTreeView;
-class ClientSideEntityStorage;
 }
 
 class KJotsPage;
@@ -50,9 +50,7 @@
   KJotsWidget( QWidget *parent = 0, Qt::WindowFlags f = 0 );
   ~KJotsWidget();
 
-
 protected slots:
-//   void setSelection( const QModelIndex &index );
   void selectionChanged ( const QItemSelection & selected, const QItemSelection & \
deselected );  void dataChanged(const QModelIndex &, const QModelIndex &);
 
@@ -68,9 +66,9 @@
   QTextBrowser   *browser;
   QStackedWidget *stackedWidget;
   Akonadi::EntityTreeModel *etm;
-  Akonadi::EntityTreeView *treeview;
-  Akonadi::ClientSideEntityStorage *m_clientSideEntityStorage;
-  //   KJotsBookshelf *bookshelf;
+//   Akonadi::EntityTreeView *treeview;
+//   QColumnView *treeview;
+  QAbstractItemView *treeview;
 };
 
 #endif
--- trunk/playground/pim/kjotsrewrite/kjots_common/kjotswidgetpimstyle.cpp \
#929149:929150 @@ -36,7 +36,7 @@
 #include "collectionchildorderattribute.h"
 #include <akonadi/collectionfetchjob.h>
 #include <akonadi/collectionmodel.h>
-#include "clientsideentitystorage.h"
+// #include "clientsideentitystorage.h"
 #include <akonadi/entitydisplayattribute.h>
 #include "entitytreemodel.h"
 #include "entityfilterproxymodel.h"
@@ -100,12 +100,14 @@
   Session *session = new Session( QByteArray( "EntityTreeModel-" ) + \
QByteArray::number( qrand() ), this );  EntityUpdateAdapter *eua = new \
EntityUpdateAdapter( session, this );  
-  ClientSideEntityStorage *cses = new ClientSideEntityStorage( monitor,
-                                                               QStringList() << \
                KJotsPage::mimeType(),
-                                                               rootCollection,
-                                                               this);
+//   ClientSideEntityStorage *cses = new ClientSideEntityStorage( monitor,
+//                                                                QStringList() << \
KJotsPage::mimeType(), +//                                                            \
rootCollection, +//                                                                \
this);  
-  etm = new Akonadi::EntityTreeModel( eua, cses, this);
+//   etm = new Akonadi::EntityTreeModel( eua, cses, this);
+  etm = new Akonadi::EntityTreeModel( eua, monitor, this);
+  etm->fetchMimeTypes(QStringList() << KJotsPage::mimeType());
 
   treeproxy = new EntityFilterProxyModel(this);
 
@@ -137,8 +139,13 @@
 
 //   QVBoxLayout *vl = new QVBoxLayout( stackedWidget );
 
+
+//   DescendantEntitiesProxyModel *descList = new \
DescendantEntitiesProxyModel(this); +//   descList->setSourceModel(etm);
+
   listproxy = new EntityFilterProxyModel(this);
   listproxy->setSourceModel(etm);
+//   listproxy->setSourceModel(descList);
 
   listproxy->addMimeTypeInclusionFilter( KJotsPage::mimeType() );
 //   listproxy->includeChildCollectionTree(false);


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

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