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

List:       kde-commits
Subject:    KDE/kdepim/akonadi/libakonadi
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2006-09-26 12:32:31
Message-ID: 1159273951.944524.30445.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 588589 by tokoe:

Add support for viewing assigned agents


 M  +35 -1     profilemodel.cpp  
 M  +2 -0      profilemodel.h  


--- trunk/KDE/kdepim/akonadi/libakonadi/profilemodel.cpp #588588:588589
@@ -28,6 +28,7 @@
 {
   public:
     QString identifier;
+    QStringList agents;
 };
 
 class ProfileModel::Private
@@ -44,6 +45,8 @@
 
     void profileAdded( const QString &profile );
     void profileRemoved( const QString &profile );
+    void profileAgentAdded( const QString &profile, const QString &agent );
+    void profileAgentRemoved( const QString &profile, const QString &agent );
 
     void addProfile( const QString &profile );
 };
@@ -52,6 +55,7 @@
 {
   ProfileInfo info;
   info.identifier = profile;
+  info.agents = mManager.profileAgents( profile );
 
   mInfos.append( info );
 }
@@ -75,6 +79,32 @@
   emit mParent->layoutChanged();
 }
 
+void ProfileModel::Private::profileAgentAdded( const QString &profile, const QString &agent )
+{
+  for ( int i = 0; i < mInfos.count(); ++i ) {
+    if ( mInfos[ i ].identifier == profile ) {
+      mInfos[ i ].agents.append( agent );
+
+      const QModelIndex index = mParent->index( i, 0 );
+      emit mParent->dataChanged( index, index );
+      break;
+    }
+  }
+}
+
+void ProfileModel::Private::profileAgentRemoved( const QString &profile, const QString &agent )
+{
+  for ( int i = 0; i < mInfos.count(); ++i ) {
+    if ( mInfos[ i ].identifier == profile ) {
+      mInfos[ i ].agents.removeAll( agent );
+
+      const QModelIndex index = mParent->index( i, 0 );
+      emit mParent->dataChanged( index, index );
+      break;
+    }
+  }
+}
+
 ProfileModel::ProfileModel( QObject *parent )
   : QAbstractItemModel( parent ), d( new Private( this ) )
 {
@@ -86,6 +116,10 @@
            this, SLOT( profileAdded( const QString& ) ) );
   connect( &d->mManager, SIGNAL( profileRemoved( const QString& ) ),
            this, SLOT( profileRemoved( const QString& ) ) );
+  connect( &d->mManager, SIGNAL( profileAgentAdded( const QString&, const QString& ) ),
+           this, SLOT( profileAgentAdded( const QString&, const QString& ) ) );
+  connect( &d->mManager, SIGNAL( profileAgentRemoved( const QString&, const QString& ) ),
+           this, SLOT( profileAgentRemoved( const QString&, const QString& ) ) );
 }
 
 ProfileModel::~ProfileModel()
@@ -115,7 +149,7 @@
 
   switch ( role ) {
     case Qt::DisplayRole:
-      return info.identifier;
+      return QString( "%1 (%2)" ).arg( info.identifier, info.agents.join( ", " ) );
       break;
     case Qt::UserRole:
       return info.identifier;
--- trunk/KDE/kdepim/akonadi/libakonadi/profilemodel.h #588588:588589
@@ -46,6 +46,8 @@
 
     Q_PRIVATE_SLOT( d, void profileAdded( const QString& ) )
     Q_PRIVATE_SLOT( d, void profileRemoved( const QString& ) )
+    Q_PRIVATE_SLOT( d, void profileAgentAdded( const QString&, const QString& ) )
+    Q_PRIVATE_SLOT( d, void profileAgentRemoved( const QString&, const QString& ) )
 };
 
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

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