[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/akonadi-ports/kdepimlibs (merge)
From: Volker Krause <vkrause () kde ! org>
Date: 2009-09-30 7:30:32
Message-ID: 1254295832.150484.9350.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1029555 by vkrause:
SVN_MERGE
Merged revisions 1029242-1029243,1029267,1029330 via svnmerge from
https://vkrause@svn.kde.org/home/kde/trunk/KDE/kdepimlibs
........
r1029242 | skelly | 2009-09-29 12:11:13 +0200 (Tue, 29 Sep 2009) | 1 line
Fetch resource trees into ETM if they are monitored explicitly. Enables virtual \
collections/resources.
........
r1029243 | skelly | 2009-09-29 12:11:18 +0200 (Tue, 29 Sep 2009) | 1 line
Use a queued connection in the state saver to delay restoration a bit.
........
r1029267 | skelly | 2009-09-29 13:38:42 +0200 (Tue, 29 Sep 2009) | 3 lines
Initialize the currentIndex key and store a negative key for invalid indexes.
This should fix the KAddressBook phantom contacts issue.
........
r1029330 | dfaure | 2009-09-29 16:58:28 +0200 (Tue, 29 Sep 2009) | 3 lines
Because the 3 korganizer plugins share the same part, we need to switch
that part's XML files every time we are about to show its GUI.
........
_M . (directory)
M +1 -0 akonadi/entitytreemodel.h
M +56 -1 akonadi/entitytreemodel_p.cpp
M +4 -0 akonadi/entitytreemodel_p.h
M +4 -2 akonadi/entitytreeviewstatesaver.cpp
M +21 -2 kontactinterface/plugin.cpp
M +7 -0 kontactinterface/plugin.h
--- branches/work/akonadi-ports/kdepimlibs/akonadi/entitytreemodel.h #1029554:1029555
@@ -326,6 +326,7 @@
Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) )
Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) )
+ Q_PRIVATE_SLOT( d_func(), void topLevelCollectionsFetched( \
Akonadi::Collection::List ) )
Q_PRIVATE_SLOT( d_func(), void ancestorsFetched( Akonadi::Collection::List ) )
Q_PRIVATE_SLOT( d_func(), void monitoredMimeTypeChanged( const QString&, bool ) \
)
--- branches/work/akonadi-ports/kdepimlibs/akonadi/entitytreemodel_p.cpp \
#1029554:1029555 @@ -129,6 +129,9 @@
{
const Collection col = it.next();
+ if ( m_collections.contains( col.id() ) )
+ continue;
+
Collection parent = col;
Collection tmp;
@@ -154,6 +157,7 @@
const QModelIndex parentIndex = q->indexForCollection( parents.value( \
topCollectionId ) ); q->beginInsertRows( parentIndex, row, row );
+ Q_ASSERT( !colIt.value().isEmpty() );
foreach( const Collection &col, colIt.value() )
{
m_collections.insert( col.id(), col );
@@ -199,6 +203,8 @@
if ( itemsToInsert.size() > 0 ) {
const int startRow = m_childEntities.value( collectionId ).size();
+ Q_ASSERT( m_collections.contains( collectionId ) );
+
const QModelIndex parentIndex = q->indexForCollection( m_collections.value( \
collectionId ) );
q->beginInsertRows( parentIndex, startRow, startRow + items.size() - 1 );
foreach ( const Item &item, items ) {
@@ -746,11 +752,60 @@
// retrieved now.
if ( m_itemPopulation != EntityTreeModel::NoItemPopulation ) {
- if (rootCollection != Collection::root())
+ if ( rootCollection != Collection::root() )
fetchItems( rootCollection );
}
+
+ // Resources which are explicitly monitored won't have appeared yet if their \
mimetype didn't match. + // We fetch the top level collections and examine them for \
whether to add them. + // This fetches virtual collections into the tree.
+ if ( !m_monitor->resourcesMonitored().isEmpty() )
+ fetchTopLevelCollections();
}
+void EntityTreeModelPrivate::fetchTopLevelCollections() const
+{
+ Q_Q( const EntityTreeModel );
+ CollectionFetchJob *job = new CollectionFetchJob( Collection::root(), \
CollectionFetchJob::FirstLevel, m_session ); + q->connect( job, SIGNAL( \
collectionsReceived( const Akonadi::Collection::List& ) ), + q, SLOT( \
topLevelCollectionsFetched( const Akonadi::Collection::List& ) ) ); + q->connect( \
job, SIGNAL( result( KJob* ) ), + q, SLOT( fetchJobDone( KJob* ) ) );
+}
+
+void EntityTreeModelPrivate::topLevelCollectionsFetched( const \
Akonadi::Collection::List& list ) +{
+ Q_Q( EntityTreeModel );
+ foreach( const Collection &collection, list )
+ {
+ if ( m_monitor->resourcesMonitored().contains( collection.resource().toUtf8() ) \
&& !m_collections.contains( collection.id() ) ) + {
+ const QModelIndex parentIndex = q->indexForCollection( \
collection.parentCollection() ); + // Prepending new collections.
+ const int row = 0;
+ q->beginInsertRows( parentIndex, row, row );
+
+ m_collections.insert( collection.id(), collection );
+ Node *node = new Node;
+ node->id = collection.id();
+ node->parent = collection.parentCollection().id();
+ node->type = Node::Collection;
+ m_childEntities[ collection.parentCollection().id() ].prepend( node );
+
+ q->endInsertRows();
+
+ CollectionFetchJob *job = new CollectionFetchJob( collection, \
CollectionFetchJob::FirstLevel, m_session ); + \
job->fetchScope().setIncludeUnsubscribed( m_includeUnsubscribed ); + \
job->fetchScope().setIncludeStatistics( m_includeStatistics ); + \
job->fetchScope().setAncestorRetrieval( Akonadi::CollectionFetchScope::All ); + \
q->connect( job, SIGNAL( collectionsReceived( const Akonadi::Collection::List& ) ), + \
q, SLOT( collectionsFetched( const Akonadi::Collection::List& ) ) ); + \
q->connect( job, SIGNAL( result( KJob* ) ), + q, SLOT( fetchJobDone( \
KJob* ) ) ); + }
+ }
+}
+
Collection EntityTreeModelPrivate::getParentCollection( Entity::Id id ) const
{
QHashIterator<Collection::Id, QList<Node*> > iter( m_childEntities );
--- branches/work/akonadi-ports/kdepimlibs/akonadi/entitytreemodel_p.h \
#1029554:1029555 @@ -143,6 +143,10 @@
Session *m_session;
Q_DECLARE_PUBLIC( EntityTreeModel )
+
+ void fetchTopLevelCollections() const;
+ void topLevelCollectionsFetched(const Akonadi::Collection::List& collectionList);
+
};
}
--- branches/work/akonadi-ports/kdepimlibs/akonadi/entitytreeviewstatesaver.cpp \
#1029554:1029555 @@ -34,7 +34,7 @@
struct State
{
- State() : selected( false ), expanded( false ) {}
+ State() : selected( false ), expanded( false ), currentIndex( false ) {}
bool selected;
bool expanded;
bool currentIndex;
@@ -58,6 +58,8 @@
static inline QString key( const QModelIndex &index )
{
+ if ( !index.isValid() )
+ return QLatin1String( "x-1" );
const Collection c = index.data( EntityTreeModel::CollectionRole \
).value<Collection>(); if ( c.isValid() )
return QString::fromLatin1( "c%1" ).arg( c.id() );
@@ -215,7 +217,7 @@
// watch the model for stuff coming in delayed
if ( d->hasChanges() )
- connect( d->view->model(), SIGNAL(rowsInserted(QModelIndex,int,int)), \
SLOT(rowsInserted(QModelIndex,int,int)) ); + connect( d->view->model(), \
SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(rowsInserted(QModelIndex,int,int)), \
Qt::QueuedConnection ); }
} // namespace Akonadi
--- branches/work/akonadi-ports/kdepimlibs/kontactinterface/plugin.cpp \
#1029554:1029555 @@ -52,6 +52,7 @@
public:
void partDestroyed();
+ void setXmlFiles();
void removeInvisibleToolbarActions(Plugin* plugin);
Core *core;
@@ -268,6 +269,15 @@
return d->core;
}
+void Plugin::aboutToSelect()
+{
+ // Because the 3 korganizer plugins share the same part, we need to switch
+ // that part's XML files every time we are about to show its GUI...
+ d->setXmlFiles();
+
+ select();
+}
+
void Plugin::select()
{
}
@@ -292,7 +302,7 @@
// work visually, but only modifying the XML ensures that the actions don't appear
// in "edit toolbars". #207296
const QStringList hideActions = plugin->invisibleToolbarActions();
- //kDebug() << "Hiding actions" << hideActions;
+ //kDebug() << "Hiding actions" << hideActions << "from" << pluginName << part;
QDomDocument doc = part->domDocument();
QDomElement docElem = doc.documentElement();
// 1. Iterate over containers
@@ -326,8 +336,17 @@
if (!file.open(QFile::WriteOnly))
return;
file.write(doc.toString().toUtf8());
+ setXmlFiles();
+}
+
+void Plugin::Private::setXmlFiles()
+{
+ const QString newAppFile = KStandardDirs::locateLocal("data", "kontact/default-" + \
pluginName + ".rc"); const QString localFile = KStandardDirs::locateLocal("data", \
"kontact/local-" + pluginName + ".rc");
- part->replaceXMLFile(newAppFile, localFile);
+ if (part->xmlFile() != newAppFile
+ || part->localXMLFile() != localFile) {
+ part->replaceXMLFile(newAppFile, localFile);
+ }
}
//@endcond
--- branches/work/akonadi-ports/kdepimlibs/kontactinterface/plugin.h #1029554:1029555
@@ -189,6 +189,13 @@
virtual void select();
/**
+ * Called by kontact when the plugin is selected by the user.
+ * Calls the virtual method select(), but also handles some standard behavior
+ * like "invisible toolbar actions".
+ */
+ void aboutToSelect();
+
+ /**
* This function is called whenever the config dialog has been closed
* successfully.
*/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic