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

List:       kde-commits
Subject:    [kdepim] calendarsupport: Cache the collection selection dialog, it is expensive to create for large
From:       Till Adam <adam () kde ! org>
Date:       2012-08-26 19:12:41
Message-ID: 20120826191241.0707BA6094 () git ! kde ! org
[Download RAW message or body]

Git commit 4fd1a2b2d4c0861deb78d285db5f3f4997a481de by Till Adam.
Committed on 25/08/2012 at 19:53.
Pushed by tilladam into branch 'master'.

Cache the collection selection dialog, it is expensive to create for large collection trees.

M  +9    -2    calendarsupport/utils.cpp

http://commits.kde.org/kdepim/4fd1a2b2d4c0861deb78d285db5f3f4997a481de

diff --git a/calendarsupport/utils.cpp b/calendarsupport/utils.cpp
index e70ec7c..d901b43 100644
--- a/calendarsupport/utils.cpp
+++ b/calendarsupport/utils.cpp
@@ -71,6 +71,13 @@
 using namespace CalendarSupport;
 using namespace KHolidays;
 
+K_GLOBAL_STATIC( Akonadi::CollectionDialog, globalCollectionDialog )
+
+static Akonadi::CollectionDialog* collectionDialog()
+{
+    return globalCollectionDialog;
+}
+
 KCalCore::Incidence::Ptr CalendarSupport::incidence( const Akonadi::Item &item )
 {
   try {
@@ -388,7 +395,8 @@ Akonadi::Collection CalendarSupport::selectCollection( QWidget *parent,
                                                        const QStringList &mimeTypes,
                                                        const Akonadi::Collection &defCollection )
 {
-  QPointer<Akonadi::CollectionDialog> dlg( new Akonadi::CollectionDialog( parent ) );
+  Akonadi::CollectionDialog* dlg = collectionDialog();
+  dlg->setParent( parent );
   dlg->setCaption( i18n( "Select Calendar" ) );
   dlg->setDescription( i18n( "Select the calendar where this item will be stored." ) );
   kDebug() << "selecting collections with mimeType in " << mimeTypes;
@@ -409,7 +417,6 @@ Akonadi::Collection CalendarSupport::selectCollection( QWidget *parent,
       kWarning() << "An invalid collection was selected!";
     }
   }
-  delete dlg;
 
   return collection;
 }

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

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