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

List:       kde-commits
Subject:    playground/pim/kblogger/src
From:       Antonio Aloisio <antonio.aloisio () gmail ! com>
Date:       2008-05-05 22:51:12
Message-ID: 1210027872.531794.13962.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 804429 by aloisio:

-kblogger is not more a KUniqueApplication: This make easy to debug it.
-Add some comments in the code
-Cleanups
-Crash Fix: Full size images are added before to add their thumbnails

 M  +14 -16    itemsmanager.cpp  
 M  +1 -1      kbloggerapplication.h  
 M  +10 -6     media/importmediawidget.cpp  


--- trunk/playground/pim/kblogger/src/itemsmanager.cpp #804428:804429
@@ -272,32 +272,30 @@
     QList<Media*> MediaList;
     MediaList = mediaWidgetsList.value( blogname )->getMediaList();
 
-    QStringList uploadedMediaUrlList;
+    //Get the list of media present in the kblogger cache.
+    QStringList cachedMedia;
     foreach (Media* media, MediaList) {
         QString url;
         url = media->url().url();
         if (!url.isEmpty())
-            uploadedMediaUrlList += url;
+            cachedMedia += url;
     }
 
+    //Get mediaURl from the uploaded posts list
+    //And add them to the ImportMediaDialog.
     foreach (Post* post, PostsList) {
-        /*
-        QMap<const QString& uploadedMediaUrl, Post*> mediaMap;
-        mediaMap= post->getUploadedMedia();
-        foreach( QString url, mediaMap){
-          if ( !uploadedMediaUrlList.contains(url) )
-          ImportMediaDialog()::self()->addUrl(url, mediaMap.value(url) );
-        }
-        */
-        QStringList uploadedMediaUrlInThePost;
-        uploadedMediaUrlInThePost = post->mediaUrlList();
-        foreach( QString url, uploadedMediaUrlInThePost) {
-            kDebug() << "cached Urls:" << uploadedMediaUrlInThePost << endl
-            << "url in the post:" << url;
-            if ( !uploadedMediaUrlList.contains(url) ) {
+        QStringList postsMediaUrl; //list of uploaded media url
+        postsMediaUrl = post->mediaUrlList(); //retrive the media url present in the post
+        
+        foreach( QString url, postsMediaUrl) {
+            kDebug()<< "url in the post:" << url;
+            //Any url can be added once time to the ImportMediaDialog.
+            if ( !cachedMedia.contains(url) ) {
+                cachedMedia << url;
                 ImportMediaDialog::self()->addUrl(url, post->getBlogName(), post->postId() );
             }
         }
+        kDebug() << "url added to the ImportMediaDialog:" << postsMediaUrl;
     }
     ImportMediaDialog::self()->show();
 }
--- trunk/playground/pim/kblogger/src/kbloggerapplication.h #804428:804429
@@ -27,7 +27,7 @@
 
 using namespace KBlogger;
 
-class KBloggerApplication: public KUniqueApplication
+class KBloggerApplication: public KApplication
 {
 public:
     KBloggerApplication();
--- trunk/playground/pim/kblogger/src/media/importmediawidget.cpp #804428:804429
@@ -69,12 +69,15 @@
 
 bool ImportMediaWidget::addUrl(const QString& imageUrl, const QString& blogname, const QString& postId)
 {
-    kDebug() << "ImageUrl" << imageUrl
-             << "Blogname" << blogname
-             << "Post ID" << postId;
+    kDebug() << "ImageUrl" << imageUrl << endl
+             << "Blogname" << blogname << endl
+             << "Post ID" << postId << endl;
 
     Q_ASSERT( !imageUrl.isEmpty() );
     Q_ASSERT( !blogname.isEmpty() );
+    if ( treeItemList.count() ){
+        kWarning() << "treeItemList is empty";
+    }
 
     QStringList ignoredUrls;
     ignoredUrls = ItemsManager::self()->getIgnoredMediaUrls(blogname);
@@ -99,6 +102,7 @@
      * So kblogger will process the thumbnail before the image.
      */
     //FIXME does this only simple condition work reliably?
+
     if ( !thumbnailUrlRx.pattern().isEmpty() &&
 	  imageUrl.contains( thumbnailUrlRx ) 
        ) {
@@ -166,7 +170,7 @@
     if ( mediaData.isEmpty() ) {
         item->setIcon(fileName_coloumn, KIcon("dialog-cancel") );
         item->setText(status_coloumn, i18n("Read-Error. The media is empty.") );
-        kDebug() << "Read-Error: The media is empty.";
+        kError() << "Read-Error: The media is empty.";
         jobsMap.remove( job );
         delete job;
         jobsFinished();
@@ -176,7 +180,7 @@
     if ( job->error() ) {
         item->setIcon(fileName_coloumn, KIcon("dialog-cancel") );
         item->setText(status_coloumn, i18n("Read-Error.") );
-        kDebug() << "Read-Error: " << job->errorString();
+        kError() << "Read-Error: " << job->errorString();
         jobsMap.remove( job );
         delete job;
         jobsFinished();
@@ -256,7 +260,7 @@
 	Media* currentMedia=mediaMap[ currentItem ];
 	if (!currentMedia){
 	    //Media is null when a job exits with error.
-	    kDebug() << "currentMedia is null. Continue..";
+	    kWarning() << "Some errors occours: currentMedia is null. Continue..";
 	    continue;
 	}
 	Media* previouslyMedia=0;
[prev in list] [next in list] [prev in thread] [next in thread] 

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